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.
This commit is contained in:
Sebastian Kügler 2013-07-10 02:33:28 +02:00
parent 843ad0b429
commit 0822e4cb9e
3 changed files with 11 additions and 12 deletions

View File

@ -42,7 +42,6 @@
#include <klocalizedstring.h>
#include <kservice.h>
#include <kservicetypetrader.h>
#include <kshortcut.h>
#include <kwindowsystem.h>
#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<QKeySequence> 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

View File

@ -24,11 +24,11 @@
#include <QObject>
#include <QIcon>
#include <QKeySequence>
#include <QUrl>
#include <kconfiggroup.h>
#include <kplugininfo.h>
#include <kshortcut.h>
#include <plasma/configloader.h>
#include <plasma/plasma.h>
@ -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
/**

View File

@ -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));
}
}