diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index 79a871b8a..afc7d0feb 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -114,7 +114,6 @@ public: void syncToMainItemSize(); Dialog *q; - QTimer *syncTimer; Plasma::Types::Location location; Plasma::FrameSvgItem *frameSvgItem; QPointer mainItem; @@ -238,7 +237,9 @@ void DialogPrivate::updateVisibility(bool visible) } cachedGeometry = QRect(); } - syncToMainItemSize(); + if (mainItem) { + syncToMainItemSize(); + } if (mainItemLayout) { updateLayoutParameters(); } @@ -540,7 +541,9 @@ void DialogPrivate::updateInputShape() void DialogPrivate::syncToMainItemSize() { - if (!componentComplete || !mainItem || !q->isVisible()) { + Q_ASSERT(mainItem); + + if (!componentComplete || !q->isVisible()) { return; } @@ -733,7 +736,9 @@ void Dialog::setVisualParent(QQuickItem *visualParent) if (visualParent->window()) { setTransientParent(visualParent->window()); } - d->syncToMainItemSize(); + if (d->mainItem) { + d->syncToMainItemSize(); + } } } @@ -881,7 +886,9 @@ void Dialog::setLocation(Plasma::Types::Location location) d->location = location; emit locationChanged(); - d->syncToMainItemSize(); + if (d->mainItem) { + d->syncToMainItemSize(); + } } QObject *Dialog::margins() const @@ -903,6 +910,19 @@ void Dialog::adjustGeometry(const QRect &geom) void Dialog::resizeEvent(QResizeEvent* re) { QQuickWindow::resizeEvent(re); + + d->mainItem->disconnect(this); + + d->frameSvgItem->setWidth(re->size().width()); + d->frameSvgItem->setHeight(re->size().height()); + auto margin = d->frameSvgItem->margins(); + d->mainItem->setX(margin->left()); + d->mainItem->setY(margin->top()); + d->mainItem->setWidth(re->size().width() - margin->left() - margin->right()); + d->mainItem->setHeight(re->size().height() - margin->top() - margin->bottom()); + + QObject::connect(d->mainItem, SIGNAL(widthChanged()), this, SLOT(slotMainItemSizeChanged())); + QObject::connect(d->mainItem, SIGNAL(heightChanged()), this, SLOT(slotMainItemSizeChanged())); } void Dialog::setType(WindowType type) @@ -1013,7 +1033,12 @@ void Dialog::classBegin() void Dialog::componentComplete() { d->componentComplete = true; - d->syncToMainItemSize(); + + d->updateTheme(); + + if (d->mainItem) { + d->syncToMainItemSize(); + } if (d->mainItemLayout) { d->updateLayoutParameters(); diff --git a/tests/dialog_minWidthHeightRepositioning.qml b/tests/dialog_minWidthHeightRepositioning.qml index 37bd622dd..c37543831 100644 --- a/tests/dialog_minWidthHeightRepositioning.qml +++ b/tests/dialog_minWidthHeightRepositioning.qml @@ -25,6 +25,7 @@ import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore PlasmaCore.Dialog { + id: root location: PlasmaCore.Types.Floating Rectangle { @@ -34,6 +35,10 @@ PlasmaCore.Dialog { color: "red" + Rectangle { + width: rect.Layout.minimumWidth + height: rect.Layout.minimumHeight + } ColumnLayout { anchors.top: parent.top Controls.Label { @@ -53,6 +58,18 @@ PlasmaCore.Dialog { rect.Layout.minimumHeight = rect.Layout.minimumHeight + 10 } } + Controls.Button { + text: "Increase dialog width" + onClicked: { + root.width = root.width + 10 + } + } + Controls.Button { + text: "Increase dialog height" + onClicked: { + root.height = root.height + 10 + } + } } } }