From kde-commits Sat Feb 28 23:10:06 2009 From: Michael Jansen Date: Sat, 28 Feb 2009 23:10:06 +0000 To: kde-commits Subject: KDE/kdebase/workspace/kcontrol/keys Message-Id: <1235862606.475777.1893.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=123586262103138 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 +#include #include + #include @@ -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();