summaryrefslogtreecommitdiffstats
path: root/tools/qml
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@nokia.com>2010-07-12 12:35:33 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-07-13 03:14:33 (GMT)
commit5f64427b79dc3053fdb8e8b82698a08fa8ab179b (patch)
tree400454f21be0c4291d895417fe6c13e06d59b9c4 /tools/qml
parentab14670bb3d29791ea153f23c5e93c65f122afa2 (diff)
downloadQt-5f64427b79dc3053fdb8e8b82698a08fa8ab179b.zip
Qt-5f64427b79dc3053fdb8e8b82698a08fa8ab179b.tar.gz
Qt-5f64427b79dc3053fdb8e8b82698a08fa8ab179b.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 (cherry picked from commit 07321dfceed41c1851781841e03c4148da47e41e)
Diffstat (limited to 'tools/qml')
-rw-r--r--tools/qml/qmlruntime.cpp60
-rw-r--r--tools/qml/qmlruntime.h4
2 files changed, 28 insertions, 36 deletions
diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp
index debc902..51579f4 100644
--- a/tools/qml/qmlruntime.cpp
+++ b/tools/qml/qmlruntime.cpp
@@ -924,13 +924,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);
}
}
@@ -1055,13 +1049,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)
@@ -1324,17 +1314,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)
@@ -1383,20 +1363,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()
diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h
index e70e69f..68d3452 100644
--- a/tools/qml/qmlruntime.h
+++ b/tools/qml/qmlruntime.h
@@ -145,9 +145,9 @@ private slots:
void warningsWidgetOpened();
void warningsWidgetClosed();
- void updateSizeHints();
-
private:
+ void updateSizeHints(bool initial = false);
+
QString getVideoFileName();
LoggerWidget *loggerWindow;