Forward unbound non-alphanumeric keys by default.

We do this so we benefit from some default WebKit keybindings users would
expect. For example, we'd need to bind Ctrl+X/C/V by default without this.

We also remove the custom-bound scrolling keybindings as they're redundant now.

The forward-unbound-keys setting now isn't a bool anymore, instead it can be
set to all/auto/none.
This commit is contained in:
Florian Bruhin 2014-06-19 11:51:25 +02:00
parent e6f9c0ccea
commit fdda1dd3a0
4 changed files with 24 additions and 18 deletions

View File

@ -376,8 +376,8 @@ DATA = OrderedDict([
"is focused after page load."),
('forward-unbound-keys',
SettingValue(types.Bool(), 'false'),
"Whether to forward unbound keys to the website in normal mode."),
SettingValue(types.ForwardUnboundKeys(), 'auto'),
"Whether to forward unbound keys to the webview in normal mode."),
('spatial-navigation',
SettingValue(types.Bool(), 'false'),
@ -678,14 +678,6 @@ DATA = OrderedDict([
('<Alt-8>', 'tab-focus 8'),
('<Alt-9>', 'tab-focus 9'),
('<Backspace>', 'back'),
('<Left>', 'scroll -50 0'),
('<Down>', 'scroll 0 50'),
('<Up>', 'scroll 0 -50'),
('<Right>', 'scroll 50 0'),
('<Shift-Space>', 'scroll-page 0 -1'),
('<Space>', 'scroll-page 0 1'),
('<PgUp>', 'scroll-page 0 -1'),
('<PgDown>', 'scroll-page 0 1'),
('<Ctrl-h>', 'home'),
('<Ctrl-s>', 'stop'),
('<Ctrl-Alt-p>', 'print'),

View File

@ -916,3 +916,13 @@ class ConfirmQuit(String):
('multiple-tabs', "Show a confirmation if "
"multiple tabs are opened."),
('never', "Never show a confirmation."))
class ForwardUnboundKeys(String):
"""Whether to forward unbound keys."""
valid_values = ValidValues(('all', "Forward all unbound keys."),
('auto', "Forward unbound non-alphanumeric "
"keys."),
('none', "Don't forward any keys."))

View File

@ -184,8 +184,8 @@ class BaseKeyParser(QObject):
self._keystring = ''
return
if txt not in (string.ascii_letters + string.digits +
string.punctuation):
if (not txt) or txt not in (string.ascii_letters + string.digits +
string.punctuation):
logger.debug("Ignoring, no text char")
return False

View File

@ -127,9 +127,13 @@ class ModeManager(QObject):
logger.debug("calling handler {}".format(handler.__qualname__))
handled = handler(event) if handler is not None else False
is_non_alnum = event.modifiers() or not event.text().strip()
if handled:
filter_this = True
elif self.mode in self.passthrough or self._forward_unbound_keys:
elif (self.mode in self.passthrough or
self._forward_unbound_keys == 'all' or
(self._forward_unbound_keys == 'auto' and is_non_alnum)):
filter_this = False
else:
filter_this = True
@ -137,11 +141,11 @@ class ModeManager(QObject):
if not filter_this:
self._releaseevents_to_pass.append(event)
logger.debug("handled: {}, forward-unbound-keys: {}, passthrough: {} "
"--> filter: {}".format(handled,
self._forward_unbound_keys,
self.mode in self.passthrough,
filter_this))
logger.debug("handled: {}, forward-unbound-keys: {}, passthrough: {}, "
"is_non_alnum: {} --> filter: {}".format(
handled, self._forward_unbound_keys,
self.mode in self.passthrough, is_non_alnum,
filter_this))
return filter_this
def _eventFilter_keyrelease(self, event):