Leave insert mode in loadStarted
This commit is contained in:
parent
745e0374ff
commit
6f7391d7d1
1
TODO
1
TODO
@ -3,7 +3,6 @@ keyparser foo
|
|||||||
|
|
||||||
- Create a SimpleKeyParser and inherit KeyParser from that.
|
- Create a SimpleKeyParser and inherit KeyParser from that.
|
||||||
- Handle keybind to get out of insert mode (e.g. esc)
|
- Handle keybind to get out of insert mode (e.g. esc)
|
||||||
- Enter normal mode in loadingStarted already
|
|
||||||
- Read unbound-keys setting only once
|
- Read unbound-keys setting only once
|
||||||
- Add more element-selection-detection code (with options?) based on:
|
- Add more element-selection-detection code (with options?) based on:
|
||||||
-> javascript: http://stackoverflow.com/a/2848120/2085149
|
-> javascript: http://stackoverflow.com/a/2848120/2085149
|
||||||
|
@ -86,6 +86,7 @@ class BrowserTab(QWebView):
|
|||||||
self.page_.setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
|
self.page_.setLinkDelegationPolicy(QWebPage.DelegateAllLinks)
|
||||||
self.page_.linkHovered.connect(self.linkHovered)
|
self.page_.linkHovered.connect(self.linkHovered)
|
||||||
self.linkClicked.connect(self.on_link_clicked)
|
self.linkClicked.connect(self.on_link_clicked)
|
||||||
|
self.loadStarted.connect(lambda: modemanager.maybe_leave("insert"))
|
||||||
self.loadFinished.connect(self.on_load_finished)
|
self.loadFinished.connect(self.on_load_finished)
|
||||||
# FIXME find some way to hide scrollbars without setScrollBarPolicy
|
# FIXME find some way to hide scrollbars without setScrollBarPolicy
|
||||||
|
|
||||||
@ -245,21 +246,18 @@ class BrowserTab(QWebView):
|
|||||||
QApplication.postEvent(self, evt)
|
QApplication.postEvent(self, evt)
|
||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def on_load_finished(self, ok):
|
def on_load_finished(self, _ok):
|
||||||
"""Handle insert mode after loading finished."""
|
"""Handle auto_insert_mode after loading finished."""
|
||||||
if not ok:
|
if not config.get('general', 'auto_insert_mode'):
|
||||||
|
return
|
||||||
|
frame = self.page_.currentFrame()
|
||||||
|
elem = frame.findFirstElement(
|
||||||
|
webelem.SELECTORS['editable_focused'])
|
||||||
|
logging.debug("focus element: {}".format(not elem.isNull()))
|
||||||
|
if elem.isNull():
|
||||||
modemanager.maybe_leave("insert")
|
modemanager.maybe_leave("insert")
|
||||||
elif config.get('general', 'auto_insert_mode'):
|
|
||||||
frame = self.page_.currentFrame()
|
|
||||||
elem = frame.findFirstElement(
|
|
||||||
webelem.SELECTORS['editable_focused'])
|
|
||||||
logging.debug("focus element: {}".format(not elem.isNull()))
|
|
||||||
if elem.isNull():
|
|
||||||
modemanager.maybe_leave("insert")
|
|
||||||
else:
|
|
||||||
modemanager.enter("insert")
|
|
||||||
else:
|
else:
|
||||||
modemanager.maybe_leave("insert")
|
modemanager.enter("insert")
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def set_force_open_target(self, target):
|
def set_force_open_target(self, target):
|
||||||
|
Loading…
Reference in New Issue
Block a user