Repository: spyder-ide/spyder

Issue:
Keyboard shortcuts reset button cannot be canceled/undone and too easy to trigger  
## Description of your problem

I'd spent considerable time customizing Spyder's default keyboard shortcuts, and had to go in from time to time to tweak things. However, recently I accidentally hit the very large "Reset to Default Values" button at the bottom, which without the typical confirmation dialog (like for preferences in general) instantly wiped all of them out. Furthermore, a more serious bug presented itself when I then immediately hit "cancel" on the preferences dialog without hitting "apply," "ok" or doing anything else, as this did not cancel the changes (i.e. the reset shortcuts) and thus there was no user-visible way to get my shortcuts back. At the time, I was able to mess with config files and restore from an older backup, but when I reproduced the same behavior on my other machine, I wasn't even able to do that at least with the automatic backup spyder makes, and was stuck with the change.

**What steps will reproduce the problem?**

1. Set some custom keyboard shortcuts
2. Hit large "reset to default values" button 
3. Hit cancel
4. Reopen preferences
5. Rage as you realize all your carefully set keybindings are wiped out

**What is the expected output? What do you see instead?**

Expected: Confirmation dialog appears when hitting large "reset to defaults" button. Subsequently, "cancel" in the preferences window doesn't commit/undos this change, as it should.

Actual: Reset is executed instantly, without confirmation. "Cancel" does not undo change.

**Please provide any additional information below**

Tried and replicated on multiple clean installs over the past few anaconda versions.

## Versions and main components

* Spyder Version: 3.2.3–3.2.4
* Python Version: 3.6.1–3.6.3
* Qt Version: 5.6.2
* PyQt Version: 5.6
* Operating system: Windows 8.1 Pro x64


## Dependencies

IPython >=4.0    :  6.1.0 (OK)
cython >=0.21    :  0.26.1 (OK)
jedi >=0.9.0     :  0.10.2 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
numpy >=1.7      :  1.13.1 (OK)
pandas >=0.13.1  :  0.20.3 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pyflakes >=0.6.0 :  1.5.0 (OK)
pygments >=2.0   :  2.2.0 (OK)
pylint >=0.25    :  1.7.2 (OK)
qtconsole >=4.2.0:  4.3.1 (OK)
rope >=0.9.4     :  0.10.5 (OK)
sphinx >=0.6.6   :  1.6.3 (OK)
sympy >=0.7.3    :  1.1.1 (OK)




Discussion:
@dalthviz, please add a confirmation dialog to the Reset button to fix this one.

Also take a look at the workings of the Reset button to see that its action is not applied until the user hits the Preferences *Apply* button.

Resolving patch:
diff --git a/spyder/plugins/shortcuts.py b/spyder/plugins/shortcuts.py
--- a/spyder/plugins/shortcuts.py
+++ b/spyder/plugins/shortcuts.py
@@ -855,6 +855,13 @@ def check_settings(self):
         self.table.check_shortcuts()
 
     def reset_to_default(self):
+        """Reset to default values of the shortcuts making a confirmation."""
+        reset = QMessageBox.warning(self, _("Shortcuts reset"),
+                                    _("Do you want to reset "
+                                      "to default values?"),
+                                    QMessageBox.Yes | QMessageBox.No)
+        if reset == QMessageBox.No:
+            return
         reset_shortcuts()
         self.main.apply_shortcuts()
         self.table.load_shortcuts()


Test patch: