diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-03-18 17:41:07 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-03-30 14:00:36 +0000 |
commit | 5061d101310bd110e86831249b94d137a831d3be (patch) | |
tree | 6f051f732557a3df70969dc601bd5ea9567d766d | |
parent | 4606c04a689cbc73bc5150f36ad22ce2d6d405ae (diff) | |
download | qtquickcontrols-5061d101310bd110e86831249b94d137a831d3be.tar.gz |
Dialogs: redo calculations depending on __maximumDimension before show
Once again the old problem recurs that on Android the primaryScreen
has invalid geometry at the time the dialog's QML implementation is
loaded. So if the loading occurs before the main window is shown,
the dialog was resized to 0x0 and stayed that way.
The fix is to make __maximumDimension a notifying property and
artificially emit a change signal each time before the dialog is shown.
Task-number: QTBUG-45092
Change-Id: Ie86eb7f7bd3cbe8401ccc98c9cc8829c788a71dd
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
-rw-r--r-- | src/dialogs/qquickabstractdialog.cpp | 5 | ||||
-rw-r--r-- | src/dialogs/qquickabstractdialog_p.h | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/dialogs/qquickabstractdialog.cpp b/src/dialogs/qquickabstractdialog.cpp index ffc995c8..ba65bd8b 100644 --- a/src/dialogs/qquickabstractdialog.cpp +++ b/src/dialogs/qquickabstractdialog.cpp @@ -107,6 +107,8 @@ void QQuickAbstractDialog::setVisible(bool v) // Pure QML implementation: wrap the contentItem in a window, or fake it if (!m_dialogWindow && m_contentItem) { + if (v) + emit __maximumDimensionChanged(); if (m_hasNativeWindows) m_dialogWindow = m_contentItem->window(); // An Item-based dialog implementation doesn't come with a window, so @@ -220,7 +222,7 @@ void QQuickAbstractDialog::decorationLoaded() m_windowDecoration->setProperty("content", contentVariant); connect(m_windowDecoration, SIGNAL(dismissed()), this, SLOT(reject())); ok = true; - qCDebug(lcWindow) << "using synthetic window decoration" << m_windowDecoration; + qCDebug(lcWindow) << "using synthetic window decoration" << m_windowDecoration << "from" << m_decorationComponent->url(); } else { qWarning() << m_decorationComponent->url() << "cannot be used as a window decoration because it's not an Item"; @@ -360,6 +362,7 @@ int QQuickAbstractDialog::height() const int QQuickAbstractDialog::__maximumDimension() const { QScreen *screen = QGuiApplication::primaryScreen(); + qCDebug(lcWindow) << "__maximumDimension checking screen" << screen << "geometry" << screen->availableVirtualGeometry(); return (screen ? qMin(screen->availableVirtualGeometry().width(), screen->availableVirtualGeometry().height()) : 480) * 9 / 10; diff --git a/src/dialogs/qquickabstractdialog_p.h b/src/dialogs/qquickabstractdialog_p.h index 3a9a0cd5..0fe7fa67 100644 --- a/src/dialogs/qquickabstractdialog_p.h +++ b/src/dialogs/qquickabstractdialog_p.h @@ -69,7 +69,7 @@ class QQuickAbstractDialog : public QObject Q_PROPERTY(int y READ y WRITE setY NOTIFY geometryChanged) Q_PROPERTY(int width READ width WRITE setWidth NOTIFY geometryChanged) Q_PROPERTY(int height READ height WRITE setHeight NOTIFY geometryChanged) - Q_PROPERTY(int __maximumDimension READ __maximumDimension CONSTANT) + Q_PROPERTY(int __maximumDimension READ __maximumDimension NOTIFY __maximumDimensionChanged) public: QQuickAbstractDialog(QObject *parent = 0); @@ -131,6 +131,7 @@ Q_SIGNALS: void titleChanged(); void accepted(); void rejected(); + void __maximumDimensionChanged(); protected Q_SLOTS: void decorationLoaded(); |