stuff that lets me move "add activity" to plasmaapp:

-added enableAction function to corona for convenience
-added immutabilityChanged signal so that plasmaapp can respond to lock/unlock
-removed "add activity" action from containment because it's on its way to plasmaapp
-stopped adding corona actions to the containment toolbox, plasmaapp can do a better job of it
-made lock action actually disable on SystemImmutable; sure it wouldn't have worked, but now there's no worries about it showing up in the UI

svn path=/trunk/KDE/kdelibs/; revision=938383
This commit is contained in:
Chani Armitage 2009-03-11 18:37:12 +00:00
parent e1730c4704
commit f406ed1d77
3 changed files with 41 additions and 21 deletions

View File

@ -186,24 +186,18 @@ void Containment::init()
zoomAction->setShortcut(QKeySequence("alt+d,-")); zoomAction->setShortcut(QKeySequence("alt+d,-"));
d->actions().addAction("zoom out", zoomAction); d->actions().addAction("zoom out", zoomAction);
KAction *activityAction = new KAction(i18n("Add Activity"), this); if (corona()) {
activityAction->setIcon(KIcon("list-add")); QAction *action = corona()->action("add sibling containment");
activityAction->setVisible(unlocked); if (action) {
activityAction->setEnabled(unlocked); d->actions().addAction("add sibling containment", action);
connect(activityAction, SIGNAL(triggered(bool)), this, SLOT(addSiblingContainment())); }
activityAction->setShortcut(QKeySequence("alt+d,alt+a")); }
d->actions().addAction("add sibling containment", activityAction);
if (d->type == DesktopContainment && d->toolBox) { if (d->type == DesktopContainment && d->toolBox) {
d->toolBox->addTool(this->action("add widgets")); d->toolBox->addTool(this->action("add widgets"));
d->toolBox->addTool(this->action("add sibling containment"));
d->toolBox->addTool(this->action("zoom in")); d->toolBox->addTool(this->action("zoom in"));
d->toolBox->addTool(this->action("zoom out")); d->toolBox->addTool(this->action("zoom out"));
if (immutability() != SystemImmutable) {
d->toolBox->addTool(this->action("lock widgets"));
}
//TODO: do we need some way to allow this be overridden? //TODO: do we need some way to allow this be overridden?
// it's always available because shells rely on this // it's always available because shells rely on this
// to offer their own custom configuration as well // to offer their own custom configuration as well
@ -1603,12 +1597,6 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constra
bool unlocked = q->immutability() == Mutable; bool unlocked = q->immutability() == Mutable;
q->setAcceptDrops(unlocked); q->setAcceptDrops(unlocked);
q->enableAction("add widgets", unlocked); q->enableAction("add widgets", unlocked);
//FIXME immutability changes conflict with zoom changes
/*action = actions().action("add sibling containment");
if (action) {
action->setVisible(unlocked);
action->setEnabled(unlocked);
}*/
// tell the applets too // tell the applets too
foreach (Applet *a, applets) { foreach (Applet *a, applets) {

View File

@ -566,14 +566,21 @@ void Corona::setImmutability(const ImmutabilityType immutable)
kDebug() << "setting immutability to" << immutable; kDebug() << "setting immutability to" << immutable;
d->immutability = immutable; d->immutability = immutable;
d->updateContainmentImmutability(); d->updateContainmentImmutability();
//tell non-containments that might care (like plasmaapp or a custom corona)
emit immutabilityChanged(immutable);
//update our actions //update our actions
bool unlocked = d->immutability == Mutable;
QAction *action = d->actions.action("lock widgets"); QAction *action = d->actions.action("lock widgets");
if (action) { if (action) {
if (d->immutability == SystemImmutable) {
action->setEnabled(false);
action->setVisible(false);
} else {
bool unlocked = d->immutability == Mutable;
action->setText(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets")); action->setText(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets"));
action->setIcon(KIcon(unlocked ? "object-locked" : "object-unlocked")); action->setIcon(KIcon(unlocked ? "object-locked" : "object-unlocked"));
} }
}
KConfigGroup cg(config(), "General"); KConfigGroup cg(config(), "General");
@ -614,6 +621,15 @@ QList<QAction*> Corona::actions() const
return d->actions.actions(); return d->actions.actions();
} }
void Corona::enableAction(const QString &name, bool enable)
{
QAction *action = d->actions.action(name);
if (action) {
action->setEnabled(enable);
action->setVisible(enable);
}
}
} // namespace Plasma } // namespace Plasma
#include "corona.moc" #include "corona.moc"

View File

@ -171,6 +171,14 @@ public:
*/ */
QList<QAction*> actions() const; QList<QAction*> actions() const;
/**
* convenience function - enables or disables an action by name
*
* @param name the name of the action in our collection
* @param enable true to enable, false to disable
*/
void enableAction(const QString &name, bool enable);
public Q_SLOTS: public Q_SLOTS:
/** /**
* Initializes the layout from a config file. This will first clear any existing * Initializes the layout from a config file. This will first clear any existing
@ -259,6 +267,14 @@ Q_SIGNALS:
*/ */
void availableScreenRegionChanged(); void availableScreenRegionChanged();
/**
* emitted when immutability changes.
* this is for use by things that don't get contraints events, like plasmaapp.
* it's NOT for containments or applets or any of the other stuff on the scene.
* if your code's not in shells/ it probably shouldn't be using it.
*/
void immutabilityChanged(Plasma::ImmutabilityType immutability);
protected: protected:
/** /**
* Loads the default (system wide) layout for this user * Loads the default (system wide) layout for this user