Set componentName to KWIN_NAME on QActions for KGlobalAccel

By setting the componentName we ensure that test don't grab the shortcut.

CCBUG: 368675
This commit is contained in:
Martin Gräßlin 2016-09-13 13:02:20 +02:00
parent 6ae917d7f8
commit cb7f922222
3 changed files with 5 additions and 0 deletions

View file

@ -518,6 +518,7 @@ template <typename Slot>
void TabBox::key(const char *actionName, Slot slot, const QKeySequence &shortcut) void TabBox::key(const char *actionName, Slot slot, const QKeySequence &shortcut)
{ {
QAction *a = new QAction(this); QAction *a = new QAction(this);
a->setProperty("componentName", QStringLiteral(KWIN_NAME));
a->setObjectName(QString::fromUtf8(actionName)); a->setObjectName(QString::fromUtf8(actionName));
a->setText(i18n(actionName)); a->setText(i18n(actionName));
KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << shortcut); KGlobalAccel::self()->setShortcut(a, QList<QKeySequence>() << shortcut);

View file

@ -973,6 +973,7 @@ template <typename Slot>
void Workspace::initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, Slot slot, const QVariant &data) void Workspace::initShortcut(const QString &actionName, const QString &description, const QKeySequence &shortcut, Slot slot, const QVariant &data)
{ {
QAction *a = new QAction(this); QAction *a = new QAction(this);
a->setProperty("componentName", QStringLiteral(KWIN_NAME));
a->setObjectName(actionName); a->setObjectName(actionName);
a->setText(description); a->setText(description);
if (data.isValid()) { if (data.isValid()) {
@ -1042,6 +1043,7 @@ void Workspace::clientShortcutUpdated(Client* c)
if (!c->shortcut().isEmpty()) { if (!c->shortcut().isEmpty()) {
if (action == NULL) { // new shortcut if (action == NULL) { // new shortcut
action = new QAction(this); action = new QAction(this);
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
action->setObjectName(key); action->setObjectName(key);
action->setText(i18n("Activate Window (%1)", c->caption())); action->setText(i18n("Activate Window (%1)", c->caption()));
connect(action, &QAction::triggered, c, connect(action, &QAction::triggered, c,

View file

@ -455,6 +455,7 @@ void VirtualDesktopManager::initSwitchToShortcuts()
void VirtualDesktopManager::addAction(const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, void (VirtualDesktopManager::*slot)()) void VirtualDesktopManager::addAction(const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, void (VirtualDesktopManager::*slot)())
{ {
QAction *a = new QAction(this); QAction *a = new QAction(this);
a->setProperty("componentName", QStringLiteral(KWIN_NAME));
a->setObjectName(name.arg(value)); a->setObjectName(name.arg(value));
a->setText(label.subs(value).toString()); a->setText(label.subs(value).toString());
a->setData(value); a->setData(value);
@ -465,6 +466,7 @@ void VirtualDesktopManager::addAction(const QString &name, const KLocalizedStrin
void VirtualDesktopManager::addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)()) void VirtualDesktopManager::addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)())
{ {
QAction *a = new QAction(this); QAction *a = new QAction(this);
a->setProperty("componentName", QStringLiteral(KWIN_NAME));
a->setObjectName(name); a->setObjectName(name);
a->setText(label); a->setText(label);
KGlobalAccel::setGlobalShortcut(a, QKeySequence()); KGlobalAccel::setGlobalShortcut(a, QKeySequence());