David Edmundson has uploaded a new change for review. https://gerrit.vesnicky.cesnet.cz/r/419
Change subject: Simplify code flow ...................................................................... Simplify code flow return immediately rather than wrapping an entire function inside an if Change-Id: Ic5046875ad39795248496a0d71f77b1e476058c4 --- M src/plasmaquick/dialog.cpp 1 file changed, 59 insertions(+), 57 deletions(-) git pull ssh://gerrit.vesnicky.cesnet.cz:29418/plasma-framework refs/changes/19/419/1 diff --git a/src/plasmaquick/dialog.cpp b/src/plasmaquick/dialog.cpp index 097cc31..34e5424 100644 --- a/src/plasmaquick/dialog.cpp +++ b/src/plasmaquick/dialog.cpp @@ -692,64 +692,66 @@ void Dialog::setMainItem(QQuickItem *mainItem) { - if (d->mainItem != mainItem) { - disconnect(d->mainItem, 0, this, 0); - disconnect(d->mainItemLayout, 0, this, 0); - - d->hintsCommitTimer.stop(); - if (d->mainItem) { - d->mainItem->setVisible(false); - } - - d->mainItem = mainItem; - - if (mainItem) { - d->mainItem->setVisible(isVisible()); - mainItem->setParentItem(contentItem()); - - connect(mainItem, SIGNAL(widthChanged()), this, SLOT(slotMainItemSizeChanged())); - connect(mainItem, SIGNAL(heightChanged()), this, SLOT(slotMainItemSizeChanged())); - d->slotMainItemSizeChanged(); - - //Extract the representation's Layout, if any - QObject *layout = 0; - setMinimumSize(QSize(0, 0)); - setMaximumSize(QSize(DIALOGSIZE_MAX, DIALOGSIZE_MAX)); - - //Search a child that has the needed Layout properties - //HACK: here we are not type safe, but is the only way to access to a pointer of Layout - foreach (QObject *child, mainItem->children()) { - //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight - if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && - child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && - child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && - child->property("fillWidth").isValid() && child->property("fillHeight").isValid() - ) { - layout = child; - } - } - if (d->mainItemLayout) { - disconnect(d->mainItemLayout, 0, this, 0); - } - d->mainItemLayout = layout; - - if (layout) { - //Why queued connections? - //we need to be sure that the properties are - //already *all* updated when we call the management code - connect(layout, SIGNAL(minimumWidthChanged()), this, SLOT(updateMinimumWidth())); - connect(layout, SIGNAL(minimumHeightChanged()), this, SLOT(updateMinimumHeight())); - connect(layout, SIGNAL(maximumWidthChanged()), this, SLOT(updateMaximumWidth())); - connect(layout, SIGNAL(maximumHeightChanged()), this, SLOT(updateMaximumHeight())); - - d->updateLayoutParameters(); - } - - } - - //if this is called in Component.onCompleted we have to wait a loop the item is added to a scene - emit mainItemChanged(); + if (d->mainItem == mainItem) { + return; } + + disconnect(d->mainItem, 0, this, 0); + disconnect(d->mainItemLayout, 0, this, 0); + + d->hintsCommitTimer.stop(); + if (d->mainItem) { + d->mainItem->setVisible(false); + } + + d->mainItem = mainItem; + + if (mainItem) { + d->mainItem->setVisible(isVisible()); + mainItem->setParentItem(contentItem()); + + connect(mainItem, SIGNAL(widthChanged()), this, SLOT(slotMainItemSizeChanged())); + connect(mainItem, SIGNAL(heightChanged()), this, SLOT(slotMainItemSizeChanged())); + d->slotMainItemSizeChanged(); + + //Extract the representation's Layout, if any + QObject *layout = 0; + setMinimumSize(QSize(0, 0)); + setMaximumSize(QSize(DIALOGSIZE_MAX, DIALOGSIZE_MAX)); + + //Search a child that has the needed Layout properties + //HACK: here we are not type safe, but is the only way to access to a pointer of Layout + foreach (QObject *child, mainItem->children()) { + //find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight + if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() && + child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() && + child->property("maximumWidth").isValid() && child->property("maximumHeight").isValid() && + child->property("fillWidth").isValid() && child->property("fillHeight").isValid() + ) { + layout = child; + } + } + if (d->mainItemLayout) { + disconnect(d->mainItemLayout, 0, this, 0); + } + d->mainItemLayout = layout; + + if (layout) { + //Why queued connections? + //we need to be sure that the properties are + //already *all* updated when we call the management code + connect(layout, SIGNAL(minimumWidthChanged()), this, SLOT(updateMinimumWidth())); + connect(layout, SIGNAL(minimumHeightChanged()), this, SLOT(updateMinimumHeight())); + connect(layout, SIGNAL(maximumWidthChanged()), this, SLOT(updateMaximumWidth())); + connect(layout, SIGNAL(maximumHeightChanged()), this, SLOT(updateMaximumHeight())); + + d->updateLayoutParameters(); + } + + } + + //if this is called in Component.onCompleted we have to wait a loop the item is added to a scene + emit mainItemChanged(); } void DialogPrivate::slotMainItemSizeChanged() -- To view, visit https://gerrit.vesnicky.cesnet.cz/r/419 To unsubscribe, visit https://gerrit.vesnicky.cesnet.cz/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic5046875ad39795248496a0d71f77b1e476058c4 Gerrit-PatchSet: 1 Gerrit-Project: plasma-framework Gerrit-Branch: master Gerrit-Owner: David Edmundson <da...@davidedmundson.co.uk> Gerrit-Reviewer: Kevin Ottens <er...@kde.org> Gerrit-Reviewer: Marco Martin <notm...@gmail.com> Gerrit-Reviewer: Vishesh Handa <m...@vhanda.in> _______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel