don't update the minimum size when not visible

since when is not visible the dialog doesn't update its size
from the mainItem size, the minimum size should not be
updated as well, or the initial mainitem size will get lost
and the dialog will be initialized to a wrong size

Patch by: Vishesh Handa <vhanda@kde.org>

Change-Id: I272727fb4732474b102de64c9bfdddb7fc3906c8
This commit is contained in:
Marco Martin 2014-09-23 16:54:49 +02:00
parent d28871cb65
commit e3fd010166
2 changed files with 89 additions and 12 deletions

View File

@ -294,6 +294,10 @@ void DialogPrivate::updateMinimumWidth()
Q_ASSERT(mainItem); Q_ASSERT(mainItem);
Q_ASSERT(mainItemLayout); Q_ASSERT(mainItemLayout);
if (!componentComplete || !q->isVisible()) {
return;
}
mainItem->disconnect(q); mainItem->disconnect(q);
syncBorders(q->geometry()); syncBorders(q->geometry());
@ -326,12 +330,13 @@ void DialogPrivate::updateMinimumWidth()
void DialogPrivate::updateMinimumHeight() void DialogPrivate::updateMinimumHeight()
{ {
if (!componentComplete) {
return;
}
Q_ASSERT(mainItem); Q_ASSERT(mainItem);
Q_ASSERT(mainItemLayout); Q_ASSERT(mainItemLayout);
if (!componentComplete || !q->isVisible()) {
return;
}
mainItem->disconnect(q); mainItem->disconnect(q);
syncBorders(q->geometry()); syncBorders(q->geometry());
@ -364,12 +369,13 @@ void DialogPrivate::updateMinimumHeight()
void DialogPrivate::updateMaximumWidth() void DialogPrivate::updateMaximumWidth()
{ {
if (!componentComplete) {
return;
}
Q_ASSERT(mainItem); Q_ASSERT(mainItem);
Q_ASSERT(mainItemLayout); Q_ASSERT(mainItemLayout);
if (!componentComplete || !q->isVisible()) {
return;
}
mainItem->disconnect(q); mainItem->disconnect(q);
syncBorders(q->geometry()); syncBorders(q->geometry());
@ -397,12 +403,13 @@ void DialogPrivate::updateMaximumWidth()
void DialogPrivate::updateMaximumHeight() void DialogPrivate::updateMaximumHeight()
{ {
if (!componentComplete) {
return;
}
Q_ASSERT(mainItem); Q_ASSERT(mainItem);
Q_ASSERT(mainItemLayout); Q_ASSERT(mainItemLayout);
if (!componentComplete || !q->isVisible()) {
return;
}
mainItem->disconnect(q); mainItem->disconnect(q);
syncBorders(q->geometry()); syncBorders(q->geometry());
@ -551,9 +558,8 @@ void DialogPrivate::syncToMainItemSize()
} }
if (visualParent) { if (visualParent) {
// Get the full size with ALL the borders // fixedMargins will get all the borders, no matter if they are enabled
frameSvgItem->setEnabledBorders(Plasma::FrameSvg::AllBorders); auto margins = frameSvgItem->fixedMargins();
auto margins = frameSvgItem->margins();
const QSize fullSize = QSize(mainItem->width(), mainItem->height()) + const QSize fullSize = QSize(mainItem->width(), mainItem->height()) +
QSize(margins->left() + margins->right(), QSize(margins->left() + margins->right(),

View File

@ -0,0 +1,71 @@
/*
* Copyright 2014 Vishesh Handa <vhanda@kde.org>
* Copyright 2014 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2,
* or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.0
import QtQuick.Controls 1.1 as Controls
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
id: root
Layout.minimumWidth: 300
Layout.minimumHeight: 300
Controls.Button {
id: button
anchors.centerIn: parent
text: "Show Dialog"
onClicked: {
//changing the minimumHeight of the mainItem of an hidden dialog
//shouldn't
rect.Layout.minimumHeight = rect.Layout.minimumHeight + 1
rect.Layout.minimumWidth = rect.Layout.minimumWidth + 1
subDialog.visible = !subDialog.visible
}
}
PlasmaCore.Dialog {
id: subDialog
location: PlasmaCore.Types.Floating
visualParent: button
visible: false
Rectangle {
id: rect
width: 500
height: 500
Layout.minimumWidth: 300
Layout.minimumHeight: 300
color: "red"
Rectangle {
anchors.centerIn: parent
width: rect.Layout.minimumWidth
height: rect.Layout.minimumHeight
Text {
anchors.fill: parent
wrapMode: Text.WordWrap
text: "you should see a red border around this white area"
}
}
}
}
}