* optional names for tools

* respond to immutability constraint updates, in particular hide the add widgets toolbox button

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=745246
This commit is contained in:
Aaron J. Seigo 2007-12-05 20:26:23 +00:00
parent 5c257fce5a
commit 198544318a
2 changed files with 13 additions and 6 deletions

View File

@ -145,9 +145,16 @@ void Containment::saveConstraints(KConfigGroup* group) const
void Containment::containmentConstraintsUpdated(Plasma::Constraints constraints)
{
if (d->toolbox && constraints & Plasma::ScreenConstraint) {
//kDebug() << "got containmentConstraintsUpdated" << constraints << (QObject*)d->toolbox;
if (d->toolbox) {
if (constraints & Plasma::ScreenConstraint) {
d->toolbox->setPos(geometry().width() - d->toolbox->boundingRect().width(), 0);
}
if (constraints & Plasma::ImmutableConstraint) {
d->toolbox->enableTool("addwidgets", !isImmutable());
}
}
}
Containment::Type Containment::containmentType() const
@ -163,7 +170,7 @@ void Containment::setContainmentType(Containment::Type type)
if (!d->toolbox) {
Plasma::PushButton *tool = new Plasma::PushButton(i18n("Add Widgets"));
tool->resize(tool->sizeHint());
addToolBoxTool(tool);
addToolBoxTool(tool, "addwidgets");
connect(tool, SIGNAL(clicked()), this, SIGNAL(showAddWidgets()));
tool = new Plasma::PushButton(i18n("Zoom In"));
@ -681,14 +688,14 @@ void Containment::emitLaunchActivated()
emit launchActivated();
}
void Containment::addToolBoxTool(QGraphicsItem *tool)
void Containment::addToolBoxTool(QGraphicsItem *tool, const QString& toolName)
{
if (!d->toolbox) {
d->toolbox = new DesktopToolbox(this);
d->toolbox->setPos(geometry().width() - d->toolbox->boundingRect().width(), 0);
}
d->toolbox->addTool(tool);
d->toolbox->addTool(tool, toolName);
}
} // Plasma namespace

View File

@ -217,7 +217,7 @@ class PLASMA_EXPORT Containment : public Applet
* Adds an item to the toolbox. The toolbox takes over ownership of the item.
* TODO: add remove and accessor methods
*/
void addToolBoxTool(QGraphicsItem *tool);
void addToolBoxTool(QGraphicsItem *tool, const QString &toolname = QString());
/**
* @internal