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
This commit is contained in:
parent
334e818af0
commit
7c135314aa
@ -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
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QQuickWindow>
|
||||
#include <QWeakPointer>
|
||||
#include <QPoint>
|
||||
#include <QQmlParserStatus>
|
||||
|
||||
#include <Plasma/Plasma>
|
||||
#include <Plasma/Theme>
|
||||
@ -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 <QObject> m_mainItemLayout;
|
||||
|
Loading…
Reference in New Issue
Block a user