Changeset View
Changeset View
Standalone View
Standalone View
useractions.cpp
Show First 20 Lines • Show All 1047 Lines • ▼ Show 20 Line(s) | 1047 | { | |||
---|---|---|---|---|---|
1048 | QString key = QStringLiteral("_k_session:%1").arg(c->window()); | 1048 | QString key = QStringLiteral("_k_session:%1").arg(c->window()); | ||
1049 | QAction* action = findChild<QAction*>(key); | 1049 | QAction* action = findChild<QAction*>(key); | ||
1050 | if (!c->shortcut().isEmpty()) { | 1050 | if (!c->shortcut().isEmpty()) { | ||
1051 | if (action == NULL) { // new shortcut | 1051 | if (action == NULL) { // new shortcut | ||
1052 | action = new QAction(this); | 1052 | action = new QAction(this); | ||
1053 | action->setProperty("componentName", QStringLiteral(KWIN_NAME)); | 1053 | action->setProperty("componentName", QStringLiteral(KWIN_NAME)); | ||
1054 | action->setObjectName(key); | 1054 | action->setObjectName(key); | ||
1055 | action->setText(i18n("Activate Window (%1)", c->caption())); | 1055 | action->setText(i18n("Activate Window (%1)", c->caption())); | ||
1056 | connect(action, &QAction::triggered, c, | 1056 | connect(action, &QAction::triggered, c, std::bind(&Workspace::activateClient, this, c, true)); | ||
1057 | [c]() { | | |||
1058 | workspace()->activateClient(c, true); | | |||
1059 | } | | |||
1060 | ); | | |||
1061 | } | 1057 | } | ||
1062 | 1058 | | |||
1063 | // no autoloading, since it's configured explicitly here and is not meant to be reused | 1059 | // no autoloading, since it's configured explicitly here and is not meant to be reused | ||
1064 | // (the key is the window id anyway, which is kind of random) | 1060 | // (the key is the window id anyway, which is kind of random) | ||
1065 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>() << c->shortcut(), | 1061 | KGlobalAccel::self()->setShortcut(action, QList<QKeySequence>() << c->shortcut(), | ||
1066 | KGlobalAccel::NoAutoloading); | 1062 | KGlobalAccel::NoAutoloading); | ||
1067 | action->setEnabled(true); | 1063 | action->setEnabled(true); | ||
1068 | } else { | 1064 | } else { | ||
▲ Show 20 Lines • Show All 789 Lines • ▼ Show 20 Line(s) | 1851 | { | |||
1858 | _shortcut = cut; | 1854 | _shortcut = cut; | ||
1859 | updateCaption(); | 1855 | updateCaption(); | ||
1860 | #if 0 | 1856 | #if 0 | ||
1861 | workspace()->clientShortcutUpdated(this); | 1857 | workspace()->clientShortcutUpdated(this); | ||
1862 | #else | 1858 | #else | ||
1863 | // Workaround for kwin<->kglobalaccel deadlock, when KWin has X grab and the kded | 1859 | // Workaround for kwin<->kglobalaccel deadlock, when KWin has X grab and the kded | ||
1864 | // kglobalaccel module tries to create the key grab. KWin should preferably grab | 1860 | // kglobalaccel module tries to create the key grab. KWin should preferably grab | ||
1865 | // they keys itself anyway :(. | 1861 | // they keys itself anyway :(. | ||
1866 | QTimer::singleShot(0, this, SLOT(delayedSetShortcut())); | 1862 | QTimer::singleShot(0, this, std::bind(&Workspace::clientShortcutUpdated, workspace(), this)); | ||
1867 | #endif | 1863 | #endif | ||
1868 | } | 1864 | } | ||
1869 | 1865 | | |||
1870 | void Client::delayedSetShortcut() | | |||
1871 | { | | |||
1872 | workspace()->clientShortcutUpdated(this); | | |||
1873 | } | | |||
1874 | | ||||
1875 | bool Workspace::shortcutAvailable(const QKeySequence &cut, Client* ignore) const | 1866 | bool Workspace::shortcutAvailable(const QKeySequence &cut, Client* ignore) const | ||
1876 | { | 1867 | { | ||
1877 | if (ignore && cut == ignore->shortcut()) | 1868 | if (ignore && cut == ignore->shortcut()) | ||
1878 | return true; | 1869 | return true; | ||
1879 | 1870 | | |||
1880 | if (!KGlobalAccel::getGlobalShortcutsByKey(cut).isEmpty()) { | 1871 | if (!KGlobalAccel::getGlobalShortcutsByKey(cut).isEmpty()) { | ||
1881 | return false; | 1872 | return false; | ||
1882 | } | 1873 | } | ||
Show All 10 Lines |