From e3fd0101660da0c47899090ceb6aa85a6fbf749a Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 23 Sep 2014 16:54:49 +0200 Subject: [PATCH] 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 Change-Id: I272727fb4732474b102de64c9bfdddb7fc3906c8 --- src/plasmaquick/dialog.cpp | 30 ++++++++------ tests/dialog_sizeMoreThanMin.qml | 71 ++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 tests/dialog_sizeMoreThanMin.qml diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index 0dc0257cc..4228bca8b 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -294,6 +294,10 @@ void DialogPrivate::updateMinimumWidth() Q_ASSERT(mainItem); Q_ASSERT(mainItemLayout); + if (!componentComplete || !q->isVisible()) { + return; + } + mainItem->disconnect(q); syncBorders(q->geometry()); @@ -326,12 +330,13 @@ void DialogPrivate::updateMinimumWidth() void DialogPrivate::updateMinimumHeight() { - if (!componentComplete) { - return; - } Q_ASSERT(mainItem); Q_ASSERT(mainItemLayout); + if (!componentComplete || !q->isVisible()) { + return; + } + mainItem->disconnect(q); syncBorders(q->geometry()); @@ -364,12 +369,13 @@ void DialogPrivate::updateMinimumHeight() void DialogPrivate::updateMaximumWidth() { - if (!componentComplete) { - return; - } Q_ASSERT(mainItem); Q_ASSERT(mainItemLayout); + if (!componentComplete || !q->isVisible()) { + return; + } + mainItem->disconnect(q); syncBorders(q->geometry()); @@ -397,12 +403,13 @@ void DialogPrivate::updateMaximumWidth() void DialogPrivate::updateMaximumHeight() { - if (!componentComplete) { - return; - } Q_ASSERT(mainItem); Q_ASSERT(mainItemLayout); + if (!componentComplete || !q->isVisible()) { + return; + } + mainItem->disconnect(q); syncBorders(q->geometry()); @@ -551,9 +558,8 @@ void DialogPrivate::syncToMainItemSize() } if (visualParent) { - // Get the full size with ALL the borders - frameSvgItem->setEnabledBorders(Plasma::FrameSvg::AllBorders); - auto margins = frameSvgItem->margins(); + // fixedMargins will get all the borders, no matter if they are enabled + auto margins = frameSvgItem->fixedMargins(); const QSize fullSize = QSize(mainItem->width(), mainItem->height()) + QSize(margins->left() + margins->right(), diff --git a/tests/dialog_sizeMoreThanMin.qml b/tests/dialog_sizeMoreThanMin.qml new file mode 100644 index 000000000..693f1fd9b --- /dev/null +++ b/tests/dialog_sizeMoreThanMin.qml @@ -0,0 +1,71 @@ +/* + * Copyright 2014 Vishesh Handa + * Copyright 2014 Marco Martin + * + * 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" + } + } + } + } +}