From b19af6efc276f4837407c4c1d14504f8b190fb2d Mon Sep 17 00:00:00 2001 From: chr Date: Tue, 23 May 2017 21:48:27 +0200 Subject: opject panel: rework shotcuts: let the user decide This implemetation respect the users action shortcuts, handled in this order: 1) Two hardcoded keystrokes: * crtl+f engage search on tree view * esc: defocus: next keystrokes goes to desktop 2) Try to invoke user defined shortcut action 3) RETURN-key: activate action of selected column currently works on the name-column only 4) shortcut goes to Treeview For the testers: The new verbs "stack up/down" are not bound to keystrokes. Set them up as you like via preferences / interface / keyboard shortcuts / selection / stack up and down Try keystrokes with focus on desktop, on object-panel and compare with layer-panel: PageUp/Down + - shift, ctrl esc esc arrow esc arrow ctrl+f V, H - may(!) flip objects ctrl+a (!) ! invert selection Beside user definable keystrokes, there are some hardcoded: arrow-up/down + shift,ctrl [ ] - rotate objects - not user defined actions, so does not work in panel focus / * also keypad / * is usually fold/unfold tree but * actually selects the "star tool", which can be disabled if you don't like that Conflicts: src/ui/dialog/objects.cpp (bzr r15698.1.10) --- src/ui/dialog/objects.cpp | 63 +++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 27 deletions(-) (limited to 'src/ui/dialog/objects.cpp') diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 95302387f..61ce3ada3 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -30,6 +30,7 @@ #include "helper/action.h" #include "inkscape.h" #include "layer-manager.h" +#include "shortcuts.h" #include "sp-clippath.h" #include "sp-mask.h" #include "sp-root.h" @@ -692,7 +693,41 @@ void ObjectsPanel::_setLockedIter( const Gtk::TreeModel::iterator& iter, const b */ bool ObjectsPanel::_handleKeyEvent(GdkEventKey *event) { + if (!_desktop) + return false; + + unsigned int shortcut; + shortcut = Inkscape::UI::Tools::get_group0_keyval(event) | + ( event->state & GDK_SHIFT_MASK ? + SP_SHORTCUT_SHIFT_MASK : 0 ) | + ( event->state & GDK_CONTROL_MASK ? + SP_SHORTCUT_CONTROL_MASK : 0 ) | + ( event->state & GDK_MOD1_MASK ? + SP_SHORTCUT_ALT_MASK : 0 ); + + switch (shortcut) { + // how to get users key binding for the action “start-interactive-search” ?? + // ctrl+f is just the default + case GDK_KEY_f | SP_SHORTCUT_CONTROL_MASK: + return false; + break; + // shall we slurp ctrl+w to close panel? + + // defocus: + case GDK_KEY_Escape: + if (_desktop->canvas) { + gtk_widget_grab_focus (GTK_WIDGET(_desktop->canvas)); + return true; + } + break; + } + // invoke user defined shortcuts first + bool done = sp_shortcut_invoke(shortcut, _desktop); + if (done) + return true; + + // handle events for the treeview bool empty = _desktop->selection->isEmpty(); switch (Inkscape::UI::Tools::get_group0_keyval(event)) { @@ -711,36 +746,10 @@ bool ObjectsPanel::_handleKeyEvent(GdkEventKey *event) return true; } return false; - } - break; - case GDK_KEY_Home: - //Move item(s) to top of containing group/layer - _fireAction( empty ? SP_VERB_LAYER_TO_TOP : SP_VERB_SELECTION_TO_FRONT ); - break; - case GDK_KEY_End: - //Move item(s) to bottom of containing group/layer - _fireAction( empty ? SP_VERB_LAYER_TO_BOTTOM : SP_VERB_SELECTION_TO_BACK ); - break; - case GDK_KEY_Page_Up: - { - //Move item(s) up in containing group/layer - int ch = event->state & GDK_SHIFT_MASK ? SP_VERB_LAYER_MOVE_TO_NEXT : SP_VERB_SELECTION_STACK_UP; - _fireAction( empty ? SP_VERB_LAYER_RAISE : ch ); break; } - case GDK_KEY_Page_Down: - { - //Move item(s) down in containing group/layer - int ch = event->state & GDK_SHIFT_MASK ? SP_VERB_LAYER_MOVE_TO_PREV : SP_VERB_SELECTION_STACK_DOWN; - _fireAction( empty ? SP_VERB_LAYER_LOWER : ch ); - break; - } - - //TODO: Handle Ctrl-A, etc. - default: - return false; } - return true; + return false; } /** -- cgit v1.2.3