summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-04-10 22:37:57 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-04-10 22:45:26 +0000
commit331007daf93a64a88f7e064400b72a89a6f87417 (patch)
treec72ed483db34fa0568951bd12f80b38385dadbe5 /src
parentPrevent segmentation fault when editing flow text missing <flowPara>. (diff)
downloadinkscape-331007daf93a64a88f7e064400b72a89a6f87417.tar.gz
inkscape-331007daf93a64a88f7e064400b72a89a6f87417.zip
Ask user whether to reassign already used shortcuts
Fixes https://gitlab.com/inkscape/inkscape/issues/182
Diffstat (limited to 'src')
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 2b1a23571..0c89a2257 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -2137,7 +2137,26 @@ void InkscapePreferences::onKBTreeEdited (const Glib::ustring& path, guint accel
}
unsigned int const new_shortcut_id = sp_shortcut_get_from_gdk_event(accel_key, accel_mods, hardware_keycode);
- if (new_shortcut_id) {
+ if (new_shortcut_id && (new_shortcut_id != current_shortcut_id)) {
+ // check if there is currently a verb assigned to this shortcut; if yes ask if the shortcut should be reassigned
+ Inkscape::Verb *current_verb = sp_shortcut_get_verb(new_shortcut_id);
+ if (current_verb) {
+ Glib::ustring verb_name = _(current_verb->get_name());
+ Glib::ustring::size_type pos = 0;
+ while ((pos = verb_name.find('_', pos)) != verb_name.npos) { // strip mnemonics
+ verb_name.erase(pos, 1);
+ }
+ Glib::ustring message = Glib::ustring::compose(_("Keyboard shortcut \"%1\"\nis already assigned to \"%2\""),
+ sp_shortcut_get_label(new_shortcut_id), verb_name);
+ Gtk::MessageDialog dialog(message, false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO, true);
+ dialog.set_title(_("Reassign shortcut?"));
+ dialog.set_secondary_text(_("Are you sure you want to reassign this shortcut?"));
+ dialog.set_transient_for(*dynamic_cast<Gtk::Window *>(get_toplevel()));
+ int response = dialog.run();
+ if (response != Gtk::RESPONSE_YES) {
+ return;
+ }
+ }
// Delete current shortcut if it existed
sp_shortcut_delete_from_file(id.c_str(), current_shortcut_id);