Go to insert mode when plugin clicked
This commit is contained in:
parent
5b84848ad9
commit
a82ab6d707
1
TODO
1
TODO
@ -1,7 +1,6 @@
|
|||||||
keyparser foo
|
keyparser foo
|
||||||
=============
|
=============
|
||||||
|
|
||||||
- Get to insert mode when clicking flash plugins
|
|
||||||
- Handle keybind to get out of insert mode (e.g. esc)
|
- Handle keybind to get out of insert mode (e.g. esc)
|
||||||
- Pass keypresses to statusbar correctly
|
- Pass keypresses to statusbar correctly
|
||||||
- Switch to normal mode if new page loaded
|
- Switch to normal mode if new page loaded
|
||||||
|
@ -166,6 +166,11 @@ DATA = OrderedDict([
|
|||||||
('cmd_timeout',
|
('cmd_timeout',
|
||||||
SettingValue(types.Int(minval=0), "500"),
|
SettingValue(types.Int(minval=0), "500"),
|
||||||
"Timeout for ambiguous keybindings."),
|
"Timeout for ambiguous keybindings."),
|
||||||
|
|
||||||
|
('insert_mode_on_plugins',
|
||||||
|
SettingValue(types.Bool(), "true"),
|
||||||
|
"Whether to switch to insert mode when clicking flash and other "
|
||||||
|
"plugins."),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
('tabbar', sect.KeyValue(
|
('tabbar', sect.KeyValue(
|
||||||
|
@ -110,6 +110,30 @@ class BrowserTab(QWebView):
|
|||||||
logging.debug("Everything destroyed, calling callback")
|
logging.debug("Everything destroyed, calling callback")
|
||||||
self._shutdown_callback()
|
self._shutdown_callback()
|
||||||
|
|
||||||
|
def _is_editable(self, hitresult):
|
||||||
|
"""Checks if the hitresult needs keyboard focus.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
hitresult: A QWebHitTestResult
|
||||||
|
"""
|
||||||
|
# FIXME is this algorithm accurate?
|
||||||
|
if hitresult.isContentEditable():
|
||||||
|
return True
|
||||||
|
if not config.get('general', 'insert_mode_on_plugins'):
|
||||||
|
return False
|
||||||
|
elem = hitresult.element()
|
||||||
|
tag = elem.tagName().lower()
|
||||||
|
if tag in ['embed', 'applet']:
|
||||||
|
return True
|
||||||
|
elif tag == 'object':
|
||||||
|
if not elem.hasAttribute("type"):
|
||||||
|
logging.warn("<object> without type clicked...")
|
||||||
|
return False
|
||||||
|
objtype = elem.attribute("type")
|
||||||
|
if not objtype.startswith("image/"):
|
||||||
|
logging.debug("<object type=\"{}\"> clicked.".format(objtype))
|
||||||
|
return True
|
||||||
|
|
||||||
def openurl(self, url):
|
def openurl(self, url):
|
||||||
"""Open an URL in the browser.
|
"""Open an URL in the browser.
|
||||||
|
|
||||||
@ -268,10 +292,11 @@ class BrowserTab(QWebView):
|
|||||||
frame = self.page_.frameAt(pos)
|
frame = self.page_.frameAt(pos)
|
||||||
pos -= frame.geometry().topLeft()
|
pos -= frame.geometry().topLeft()
|
||||||
hitresult = frame.hitTestContent(pos)
|
hitresult = frame.hitTestContent(pos)
|
||||||
if hitresult.isContentEditable():
|
if self._is_editable(hitresult):
|
||||||
logging.debug("Clicked editable element!")
|
logging.debug("Clicked editable element!")
|
||||||
modemanager.enter("insert")
|
modemanager.enter("insert")
|
||||||
else:
|
else:
|
||||||
|
logging.debug("Clicked non-editable element!")
|
||||||
try:
|
try:
|
||||||
modemanager.leave("insert")
|
modemanager.leave("insert")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
Loading…
Reference in New Issue
Block a user