diff options
author | Robin Burchell <robin+qt@viroteck.net> | 2012-05-25 15:30:47 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-28 04:07:35 +0200 |
commit | 4d9bc3bb6a3b500013a569267dcdbd423ee50ac2 (patch) | |
tree | d2248020fdc5635fc8c38a3e1ea26e2717d89e32 /tools | |
parent | f62ab0a3dfaa873bb15cd1526f98f50a17228a9c (diff) |
Add --resize-to-root option, sets ResizeViewToRootObject on the qmlscene view.
Sometimes it is useful to be able to resize a view from within QML, for example,
when writing QML which must operate in both portrait and landscape conditions.
Change-Id: I10564bb3c8661fae6c1d175985268a409dc3dafd
Reviewed-by: Alan Alpert <alan.alpert@nokia.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlscene/main.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index 0d97ba190b..9ed0256ffd 100644 --- a/tools/qmlscene/main.cpp +++ b/tools/qmlscene/main.cpp @@ -137,15 +137,6 @@ void RenderStatistics::printTotalStats() } #endif -class MyQQuickView : public QQuickView -{ -public: - MyQQuickView() : QQuickView() - { - setResizeMode(QQuickView::SizeRootObjectToView); - } -}; - struct Options { Options() @@ -157,6 +148,7 @@ struct Options , versionDetection(true) , slowAnimations(false) , quitImmediately(false) + , resizeViewToRootItem(false) { } @@ -170,6 +162,7 @@ struct Options bool versionDetection; bool slowAnimations; bool quitImmediately; + bool resizeViewToRootItem; }; #if defined(QMLSCENE_BUNDLE) @@ -349,6 +342,7 @@ static void usage() qWarning(" --no-multisample .......................... Disable multisampling (anti-aliasing)"); qWarning(" --no-version-detection .................... Do not try to detect the version of the .qml file"); qWarning(" --slow-animations ......................... Run all animations in slow motion"); + qWarning(" --resize-to-root .......................... Resize the window to the size of the root item"); qWarning(" --quit .................................... Quit immediately after starting"); qWarning(" -I <path> ................................. Add <path> to the list of import paths"); qWarning(" -B <name> <file> .......................... Add a named bundle"); @@ -380,6 +374,8 @@ int main(int argc, char ** argv) options.slowAnimations = true; else if (lowerArgument == QLatin1String("--quit")) options.quitImmediately = true; + else if (lowerArgument == QLatin1String("--resize-to-root")) + options.resizeViewToRootItem = true; else if (lowerArgument == QLatin1String("-i") && i + 1 < argc) imports.append(QString::fromLatin1(argv[++i])); else if (lowerArgument == QLatin1String("-b") && i + 2 < argc) { @@ -419,7 +415,7 @@ int main(int argc, char ** argv) if (!options.file.isEmpty()) { if (!options.versionDetection || checkVersion(options.file)) { - QQuickView *qxView = new MyQQuickView(); + QQuickView *qxView = new QQuickView(); engine = qxView->engine(); for (int i = 0; i < imports.size(); ++i) engine->addImportPath(imports.at(i)); @@ -434,6 +430,11 @@ int main(int argc, char ** argv) QObject::connect(engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit())); + if (options.resizeViewToRootItem) + qxView->setResizeMode(QQuickView::SizeViewToRootObject); + else + qxView->setResizeMode(QQuickView::SizeRootObjectToView); + window->setWindowFlags(Qt::Window | Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint); if (options.fullscreen) window->showFullScreen(); |