panel toolbox looks way better, but is not displayed right now because

isContainment of the panel returns false again and it seems geometry()
returns a size of 0x0 in constraintsUpdated

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=797075
This commit is contained in:
Marco Martin 2008-04-14 21:09:15 +00:00
parent 17bba1cffc
commit f4e44f397e
3 changed files with 25 additions and 10 deletions

View File

@ -248,7 +248,11 @@ void Containment::containmentConstraintsUpdated(Plasma::Constraints constraints)
}
if (constraints & Plasma::ScreenConstraint && d->toolbox) {
d->toolbox->setPos(geometry().width() - d->toolbox->boundingRect().width(), 0);
if (d->type == PanelContainment) {
d->toolbox->setPos(geometry().width() - d->toolbox->boundingRect().width(), geometry().height()/2 - d->toolbox->size());
} else {
d->toolbox->setPos(geometry().width() - d->toolbox->boundingRect().width(), 0);
}
d->toolbox->enableTool("addwidgets", !isImmutable());
}
@ -294,7 +298,8 @@ void Containment::setContainmentType(Containment::Type type)
QGraphicsWidget *activityTool = addToolBoxTool("addSiblingContainment", "list-add", i18n("Add Activity"));
connect(activityTool, SIGNAL(clicked()), this, SLOT(addSiblingContainment()));
}
} else if (isContainment() && type == PanelContainment){
//FIXME: the isContainment fix kinda got vanished in the woc migration
} else if (isContainment() && type == PanelContainment) {
d->createToolbox();
d->toolbox->setSize(24);
d->toolbox->setIconSize(QSize(16, 16));

View File

@ -1,5 +1,6 @@
/*
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
* Copyright 2008 by Marco Martin <notmart@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as

View File

@ -101,7 +101,7 @@ PanelToolbox::PanelToolbox(QGraphicsItem *parent)
QRectF PanelToolbox::boundingRect() const
{
return QRectF(0, 0, size()*2, size()*2);
return QRectF(0, 0, -size()*2, size()*4);
}
void PanelToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
@ -109,6 +109,10 @@ void PanelToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
Q_UNUSED(option)
Q_UNUSED(widget)
painter->save();
painter->translate(boundingRect().topLeft());
QColor color1 = KColorScheme(QPalette::Active, KColorScheme::Window,
Plasma::Theme::self()->colors()).background().color();
color1.setAlpha(64);
@ -118,8 +122,9 @@ void PanelToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
color2.setAlpha(64);
QPainterPath p = shape();
QRadialGradient gradient(QPoint(size()*2, size()), size() + d->animFrame);
gradient.setFocalPoint(QPointF(size()*2, size()));
const QPoint gradientCenter(boundingRect().left(), boundingRect().center().y());
QRadialGradient gradient(gradientCenter, size() + d->animFrame - 1);
gradient.setFocalPoint(gradientCenter);
gradient.setColorAt(0, color1);
gradient.setColorAt(.87, color1);
gradient.setColorAt(.97, color2);
@ -133,26 +138,30 @@ void PanelToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
painter->restore();
const qreal progress = d->animFrame / size();
const QRect iconRect(QPoint((int)boundingRect().left() - iconSize().width() + 2, gradientCenter.y() - iconSize().height()/2), iconSize());
if (progress <= 0.9) {
d->icon.paint(painter, QRect(QPoint(size()*2 - iconSize().width() + 2, 2), iconSize()), Qt::AlignCenter, QIcon::Disabled, QIcon::Off);
d->icon.paint(painter, iconRect, Qt::AlignCenter, QIcon::Disabled, QIcon::Off);
}
if (progress > 0.1) {
painter->save();
painter->setOpacity(progress);
d->icon.paint(painter, QRect(QPoint(size()*2 - iconSize().width() + 2, 2), iconSize()));
d->icon.paint(painter, iconRect);
painter->restore();
}
painter->restore();
}
QPainterPath PanelToolbox::shape() const
{
QPainterPath path;
int toolSize = size() + (int)d->animFrame;
path.moveTo(size()*2, 0);
//path.arcTo(QRectF(size()*2 - toolSize, -toolSize, toolSize*2, toolSize*2), 180, 90);
path.addRect(QRectF(0, 0, toolSize*2, toolSize*2));
//path.moveTo(size()*2, 0);
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().center().y() - toolSize, toolSize*2, toolSize*2), 90, 180);
return path;
}