Since we're randomly changing public API, let's be consistent with Qt

instead. Use ToolBox everywhere, also for internals.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=812019
This commit is contained in:
Kevin Ottens 2008-05-24 12:25:56 +00:00
parent bea0906806
commit c3b5446a59
9 changed files with 140 additions and 140 deletions

View File

@ -178,13 +178,13 @@ void Containment::init()
activityAction->setShortcut(QKeySequence("ctrl+shift+a"));
d->actions().addAction("addSiblingContainment", activityAction);
d->toolbox->addTool(this->action("add widgets"));
d->toolbox->addTool(this->action("zoom in"));
d->toolbox->addTool(this->action("zoom out"));
d->toolBox->addTool(this->action("add widgets"));
d->toolBox->addTool(this->action("zoom in"));
d->toolBox->addTool(this->action("zoom out"));
if (immutability() != SystemImmutable) {
d->toolbox->addTool(this->action("lock widgets"));
d->toolBox->addTool(this->action("lock widgets"));
}
d->toolbox->addTool(this->action("addSiblingContainment"));
d->toolBox->addTool(this->action("addSiblingContainment"));
}
Applet::init();
@ -292,18 +292,18 @@ void Containment::setContainmentType(Containment::Type type)
d->type = type;
if (isContainment() && type == DesktopContainment) {
if (!d->toolbox) {
d->createToolbox();
if (!d->toolBox) {
d->createToolBox();
}
} else if (isContainment() && type == PanelContainment) {
if (!d->toolbox) {
d->createToolbox();
d->toolbox->setSize(22);
d->toolbox->setIconSize(QSize(16, 16));
if (!d->toolBox) {
d->createToolBox();
d->toolBox->setSize(22);
d->toolBox->setIconSize(QSize(16, 16));
}
} else {
delete d->toolbox;
d->toolbox = 0;
delete d->toolBox;
d->toolBox = 0;
}
}
@ -569,9 +569,9 @@ void Containment::setScreen(int screen)
#ifndef Q_OS_WIN
// we want to listen to changes in work area if our screen changes
if (d->screen < 0 && screen > -1) {
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(positionToolbox()));
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(positionToolBox()));
} else if (screen < 0) {
disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(positionToolbox()));
disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(positionToolBox()));
}
#endif
if (screen > -1 && corona()) {
@ -843,40 +843,40 @@ void Containment::enableAction(const QString &name, bool enable)
}
}
void Containment::addToolboxTool(QAction *action)
void Containment::addToolBoxTool(QAction *action)
{
if (d->toolbox) {
d->toolbox->addTool(action);
if (d->toolBox) {
d->toolBox->addTool(action);
}
}
void Containment::removeToolboxTool(QAction *action)
void Containment::removeToolBoxTool(QAction *action)
{
if (d->toolbox) {
d->toolbox->removeTool(action);
if (d->toolBox) {
d->toolBox->removeTool(action);
}
}
void Containment::setToolboxOpen(bool open)
void Containment::setToolBoxOpen(bool open)
{
if (open) {
openToolbox();
openToolBox();
} else {
closeToolbox();
closeToolBox();
}
}
void Containment::openToolbox()
void Containment::openToolBox()
{
if (d->toolbox) {
d->toolbox->showToolbox();
if (d->toolBox) {
d->toolBox->showToolBox();
}
}
void Containment::closeToolbox()
void Containment::closeToolBox()
{
if (d->toolbox) {
d->toolbox->hideToolbox();
if (d->toolBox) {
d->toolBox->hideToolBox();
}
}
@ -1012,45 +1012,45 @@ void Containment::Private::zoomOut()
emit q->zoomRequested(q, Plasma::ZoomOut);
}
Toolbox* Containment::Private::createToolbox()
ToolBox* Containment::Private::createToolBox()
{
if (!toolbox) {
if (!toolBox) {
switch (type) {
case PanelContainment:
toolbox = new PanelToolbox(q);
connect(toolbox, SIGNAL(toggled()), q, SIGNAL(toolboxToggled()));
toolBox = new PanelToolBox(q);
connect(toolBox, SIGNAL(toggled()), q, SIGNAL(toolBoxToggled()));
break;
//defaults to DesktopContainment right now
default:
toolbox = new DesktopToolbox(q);
connect(toolbox, SIGNAL(toggled()), toolbox, SLOT(toggle()));
toolBox = new DesktopToolBox(q);
connect(toolBox, SIGNAL(toggled()), toolBox, SLOT(toggle()));
break;
}
positionToolbox();
positionToolBox();
}
return toolbox;
return toolBox;
}
void Containment::Private::positionToolbox()
void Containment::Private::positionToolBox()
{
if (!toolbox) {
if (!toolBox) {
return;
}
//The placement assumes that the geometry width/height is no more than the screen
if (type == PanelContainment) {
if (q->formFactor() == Vertical) {
toolbox->setOrientation(Qt::Vertical);
toolbox->setPos(q->geometry().width()/2 - toolbox->boundingRect().width()/2, q->geometry().height());
toolBox->setOrientation(Qt::Vertical);
toolBox->setPos(q->geometry().width()/2 - toolBox->boundingRect().width()/2, q->geometry().height());
//defaulting to Horizontal right now
} else {
toolbox->setOrientation(Qt::Horizontal);
toolBox->setOrientation(Qt::Horizontal);
if (QApplication::layoutDirection() == Qt::RightToLeft) {
toolbox->setPos(q->geometry().left(), q->geometry().height()/2 - toolbox->boundingRect().height()/2);
toolBox->setPos(q->geometry().left(), q->geometry().height()/2 - toolBox->boundingRect().height()/2);
} else {
toolbox->setPos(q->geometry().width(), q->geometry().height()/2 - toolbox->boundingRect().height()/2);
toolBox->setPos(q->geometry().width(), q->geometry().height()/2 - toolBox->boundingRect().height()/2);
}
}
} else {
@ -1058,9 +1058,9 @@ void Containment::Private::positionToolbox()
QDesktopWidget *desktop = QApplication::desktop();
r = desktop->availableGeometry(screen);
if (q->view() && !q->view()->transform().isScaling()) {
toolbox->setPos(r.topRight());
toolBox->setPos(r.topRight());
} else {
toolbox->setPos(q->mapFromScene(QPointF(q->geometry().topRight())));
toolBox->setPos(q->mapFromScene(QPointF(q->geometry().topRight())));
}
}
@ -1083,7 +1083,7 @@ void Containment::Private::containmentConstraintsEvent(Plasma::Constraints const
return;
}
//kDebug() << "got containmentConstraintsEvent" << constraints << (QObject*)toolbox;
//kDebug() << "got containmentConstraintsEvent" << constraints << (QObject*)toolBox;
if (constraints & Plasma::ImmutableConstraint) {
//update actions
bool unlocked = q->immutability() == Mutable;
@ -1111,25 +1111,25 @@ void Containment::Private::containmentConstraintsEvent(Plasma::Constraints const
if (q->isContainment() && type == PanelContainment) {
if (unlocked) {
toolbox->show();
toolBox->show();
} else {
toolbox->hide();
toolBox->hide();
}
}
}
if ((constraints & Plasma::SizeConstraint || constraints & Plasma::ScreenConstraint) &&
toolbox) {
positionToolbox();
toolBox) {
positionToolBox();
}
if (constraints & Plasma::FormFactorConstraint) {
if (toolbox) {
if (toolBox) {
if (q->formFactor() == Vertical) {
toolbox->setOrientation(Qt::Vertical);
toolBox->setOrientation(Qt::Vertical);
//defaults to horizontal
} else {
toolbox->setOrientation(Qt::Horizontal);
toolBox->setOrientation(Qt::Horizontal);
}
}

View File

@ -230,29 +230,29 @@ class PLASMA_EXPORT Containment : public Applet
/**
* Add an action to the toolbox
*/
void addToolboxTool(QAction *action);
void addToolBoxTool(QAction *action);
/**
* Remove an action from the toolbox
*/
void removeToolboxTool(QAction *action);
void removeToolBoxTool(QAction *action);
/**
* Sets the open or closed state of the Containment's toolbox
*
* @arg open true to open the Toolbox, false to close it
* @arg open true to open the ToolBox, false to close it
*/
void setToolboxOpen(bool open);
void setToolBoxOpen(bool open);
/**
* Open the Containment's toolbox
*/
void openToolbox();
void openToolBox();
/**
* Closes Containment's toolbox
*/
void closeToolbox();
void closeToolBox();
/**
* associate actions with this widget, including ones added after this call.
@ -285,7 +285,7 @@ class PLASMA_EXPORT Containment : public Applet
/**
* Emitted when the user clicks on the toolbox
*/
void toolboxToggled();
void toolBoxToggled();
/**
* Emitted when the containment wants a new containment to be created.
@ -398,7 +398,7 @@ class PLASMA_EXPORT Containment : public Applet
Q_PRIVATE_SLOT(d, void appletAnimationComplete(QGraphicsItem *item, Plasma::Animator::Animation anim))
Q_PRIVATE_SLOT(d, void triggerShowAddWidgets())
Q_PRIVATE_SLOT(d, void handleDisappeared(AppletHandle *handle))
Q_PRIVATE_SLOT(d, void positionToolbox())
Q_PRIVATE_SLOT(d, void positionToolBox())
Q_PRIVATE_SLOT(d, void zoomIn())
Q_PRIVATE_SLOT(d, void zoomOut())
Q_PRIVATE_SLOT(d, void toggleDesktopImmutability())

View File

@ -28,7 +28,7 @@ namespace Plasma
{
class Containment;
class Toolbox;
class ToolBox;
class Containment::Private
{
@ -39,7 +39,7 @@ public:
location(Floating),
focusedApplet(0),
screen(-1), // no screen
toolbox(0),
toolBox(0),
type(Containment::NoContainmentType),
positioning(false)
{
@ -51,8 +51,8 @@ public:
applets.clear();
}
Toolbox* createToolbox();
void positionToolbox();
ToolBox* createToolBox();
void positionToolBox();
void triggerShowAddWidgets();
/**
@ -97,7 +97,7 @@ public:
Applet *focusedApplet;
QMap<Applet*, AppletHandle*> handles;
int screen;
Toolbox *toolbox;
ToolBox *toolBox;
Containment::Type type;
bool positioning;
};

View File

@ -77,7 +77,7 @@ class EmptyGraphicsItem : public QGraphicsItem
// used with QGrahphicsItem::setData
static const int ToolName = 7001;
class DesktopToolbox::Private
class DesktopToolBox::Private
{
public:
Private()
@ -99,8 +99,8 @@ public:
bool hovering : 1;
};
DesktopToolbox::DesktopToolbox(QGraphicsItem *parent)
: Toolbox(parent),
DesktopToolBox::DesktopToolBox(QGraphicsItem *parent)
: ToolBox(parent),
d(new Private)
{
connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*)));
@ -111,17 +111,17 @@ DesktopToolbox::DesktopToolbox(QGraphicsItem *parent)
setFlag(ItemIgnoresTransformations, true);
}
DesktopToolbox::~DesktopToolbox()
DesktopToolBox::~DesktopToolBox()
{
delete d;
}
QRectF DesktopToolbox::boundingRect() const
QRectF DesktopToolBox::boundingRect() const
{
return QRectF(0, 0, -size()*2, size()*2);
}
void DesktopToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void DesktopToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
@ -168,7 +168,7 @@ void DesktopToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
painter->restore();
}
QPainterPath DesktopToolbox::shape() const
QPainterPath DesktopToolBox::shape() const
{
QPainterPath path;
int toolSize = size() + (int)d->animCircleFrame;
@ -177,7 +177,7 @@ QPainterPath DesktopToolbox::shape() const
return path;
}
void DesktopToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void DesktopToolBox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
if (showing() || d->hovering) {
QGraphicsItem::hoverEnterEvent(event);
@ -193,7 +193,7 @@ void DesktopToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
QGraphicsItem::hoverEnterEvent(event);
}
void DesktopToolbox::showToolbox()
void DesktopToolBox::showToolBox()
{
if (showing()) {
return;
@ -248,7 +248,7 @@ void DesktopToolbox::showToolbox()
d->animCircleId = animdriver->customAnimation(10, 240, Plasma::Animator::EaseInCurve, this, "animateCircle");
}
void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void DesktopToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
//kDebug() << event->pos() << event->scenePos() << d->toolBacker->rect().contains(event->scenePos().toPoint());
if (! d->hovering) {
@ -256,7 +256,7 @@ void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
return;
}
hideToolbox();
hideToolBox();
Plasma::Animator* animdriver = Plasma::Animator::self();
if (d->animHighlightId) {
animdriver->stopCustomAnimation(d->animHighlightId);
@ -267,7 +267,7 @@ void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
QGraphicsItem::hoverLeaveEvent(event);
}
void DesktopToolbox::hideToolbox()
void DesktopToolBox::hideToolBox()
{
if (!showing()) {
return;
@ -297,7 +297,7 @@ void DesktopToolbox::hideToolbox()
}
}
void DesktopToolbox::animateCircle(qreal progress)
void DesktopToolBox::animateCircle(qreal progress)
{
if (showing()) {
d->animCircleFrame = size() * progress;
@ -312,7 +312,7 @@ void DesktopToolbox::animateCircle(qreal progress)
update();
}
void DesktopToolbox::animateHighlight(qreal progress)
void DesktopToolBox::animateHighlight(qreal progress)
{
if (d->hovering) {
d->animHighlightFrame = progress;
@ -327,7 +327,7 @@ void DesktopToolbox::animateHighlight(qreal progress)
update();
}
void DesktopToolbox::toolMoved(QGraphicsItem *item)
void DesktopToolBox::toolMoved(QGraphicsItem *item)
{
//kDebug() << "geometry is now " << static_cast<Plasma::Widget*>(item)->geometry();
if (!showing() &&
@ -336,12 +336,12 @@ void DesktopToolbox::toolMoved(QGraphicsItem *item)
}
}
void DesktopToolbox::toggle()
void DesktopToolBox::toggle()
{
if (showing()) {
hideToolbox();
hideToolBox();
} else {
showToolbox();
showToolBox();
}
}

View File

@ -37,18 +37,18 @@ namespace Plasma
class Widget;
class EmptyGraphicsItem;
class DesktopToolbox : public Toolbox
class DesktopToolBox : public ToolBox
{
Q_OBJECT
public:
explicit DesktopToolbox(QGraphicsItem *parent = 0);
~DesktopToolbox();
explicit DesktopToolBox(QGraphicsItem *parent = 0);
~DesktopToolBox();
QRectF boundingRect() const;
QPainterPath shape() const;
void showToolbox();
void hideToolbox();
void showToolBox();
void hideToolBox();
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);

View File

@ -76,7 +76,7 @@ class EmptyGraphicsItem : public QGraphicsItem
// used with QGrahphicsItem::setData
static const int ToolName = 7001;
class PanelToolbox::Private
class PanelToolBox::Private
{
public:
Private()
@ -93,8 +93,8 @@ public:
qreal animFrame;
};
PanelToolbox::PanelToolbox(QGraphicsItem *parent)
: Toolbox(parent),
PanelToolBox::PanelToolBox(QGraphicsItem *parent)
: ToolBox(parent),
d(new Private)
{
connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)), this, SLOT(toolMoved(QGraphicsItem*)));
@ -105,12 +105,12 @@ PanelToolbox::PanelToolbox(QGraphicsItem *parent)
setFlag(ItemIgnoresTransformations, true);
}
PanelToolbox::~PanelToolbox()
PanelToolBox::~PanelToolBox()
{
delete d;
}
QRectF PanelToolbox::boundingRect() const
QRectF PanelToolBox::boundingRect() const
{
if (orientation() == Qt::Vertical) {
return QRectF(0, 0, size()*2, -size());
@ -122,7 +122,7 @@ QRectF PanelToolbox::boundingRect() const
}
}
void PanelToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
void PanelToolBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(option)
Q_UNUSED(widget)
@ -187,7 +187,7 @@ void PanelToolbox::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
}
QPainterPath PanelToolbox::shape() const
QPainterPath PanelToolBox::shape() const
{
QPainterPath path;
int toolSize = size();// + (int)d->animFrame;
@ -203,18 +203,18 @@ QPainterPath PanelToolbox::shape() const
return path;
}
void PanelToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
void PanelToolBox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
if (showing() || d->stopwatch.elapsed() < 100) {
QGraphicsItem::hoverEnterEvent(event);
return;
}
showToolbox();
showToolBox();
QGraphicsItem::hoverEnterEvent(event);
}
void PanelToolbox::showToolbox()
void PanelToolBox::showToolBox()
{
if (showing()) {
return;
@ -270,7 +270,7 @@ void PanelToolbox::showToolbox()
d->stopwatch.restart();
}
void PanelToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
void PanelToolBox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
//kDebug() << event->pos() << event->scenePos() << d->toolBacker->rect().contains(event->scenePos().toPoint());
if ((d->toolBacker && d->toolBacker->rect().contains(event->scenePos().toPoint())) ||
@ -278,11 +278,11 @@ void PanelToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
QGraphicsItem::hoverLeaveEvent(event);
return;
}
hideToolbox();
hideToolBox();
QGraphicsItem::hoverLeaveEvent(event);
}
void PanelToolbox::hideToolbox()
void PanelToolBox::hideToolBox()
{
if (!showing()) {
return;
@ -314,7 +314,7 @@ void PanelToolbox::hideToolbox()
d->stopwatch.restart();
}
void PanelToolbox::animate(qreal progress)
void PanelToolBox::animate(qreal progress)
{
if (showing()) {
d->animFrame = size() * progress;
@ -331,7 +331,7 @@ void PanelToolbox::animate(qreal progress)
update();
}
void PanelToolbox::toolMoved(QGraphicsItem *item)
void PanelToolBox::toolMoved(QGraphicsItem *item)
{
//kDebug() << "geometry is now " << static_cast<Plasma::Widget*>(item)->geometry();
if (!showing() &&

View File

@ -37,18 +37,18 @@ namespace Plasma
class Widget;
class EmptyGraphicsItem;
class PanelToolbox : public Toolbox
class PanelToolBox : public ToolBox
{
Q_OBJECT
public:
explicit PanelToolbox(QGraphicsItem *parent = 0);
~PanelToolbox();
explicit PanelToolBox(QGraphicsItem *parent = 0);
~PanelToolBox();
QRectF boundingRect() const;
QPainterPath shape() const;
void showToolbox();
void hideToolbox();
void showToolBox();
void hideToolBox();
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);

View File

@ -35,7 +35,7 @@
namespace Plasma
{
class Toolbox::Private
class ToolBox::Private
{
public:
Private()
@ -53,19 +53,19 @@ public:
Qt::Orientation orientation;
};
Toolbox::Toolbox(QGraphicsItem *parent)
ToolBox::ToolBox(QGraphicsItem *parent)
: QGraphicsItem(parent),
d(new Private)
{
setAcceptsHoverEvents(true);
}
Toolbox::~Toolbox()
ToolBox::~ToolBox()
{
delete d;
}
void Toolbox::addTool(QAction *action)
void ToolBox::addTool(QAction *action)
{
if (!action) {
return;
@ -87,18 +87,18 @@ void Toolbox::addTool(QAction *action)
tool->setZValue(zValue() + 1);
//make enabled/disabled tools appear/disappear instantly
connect(tool, SIGNAL(changed()), this, SLOT(updateToolbox()));
connect(tool, SIGNAL(changed()), this, SLOT(updateToolBox()));
}
void Toolbox::updateToolbox()
void ToolBox::updateToolBox()
{
if ( d->showing) {
d->showing = false;
showToolbox();
showToolBox();
}
}
void Toolbox::removeTool(QAction *action)
void ToolBox::removeTool(QAction *action)
{
foreach (QGraphicsItem *child, QGraphicsItem::children()) {
//kDebug() << "checking tool" << child << child->data(ToolName);
@ -111,52 +111,52 @@ void Toolbox::removeTool(QAction *action)
}
}
int Toolbox::size() const
int ToolBox::size() const
{
return d->size;
}
void Toolbox::setSize(const int newSize)
void ToolBox::setSize(const int newSize)
{
d->size = newSize;
}
QSize Toolbox::iconSize() const
QSize ToolBox::iconSize() const
{
return d->iconSize;
}
void Toolbox::setIconSize(const QSize newSize)
void ToolBox::setIconSize(const QSize newSize)
{
d->iconSize = newSize;
}
bool Toolbox::showing() const
bool ToolBox::showing() const
{
return d->showing;
}
void Toolbox::setShowing(const bool show)
void ToolBox::setShowing(const bool show)
{
d->showing = show;
}
Qt::Orientation Toolbox::orientation() const
Qt::Orientation ToolBox::orientation() const
{
return d->orientation;
}
void Toolbox::setOrientation( Qt::Orientation orient )
void ToolBox::setOrientation( Qt::Orientation orient )
{
d->orientation = orient;
}
void Toolbox::mousePressEvent(QGraphicsSceneMouseEvent *event)
void ToolBox::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
event->accept();
}
void Toolbox::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
void ToolBox::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (boundingRect().contains(event->pos())) {
emit toggled();

View File

@ -34,13 +34,13 @@ namespace Plasma
//class Widget;
//class EmptyGraphicsItem;
class Toolbox : public QObject, public QGraphicsItem
class ToolBox : public QObject, public QGraphicsItem
{
Q_OBJECT
public:
explicit Toolbox(QGraphicsItem *parent = 0);
~Toolbox();
explicit ToolBox(QGraphicsItem *parent = 0);
~ToolBox();
/**
* create a toolbox tool from the given action
@ -60,13 +60,13 @@ public:
Qt::Orientation orientation() const;
void setOrientation(Qt::Orientation orient);
virtual void showToolbox() = 0;
virtual void hideToolbox() = 0;
virtual void showToolBox() = 0;
virtual void hideToolBox() = 0;
public Q_SLOTS:
/**
* re-show the toolbox, in case any tools have changed
*/
void updateToolbox();
void updateToolBox();
Q_SIGNALS:
void toggled();