diff --git a/kcms/keyboard/bindings.cpp b/kcms/keyboard/bindings.cpp index 540ec4989..164100a77 100644 --- a/kcms/keyboard/bindings.cpp +++ b/kcms/keyboard/bindings.cpp @@ -1,147 +1,148 @@ /* * Copyright (C) 2010 Andriy Rysin (rysin@kde.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "bindings.h" #include "debug.h" #include #include #include #include #include #include "x11_helper.h" #include "flags.h" static const char actionName[] = I18N_NOOP("Switch to Next Keyboard Layout"); static const char COMPONENT_NAME[] = I18N_NOOP("KDE Keyboard Layout Switcher"); KeyboardLayoutActionCollection::KeyboardLayoutActionCollection(QObject* parent, bool configAction_): KActionCollection(parent, COMPONENT_NAME), configAction(configAction_) { + setComponentDisplayName(i18n("Keyboard Layout Switcher")); QAction* toggleAction = addAction( actionName ); toggleAction->setText( i18n(actionName) ); KGlobalAccel::self()->setShortcut(toggleAction, QList() << QKeySequence(Qt::ALT+Qt::CTRL+Qt::Key_K), KGlobalAccel::Autoloading); if( configAction ) { toggleAction->setProperty("isConfigurationAction", true); } } KeyboardLayoutActionCollection::~KeyboardLayoutActionCollection() { clear(); } QAction* KeyboardLayoutActionCollection::getToggleAction() { return action(0); } QAction* KeyboardLayoutActionCollection::createLayoutShortcutActon(const LayoutUnit& layoutUnit, const Rules* rules, bool autoload) { QString longLayoutName = Flags::getLongText( layoutUnit, rules ); QString actionName = QStringLiteral("Switch keyboard layout to "); actionName += longLayoutName; QAction* action = addAction( actionName ); action->setText( i18n("Switch keyboard layout to %1", longLayoutName) ); KGlobalAccel::GlobalShortcutLoading loading = autoload ? KGlobalAccel::Autoloading : KGlobalAccel::NoAutoloading; QList shortcuts; if (!autoload) { shortcuts << layoutUnit.getShortcut(); } KGlobalAccel::self()->setShortcut(action, shortcuts, loading); action->setData(layoutUnit.toString()); if( configAction ) { action->setProperty("isConfigurationAction", true); } return action; } void KeyboardLayoutActionCollection::setToggleShortcut(const QKeySequence& keySequence) { KGlobalAccel::self()->setShortcut(getToggleAction(), QList() << keySequence, KGlobalAccel::NoAutoloading); } //KAction* KeyboardLayoutActionCollection::setShortcut(LayoutUnit& layoutUnit, const QKeySequence& keySequence, const Rules* rules) //{ // KAction* action = getAction(layoutUnit); // if( action == NULL && ! keySequence.isEmpty() ) { // action = createLayoutShortcutActon(layoutUnit, rules, false); // } // else if( action != NULL && keySequence.isEmpty() ){ //// action->setGlobalShortcut(KShortcut(keySequence), KAction::ActiveShortcut, KAction::NoAutoloading); // do we need this? // removeAction(action); // action = NULL; // } //// if( configAction ) { //// layoutUnit.setShortcut(keySequence); // shortcut was restored //// } // return action; //} void KeyboardLayoutActionCollection::setLayoutShortcuts(QList& layoutUnits, const Rules* rules) { for (QList::iterator i = layoutUnits.begin(); i != layoutUnits.end(); ++i) { LayoutUnit& layoutUnit = *i; if( ! layoutUnit.getShortcut().isEmpty() ) { createLayoutShortcutActon(layoutUnit, rules, false); } } qCDebug(KCM_KEYBOARD) << "Cleaning component shortcuts on save" << KGlobalAccel::cleanComponent(COMPONENT_NAME); } void KeyboardLayoutActionCollection::loadLayoutShortcuts(QList& layoutUnits, const Rules* rules) { for (QList::iterator i = layoutUnits.begin(); i != layoutUnits.end(); ++i) { LayoutUnit& layoutUnit = *i; QAction* action = createLayoutShortcutActon(layoutUnit, rules, true); const auto shortcut = KGlobalAccel::self()->shortcut(action); if( ! shortcut.isEmpty() ) { qCDebug(KCM_KEYBOARD, ) << "Restored shortcut for" << layoutUnit.toString() << shortcut.first(); layoutUnit.setShortcut(shortcut.first()); } else { qCDebug(KCM_KEYBOARD, ) << "Skipping empty shortcut for" << layoutUnit.toString(); removeAction(action); } } qCDebug(KCM_KEYBOARD) << "Cleaning component shortcuts on load" << KGlobalAccel::cleanComponent(COMPONENT_NAME); } //KAction* KeyboardLayoutActionCollection::getAction(const LayoutUnit& layoutUnit) //{ // for(int i=1; idata() == layoutUnit.toString() ) // return static_cast(action(i)); // } // return NULL; //} void KeyboardLayoutActionCollection::resetLayoutShortcuts() { for(int i=1; isetShortcut(action(i), QList(), KGlobalAccel::NoAutoloading); KGlobalAccel::self()->setDefaultShortcut(action(i), QList(), KGlobalAccel::NoAutoloading); } } diff --git a/kcms/touchpad/kded/kdedactions.cpp b/kcms/touchpad/kded/kdedactions.cpp index 250da3afe..d1a431ce3 100644 --- a/kcms/touchpad/kded/kdedactions.cpp +++ b/kcms/touchpad/kded/kdedactions.cpp @@ -1,64 +1,65 @@ /* * Copyright (C) 2013 Alexander Mezin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kdedactions.h" #include #include #include #include #include "plugins.h" TouchpadGlobalActions::TouchpadGlobalActions(bool isConfiguration, QObject *parent) : KActionCollection(parent) { //setComponentName(TouchpadPluginFactory::componentData()); setComponentName("kcm_touchpad"); + setComponentDisplayName(i18n("Touchpad")); QAction *enable = addAction("Enable Touchpad"); enable->setText(i18n("Enable Touchpad")); connect(enable, SIGNAL(triggered()), SIGNAL(enableTriggered())); bool okEnable = KGlobalAccel::setGlobalShortcut(enable, QKeySequence(Qt::Key_TouchpadOn)); if (!okEnable) { qWarning() << "Couldn't set global shortcut to Qt::Key_TouchpadOn. There's another program using it, otherwise file a bug against kcm_touchpad"; } QAction *disable = addAction("Disable Touchpad"); disable->setText(i18n("Disable Touchpad")); connect(disable, SIGNAL(triggered()), SIGNAL(disableTriggered())); bool okDisable = KGlobalAccel::setGlobalShortcut(disable, QKeySequence(Qt::Key_TouchpadOff)); if (!okDisable) { qWarning() << "Couldn't set global shortcut to Qt::Key_TouchpadOff. There's another program using it, otherwise file a bug against kcm_touchpad"; } QAction *toggle = addAction("Toggle Touchpad"); toggle->setText(i18n("Toggle Touchpad")); connect(toggle, SIGNAL(triggered()), SIGNAL(toggleTriggered())); bool okToggle = KGlobalAccel::setGlobalShortcut(toggle, QKeySequence(Qt::Key_TouchpadToggle)); if (!okToggle) { qWarning() << "Couldn't set global shortcut to Qt::Key_TouchpadToggle. There's another program using it, otherwise file a bug against kcm_touchpad"; } Q_FOREACH (QAction *act, actions()) { KActionCollection::setShortcutsConfigurable(act,true); if (isConfiguration) { act->setProperty("isConfigurationAction", true); } } }