aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-07-26 13:48:45 +1000
committerQt by Nokia <qt-info@nokia.com>2011-07-26 08:00:31 +0200
commite06211e4c67c0c7470fdac86c3fa6d50792516c5 (patch)
treefc672331a442d93f714c962efc47cbeb6b23dd3c /tools
parente5be1482c81fb3a502e2e5f8e56f11f182c2adab (diff)
qmlviewer resizes the root object multiple times.
In SizeRootObjectToView mode on initial load the view was set to root object size, then the sceneResized() slot would resize back, then we would finally reset back to the correct value in statusChanged(true). Now react directly to the initial size being set. Change-Id: Ib6977cf7bad3fe79b9ac80bb6d916fb0f57c5f5e Fixes: QTBUG-16499 Reviewed-on: http://codereview.qt.nokia.com/2148 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmlviewer/qmlruntime.cpp13
-rw-r--r--tools/qmlviewer/qmlruntime.h1
2 files changed, 13 insertions, 1 deletions
diff --git a/tools/qmlviewer/qmlruntime.cpp b/tools/qmlviewer/qmlruntime.cpp
index 55f0f4f2bc..bb2191b2a4 100644
--- a/tools/qmlviewer/qmlruntime.cpp
+++ b/tools/qmlviewer/qmlruntime.cpp
@@ -651,7 +651,7 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags)
canvas->setFocus();
- QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
+ QObject::connect(canvas, SIGNAL(initialSizeChanged(QSize)), this, SLOT(initialSizeChanged(QSize)));
QObject::connect(canvas, SIGNAL(statusChanged(QDeclarativeView::Status)), this, SLOT(statusChanged()));
QObject::connect(canvas->engine(), SIGNAL(quit()), this, SLOT(close()));
@@ -1052,6 +1052,7 @@ void QDeclarativeViewer::statusChanged()
if (canvas->status() == QDeclarativeView::Ready) {
initialSize = canvas->initialSize();
updateSizeHints(true);
+ QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
}
}
@@ -1144,6 +1145,7 @@ bool QDeclarativeViewer::open(const QString& file_or_url)
QTime t;
t.start();
+ QObject::disconnect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
canvas->setSource(url);
return true;
@@ -1177,6 +1179,15 @@ void QDeclarativeViewer::sceneResized(QSize)
updateSizeHints();
}
+void QDeclarativeViewer::initialSizeChanged(QSize size)
+{
+ if (!isFullScreen() && !isMaximized()) {
+ canvas->setFixedSize(size);
+ layout()->setSizeConstraint(QLayout::SetFixedSize);
+ layout()->activate();
+ }
+}
+
void QDeclarativeViewer::keyPressEvent(QKeyEvent *event)
{
if (event->key() == Qt::Key_0 && devicemode)
diff --git a/tools/qmlviewer/qmlruntime.h b/tools/qmlviewer/qmlruntime.h
index d56cee8d2f..20e0303b14 100644
--- a/tools/qmlviewer/qmlruntime.h
+++ b/tools/qmlviewer/qmlruntime.h
@@ -112,6 +112,7 @@ public:
public slots:
void sceneResized(QSize size);
+ void initialSizeChanged(QSize size);
bool open(const QString&);
void openFile();
void openUrl();