From e06211e4c67c0c7470fdac86c3fa6d50792516c5 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 26 Jul 2011 13:48:45 +1000 Subject: 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 Reviewed-by: Michael Brasser --- tools/qmlviewer/qmlruntime.cpp | 13 ++++++++++++- tools/qmlviewer/qmlruntime.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'tools') 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(); -- cgit v1.2.3