Only focus qutebrowser again after editing finished

See #3431, #3432
This commit is contained in:
Florian Bruhin 2018-02-07 23:13:13 +01:00
parent 3306247ae5
commit 37a9691e29
2 changed files with 9 additions and 2 deletions

View File

@ -1619,6 +1619,8 @@ class CommandDispatcher:
ed = editor.ExternalEditor(watch=True, parent=self._tabbed_browser)
ed.file_updated.connect(functools.partial(
self.on_file_updated, elem))
ed.editing_finished.connect(lambda: mainwindow.raise_window(
objreg.last_focused_window(), alert=False))
ed.edit(text, caret_position)
@cmdutils.register(instance='command-dispatcher', scope='window')
@ -1647,8 +1649,6 @@ class CommandDispatcher:
except webelem.Error as e:
raise cmdexc.CommandError(str(e))
mainwindow.raise_window(objreg.last_focused_window(), alert=False)
@cmdutils.register(instance='command-dispatcher', maxsplit=0,
scope='window')
def insert_text(self, text):

View File

@ -42,9 +42,15 @@ class ExternalEditor(QObject):
_proc: The GUIProcess of the editor.
_watcher: A QFileSystemWatcher to watch the edited file for changes.
Only set if watch=True.
Signals:
file_updated: The text in the edited file was updated.
arg: The new text.
editing_finished: The editor process was closed.
"""
file_updated = pyqtSignal(str)
editing_finished = pyqtSignal()
def __init__(self, parent=None, watch=False):
super().__init__(parent)
@ -84,6 +90,7 @@ class ExternalEditor(QObject):
return
# do a final read to make sure we don't miss the last signal
self._on_file_changed(self._filename)
self.editing_finished.emit()
self._cleanup()
@pyqtSlot(QProcess.ProcessError)