From f688c904a81c72d077580ab942b874f398fbd7d4 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 21 Jan 2016 15:35:19 +0100 Subject: [PATCH] AppletQuickItem: Don't try to set initial size bigger than parent size Trying to set initial size bigger than parent size only results to item being resized down to fit in parent later. REVIEW: 126822 BUG: 358200 --- src/plasmaquick/appletquickitem.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/plasmaquick/appletquickitem.cpp b/src/plasmaquick/appletquickitem.cpp index 995ec101b..48e78cdac 100644 --- a/src/plasmaquick/appletquickitem.cpp +++ b/src/plasmaquick/appletquickitem.cpp @@ -535,16 +535,20 @@ void AppletQuickItem::init() QVariantHash initialProperties; //initialize with our size only if valid if (width() > 0 && height() > 0) { - initialProperties[QStringLiteral("width")] = width(); - initialProperties[QStringLiteral("height")] = height(); + const qreal w = parentItem() ? std::min(parentItem()->width(), width()) : width(); + const qreal h = parentItem() ? std::min(parentItem()->height(), height()) : height(); + initialProperties[QStringLiteral("width")] = w; + initialProperties[QStringLiteral("height")] = h; } d->qmlObject->setInitializationDelayed(false); d->qmlObject->completeInitialization(initialProperties); //otherwise, initialize our size to root object's size if (d->qmlObject->rootObject() && (width() <= 0 || height() <= 0)) { - setWidth(d->qmlObject->rootObject()->property("width").value()); - setHeight(d->qmlObject->rootObject()->property("height").value()); + const qreal w = d->qmlObject->rootObject()->property("width").value(); + const qreal h = d->qmlObject->rootObject()->property("height").value(); + setWidth(parentItem() ? std::min(parentItem()->width(), w) : w); + setHeight(parentItem() ? std::min(parentItem()->height(), h) : h); } //default fullrepresentation is our root main component, if none specified