From: Robin Burchell Date: Fri, 25 May 2012 13:30:47 +0000 (+0200) Subject: Add --resize-to-root option, sets ResizeViewToRootObject on the qmlscene view. X-Git-Tag: 071012131707~286 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4d9bc3bb6a3b500013a569267dcdbd423ee50ac2;p=profile%2Fivi%2Fqtdeclarative.git 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 --- diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp index 0d97ba1..9ed0256 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 ................................. Add to the list of import paths"); qWarning(" -B .......................... 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();