diff options
author | Florian Bruhin <me@the-compiler.org> | 2023-06-09 14:19:38 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2023-06-09 14:19:38 +0200 |
commit | 0fe03ae475441c7f9579f924e03df52e53fea943 (patch) | |
tree | 7360668dbdba218eb4d1e495cd96d89455ead0f9 /qutebrowser/mainwindow | |
parent | 2c61ec38b81c0022e448f18c643df0335e27388c (diff) | |
download | qutebrowser-0fe03ae475441c7f9579f924e03df52e53fea943.tar.gz qutebrowser-0fe03ae475441c7f9579f924e03df52e53fea943.zip |
Inline misc.MinimalLineEdit into statusbar.command.Command
Ever since 33088588d959b903a9c088a13d5bfad7862c72a5,
misc.MinimalLineEdit is only used in statusbar.command.Command.
Having it separated into a mixin makes a lot of things more complicated,
and also needs pylint ignores and a hand-written superclass __init__.
This commit inlines it into statusbar.command.Command, which makes
everything a lot simpler.
It also avoids triggering a segfault in Python 3.12.0b2:
https://github.com/qutebrowser/qutebrowser/issues/7727#issuecomment-1583144545
https://www.riverbankcomputing.com/pipermail/pyqt/2023-June/045325.html
Diffstat (limited to 'qutebrowser/mainwindow')
-rw-r--r-- | qutebrowser/mainwindow/statusbar/command.py | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/qutebrowser/mainwindow/statusbar/command.py b/qutebrowser/mainwindow/statusbar/command.py index df85d0dfa..925ade795 100644 --- a/qutebrowser/mainwindow/statusbar/command.py +++ b/qutebrowser/mainwindow/statusbar/command.py @@ -33,7 +33,7 @@ from qutebrowser.utils import usertypes, log, objreg, message, utils from qutebrowser.config import config -class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): +class Command(misc.CommandLineEdit): """The commandline part of the statusbar. @@ -63,8 +63,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): def __init__(self, *, win_id: int, private: bool, parent: QWidget = None) -> None: - misc.CommandLineEdit.__init__(self, parent=parent) - misc.MinimalLineEditMixin.__init__(self) + super().__init__(parent) self._win_id = win_id if not private: command_history = objreg.get('command-history') @@ -77,6 +76,17 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): self.textChanged.connect(self.updateGeometry) self.textChanged.connect(self._incremental_search) + self.setStyleSheet( + """ + QLineEdit { + border: 0px; + padding-left: 1px; + background-color: transparent; + } + """ + ) + self.setAttribute(Qt.WidgetAttribute.WA_MacShowFocusRect, False) + def _handle_search(self) -> bool: """Check if the currently entered text is a search, and if so, run it. @@ -253,7 +263,7 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): super().setText(text) def keyPressEvent(self, e: QKeyEvent) -> None: - """Override keyPressEvent to ignore Return key presses. + """Override keyPressEvent to ignore Return key presses, and add Shift-Ins. If this widget is focused, we are in passthrough key mode, and Enter/Shift+Enter/etc. will cause QLineEdit to think it's finished @@ -264,10 +274,16 @@ class Command(misc.MinimalLineEditMixin, misc.CommandLineEdit): e.accept() modeman.leave(self._win_id, usertypes.KeyMode.command, 'prefix deleted') - return - if e.key() == Qt.Key.Key_Return: + elif e.key() == Qt.Key.Key_Return: e.ignore() - return + elif e.key() == Qt.Key.Key_Insert and e.modifiers() == Qt.KeyboardModifier.ShiftModifier: + try: + text = utils.get_clipboard(selection=True, fallback=True) + except utils.ClipboardError: + e.ignore() + else: + e.accept() + self.insert(text) else: super().keyPressEvent(e) |