fix positioning

svn path=/trunk/KDE/kdelibs/; revision=1071385
This commit is contained in:
Aaron J. Seigo 2010-01-07 22:14:19 +00:00
parent d302d838d5
commit 4246f430ec

View File

@ -558,37 +558,37 @@ void DesktopToolBox::showToolBox()
const int iconWidth = KIconLoader::SizeMedium; const int iconWidth = KIconLoader::SizeMedium;
switch (corner()) { switch (corner()) {
case TopRight: case TopRight:
x = (int)boundingRect().right() - iconWidth - 5 - d->toolBacker->size().width(); x = (int)boundingRect().left() - d->toolBacker->size().width();
y = (int)boundingRect().top() + 10; y = (int)boundingRect().top();
break; break;
case Top: case Top:
x = (int)boundingRect().center().x() - iconWidth - (d->toolBacker->size().width() / 2); x = (int)boundingRect().center().x() - (d->toolBacker->size().width() / 2);
y = (int)boundingRect().top() + iconWidth + 10; y = (int)boundingRect().bottom();
break; break;
case TopLeft: case TopLeft:
x = (int)boundingRect().left() + iconWidth + 5; x = (int)boundingRect().right();
y = (int)boundingRect().top() + 10; y = (int)boundingRect().top();
break; break;
case Left: case Left:
x = (int)boundingRect().left() + iconWidth + 5; x = (int)boundingRect().left() + iconWidth;
y = (int)boundingRect().center().y() - iconWidth; y = (int)boundingRect().y();
break; break;
case Right: case Right:
x = (int)boundingRect().right() - iconWidth - 5 - d->toolBacker->size().width(); x = (int)boundingRect().right() - iconWidth - d->toolBacker->size().width();
y = (int)boundingRect().center().y() - iconWidth; y = (int)boundingRect().y();
break; break;
case BottomLeft: case BottomLeft:
x = (int)boundingRect().left() + iconWidth + 5; x = (int)boundingRect().left() + iconWidth;
y = (int)boundingRect().bottom() - 5; y = (int)boundingRect().bottom();
break; break;
case Bottom: case Bottom:
x = (int)boundingRect().center().x() - iconWidth - (d->toolBacker->size().width() / 2); x = (int)boundingRect().center().x() - (d->toolBacker->size().width() / 2);
y = (int)boundingRect().bottom() - iconWidth - 5; y = (int)boundingRect().top();
break; break;
case BottomRight: case BottomRight:
default: default:
x = (int)boundingRect().right() - iconWidth - 5 - d->toolBacker->size().width(); x = (int)boundingRect().right() - iconWidth - d->toolBacker->size().width();
y = (int)boundingRect().bottom() - iconWidth - 5; y = (int)boundingRect().top();
break; break;
} }
@ -611,19 +611,16 @@ void DesktopToolBox::showToolBox()
QRectF backerRect = mapToParent(d->toolBacker->geometry()).boundingRect(); QRectF backerRect = mapToParent(d->toolBacker->geometry()).boundingRect();
QSizeF parentSize = parentWidget()->size(); QSizeF parentSize = parentWidget()->size();
if (backerRect.x() < 5) { if (backerRect.x() < 5) {
d->toolBacker->setPos(5, y); d->toolBacker->setPos(mapFromParent(QPointF(5, 0)).x(), y);
} else if (backerRect.right() > parentSize.width() - 5) { } else if (backerRect.right() > parentSize.width() - 5) {
d->toolBacker->setPos(parentSize.width() - 5 - backerRect.width(), y); d->toolBacker->setPos(mapFromParent(QPointF(parentSize.width() - 5 - backerRect.width(), 0)).x(), y);
} }
if (backerRect.y() < 5) { if (backerRect.y() < 5) {
d->toolBacker->setPos(x, 5); d->toolBacker->setPos(x, mapFromParent(QPointF(0, 5)).y());
} else if (backerRect.bottom() > parentSize.height() - 5) { } else if (backerRect.bottom() > parentSize.height() - 5) {
d->toolBacker->setPos(x, parentSize.height() - 5 - backerRect.height()); d->toolBacker->setPos(x, mapFromParent(QPointF(0, parentSize.height() - 5 - backerRect.height())).y());
} }
// re-map our starting points back to our coordinate system
backerRect = mapFromParent(backerRect).boundingRect();
} }
d->toolBacker->setOpacity(0); d->toolBacker->setOpacity(0);
@ -658,7 +655,6 @@ void DesktopToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void DesktopToolBox::hideToolBox() void DesktopToolBox::hideToolBox()
{ {
Plasma::Animator *animdriver = Plasma::Animator::self();
foreach (QGraphicsItem *tool, tools()) { foreach (QGraphicsItem *tool, tools()) {
const int height = static_cast<int>(tool->boundingRect().height()); const int height = static_cast<int>(tool->boundingRect().height());
if (isToolbar()) { if (isToolbar()) {