[kwin] Do not use a KActionCollection for Workspace's global shortcut actions
The ActionCollection was only used for two features: * setting the object name * finding the action for retrieving it's shortcut This can also be achieved by just setting the object name and searching for the children of the Workspace singleton.icc-effect-5.14.5
parent
edeb8051e9
commit
a6f32bf3e8
|
@ -420,7 +420,7 @@ void Compositor::toggleCompositing()
|
||||||
slotToggleCompositing(); // TODO only operate on script level here?
|
slotToggleCompositing(); // TODO only operate on script level here?
|
||||||
if (m_suspended) {
|
if (m_suspended) {
|
||||||
// when disabled show a shortcut how the user can get back compositing
|
// when disabled show a shortcut how the user can get back compositing
|
||||||
const auto shortcuts = KGlobalAccel::self()->shortcut(workspace()->actionCollection()->action(QStringLiteral("Suspend Compositing")));
|
const auto shortcuts = KGlobalAccel::self()->shortcut(workspace()->findChild<QAction*>(QStringLiteral("Suspend Compositing")));
|
||||||
if (!shortcuts.isEmpty()) {
|
if (!shortcuts.isEmpty()) {
|
||||||
// display notification only if there is the shortcut
|
// display notification only if there is the shortcut
|
||||||
const QString message = i18n("Desktop effects have been suspended by another application.<br/>"
|
const QString message = i18n("Desktop effects have been suspended by another application.<br/>"
|
||||||
|
|
|
@ -37,17 +37,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
initShortcut(QStringLiteral(name).arg(value), i18n(name, value), key, &Workspace::fnSlot, value);
|
initShortcut(QStringLiteral(name).arg(value), i18n(name, value), key, &Workspace::fnSlot, value);
|
||||||
|
|
||||||
|
|
||||||
a = actionCollection->addAction(QStringLiteral("Program:kwin"));
|
|
||||||
a->setText(i18n("System"));
|
|
||||||
|
|
||||||
a = actionCollection->addAction(QStringLiteral("Group:Navigation"));
|
|
||||||
a->setText(i18n("Navigation"));
|
|
||||||
DEF(I18N_NOOP("Walk Through Window Tabs"), 0, slotActivateNextTab);
|
DEF(I18N_NOOP("Walk Through Window Tabs"), 0, slotActivateNextTab);
|
||||||
DEF(I18N_NOOP("Walk Through Window Tabs (Reverse)"), 0, slotActivatePrevTab);
|
DEF(I18N_NOOP("Walk Through Window Tabs (Reverse)"), 0, slotActivatePrevTab);
|
||||||
DEF(I18N_NOOP("Remove Window From Group"), 0, slotUntab);
|
DEF(I18N_NOOP("Remove Window From Group"), 0, slotUntab);
|
||||||
|
|
||||||
a = actionCollection->addAction(QStringLiteral("Group:Windows"));
|
|
||||||
a->setText(i18n("Windows"));
|
|
||||||
DEF(I18N_NOOP("Window Operations Menu"),
|
DEF(I18N_NOOP("Window Operations Menu"),
|
||||||
Qt::ALT + Qt::Key_F3, slotWindowOperations);
|
Qt::ALT + Qt::Key_F3, slotWindowOperations);
|
||||||
DEF2("Window Close", I18N_NOOP("Close Window"),
|
DEF2("Window Close", I18N_NOOP("Close Window"),
|
||||||
|
@ -125,8 +118,6 @@ DEF2("Increase Opacity", I18N_NOOP("Increase Opacity of Active Window by 5 %"),
|
||||||
DEF2("Decrease Opacity", I18N_NOOP("Decrease Opacity of Active Window by 5 %"),
|
DEF2("Decrease Opacity", I18N_NOOP("Decrease Opacity of Active Window by 5 %"),
|
||||||
0, slotLowerWindowOpacity);
|
0, slotLowerWindowOpacity);
|
||||||
|
|
||||||
a = actionCollection->addAction(QStringLiteral("Group:Window Desktop"));
|
|
||||||
a->setText(i18n("Window & Desktop"));
|
|
||||||
DEF2("Window On All Desktops", I18N_NOOP("Keep Window on All Desktops"),
|
DEF2("Window On All Desktops", I18N_NOOP("Keep Window on All Desktops"),
|
||||||
0, slotWindowOnAllDesktops);
|
0, slotWindowOnAllDesktops);
|
||||||
|
|
||||||
|
@ -154,8 +145,6 @@ for (int i = 0; i < 8; ++i) {
|
||||||
DEF(I18N_NOOP("Switch to Next Screen"), 0, slotSwitchToNextScreen);
|
DEF(I18N_NOOP("Switch to Next Screen"), 0, slotSwitchToNextScreen);
|
||||||
DEF(I18N_NOOP("Switch to Previous Screen"), 0, slotSwitchToPrevScreen);
|
DEF(I18N_NOOP("Switch to Previous Screen"), 0, slotSwitchToPrevScreen);
|
||||||
|
|
||||||
a = actionCollection->addAction(QStringLiteral("Group:Miscellaneous"));
|
|
||||||
a->setText(i18n("Miscellaneous"));
|
|
||||||
DEF(I18N_NOOP("Kill Window"), Qt::CTRL + Qt::ALT + Qt::Key_Escape, slotKillWindow);
|
DEF(I18N_NOOP("Kill Window"), Qt::CTRL + Qt::ALT + Qt::Key_Escape, slotKillWindow);
|
||||||
DEF(I18N_NOOP("Suspend Compositing"), Qt::SHIFT + Qt::ALT + Qt::Key_F12, slotToggleCompositing);
|
DEF(I18N_NOOP("Suspend Compositing"), Qt::SHIFT + Qt::ALT + Qt::Key_F12, slotToggleCompositing);
|
||||||
DEF(I18N_NOOP("Invert Screen Colors"), 0, slotInvertScreen);
|
DEF(I18N_NOOP("Invert Screen Colors"), 0, slotInvertScreen);
|
||||||
|
|
|
@ -183,8 +183,7 @@ void UserActionsMenu::helperDialog(const QString& message, const QWeakPointer<Cl
|
||||||
QStringList args;
|
QStringList args;
|
||||||
QString type;
|
QString type;
|
||||||
auto shortcut = [](const QString &name) {
|
auto shortcut = [](const QString &name) {
|
||||||
KActionCollection *keys = Workspace::self()->actionCollection();
|
QAction* action = Workspace::self()->findChild<QAction*>(name);
|
||||||
QAction* action = keys->action(name);
|
|
||||||
assert(action != NULL);
|
assert(action != NULL);
|
||||||
const auto shortcuts = KGlobalAccel::self()->shortcut(action);
|
const auto shortcuts = KGlobalAccel::self()->shortcut(action);
|
||||||
return QStringLiteral("%1 (%2)").arg(action->text())
|
return QStringLiteral("%1 (%2)").arg(action->text())
|
||||||
|
@ -268,7 +267,7 @@ void UserActionsMenu::init()
|
||||||
});
|
});
|
||||||
|
|
||||||
auto setShortcut = [](QAction *action, const QString &actionName) {
|
auto setShortcut = [](QAction *action, const QString &actionName) {
|
||||||
const auto shortcuts = KGlobalAccel::self()->shortcut(Workspace::self()->actionCollection()->action(actionName));
|
const auto shortcuts = KGlobalAccel::self()->shortcut(Workspace::self()->findChild<QAction*>(actionName));
|
||||||
if (!shortcuts.isEmpty()) {
|
if (!shortcuts.isEmpty()) {
|
||||||
action->setShortcut(shortcuts.first());
|
action->setShortcut(shortcuts.first());
|
||||||
}
|
}
|
||||||
|
@ -940,7 +939,8 @@ void Workspace::closeActivePopup()
|
||||||
template <typename Slot>
|
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 = keys->addAction(actionName);
|
QAction *a = new QAction(this);
|
||||||
|
a->setObjectName(actionName);
|
||||||
a->setText(description);
|
a->setText(description);
|
||||||
if (data.isValid()) {
|
if (data.isValid()) {
|
||||||
a->setData(data);
|
a->setData(data);
|
||||||
|
@ -955,10 +955,6 @@ void Workspace::initShortcut(const QString &actionName, const QString &descripti
|
||||||
*/
|
*/
|
||||||
void Workspace::initShortcuts()
|
void Workspace::initShortcuts()
|
||||||
{
|
{
|
||||||
keys = new KActionCollection(this);
|
|
||||||
KActionCollection* actionCollection = keys;
|
|
||||||
QAction* a = 0L;
|
|
||||||
|
|
||||||
#define IN_KWIN
|
#define IN_KWIN
|
||||||
#include "kwinbindings.cpp"
|
#include "kwinbindings.cpp"
|
||||||
#ifdef KWIN_BUILD_TABBOX
|
#ifdef KWIN_BUILD_TABBOX
|
||||||
|
|
|
@ -147,7 +147,6 @@ Workspace::Workspace(bool restore)
|
||||||
, session_saving(false)
|
, session_saving(false)
|
||||||
, block_focus(0)
|
, block_focus(0)
|
||||||
, m_userActionsMenu(new UserActionsMenu(this))
|
, m_userActionsMenu(new UserActionsMenu(this))
|
||||||
, keys(0)
|
|
||||||
, client_keys(NULL)
|
, client_keys(NULL)
|
||||||
, client_keys_dialog(NULL)
|
, client_keys_dialog(NULL)
|
||||||
, client_keys_client(NULL)
|
, client_keys_client(NULL)
|
||||||
|
|
|
@ -191,9 +191,6 @@ public:
|
||||||
int oldDisplayWidth() const;
|
int oldDisplayWidth() const;
|
||||||
int oldDisplayHeight() const;
|
int oldDisplayHeight() const;
|
||||||
|
|
||||||
KActionCollection* actionCollection() const {
|
|
||||||
return keys;
|
|
||||||
}
|
|
||||||
KActionCollection* clientKeys() const {
|
KActionCollection* clientKeys() const {
|
||||||
return client_keys;
|
return client_keys;
|
||||||
}
|
}
|
||||||
|
@ -507,7 +504,6 @@ private:
|
||||||
|
|
||||||
void modalActionsSwitch(bool enabled);
|
void modalActionsSwitch(bool enabled);
|
||||||
|
|
||||||
KActionCollection* keys;
|
|
||||||
KActionCollection* client_keys;
|
KActionCollection* client_keys;
|
||||||
ShortcutDialog* client_keys_dialog;
|
ShortcutDialog* client_keys_dialog;
|
||||||
Client* client_keys_client;
|
Client* client_keys_client;
|
||||||
|
|
Loading…
Reference in New Issue