From 7c135314aa9de3e474f1e482d61a415da29fffad Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 12 Feb 2014 23:40:15 +0100 Subject: [PATCH] Watch QQmlParserStatus in dialog This way we only call the expensive syncToMainItemSize once we have all the information to accurately position the window. Using the timer to limit the calls doesn't work entirely (according to qDebug) especially with the multiple threads to compile things. Seems to prevent the dialog ever jumping around on load. REVIEW: 115709 --- src/declarativeimports/core/dialog.cpp | 18 +++++++++++++++++- src/declarativeimports/core/dialog.h | 8 +++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/declarativeimports/core/dialog.cpp b/src/declarativeimports/core/dialog.cpp index b353caf02..db3c67e8c 100644 --- a/src/declarativeimports/core/dialog.cpp +++ b/src/declarativeimports/core/dialog.cpp @@ -54,7 +54,8 @@ DialogProxy::DialogProxy(QQuickItem *parent) m_location(Plasma::Types::BottomEdge), m_type(Normal), m_hideOnWindowDeactivate(false), - m_outputOnly(false) + m_outputOnly(false), + m_componentComplete(false) { QSurfaceFormat format; format.setAlphaBufferSize(8); @@ -453,6 +454,10 @@ void DialogProxy::syncToMainItemSize() void DialogProxy::requestSyncToMainItemSize(bool delayed) { + if (!m_componentComplete) { + return; + } + if (delayed && !m_syncTimer->isActive()) { m_syncTimer->start(150); } else { @@ -524,6 +529,17 @@ void DialogProxy::hideEvent(QHideEvent *event) QQuickWindow::hideEvent(event); } +void DialogProxy::classBegin() +{ + +} + +void DialogProxy::componentComplete() +{ + m_componentComplete = true; + syncToMainItemSize(); +} + void DialogProxy::syncBorders() { // FIXME: QWindow::screen() never ever changes if the window is moved across diff --git a/src/declarativeimports/core/dialog.h b/src/declarativeimports/core/dialog.h index 3c0df8b71..a4cd427f9 100644 --- a/src/declarativeimports/core/dialog.h +++ b/src/declarativeimports/core/dialog.h @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -44,9 +45,10 @@ namespace Plasma * * Exposed as `PlasmaCore.Dialog` in QML. */ -class DialogProxy : public QQuickWindow +class DialogProxy : public QQuickWindow, public QQmlParserStatus { Q_OBJECT + Q_INTERFACES(QQmlParserStatus) /** * The main QML item that will be displayed in the Dialog @@ -161,6 +163,9 @@ protected: void hideEvent(QHideEvent *event); bool event(QEvent *event); + virtual void classBegin(); + virtual void componentComplete(); + QTimer *m_syncTimer; Plasma::Types::Location m_location; Plasma::FrameSvgItem *m_frameSvgItem; @@ -185,6 +190,7 @@ private: bool m_hideOnWindowDeactivate; bool m_outputOnly; Plasma::Theme m_theme; + bool m_componentComplete; //Attached Layout property of mainItem, if any QWeakPointer m_mainItemLayout;