summaryrefslogtreecommitdiffstats
path: root/tools/qml/qmlruntime.cpp
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-05-05 04:57:53 (GMT)
committerJoona Petrell <joona.t.petrell@nokia.com>2010-05-07 00:59:27 (GMT)
commit7c945e152c9abd0478bed5a4d251012944d93b44 (patch)
tree4edc61eaf52e44485db237ead602f0871726c2d5 /tools/qml/qmlruntime.cpp
parent35e6100977e496a242c41f6f0fc66889e7cd49fc (diff)
downloadQt-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/qmlruntime.cpp')
-rw-r--r--tools/qml/qmlruntime.cpp19
1 files changed, 16 insertions, 3 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;