diff --git a/kcontrol/standard_actions/standard_actions_module.cpp b/kcontrol/standard_actions/standard_actions_module.cpp index 0d8adb39..6cb0aeaf 100644 --- a/kcontrol/standard_actions/standard_actions_module.cpp +++ b/kcontrol/standard_actions/standard_actions_module.cpp @@ -36,7 +36,7 @@ K_PLUGIN_FACTORY(StandardActionsModuleFactory, registerPluginsetData(shortcutId); // We have to manually adjust the action. We want to show the @@ -50,20 +50,17 @@ static void dressUpAction(KAction *action, KStandardShortcut::StandardShortcut s // Set the user defined values as active shortcuts. If the user only // has overwritten the primary shortcut make sure the alternate one // still get's shown - if (active[1] == 0) - { + if (active[1] == 0) { active = QKeySequence(active[0], hardcoded[1]); - } - action->setShortcut(active, KAction::ActiveShortcut); } + action->setShortcut(active, KAction::ActiveShortcut); +} -StandardActionsModule::StandardActionsModule( - QWidget *parent, - const QVariantList &args ) - : KCModule(StandardActionsModuleFactory::componentData(), parent, args ) - ,m_editor(NULL) - ,m_actionCollection(NULL) - { +StandardActionsModule::StandardActionsModule(QWidget *parent, const QVariantList &args) + : KCModule(StandardActionsModuleFactory::componentData(), parent, args), + m_editor(nullptr), + m_actionCollection(nullptr) +{ KAboutData about("kcm_standard_actions", 0, ki18n("Standard Shortcuts"), "0.1"); StandardActionsModuleFactory::componentData().setAboutData(about); @@ -78,81 +75,67 @@ StandardActionsModule::StandardActionsModule( QVBoxLayout *global = new QVBoxLayout; global->addWidget(m_editor); setLayout(global); - } - - -StandardActionsModule::~StandardActionsModule() - {} - +} void StandardActionsModule::defaults() - { +{ m_editor->allDefault(); - } +} void StandardActionsModule::keyChanged() - { +{ emit changed(true); - } - +} void StandardActionsModule::load() - { +{ // Create a collection to handle the shortcuts - m_actionCollection = new KActionCollection( - this, - StandardActionsModuleFactory::componentData()); + m_actionCollection = new KActionCollection(this, StandardActionsModuleFactory::componentData()); // Keeps track of which shortcut IDs have been added QSet shortcutIdsAdded; // Put all shortcuts for standard actions into the collection - Q_FOREACH(KStandardAction::StandardAction id, KStandardAction::actionIds()) - { + foreach (KStandardAction::StandardAction id, KStandardAction::actionIds()) { KStandardShortcut::StandardShortcut shortcutId = KStandardAction::shortcutForActionId(id); // If the StandardShortcutId is AccelNone skip configuration for this // action. - if (shortcutId == KStandardShortcut::AccelNone || shortcutIdsAdded.contains(shortcutId)) - { + if (shortcutId == KStandardShortcut::AccelNone || shortcutIdsAdded.contains(shortcutId)) { continue; - } + } // Create the action KAction *action = KStandardAction::create(id, NULL, NULL, m_actionCollection); dressUpAction(action, shortcutId); shortcutIdsAdded << shortcutId; - } + } // Put in the remaining standard shortcuts too... - for(int i = int(KStandardShortcut::AccelNone) + 1; i < KStandardShortcut::StandardShortcutCount; ++i) - { + for(int i = int(KStandardShortcut::AccelNone) + 1; i < KStandardShortcut::StandardShortcutCount; ++i) { KStandardShortcut::StandardShortcut shortcutId = static_cast(i); - if(!shortcutIdsAdded.contains(shortcutId)) - { + if (!shortcutIdsAdded.contains(shortcutId)) { KAction *action = new KAction(KStandardShortcut::label(shortcutId), this); action->setWhatsThis(KStandardShortcut::whatsThis(shortcutId)); dressUpAction(action, shortcutId); m_actionCollection->addAction(KStandardShortcut::name(shortcutId), action); - } } + } // Hand the collection to the editor m_editor->addCollection(m_actionCollection, i18n("Standard Shortcuts")); - } - +} void StandardActionsModule::save() - { - m_editor->commit(); +{ + m_editor->exportConfiguration(); - Q_FOREACH(QAction* action, m_actionCollection->actions()) - { + foreach (QAction* action, m_actionCollection->actions()) { KAction *kaction = qobject_cast(action); - KStandardShortcut::saveShortcut( - static_cast(action->data().toInt()) - , kaction->shortcut()); - } + static_cast(action->data().toInt()), + kaction->shortcut() + ); + } KGlobal::config()->sync(); KConfigGroup cg(KGlobal::config(), "Shortcuts"); @@ -163,8 +146,9 @@ void StandardActionsModule::save() "The changes have been saved. Please note that:" "
  • Applications need to be restarted to see the changes.
  • " "
  • This change could introduce shortcut conflicts in some applications.
  • " - "
" ); + "" + ); KMessageBox::information(this, message, title, "shortcuts_saved_info"); - } +} #include "moc_standard_actions_module.cpp" diff --git a/kcontrol/standard_actions/standard_actions_module.h b/kcontrol/standard_actions/standard_actions_module.h index 2a24f731..76fe751a 100644 --- a/kcontrol/standard_actions/standard_actions_module.h +++ b/kcontrol/standard_actions/standard_actions_module.h @@ -1,5 +1,3 @@ -#ifndef STANDARD_ACTIONS_MODULE_H -#define STANDARD_ACTIONS_MODULE_H /* Copyright (C) 2008 Michael Jansen This library is free software; you can redistribute it and/or @@ -18,32 +16,32 @@ Boston, MA 02110-1301, USA. */ +#ifndef STANDARD_ACTIONS_MODULE_H +#define STANDARD_ACTIONS_MODULE_H + #include class KActionCollection; class KShortcutsEditor; class StandardActionsModule : public KCModule - { +{ Q_OBJECT public: StandardActionsModule(QWidget *parent, const QVariantList &args); - ~StandardActionsModule(); - /*reimp*/ void save(); - /*reimp*/ void load(); - /*reimp*/ void defaults(); + void save() final; + void load() final; + void defaults() final; private slots: void keyChanged(); private: - KShortcutsEditor *m_editor; KActionCollection *m_actionCollection; - -}; // class StandardActionsModule +}; -#endif /* #ifndef STANDARD_ACTIONS_MODULE_H */ +#endif // STANDARD_ACTIONS_MODULE_H diff --git a/kwin/effects/magnifier/magnifier_config.cpp b/kwin/effects/magnifier/magnifier_config.cpp index 8c18f42e..8ff3bbc7 100644 --- a/kwin/effects/magnifier/magnifier_config.cpp +++ b/kwin/effects/magnifier/magnifier_config.cpp @@ -80,17 +80,11 @@ MagnifierEffectConfig::MagnifierEffectConfig(QWidget* parent, const QVariantList load(); } -MagnifierEffectConfig::~MagnifierEffectConfig() -{ - // Undo (only) unsaved changes to global key shortcuts - m_ui->editor->undoChanges(); -} - void MagnifierEffectConfig::save() { kDebug(1212) << "Saving config of Magnifier" ; - m_ui->editor->save(); // undo() will restore to this state from now on + m_ui->editor->exportConfiguration(); KCModule::save(); EffectsHandler::sendReloadMessage("magnifier"); } diff --git a/kwin/effects/magnifier/magnifier_config.h b/kwin/effects/magnifier/magnifier_config.h index f21652a1..79943ef0 100644 --- a/kwin/effects/magnifier/magnifier_config.h +++ b/kwin/effects/magnifier/magnifier_config.h @@ -42,7 +42,6 @@ class MagnifierEffectConfig : public KCModule Q_OBJECT public: explicit MagnifierEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~MagnifierEffectConfig(); virtual void save(); virtual void defaults(); diff --git a/kwin/effects/mousemark/mousemark_config.cpp b/kwin/effects/mousemark/mousemark_config.cpp index 4677d6d6..35039b70 100644 --- a/kwin/effects/mousemark/mousemark_config.cpp +++ b/kwin/effects/mousemark/mousemark_config.cpp @@ -74,19 +74,13 @@ MouseMarkEffectConfig::MouseMarkEffectConfig(QWidget* parent, const QVariantList load(); } -MouseMarkEffectConfig::~MouseMarkEffectConfig() -{ - // Undo (only) unsaved changes to global key shortcuts - m_ui->editor->undoChanges(); -} - void MouseMarkEffectConfig::save() { kDebug(1212) << "Saving config of MouseMark" ; KCModule::save(); m_actionCollection->writeSettings(); - m_ui->editor->save(); // undo() will restore to this state from now on + m_ui->editor->exportConfiguration(); EffectsHandler::sendReloadMessage("mousemark"); } diff --git a/kwin/effects/mousemark/mousemark_config.h b/kwin/effects/mousemark/mousemark_config.h index 290c9add..2eb863a3 100644 --- a/kwin/effects/mousemark/mousemark_config.h +++ b/kwin/effects/mousemark/mousemark_config.h @@ -42,7 +42,6 @@ class MouseMarkEffectConfig : public KCModule Q_OBJECT public: explicit MouseMarkEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~MouseMarkEffectConfig(); virtual void save(); diff --git a/kwin/effects/presentwindows/presentwindows_config.cpp b/kwin/effects/presentwindows/presentwindows_config.cpp index 88428db8..17ef92cd 100644 --- a/kwin/effects/presentwindows/presentwindows_config.cpp +++ b/kwin/effects/presentwindows/presentwindows_config.cpp @@ -80,16 +80,10 @@ PresentWindowsEffectConfig::PresentWindowsEffectConfig(QWidget* parent, const QV load(); } -PresentWindowsEffectConfig::~PresentWindowsEffectConfig() -{ - // If save() is called undoChanges() has no effect - m_ui->shortcutEditor->undoChanges(); -} - void PresentWindowsEffectConfig::save() { KCModule::save(); - m_ui->shortcutEditor->save(); + m_ui->shortcutEditor->exportConfiguration(); EffectsHandler::sendReloadMessage("presentwindows"); } diff --git a/kwin/effects/presentwindows/presentwindows_config.h b/kwin/effects/presentwindows/presentwindows_config.h index ce6fdc32..dd1fee54 100644 --- a/kwin/effects/presentwindows/presentwindows_config.h +++ b/kwin/effects/presentwindows/presentwindows_config.h @@ -42,7 +42,6 @@ class PresentWindowsEffectConfig : public KCModule Q_OBJECT public: explicit PresentWindowsEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~PresentWindowsEffectConfig(); public slots: virtual void save(); diff --git a/kwin/effects/thumbnailaside/thumbnailaside_config.cpp b/kwin/effects/thumbnailaside/thumbnailaside_config.cpp index bf46a5d5..a6c2b622 100644 --- a/kwin/effects/thumbnailaside/thumbnailaside_config.cpp +++ b/kwin/effects/thumbnailaside/thumbnailaside_config.cpp @@ -73,15 +73,10 @@ ThumbnailAsideEffectConfig::ThumbnailAsideEffectConfig(QWidget* parent, const QV load(); } -ThumbnailAsideEffectConfig::~ThumbnailAsideEffectConfig() -{ - // Undo (only) unsaved changes to global key shortcuts - m_ui->editor->undoChanges(); -} - void ThumbnailAsideEffectConfig::save() { KCModule::save(); + m_ui->editor->exportConfiguration(); EffectsHandler::sendReloadMessage("thumbnailaside"); } diff --git a/kwin/effects/thumbnailaside/thumbnailaside_config.h b/kwin/effects/thumbnailaside/thumbnailaside_config.h index 67566722..235b8226 100644 --- a/kwin/effects/thumbnailaside/thumbnailaside_config.h +++ b/kwin/effects/thumbnailaside/thumbnailaside_config.h @@ -42,7 +42,6 @@ class ThumbnailAsideEffectConfig : public KCModule Q_OBJECT public: explicit ThumbnailAsideEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~ThumbnailAsideEffectConfig(); virtual void save(); diff --git a/kwin/effects/windowgeometry/windowgeometry_config.cpp b/kwin/effects/windowgeometry/windowgeometry_config.cpp index 740f4329..e51c5a54 100644 --- a/kwin/effects/windowgeometry/windowgeometry_config.cpp +++ b/kwin/effects/windowgeometry/windowgeometry_config.cpp @@ -58,16 +58,10 @@ WindowGeometryConfig::WindowGeometryConfig(QWidget* parent, const QVariantList& load(); } -WindowGeometryConfig::~WindowGeometryConfig() -{ - // Undo (only) unsaved changes to global key shortcuts - myUi->shortcuts->undoChanges(); -} - void WindowGeometryConfig::save() { KCModule::save(); - myUi->shortcuts->save(); // undo() will restore to this state from now on + myUi->shortcuts->exportConfiguration(); EffectsHandler::sendReloadMessage("windowgeometry"); } diff --git a/kwin/effects/windowgeometry/windowgeometry_config.h b/kwin/effects/windowgeometry/windowgeometry_config.h index 67c66084..b205cb09 100644 --- a/kwin/effects/windowgeometry/windowgeometry_config.h +++ b/kwin/effects/windowgeometry/windowgeometry_config.h @@ -41,7 +41,6 @@ class WindowGeometryConfig : public KCModule Q_OBJECT public: explicit WindowGeometryConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - ~WindowGeometryConfig(); public slots: void save(); diff --git a/kwin/effects/zoom/zoom_config.cpp b/kwin/effects/zoom/zoom_config.cpp index df261186..ce706cfe 100644 --- a/kwin/effects/zoom/zoom_config.cpp +++ b/kwin/effects/zoom/zoom_config.cpp @@ -108,15 +108,9 @@ ZoomEffectConfig::ZoomEffectConfig(QWidget* parent, const QVariantList& args) : load(); } -ZoomEffectConfig::~ZoomEffectConfig() -{ - // Undo (only) unsaved changes to global key shortcuts - m_ui->editor->undoChanges(); -} - void ZoomEffectConfig::save() { - m_ui->editor->save(); // undo() will restore to this state from now on + m_ui->editor->exportConfiguration(); KCModule::save(); EffectsHandler::sendReloadMessage("zoom"); } diff --git a/kwin/effects/zoom/zoom_config.h b/kwin/effects/zoom/zoom_config.h index 9b97cc28..1be5005a 100644 --- a/kwin/effects/zoom/zoom_config.h +++ b/kwin/effects/zoom/zoom_config.h @@ -42,7 +42,6 @@ class ZoomEffectConfig : public KCModule Q_OBJECT public: explicit ZoomEffectConfig(QWidget* parent = 0, const QVariantList& args = QVariantList()); - virtual ~ZoomEffectConfig(); public slots: virtual void save(); diff --git a/kwin/kcmkwin/kwindesktop/main.cpp b/kwin/kcmkwin/kwindesktop/main.cpp index f4c66dbd..5d5b0921 100644 --- a/kwin/kcmkwin/kwindesktop/main.cpp +++ b/kwin/kcmkwin/kwindesktop/main.cpp @@ -176,11 +176,6 @@ void KWinDesktopConfig::init() // End check for immutable } -KWinDesktopConfig::~KWinDesktopConfig() -{ - undo(); -} - void KWinDesktopConfig::addAction(const QString &name, const QString &label) { KAction* a = qobject_cast(m_switchDesktopCollection->addAction(name)); @@ -220,7 +215,7 @@ void KWinDesktopConfig::defaults() void KWinDesktopConfig::load() { // This method is called on reset(). So undo all changes. - undo(); + m_editor->importConfiguration(); // get number of desktops unsigned long properties[] = {NET::NumberOfDesktops | NET::DesktopNames, NET::WM2DesktopLayout }; @@ -318,7 +313,7 @@ void KWinDesktopConfig::save() break; } - m_editor->save(); + m_editor->exportConfiguration(); m_config->sync(); // Send signal to all kwin instances @@ -328,14 +323,6 @@ void KWinDesktopConfig::save() emit changed(false); } - -void KWinDesktopConfig::undo() -{ - // The global shortcuts editor makes changes active immediately. In case - // of undo we have to undo them manually - m_editor->undoChanges(); -} - QString KWinDesktopConfig::cachedDesktopName(int desktop) { if (desktop > m_desktopNames.size()) diff --git a/kwin/kcmkwin/kwindesktop/main.h b/kwin/kcmkwin/kwindesktop/main.h index b600ee92..b643c286 100644 --- a/kwin/kcmkwin/kwindesktop/main.h +++ b/kwin/kcmkwin/kwindesktop/main.h @@ -49,11 +49,8 @@ class KWinDesktopConfig : public KCModule public: explicit KWinDesktopConfig(QWidget* parent, const QVariantList& args); - ~KWinDesktopConfig(); - QString cachedDesktopName(int desktop); - // undo all changes - void undo(); + QString cachedDesktopName(int desktop); public slots: virtual void save();