From 0822e4cb9ea37a9945fa6b0d1c27b9e3f4b059c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20K=C3=BCgler?= Date: Wed, 10 Jul 2013 02:33:28 +0200 Subject: [PATCH] Applet::globalShortcut becomes QKeySequence - Port away from KShortcut - Use QKeySequence instead of QShortcut (which might be the obvious choice, for two reasons: - QKeySequence doesn't require QWidgets - It's really all we need This reduces KShortcut and QShortcut usage in plasma-framework to zarro. --- src/plasma/applet.cpp | 15 +++++++-------- src/plasma/applet.h | 6 +++--- src/shell/scripting/widget.cpp | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/plasma/applet.cpp b/src/plasma/applet.cpp index 9bb4de8cb..1ad261b00 100644 --- a/src/plasma/applet.cpp +++ b/src/plasma/applet.cpp @@ -42,7 +42,6 @@ #include #include #include -#include #include #if !PLASMA_NO_KUTILS @@ -172,7 +171,7 @@ void Applet::restore(KConfigGroup &group) KConfigGroup shortcutConfig(&group, "Shortcuts"); QString shortcutText = shortcutConfig.readEntryUntranslated("global", QString()); if (!shortcutText.isEmpty()) { - setGlobalShortcut(KShortcut(shortcutText)); + setGlobalShortcut(QKeySequence(shortcutText)); /* #ifndef NDEBUG kDebug() << "got global shortcut for" << name() << "of" << QKeySequence(shortcutText); @@ -569,7 +568,7 @@ Containment *Applet::containment() const return c; } -void Applet::setGlobalShortcut(const KShortcut &shortcut) +void Applet::setGlobalShortcut(const QKeySequence &shortcut) { if (!d->activationAction) { d->activationAction = new QAction(this); @@ -578,24 +577,24 @@ void Applet::setGlobalShortcut(const KShortcut &shortcut) connect(d->activationAction, SIGNAL(triggered()), this, SIGNAL(activate())); connect(d->activationAction, SIGNAL(globalShortcutChanged(QKeySequence)), this, SLOT(globalShortcutChanged())); - } else if (d->activationAction->shortcut() == shortcut.primary()) { + } else if (d->activationAction->shortcut() == shortcut) { return; } d->globalShortcutEnabled = true; QList seqs; - seqs << shortcut.primary() << shortcut.alternate(); + seqs << shortcut; KGlobalAccel::self()->setDefaultShortcut(d->activationAction, seqs, KGlobalAccel::NoAutoloading); d->globalShortcutChanged(); } -KShortcut Applet::globalShortcut() const +QKeySequence Applet::globalShortcut() const { if (d->activationAction) { - return KShortcut(d->activationAction->shortcut()); + return d->activationAction->shortcut(); } - return KShortcut(); + return QKeySequence(); } Types::Location Applet::location() const diff --git a/src/plasma/applet.h b/src/plasma/applet.h index f0f2dcd01..5272474f7 100644 --- a/src/plasma/applet.h +++ b/src/plasma/applet.h @@ -24,11 +24,11 @@ #include #include +#include #include #include #include -#include #include #include @@ -296,13 +296,13 @@ class PLASMA_EXPORT Applet : public QObject /** * Sets the global shortcut to associate with this widget. */ - void setGlobalShortcut(const KShortcut &shortcut); + void setGlobalShortcut(const QKeySequence &shortcut); /** * @return the global shortcut associated with this wiget, or * an empty shortcut if no global shortcut is associated. */ - KShortcut globalShortcut() const; + QKeySequence globalShortcut() const; // ASSOCIATED APPLICATION /** diff --git a/src/shell/scripting/widget.cpp b/src/shell/scripting/widget.cpp index d4f93f2be..7d93929fd 100644 --- a/src/shell/scripting/widget.cpp +++ b/src/shell/scripting/widget.cpp @@ -82,7 +82,7 @@ void Widget::remove() void Widget::setGlobalShortcut(const QString &shortcut) { if (d->applet) { - d->applet.data()->setGlobalShortcut(KShortcut(shortcut)); + d->applet.data()->setGlobalShortcut(QKeySequence(shortcut)); } }