Only update real visibility when component has finished completion
We only want to toggle our visibility until after all window flags have been set, as some flags can only be set before the window is shown. This patch caches and proxies the visibility flag and only update the real visibility when the component is complete. Change-Id: I4ce7744dc48afecf35db6679ca0991b7042e45a2
This commit is contained in:
parent
9bafdb6ed6
commit
62d240b7d6
@ -62,6 +62,7 @@ public:
|
||||
type(Dialog::Normal),
|
||||
hideOnWindowDeactivate(false),
|
||||
outputOnly(false),
|
||||
visible(false),
|
||||
componentComplete(dialog->parent() == 0),
|
||||
backgroundHints(Dialog::StandardBackground)
|
||||
{
|
||||
@ -123,6 +124,7 @@ public:
|
||||
Dialog::WindowType type;
|
||||
bool hideOnWindowDeactivate;
|
||||
bool outputOnly;
|
||||
bool visible;
|
||||
Plasma::Theme theme;
|
||||
bool componentComplete;
|
||||
Dialog::BackgroundHints backgroundHints;
|
||||
@ -641,6 +643,8 @@ Dialog::Dialog(QQuickItem *parent)
|
||||
connect(this, &QWindow::xChanged, [=]() { d->slotWindowPositionChanged(); });
|
||||
connect(this, &QWindow::yChanged, [=]() { d->slotWindowPositionChanged(); });
|
||||
|
||||
connect(this, SIGNAL(visibleChanged(bool)),
|
||||
this, SIGNAL(visibleChangedProxy()));
|
||||
connect(this, SIGNAL(visibleChanged(bool)),
|
||||
this, SLOT(updateInputShape()));
|
||||
connect(this, SIGNAL(outputOnlyChanged()),
|
||||
@ -1042,6 +1046,7 @@ void Dialog::classBegin()
|
||||
void Dialog::componentComplete()
|
||||
{
|
||||
d->componentComplete = true;
|
||||
QQuickWindow::setVisible(d->visible);
|
||||
|
||||
d->updateTheme();
|
||||
|
||||
@ -1082,6 +1087,28 @@ void Dialog::setOutputOnly(bool outputOnly)
|
||||
emit outputOnlyChanged();
|
||||
}
|
||||
|
||||
void Dialog::setVisible(bool visible)
|
||||
{
|
||||
//only update real visibility when we have finished component completion
|
||||
//and all flags have been set
|
||||
|
||||
d->visible = visible;
|
||||
if (d->componentComplete) {
|
||||
QQuickWindow::setVisible(visible);
|
||||
//signal will be emitted and proxied from the QQuickWindow code
|
||||
} else {
|
||||
emit visibleChangedProxy();
|
||||
}
|
||||
}
|
||||
|
||||
bool Dialog::isVisible() const
|
||||
{
|
||||
if (d->componentComplete) {
|
||||
return QQuickWindow::isVisible();
|
||||
}
|
||||
return d->visible;
|
||||
}
|
||||
|
||||
Dialog::BackgroundHints Dialog::backgroundHints() const
|
||||
{
|
||||
return d->backgroundHints;
|
||||
|
@ -145,6 +145,8 @@ class PLASMAQUICK_EXPORT Dialog : public QQuickWindow, public QQmlParserStatus
|
||||
*/
|
||||
Q_PROPERTY(BackgroundHints backgroundHints READ backgroundHints WRITE setBackgroundHints NOTIFY backgroundHintsChanged)
|
||||
|
||||
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChangedProxy)
|
||||
|
||||
Q_CLASSINFO("DefaultProperty", "mainItem")
|
||||
|
||||
public:
|
||||
@ -193,6 +195,9 @@ public:
|
||||
BackgroundHints backgroundHints() const;
|
||||
void setBackgroundHints(BackgroundHints hints);
|
||||
|
||||
bool isVisible() const;
|
||||
void setVisible(bool visible);
|
||||
|
||||
/**
|
||||
* @returns The suggested screen position for the popup
|
||||
* @arg item the item the popup has to be positioned relatively to. if null, the popup will be positioned in the center of the window
|
||||
@ -209,6 +214,7 @@ Q_SIGNALS:
|
||||
void outputOnlyChanged();
|
||||
void flagsChanged();
|
||||
void backgroundHintsChanged();
|
||||
void visibleChangedProxy(); //redeclaration of QQuickWindow::visibleChanged
|
||||
/**
|
||||
* Emitted when the @see hideOnWindowDeactivate property is @c true and this dialog lost focus to a
|
||||
* window that is neither a parent dialog to nor a child dialog of this dialog.
|
||||
|
Loading…
Reference in New Issue
Block a user