From 1ce5890d24bc5fcc4cbe741d244ca3cd799cd9da Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 1 Apr 2010 10:01:56 +0000 Subject: [PATCH] toolbox positioning based on layouts svn path=/trunk/KDE/kdelibs/; revision=1109934 --- extenders/extenderitem.cpp | 31 +++++++------------------------ private/extenderitem_p.h | 1 - 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/extenders/extenderitem.cpp b/extenders/extenderitem.cpp index 69f33378e..4cb12e7cc 100644 --- a/extenders/extenderitem.cpp +++ b/extenders/extenderitem.cpp @@ -75,8 +75,10 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId) //create the toolbox. d->toolbox = new QGraphicsWidget(this); - d->toolboxLayout = new QGraphicsLinearLayout(d->toolbox); - d->toolbox->setLayout(d->toolboxLayout); + d->toolboxLayout = new QGraphicsLinearLayout(); + QGraphicsLinearLayout *toolBoxMainLayout = new QGraphicsLinearLayout(d->toolbox); + toolBoxMainLayout->addStretch(); + toolBoxMainLayout->addItem(d->toolboxLayout); //create items's configgroup KConfigGroup cg = hostExtender->d->applet->config("ExtenderItems"); @@ -205,7 +207,6 @@ void ExtenderItem::setWidget(QGraphicsItem *widget) d->widget = widget; } else { widget->installSceneEventFilter(this); - QSizeF panelSize(QSizeF(size().width() - d->bgLeft - d->bgRight, d->iconSize + d->dragTop + d->dragBottom)); widget->setPos(QPointF(d->bgLeft + d->dragLeft, panelSize.height() + d->bgTop)); @@ -834,19 +835,6 @@ void ExtenderItemPrivate::updateToolBox() } toolboxLayout->updateGeometry(); - - //position the toolbox correctly. - QSizeF minimum = toolboxLayout->minimumSize(); - toolbox->resize(minimum); - repositionToolbox(); -} - -void ExtenderItemPrivate::repositionToolbox() -{ - QSizeF minimum = toolboxLayout->minimumSize(); - toolbox->setPos(q->size().width() - minimum.width() - bgRight, - (dragHandleRect().height()/2) - - (minimum.height()/2) + bgTop); } Applet *ExtenderItemPrivate::hostApplet() const @@ -899,18 +887,16 @@ void ExtenderItemPrivate::themeChanged() collapseIcon->size().height()/2 + bgTop); //reposition the widget based on the new margins. - if (widget) { + if (widget && !widget->isWidget()) { widget->setPos(QPointF(bgLeft + dragLeft, panelSize.height() + bgTop)); } - //reposition the toolbox. - repositionToolbox(); - updateSizeHints(); - if (!q->size().isEmpty()) + if (!q->size().isEmpty()) { resizeContent(q->size()); + } } void ExtenderItemPrivate::sourceAppletRemoved() @@ -943,9 +929,6 @@ void ExtenderItemPrivate::resizeContent(const QSizeF &newSize) graphicsWidget->resize(newWidgetSize); } - //reposition the toolbox. - repositionToolbox(); - q->update(); } diff --git a/private/extenderitem_p.h b/private/extenderitem_p.h index 2908a2c99..91454225e 100644 --- a/private/extenderitem_p.h +++ b/private/extenderitem_p.h @@ -50,7 +50,6 @@ class ExtenderItemPrivate QRectF titleRect(); void toggleCollapse(); void updateToolBox(); - void repositionToolbox(); Applet *hostApplet() const; void themeChanged(); void sourceAppletRemoved();