int with a frameSvg when it's not in a corner
svn path=/trunk/KDE/kdelibs/; revision=892649
This commit is contained in:
parent
2207ff1dc5
commit
e22429867b
@ -154,6 +154,7 @@ public:
|
||||
|
||||
|
||||
DesktopToolBox *q;
|
||||
Plasma::FrameSvg *background;
|
||||
Containment *containment;
|
||||
KIcon icon;
|
||||
EmptyGraphicsItem *toolBacker;
|
||||
@ -179,6 +180,9 @@ DesktopToolBox::DesktopToolBox(Containment *parent)
|
||||
setIsMovable(true);
|
||||
assignColors();
|
||||
|
||||
d->background = new Plasma::FrameSvg();
|
||||
d->background->setImagePath("widgets/translucentbackground");
|
||||
|
||||
connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)),
|
||||
this, SLOT(toolMoved(QGraphicsItem*)));
|
||||
connect(this, SIGNAL(toggled()), this, SLOT(toggle()));
|
||||
@ -217,61 +221,79 @@ void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||
QPointF gradientCenter;
|
||||
const QRectF rect = boundingRect();
|
||||
const QSize icons = iconSize();
|
||||
bool atCorner;
|
||||
|
||||
switch (corner()) {
|
||||
case TopRight:
|
||||
iconPos = QPoint((int)rect.right() - icons.width() + 2, 2);
|
||||
gradientCenter = rect.topRight();
|
||||
atCorner = true;
|
||||
break;
|
||||
case Top:
|
||||
iconPos = QPoint(rect.center().x() - icons.width() / 2, 2);
|
||||
gradientCenter = QPoint(rect.center().x(), rect.y());
|
||||
atCorner = false;
|
||||
d->background->setEnabledBorders(FrameSvg::BottomBorder|FrameSvg::LeftBorder|FrameSvg::RightBorder);
|
||||
break;
|
||||
case TopLeft:
|
||||
iconPos = QPoint(2, 2);
|
||||
gradientCenter = rect.topLeft();
|
||||
atCorner = true;
|
||||
break;
|
||||
case Left:
|
||||
iconPos = QPoint(2, rect.center().y() - icons.height() / 2);
|
||||
gradientCenter = QPointF(rect.left(), rect.center().y());
|
||||
atCorner = false;
|
||||
d->background->setEnabledBorders(FrameSvg::BottomBorder|FrameSvg::TopBorder|FrameSvg::RightBorder);
|
||||
break;
|
||||
case Right:
|
||||
iconPos = QPoint((int)rect.right() - icons.width() + 2,
|
||||
rect.center().y() - icons.height() / 2);
|
||||
gradientCenter = QPointF(rect.right(), rect.center().y());
|
||||
atCorner = false;
|
||||
d->background->setEnabledBorders(FrameSvg::BottomBorder|FrameSvg::TopBorder|FrameSvg::LeftBorder);
|
||||
break;
|
||||
case BottomLeft:
|
||||
iconPos = QPoint(2, rect.bottom() - icons.height() - 2);
|
||||
gradientCenter = rect.bottomLeft();
|
||||
atCorner = true;
|
||||
break;
|
||||
case Bottom:
|
||||
iconPos = QPoint(rect.center().x() - icons.width() / 2,
|
||||
rect.bottom() - icons.height() - 2);
|
||||
gradientCenter = QPointF(rect.center().x(), rect.bottom());
|
||||
atCorner = false;
|
||||
d->background->setEnabledBorders(FrameSvg::TopBorder|FrameSvg::LeftBorder|FrameSvg::RightBorder);
|
||||
break;
|
||||
case BottomRight:
|
||||
default:
|
||||
iconPos = QPoint((int)rect.right() - icons.width() + 2,
|
||||
(int)rect.bottom() - icons.height() - 2);
|
||||
gradientCenter = rect.bottomRight();
|
||||
atCorner = true;
|
||||
break;
|
||||
}
|
||||
|
||||
d->bgColor.setAlpha(64);
|
||||
d->fgColor.setAlpha(64);
|
||||
QRadialGradient gradient(gradientCenter, size() + d->animCircleFrame);
|
||||
gradient.setFocalPoint(gradientCenter);
|
||||
gradient.setColorAt(0, d->bgColor);
|
||||
gradient.setColorAt(.87, d->bgColor);
|
||||
gradient.setColorAt(.97, d->fgColor);
|
||||
d->fgColor.setAlpha(0);
|
||||
gradient.setColorAt(1, d->fgColor);
|
||||
painter->save();
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
painter->setBrush(gradient);
|
||||
painter->drawPath(p);
|
||||
painter->restore();
|
||||
if (atCorner) {
|
||||
d->bgColor.setAlpha(64);
|
||||
d->fgColor.setAlpha(64);
|
||||
QRadialGradient gradient(gradientCenter, size() + d->animCircleFrame);
|
||||
gradient.setFocalPoint(gradientCenter);
|
||||
gradient.setColorAt(0, d->bgColor);
|
||||
gradient.setColorAt(.87, d->bgColor);
|
||||
gradient.setColorAt(.97, d->fgColor);
|
||||
d->fgColor.setAlpha(0);
|
||||
gradient.setColorAt(1, d->fgColor);
|
||||
painter->save();
|
||||
painter->setPen(Qt::NoPen);
|
||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||
painter->setBrush(gradient);
|
||||
painter->drawPath(p);
|
||||
painter->restore();
|
||||
} else {
|
||||
d->background->resizeFrame(rect.size());
|
||||
d->background->paintFrame(painter);
|
||||
}
|
||||
|
||||
const qreal progress = d->animHighlightFrame;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user