toolbox is vertical panels is starting to appear, still in the wrong

position btw.


svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=797598
This commit is contained in:
Marco Martin 2008-04-16 13:55:23 +00:00
parent 01c5a6620c
commit ef4d4863ca
4 changed files with 59 additions and 9 deletions

View File

@ -247,15 +247,31 @@ void Containment::containmentConstraintsUpdated(Plasma::Constraints constraints)
}
}
if ((constraints & Plasma::SizeConstraint || constraints & Plasma::ScreenConstraint) && d->toolbox) {
if ((constraints & Plasma::SizeConstraint || constraints & Plasma::ScreenConstraint) &&
d->toolbox) {
//The placement assumes that the geometry width/height is no more than the screen
if (d->type == PanelContainment) {
d->toolbox->setPos(geometry().right(), geometry().height()/2 - d->toolbox->boundingRect().height()/2);
if (formFactor() == Vertical) {
d->toolbox->setPos(geometry().width()/2 - d->toolbox->boundingRect().width()/2, geometry().bottom());
//defaulting to Horizontal right now
} else {
d->toolbox->setPos(geometry().right(), geometry().height()/2 - d->toolbox->boundingRect().height()/2);
}
} else {
d->toolbox->setPos(geometry().right() - qAbs(d->toolbox->boundingRect().width()), 0);
}
d->toolbox->enableTool("addwidgets", !isImmutable());
}
if (constraints & Plasma::FormFactorConstraint) {
if (formFactor() == Vertical) {
d->toolbox->setOrientation(Qt::Vertical);
//defaults to horizontal
} else {
d->toolbox->setOrientation(Qt::Horizontal);
}
}
if (constraints & Plasma::SizeConstraint) {
switch (containmentType()) {
case PanelContainment:

View File

@ -101,7 +101,12 @@ PanelToolbox::PanelToolbox(QGraphicsItem *parent)
QRectF PanelToolbox::boundingRect() const
{
return QRectF(0, 0, -size()*2, size()*4);
if (orientation() == Qt::Vertical) {
return QRectF(0, 0, size()*4, -size()*2);
//horizontal
} else {
return QRectF(0, 0, -size()*2, size()*4);
}
}
void PanelToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
@ -122,7 +127,13 @@ void PanelToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
color2.setAlpha(64);
QPainterPath p = shape();
const QPoint gradientCenter(boundingRect().left(), boundingRect().center().y());
QPoint gradientCenter;
if (orientation() == Qt::Vertical) {
gradientCenter = QPoint(boundingRect().center().x(), boundingRect().top());
} else {
gradientCenter = QPoint(boundingRect().left(), boundingRect().center().y());
}
QRadialGradient gradient(gradientCenter, size() + d->animFrame - 1);
gradient.setFocalPoint(gradientCenter);
gradient.setColorAt(0, color1);
@ -138,7 +149,13 @@ 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());
QRect iconRect;
if (orientation() == Qt::Vertical) {
iconRect = QRect(QPoint(gradientCenter.x() - iconSize().width()/2, (int)boundingRect().top() - iconSize().height() - 2), iconSize());
} else {
iconRect = QRect(QPoint((int)boundingRect().left() - iconSize().width() + 2, gradientCenter.y() - iconSize().height()/2), iconSize());
}
if (progress <= 0.9) {
d->icon.paint(painter, iconRect, Qt::AlignCenter, QIcon::Disabled, QIcon::Off);
@ -158,9 +175,12 @@ QPainterPath PanelToolbox::shape() const
{
QPainterPath path;
int toolSize = size() + (int)d->animFrame;
//path.moveTo(size()*2, 0);
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().center().y() - toolSize, toolSize*2, toolSize*2), 90, 180);
if (orientation() == Qt::Vertical) {
path.arcTo(QRectF(boundingRect().center().x() - toolSize, boundingRect().top() - toolSize, toolSize*2, toolSize*2), 0, 180);
} else {
path.arcTo(QRectF(boundingRect().left() - toolSize, boundingRect().center().y() - toolSize, toolSize*2, toolSize*2), 90, 180);
}
return path;
}

View File

@ -43,13 +43,15 @@ public:
: size(50),
iconSize(32, 32),
hidden(false),
showing(false)
showing(false),
orientation(Qt::Horizontal)
{}
int size;
QSize iconSize;
bool hidden;
bool showing;
Qt::Orientation orientation;
};
Toolbox::Toolbox(QGraphicsItem *parent)
@ -148,7 +150,17 @@ bool Toolbox::showing() const
void Toolbox::setShowing(const bool show)
{
d->showing = show;
d->showing = show;
}
Qt::Orientation Toolbox::orientation() const
{
return d->orientation;
}
void Toolbox::setOrientation( Qt::Orientation orient )
{
d->orientation = orient;
}
} // plasma namespace

View File

@ -50,6 +50,8 @@ public:
void setIconSize(const QSize newSize);
bool showing() const;
void setShowing(const bool show);
Qt::Orientation orientation() const;
void setOrientation(Qt::Orientation orient);
virtual void showToolbox() = 0;
virtual void hideToolbox() = 0;