From fd5d33ee8ade0f2f3b516548b859e3fc2a047604 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 7 Apr 2010 22:02:52 +0000 Subject: [PATCH] several layout fixes: - extenderitem components have a fixed vertical size policy: they must not stretch when extenderitems are collapsed - one hardcoded size less -try to resize the internal scroller widget to sizehints in some case more svn path=/trunk/KDE/kdelibs/; revision=1112347 --- extenders/extendergroup.cpp | 12 +++++------- extenders/extenderitem.cpp | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/extenders/extendergroup.cpp b/extenders/extendergroup.cpp index 5efdd0de6..ec3449d8e 100644 --- a/extenders/extendergroup.cpp +++ b/extenders/extendergroup.cpp @@ -47,18 +47,17 @@ ExtenderGroup::ExtenderGroup(Extender *parent, uint groupId) config().writeEntry("isGroup", true); - //FIXME: this ain't pretty - setPreferredHeight(300); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); QGraphicsLinearLayout *lay = static_cast(layout()); d->scrollWidget = new ScrollWidget(this); d->scrollWidget->show(); lay->addItem(d->scrollWidget); d->scrollWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - d->scrollWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); d->childsWidget = new QGraphicsWidget(d->scrollWidget); d->scrollWidget->setWidget(d->childsWidget); d->layout = new QGraphicsLinearLayout(Qt::Vertical, d->childsWidget); + d->scrollWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); QAction *expand = new QAction(this); expand->setVisible(true); @@ -201,14 +200,12 @@ void ExtenderGroup::collapseGroup() } d->scrollWidget->hide(); static_cast(layout())->removeItem(d->scrollWidget); - extender()->resize(extender()->effectiveSizeHint(Qt::PreferredSize)); + extender()->resize(extender()->effectiveSizeHint(Qt::MinimumSize)); } void ExtenderGroup::resizeEvent(QGraphicsSceneResizeEvent *event) { ExtenderItem::resizeEvent(event); - - d->scrollWidget->setGeometry(0, 70, size().width(), 400); } ExtenderGroupPrivate::ExtenderGroupPrivate(ExtenderGroup *group) @@ -227,8 +224,9 @@ ExtenderGroupPrivate::~ExtenderGroupPrivate() void ExtenderGroupPrivate::addItemToGroup(Plasma::ExtenderItem *item) { if (item->group() == q) { - layout->addItem(item); item->setParentItem(childsWidget); + layout->addItem(item); + q->extender()->resize(q->extender()->effectiveSizeHint(Qt::PreferredSize).width(), q->extender()->size().height()); childsWidget->resize(childsWidget->size().width(), childsWidget->effectiveSizeHint(Qt::PreferredSize).height()); diff --git a/extenders/extenderitem.cpp b/extenders/extenderitem.cpp index 1936c862a..0bb6bfbd5 100644 --- a/extenders/extenderitem.cpp +++ b/extenders/extenderitem.cpp @@ -67,7 +67,7 @@ public: m_background(new FrameSvg(this)) { m_background->setImagePath("widgets/extender-dragger"); - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); updateTheme(); } @@ -114,6 +114,7 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId) d(new ExtenderItemPrivate(this, hostExtender)) { Q_ASSERT(hostExtender); + setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); //set the extenderId if (extenderItemId) {