summaryrefslogtreecommitdiffstats
path: root/tools/qml/qmlruntime.cpp
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@nokia.com>2010-07-12 12:35:33 (GMT)
committerRobert Griebl <robert.griebl@nokia.com>2010-07-12 12:35:33 (GMT)
commit07321dfceed41c1851781841e03c4148da47e41e (patch)
tree582964432da373f5e8979de156c30773ca8c9737 /tools/qml/qmlruntime.cpp
parentcbc7a0251a727827418707c7a05ea44241a06efb (diff)
downloadQt-07321dfceed41c1851781841e03c4148da47e41e.zip
Qt-07321dfceed41c1851781841e03c4148da47e41e.tar.gz
Qt-07321dfceed41c1851781841e03c4148da47e41e.tar.bz2
Calling setMinimumSize(0, 0) on a top-level window sometimes triggers a bug
in the Compiz window manager which leads to the QML viewer mainwindow not being composited anymore (at least until the next resize). Since we need to somehow switch between fixed size and freely resizable views, we have to work around that bug using the layout constraint hints. Task-number: QTBUG-11771 Reviewed-by: kkoehne
Diffstat (limited to 'tools/qml/qmlruntime.cpp')
-rw-r--r--tools/qml/qmlruntime.cpp60
1 files changed, 26 insertions, 34 deletions
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index 03ca798..951b187 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -944,13 +944,7 @@ void QDeclarativeViewer::statusChanged()
if (canvas->status() == QDeclarativeView::Ready) {
initialSize = canvas->initialSize();
- if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) {
- if (!isFullScreen() && !isMaximized()) {
- canvas->setFixedSize(initialSize);
- resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrink
- QTimer::singleShot(0, this, SLOT(updateSizeHints()));
- }
- }
+ updateSizeHints(true);
}
}
@@ -1075,13 +1069,9 @@ void QDeclarativeViewer::setRecordRate(int fps)
record_rate = fps;
}
-void QDeclarativeViewer::sceneResized(QSize size)
+void QDeclarativeViewer::sceneResized(QSize)
{
- if (size.width() > 0 && size.height() > 0) {
- if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) {
- updateSizeHints();
- }
- }
+ updateSizeHints();
}
void QDeclarativeViewer::keyPressEvent(QKeyEvent *event)
@@ -1344,17 +1334,7 @@ void QDeclarativeViewer::changeOrientation(QAction *action)
void QDeclarativeViewer::orientationChanged()
{
- if (canvas->resizeMode() == QDeclarativeView::SizeRootObjectToView) {
- if (canvas->rootObject()) {
- QSizeF rootObjectSize = canvas->rootObject()->boundingRect().size();
- if (size() != rootObjectSize.toSize()) {
- canvas->setMinimumSize(rootObjectSize.toSize());
- canvas->resize(rootObjectSize.toSize());
- resize(rootObjectSize.toSize());
- resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrinks
- }
- }
- }
+ updateSizeHints();
}
void QDeclarativeViewer::setDeviceKeys(bool on)
@@ -1403,20 +1383,32 @@ void QDeclarativeViewer::setSizeToView(bool sizeToView)
}
}
-void QDeclarativeViewer::updateSizeHints()
+void QDeclarativeViewer::updateSizeHints(bool initial)
{
- if (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject) {
- QSize newWindowSize = canvas->sizeHint();
+ static bool isRecursive = false;
+
+ if (isRecursive)
+ return;
+ isRecursive = true;
+
+ if (initial || (canvas->resizeMode() == QDeclarativeView::SizeViewToRootObject)) {
+ QSize newWindowSize = initial ? initialSize : canvas->sizeHint();
+ //qWarning() << "USH:" << (initial ? "INIT:" : "V2R:") << "setting fixed size " << newWindowSize;
if (!isFullScreen() && !isMaximized()) {
- canvas->setMinimumSize(newWindowSize);
- canvas->resize(newWindowSize);
- resize(1, 1); // workaround for QMainWindowLayout NOT shrinking the window if the centralWidget() shrinks
- canvas->setMinimumSize(QSize(0, 0));
+ canvas->setFixedSize(newWindowSize);
+ resize(1, 1);
+ layout()->setSizeConstraint(QLayout::SetFixedSize);
+ layout()->activate();
}
- } else { // QDeclarativeView::SizeRootObjectToView
- canvas->setMinimumSize(QSize(0,0));
- canvas->setMaximumSize(QSize(16777215,16777215));
}
+ //qWarning() << "USH: R2V: setting free size ";
+ layout()->setSizeConstraint(QLayout::SetNoConstraint);
+ layout()->activate();
+ setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
+ canvas->setMinimumSize(QSize(0,0));
+ canvas->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
+
+ isRecursive = false;
}
void QDeclarativeViewer::registerTypes()