diff options
author | Joona Petrell <joona.t.petrell@nokia.com> | 2010-05-05 04:57:53 (GMT) |
---|---|---|
committer | Joona Petrell <joona.t.petrell@nokia.com> | 2010-05-07 00:59:27 (GMT) |
commit | 7c945e152c9abd0478bed5a4d251012944d93b44 (patch) | |
tree | 4edc61eaf52e44485db237ead602f0871726c2d5 /tools/qml | |
parent | 35e6100977e496a242c41f6f0fc66889e7cd49fc (diff) | |
download | Qt-7c945e152c9abd0478bed5a4d251012944d93b44.zip Qt-7c945e152c9abd0478bed5a4d251012944d93b44.tar.gz Qt-7c945e152c9abd0478bed5a4d251012944d93b44.tar.bz2 |
Resize qmlruntime window to new dimensions when orientation changes
Task-number:
Reviewed-by: Warwick Allison
Diffstat (limited to 'tools/qml')
-rw-r--r-- | tools/qml/qmlruntime.cpp | 19 | ||||
-rw-r--r-- | tools/qml/qmlruntime.h | 5 |
2 files changed, 18 insertions, 6 deletions
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index d49b0f1..06fa004 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -535,6 +535,8 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) connect(&autoStartTimer, SIGNAL(triggered()), this, SLOT(autoStartRecording())); connect(&autoStopTimer, SIGNAL(triggered()), this, SLOT(autoStopRecording())); connect(&recordTimer, SIGNAL(triggered()), this, SLOT(recordFrame())); + connect(DeviceOrientation::instance(), SIGNAL(orientationChanged()), + this, SLOT(orientationChanged()), Qt::QueuedConnection); autoStartTimer.setRunning(false); autoStopTimer.setRunning(false); recordTimer.setRunning(false); @@ -968,10 +970,8 @@ void QDeclarativeViewer::statusChanged() if (canvas->status() == QDeclarativeView::Ready) { initialSize = canvas->sizeHint(); if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { - QSize newWindowSize = initialSize; - newWindowSize.setHeight(newWindowSize.height()+menuBarHeight()); updateSizeHints(); - resize(newWindowSize); + resize(QSize(initialSize.width(), initialSize.height()+menuBarHeight())); } } } @@ -1425,6 +1425,19 @@ void QDeclarativeViewer::recordFrame() } } +void QDeclarativeViewer::orientationChanged() +{ + if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) { + if (canvas->rootObject()) { + QSizeF rootObjectSize = canvas->rootObject()->boundingRect().size(); + QSize newSize(rootObjectSize.width(), rootObjectSize.height()+menuBarHeight()); + if (size() != newSize) { + resize(newSize); + } + } + } +} + void QDeclarativeViewer::setDeviceKeys(bool on) { devicemode = on; diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 655feea..9551090 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -125,6 +125,7 @@ public slots: void showProxySettings (); void proxySettingsChanged (); void setScaleView(); + void toggleOrientation(); void statusChanged(); void setSlowMode(bool); void launch(const QString &); @@ -132,7 +133,6 @@ public slots: protected: virtual void keyPressEvent(QKeyEvent *); virtual bool event(QEvent *); - void createMenu(QMenuBar *menu, QMenu *flatmenu); private slots: @@ -144,9 +144,9 @@ private slots: void setScaleSkin(); void setPortrait(); void setLandscape(); - void toggleOrientation(); void startNetwork(); void toggleFullScreen(); + void orientationChanged(); void showWarnings(bool show); void warningsWidgetOpened(); @@ -199,7 +199,6 @@ private: QNetworkReply *wgtreply; QString wgtdir; - NetworkAccessManagerFactory *namFactory; bool useQmlFileBrowser; |