diff options
author | Jeremy Katz <jeremy.katz@nokia.com> | 2010-05-04 12:59:04 (GMT) |
---|---|---|
committer | Jeremy Katz <jeremy.katz@nokia.com> | 2010-05-04 12:59:04 (GMT) |
commit | 47f886467b04ce712b4dcd90f0201720d614ff28 (patch) | |
tree | 2b432704562f4a96cf2dbc3a1fe5feee11a28f75 /src/plugins/platforms/vnc/qvncintegration.cpp | |
parent | c6fd02d70e22d497658153abbd9fcf3176b550ca (diff) | |
download | Qt-47f886467b04ce712b4dcd90f0201720d614ff28.zip Qt-47f886467b04ce712b4dcd90f0201720d614ff28.tar.gz Qt-47f886467b04ce712b4dcd90f0201720d614ff28.tar.bz2 |
VNC parameters for size and display id
Diffstat (limited to 'src/plugins/platforms/vnc/qvncintegration.cpp')
-rw-r--r-- | src/plugins/platforms/vnc/qvncintegration.cpp | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/src/plugins/platforms/vnc/qvncintegration.cpp b/src/plugins/platforms/vnc/qvncintegration.cpp index 7bdba35..69aea79 100644 --- a/src/plugins/platforms/vnc/qvncintegration.cpp +++ b/src/plugins/platforms/vnc/qvncintegration.cpp @@ -51,25 +51,16 @@ #include <QtCore/QTimer> -QVNCScreen::QVNCScreen() +QVNCScreen::QVNCScreen(QRect screenSize, int screenId) : QFbScreen::QFbScreen() { - int w = 800; - int h = 600; - int ew, eh; - const char *str; - if ((str=::getenv("QT_VNC_SIZE")) && sscanf(str,"%dx%d",&ew,&eh)==2) { - w = ew; - h = eh; - } - - setGeometry(QRect(0,0,w, h)); + setGeometry(screenSize); setDepth(32); setFormat(QImage::Format_RGB32); setPhysicalSize((geometry().size()*254)/720); - d_ptr = new QVNCScreenPrivate(this); + d_ptr = new QVNCScreenPrivate(this, screenId); cursor = new QVNCCursor(d_ptr->vncServer, this); d_ptr->vncServer->setCursor(static_cast<QVNCCursor *>(cursor)); @@ -91,10 +82,45 @@ QRegion QVNCScreen::doRedraw() return touched; } +static inline int defaultWidth() { return 800; } +static inline int defaultHeight() { return 600; } +static inline int defaultDisplay() { return 0; } + +static void usage() +{ + qWarning() << "VNC Platform Integration options:"; + qWarning() << " size=<Width>x<Height> - set the display width and height"; + qWarning() << " defaults to" << defaultWidth() << "x" << defaultHeight(); + qWarning() << " display=<ID> - set the VNC display port to ID + 5900"; + qWarning() << " defaults to" << defaultDisplay(); +} -QVNCIntegration::QVNCIntegration() +QVNCIntegration::QVNCIntegration(const QStringList& paramList) { - mPrimaryScreen = new QVNCScreen(); + int sizeX = defaultWidth(); + int sizeY = defaultHeight(); + int display = defaultDisplay(); + bool showUsage = false; + + foreach(QString confString, paramList) { + if (confString.startsWith(QLatin1String("size="))) { + QString val = confString.section(QLatin1Char('='), 1, 1); + sizeX = val.section(QLatin1Char('x'), 0, 0).toInt(); + sizeY = val.section(QLatin1Char('x'), 1, 1).toInt(); + } + else if (confString.startsWith(QLatin1String("display="))) { + display = confString.section(QLatin1Char('='), 1, 1).toInt(); + } + else { + qWarning() << "Unknown VNC option:" << confString; + showUsage = true; + } + } + + if (showUsage) + usage(); + + mPrimaryScreen = new QVNCScreen(QRect(0, 0, sizeX, sizeY), display); mScreens.append(mPrimaryScreen); } |