Set visibility on mainItem to match Dialog

Otherwise we can have an invisible dialog in which the items think they
are visible.

QtQuick is smart enough to not redraw anything if the window isn't
visible, but a lot of bits of our code check the visibility flag to
enable/disable animations. These animation timers do still trigger when
the window isn't visible which wastes CPU cycles.

We are already meddling with the visibility flag so this shouldn't have
too much impact.

Change-Id: I92b969e60b4fdbe4ff2c70f9cce6e3408482a862
This commit is contained in:
David Edmundson 2014-12-28 20:37:04 +01:00
parent 8a68da469c
commit 7d545e22f1

View File

@ -237,6 +237,10 @@ void DialogPrivate::updateTheme()
void DialogPrivate::updateVisibility(bool visible)
{
if (mainItem) {
mainItem->setVisible(visible);
}
if (visible) {
if (visualParent && visualParent->window()) {
q->setTransientParent(visualParent->window());
@ -269,6 +273,7 @@ void DialogPrivate::updateVisibility(bool visible)
}
}
if (!(q->flags() & Qt::ToolTip)) {
KWindowEffects::SlideFromLocation slideLocation = KWindowEffects::NoEdge;
@ -675,7 +680,7 @@ void Dialog::setMainItem(QQuickItem *mainItem)
d->mainItem = mainItem;
if (mainItem) {
d->mainItem->setVisible(true);
d->mainItem->setVisible(isVisible());
mainItem->setParentItem(contentItem());
connect(mainItem, SIGNAL(widthChanged()), this, SLOT(slotMainItemSizeChanged()));