LibreCAD/LibreCAD — pull request #429 by wiesiwies (2013-12-28 17:51:36+00:00)
Title: Misc changes concerning keyboard shortcuts

* Added 2 letter shortcuts for restrict horizontal (rh), vertical (rv),
orthogonal (rr) and none (rn).

* In my opinion, the two-letter shortcuts for snapping
should toggle and not just enable the corresponding function.
Otherwise they can't be switched off with the shortcut. Changed the
behaviour to toggle.

* actionHandler->keycode() should only be called in keyPressEvent,
if there are really two letters in the buffer. Otherwise the
double-letter shortcuts get mixed up with single letter short commands
which start with the same letter (e.g. 'os' and 'o' will be mixed up if
the user tries to type 'os' multiple times without waiting the timeout),
because we violate the fano-condition. Fixed that.
Note: This changes the user interface behaviour somewhat, because only
two letter commands (and the newly implemented shortcuts mentioned below)
now work. It is not valid to just type 'o' for offset anymore. But I think
this change is justified, because the old behaviour gave inconsistent
results.

* Added the possibility to assign actions to the function keys
(F1, F2, ...) and key combination of "Alt" plus some key and "Meta"
plus some key. Please note that Alt-keystrokes may interfere with
the menu and GUI hotkeys.

To use this feature, add an alias from e.g. Fn1, Alt-j or Meta-n
to your desired function in your librecad.alias file (where '1', 'j'
and 'n' are just examples here).

Examples:
To use F2 for lines, Alt-j for circles and Meta-x for 'extend' add:
Fn2	line
Alt-j	circle
Meta-x	xt

to your alias file. Notice that the Alt- and Meta-modifiers respect
are case sensitive. You may use different commands for upper- and lowercase
letters here.

Implementation details:
The event handler keyPressEvent detects the modifier keys. If a key
combination e.g. Meta-x. is pressed, the command string of the x key is
just prefixed with the String "Meta-", resulting in "Meta-x". This way,
no changes in the key processing code was needed to make this work.
Side Effect: Typing "Meta-x" in the command line has the same Effect as
pressing Meta+x.

_Note_: Changes are tested somewhat, but not heavily.