[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/kcontrol/keys
From:       Michael Jansen <kde () michael-jansen ! biz>
Date:       2009-02-28 23:10:06
Message-ID: 1235862606.475777.1893.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 933452 by mjansen:

After pressing default ask the user if he would like to reset all
global shortcuts for all components or only for the current component.

 M  +21 -1     globalshortcuts.cpp  
 M  +20 -6     kglobalshortcutseditor.cpp  
 M  +8 -2      kglobalshortcutseditor.h  


--- trunk/KDE/kdebase/workspace/kcontrol/keys/globalshortcuts.cpp #933451:933452
@@ -21,8 +21,11 @@
 
 #include "kglobalshortcutseditor.h"
 
+#include <KDE/KLocale>
+#include <KDE/KMessageBox>
 #include <KDE/KPluginFactory>
 
+
 #include <QtGui/QLayout>
 
 
@@ -59,7 +62,24 @@
 
 void GlobalShortcutsModule::defaults()
 {
-    editor->allDefault();
+    switch (KMessageBox::questionYesNoCancel(
+                    this,
+                    i18n("You are about to reset all shortcuts to their default value!"),
+                    i18n("Reset to defaults"),
+                    KGuiItem(i18n("Current Component")),
+                    KGuiItem(i18n("All Components"))))
+        {
+        case KMessageBox::Yes:
+            editor->defaults(KGlobalShortcutsEditor::CurrentComponent);
+            break;
+
+        case KMessageBox::No:
+            editor->defaults(KGlobalShortcutsEditor::AllComponents);
+            break;
+
+        default:
+            return;
+        }
 }
 
 
--- trunk/KDE/kdebase/workspace/kcontrol/keys/kglobalshortcutseditor.cpp #933451:933452
@@ -198,13 +198,27 @@
 }
 
 
-void KGlobalShortcutsEditor::allDefault()
+void KGlobalShortcutsEditor::defaults(ComponentScope scope)
 {
-    // The editors are responsible for the reset
-    kDebug() << "Reset";
-    foreach (const componentData &cd, d->components) {
-        cd.editor->allDefault();
-    }
+    switch (scope)
+        {
+        case AllComponents:
+            foreach (const componentData &cd, d->components) {
+                // The editors are responsible for the reset
+                cd.editor->allDefault();
+            }
+            break;
+
+        case CurrentComponent: {
+            QString name = d->ui.components->currentText();
+            // The editors are responsible for the reset
+            d->components.value(name).editor->allDefault();
+            }
+            break;
+
+        default:
+            Q_ASSERT(false);
+        };
 }
 
 
--- trunk/KDE/kdebase/workspace/kcontrol/keys/kglobalshortcutseditor.h #933451:933452
@@ -87,6 +87,12 @@
      */
     bool isModified() const;
 
+    enum ComponentScope
+        {
+        AllComponents,
+        CurrentComponent
+        };
+
 Q_SIGNALS:
 
     /**
@@ -120,9 +126,9 @@
     void save();
 
     /**
-     * Reset all \a components to default values.
+     * Set shortcuts to their default value;
      */
-    void allDefault();
+    void defaults(ComponentScope scope);
 
     virtual void importScheme();
     virtual void exportScheme();
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic