summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2009-10-26 05:41:51 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2009-10-26 05:41:51 (GMT)
commit91be655a7e893d34fdbdb71aa5a329b641c80992 (patch)
tree44fb2b8bb3040d709b85e366f7660f532caabd98
parentde3b541e40d9fdb01bc46f472c6032e2a9f45c95 (diff)
downloadQt-91be655a7e893d34fdbdb71aa5a329b641c80992.zip
Qt-91be655a7e893d34fdbdb71aa5a329b641c80992.tar.gz
Qt-91be655a7e893d34fdbdb71aa5a329b641c80992.tar.bz2
Fix "initial" size for remote content.
-rw-r--r--src/declarative/util/qmlview.cpp12
-rw-r--r--src/declarative/util/qmlview.h1
-rw-r--r--tools/qmlviewer/qmlviewer.cpp8
-rw-r--r--tools/qmlviewer/qmlviewer.h1
4 files changed, 20 insertions, 2 deletions
diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp
index 14f8279..f91d0db 100644
--- a/src/declarative/util/qmlview.cpp
+++ b/src/declarative/util/qmlview.cpp
@@ -360,6 +360,8 @@ void QmlView::continueExecute()
emit sceneResized(sz);
resize(sz);
}
+ updateGeometry();
+ emit initialSize(d->initialSize);
} else if (QWidget *wid = qobject_cast<QWidget *>(obj)) {
window()->setAttribute(Qt::WA_OpaquePaintEvent, false);
window()->setAttribute(Qt::WA_NoSystemBackground, false);
@@ -374,6 +376,7 @@ void QmlView::continueExecute()
}
layout()->addWidget(wid);
emit sceneResized(wid->size());
+ emit initialSize(wid->size());
}
}
}
@@ -382,6 +385,10 @@ void QmlView::continueExecute()
This signal is emitted when the view is resized to \a size.
*/
+/*! \fn void QmlView::initialSize(QSize size)
+ This signal is emitted when the initial size of the root item is known.
+ */
+
/*! \fn void QmlView::errors(const QList<QmlError> &errors)
This signal is emitted when the qml loaded contains \a errors.
*/
@@ -425,7 +432,10 @@ void QmlView::timerEvent(QTimerEvent* e)
automatically resize the root item.
Regardless of this property, the sizeHint of the view
- is the initial size of the root item.
+ is the initial size of the root item. Note though that
+ since QML may load dynamically, that size may change.
+
+ \sa initialSize()
*/
void QmlView::setContentResizable(bool on)
diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h
index faf2564..822827a 100644
--- a/src/declarative/util/qmlview.h
+++ b/src/declarative/util/qmlview.h
@@ -88,6 +88,7 @@ public:
QSize sizeHint() const;
Q_SIGNALS:
+ void initialSize(QSize size);
void sceneResized(QSize size);
void errors(const QList<QmlError> &error);
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index 73aae44..b115abb 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -310,6 +310,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
canvas->setFocus();
QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize)));
+ QObject::connect(canvas, SIGNAL(initialSize(QSize)), this, SLOT(adjustSizeSlot()));
QObject::connect(canvas, SIGNAL(errors(QList<QmlError>)), this, SLOT(executeErrors()));
if (!(flags & Qt::FramelessWindowHint))
@@ -335,6 +336,11 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
recordTimer.setRepeating(true);
}
+void QmlViewer::adjustSizeSlot()
+{
+ adjustSize();
+}
+
QMenuBar *QmlViewer::menuBar() const
{
if (!mb)
@@ -680,7 +686,7 @@ void QmlViewer::openQml(const QUrl& url)
canvas->updateGeometry();
if (mb)
mb->updateGeometry();
- resize(sizeHint());
+ adjustSize();
} else {
if (scaleSkin)
canvas->resize(canvas->sizeHint());
diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h
index f0578eb..50495db 100644
--- a/tools/qmlviewer/qmlviewer.h
+++ b/tools/qmlviewer/qmlviewer.h
@@ -88,6 +88,7 @@ private slots:
void chooseRecordingOptions();
void pickRecordingFile();
void setScaleSkin();
+ void adjustSizeSlot();
private:
void setupProxy();