[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdebase/workspace/libs/plasma
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2008-06-01 2:53:50
Message-ID: 1212288830.624064.28584.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 815050 by aseigo:
allow setting and getting of global shortcuts
M +32 -12 applet.cpp
M +12 -0 applet.h
--- trunk/KDE/kdebase/workspace/libs/plasma/applet.cpp #815049:815050
@@ -189,7 +189,9 @@
Private::s_maxZValue = z;
}
- setZValue(z);
+ if (z > 0) {
+ setZValue(z);
+ }
setImmutability((ImmutabilityType)group.readEntry("immutability", (int)Mutable));
@@ -201,17 +203,7 @@
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 @@
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<QWidget *> 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);
--- trunk/KDE/kdebase/workspace/libs/plasma/applet.h #815049:815050
@@ -29,6 +29,7 @@
#include <KDE/KConfigGroup>
#include <KDE/KGenericFactory>
#include <KDE/KPluginInfo>
+#include <KDE/KShortcut>
#include <plasma/configxml.h>
#include <plasma/packagestructure.h>
@@ -442,6 +443,17 @@
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.
*/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic