diff --git a/applet.cpp b/applet.cpp index ca46ca7a6..214754e7b 100644 --- a/applet.cpp +++ b/applet.cpp @@ -189,7 +189,9 @@ void Applet::restore(KConfigGroup &group) Private::s_maxZValue = z; } - setZValue(z); + if (z > 0) { + setZValue(z); + } setImmutability((ImmutabilityType)group.readEntry("immutability", (int)Mutable)); @@ -201,17 +203,7 @@ void Applet::restore(KConfigGroup &group) KConfigGroup shortcutConfig(&group, "Shortcuts"); QString shortcutText = shortcutConfig.readEntry("global", QString()); if (!shortcutText.isEmpty()) { - if (!d->activationAction) { - d->activationAction = new KAction(this); - //TODO: add better text when we aren't in a string freeze - d->activationAction->setText(name()); - d->activationAction->setObjectName(QString("Activate %1 Widget").arg(name())); // NO I18N - connect(d->activationAction, SIGNAL(triggered()), this, SIGNAL(activate())); - connect(this, SIGNAL(activate()), this, SLOT(setFocus())); - } - - KShortcut shortcut(shortcutText); - d->activationAction->setGlobalShortcut(shortcut); + setGlobalShortcut(KShortcut(shortcutText)); } // local shortcut, if any @@ -936,6 +928,34 @@ Containment* Applet::containment() const return c; } +void Applet::setGlobalShortcut(const KShortcut &shortcut) +{ + if (!d->activationAction) { + d->activationAction = new KAction(this); + //TODO: add better text when we aren't in a string freeze + d->activationAction->setText(name()); + d->activationAction->setObjectName(QString("Activate %1 Widget").arg(name())); // NO I18N + connect(d->activationAction, SIGNAL(triggered()), this, SIGNAL(activate())); + connect(this, SIGNAL(activate()), this, SLOT(setFocus())); + + QList widgets = d->actions.associatedWidgets(); + foreach (QWidget *w, widgets) { + w->addAction(d->activationAction); + } + } + + d->activationAction->setGlobalShortcut(shortcut); +} + +KShortcut Applet::globalShortcut() const +{ + if (d->activationAction) { + return d->activationAction->globalShortcut(); + } + + return KShortcut(); +} + void Applet::addAssociatedWidget(QWidget *widget) { d->actions.addAssociatedWidget(widget); diff --git a/applet.h b/applet.h index 57c2d39ce..e1bc0bcc2 100644 --- a/applet.h +++ b/applet.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -441,6 +442,17 @@ class PLASMA_EXPORT Applet : public QGraphicsWidget **/ Containment* containment() const; + /** + * Sets the global shorcut to associate with this widget. + */ + void setGlobalShortcut(const KShortcut &shortcut); + + /** + * @return the global shortcut associated with this wiget, or + * an empty shortcut if no global shortcut is associated. + */ + KShortcut globalShortcut() const; + /** * associate actions with this widget, including ones added after this call. * needed to make keyboard shortcuts work.