toolbox positioning based on layouts
svn path=/trunk/KDE/kdelibs/; revision=1109934
This commit is contained in:
parent
8f7d7bc782
commit
1ce5890d24
@ -75,8 +75,10 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId)
|
|||||||
|
|
||||||
//create the toolbox.
|
//create the toolbox.
|
||||||
d->toolbox = new QGraphicsWidget(this);
|
d->toolbox = new QGraphicsWidget(this);
|
||||||
d->toolboxLayout = new QGraphicsLinearLayout(d->toolbox);
|
d->toolboxLayout = new QGraphicsLinearLayout();
|
||||||
d->toolbox->setLayout(d->toolboxLayout);
|
QGraphicsLinearLayout *toolBoxMainLayout = new QGraphicsLinearLayout(d->toolbox);
|
||||||
|
toolBoxMainLayout->addStretch();
|
||||||
|
toolBoxMainLayout->addItem(d->toolboxLayout);
|
||||||
|
|
||||||
//create items's configgroup
|
//create items's configgroup
|
||||||
KConfigGroup cg = hostExtender->d->applet->config("ExtenderItems");
|
KConfigGroup cg = hostExtender->d->applet->config("ExtenderItems");
|
||||||
@ -205,7 +207,6 @@ void ExtenderItem::setWidget(QGraphicsItem *widget)
|
|||||||
d->widget = widget;
|
d->widget = widget;
|
||||||
} else {
|
} else {
|
||||||
widget->installSceneEventFilter(this);
|
widget->installSceneEventFilter(this);
|
||||||
|
|
||||||
QSizeF panelSize(QSizeF(size().width() - d->bgLeft - d->bgRight,
|
QSizeF panelSize(QSizeF(size().width() - d->bgLeft - d->bgRight,
|
||||||
d->iconSize + d->dragTop + d->dragBottom));
|
d->iconSize + d->dragTop + d->dragBottom));
|
||||||
widget->setPos(QPointF(d->bgLeft + d->dragLeft, panelSize.height() + d->bgTop));
|
widget->setPos(QPointF(d->bgLeft + d->dragLeft, panelSize.height() + d->bgTop));
|
||||||
@ -834,19 +835,6 @@ void ExtenderItemPrivate::updateToolBox()
|
|||||||
}
|
}
|
||||||
|
|
||||||
toolboxLayout->updateGeometry();
|
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
|
Applet *ExtenderItemPrivate::hostApplet() const
|
||||||
@ -899,18 +887,16 @@ void ExtenderItemPrivate::themeChanged()
|
|||||||
collapseIcon->size().height()/2 + bgTop);
|
collapseIcon->size().height()/2 + bgTop);
|
||||||
|
|
||||||
//reposition the widget based on the new margins.
|
//reposition the widget based on the new margins.
|
||||||
if (widget) {
|
if (widget && !widget->isWidget()) {
|
||||||
widget->setPos(QPointF(bgLeft + dragLeft, panelSize.height() +
|
widget->setPos(QPointF(bgLeft + dragLeft, panelSize.height() +
|
||||||
bgTop));
|
bgTop));
|
||||||
}
|
}
|
||||||
|
|
||||||
//reposition the toolbox.
|
|
||||||
repositionToolbox();
|
|
||||||
|
|
||||||
updateSizeHints();
|
updateSizeHints();
|
||||||
|
|
||||||
if (!q->size().isEmpty())
|
if (!q->size().isEmpty()) {
|
||||||
resizeContent(q->size());
|
resizeContent(q->size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExtenderItemPrivate::sourceAppletRemoved()
|
void ExtenderItemPrivate::sourceAppletRemoved()
|
||||||
@ -943,9 +929,6 @@ void ExtenderItemPrivate::resizeContent(const QSizeF &newSize)
|
|||||||
graphicsWidget->resize(newWidgetSize);
|
graphicsWidget->resize(newWidgetSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
//reposition the toolbox.
|
|
||||||
repositionToolbox();
|
|
||||||
|
|
||||||
q->update();
|
q->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,6 @@ class ExtenderItemPrivate
|
|||||||
QRectF titleRect();
|
QRectF titleRect();
|
||||||
void toggleCollapse();
|
void toggleCollapse();
|
||||||
void updateToolBox();
|
void updateToolBox();
|
||||||
void repositionToolbox();
|
|
||||||
Applet *hostApplet() const;
|
Applet *hostApplet() const;
|
||||||
void themeChanged();
|
void themeChanged();
|
||||||
void sourceAppletRemoved();
|
void sourceAppletRemoved();
|
||||||
|
Loading…
Reference in New Issue
Block a user