diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-08-13 05:44:28 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-08-13 05:44:28 (GMT) |
commit | 6eac745a448dfe47ae138e3400d5ce1f2be96376 (patch) | |
tree | b14c2489ede3f1149194923cde133c17e8b5a8ab /tools/qmlviewer | |
parent | 0e7409583a3c0f6d8ba01c2d61ac00c02015a52b (diff) | |
download | Qt-6eac745a448dfe47ae138e3400d5ce1f2be96376.zip Qt-6eac745a448dfe47ae138e3400d5ce1f2be96376.tar.gz Qt-6eac745a448dfe47ae138e3400d5ce1f2be96376.tar.bz2 |
Improve specifying skin on command-line.
Diffstat (limited to 'tools/qmlviewer')
-rw-r--r-- | tools/qmlviewer/main.cpp | 22 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.cpp | 35 | ||||
-rw-r--r-- | tools/qmlviewer/qmlviewer.h | 2 |
3 files changed, 40 insertions, 19 deletions
diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index 73f5382..ca159f3 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -27,7 +27,8 @@ void usage() qWarning(" -v, -version ............................. display version"); qWarning(" -frameless ............................... run with no window frame"); qWarning(" -skin <qvfbskindir> ...................... run with a skin window frame"); - qWarning(" -scaleview ...................... run with a skin window frame"); + qWarning(" \"list\" for a list of built-ins"); + qWarning(" -resizeview .............................. resize the view, not the skin"); qWarning(" -recordfile <output> ..................... set video recording file"); qWarning(" - ImageMagick 'convert' for GIF)"); qWarning(" - png file for raw frames"); @@ -65,7 +66,7 @@ int main(int argc, char ** argv) app.setOrganizationDomain("nokia.com"); bool frameless = false; - bool scaleview = false; + bool resizeview = false; QString fileName; double fps = 0; int autorecord_from = 0; @@ -85,8 +86,8 @@ int main(int argc, char ** argv) frameless = true; } else if (arg == "-skin") { skin = QString(argv[++i]); - } else if (arg == "-scaleview") { - scaleview = true; + } else if (arg == "-resizeview") { + resizeview = true; } else if (arg == "-netcache") { cache = QString(argv[++i]).toInt(); } else if (arg == "-recordrate") { @@ -133,14 +134,21 @@ int main(int argc, char ** argv) viewer.addLibraryPath(lib); viewer.setNetworkCacheSize(cache); viewer.setRecordFile(recordfile); - if (scaleview) + if (resizeview) viewer.setScaleView(); if (fps>0) viewer.setRecordRate(fps); if (autorecord_to) viewer.setAutoRecord(autorecord_from,autorecord_to); - if (!skin.isEmpty() && QDir(skin).exists()) - viewer.setSkin(skin); + if (!skin.isEmpty()) { + if (skin == "list") { + foreach (QString s, viewer.builtinSkins()) + qWarning(s.toUtf8()); + exit(0); + } else { + viewer.setSkin(skin); + } + } if (devkeys) viewer.setDeviceKeys(true); viewer.setRecordDither(dither); diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index a1e4911..7da2afb 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -337,21 +337,16 @@ void QmlViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map())); skinMenu->addSeparator(); - QDir dir(":/skins/","*.skin"); - const QFileInfoList l = dir.entryInfoList(); - for (QFileInfoList::const_iterator it = l.begin(); it != l.end(); ++it) { - QString name = (*it).baseName(); // should perhaps be in file - QString file = (*it).filePath(); + foreach (QString name, builtinSkins()) { skinAction = new QAction(name, parent); skinActions->addAction(skinAction); skinMenu->addAction(skinAction); skinAction->setCheckable(true); - if (file == currentSkin) + if (":skin/"+name+".skin" == currentSkin) skinAction->setChecked(true); - mapper->setMapping(skinAction, file); + mapper->setMapping(skinAction, name); connect(skinAction, SIGNAL(triggered()), mapper, SLOT(map())); } - //connect(skinActions, SIGNAL(triggered(QAction*)), mapper, SLOT(map(QObject*))); // "incompatible" connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setSkin(QString))); if (flatmenu) flatmenu->addSeparator(); @@ -602,17 +597,33 @@ void QmlViewer::openQml(const QString& fileName) #endif } -void QmlViewer::setSkin(const QString& skinDirectory) +QStringList QmlViewer::builtinSkins() const { - // XXX QWidget::setMask does not handle changes well, and we may - // XXX have been signalled from an item in a menu we're replacing, - // XXX hence some rather convoluted resetting here... + QDir dir(":/skins/","*.skin"); + const QFileInfoList l = dir.entryInfoList(); + QStringList r; + for (QFileInfoList::const_iterator it = l.begin(); it != l.end(); ++it) { + r += (*it).baseName(); + } + return r; +} + +void QmlViewer::setSkin(const QString& skinDirOrName) +{ + QString skinDirectory = skinDirOrName; + + if (!QDir(skinDirOrName).exists() && QDir(":/skins/"+skinDirOrName+".skin").exists()) + skinDirectory = ":/skins/"+skinDirOrName+".skin"; if (currentSkin == skinDirectory) return; currentSkin = skinDirectory; + // XXX QWidget::setMask does not handle changes well, and we may + // XXX have been signalled from an item in a menu we're replacing, + // XXX hence some rather convoluted resetting here... + QString err; if (skin) { skin->hide(); diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 319d0a5..c03c09f 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -44,6 +44,8 @@ public: void setNetworkCacheSize(int size); void addLibraryPath(const QString& lib); + QStringList builtinSkins() const; + QMenuBar *menuBar() const; public slots: |