summaryrefslogtreecommitdiff
path: root/qutebrowser/browser/hints.py
diff options
context:
space:
mode:
Diffstat (limited to 'qutebrowser/browser/hints.py')
-rw-r--r--qutebrowser/browser/hints.py46
1 files changed, 23 insertions, 23 deletions
diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py
index 91534a58b..ceefa7c78 100644
--- a/qutebrowser/browser/hints.py
+++ b/qutebrowser/browser/hints.py
@@ -29,9 +29,7 @@ import dataclasses
from string import ascii_lowercase
from typing import (TYPE_CHECKING, Callable, Dict, Iterable, Iterator, List, Mapping,
MutableSequence, Optional, Sequence, Set)
-
-from qutebrowser.qt.core import pyqtSignal, pyqtSlot, QObject, Qt, QUrl
-from qutebrowser.qt.widgets import QLabel
+from qutebrowser.qt import widgets
from qutebrowser.config import config, configexc
from qutebrowser.keyinput import modeman, modeparsers, basekeyparser
@@ -39,6 +37,8 @@ from qutebrowser.browser import webelem, history
from qutebrowser.commands import runners
from qutebrowser.api import cmdutils
from qutebrowser.utils import usertypes, log, qtutils, message, objreg, utils
+from qutebrowser.qt import core
+
if TYPE_CHECKING:
from qutebrowser.browser import browsertab
@@ -77,7 +77,7 @@ def on_mode_entered(mode: usertypes.KeyMode, win_id: int) -> None:
maybe=True)
-class HintLabel(QLabel):
+class HintLabel(widgets.QLabel):
"""A label for a link.
@@ -92,12 +92,12 @@ class HintLabel(QLabel):
self._context = context
self.elem = elem
- self.setTextFormat(Qt.TextFormat.RichText)
+ self.setTextFormat(core.Qt.TextFormat.RichText)
# Make sure we can style the background via a style sheet, and we don't
# get any extra text indent from Qt.
# The real stylesheet lives in mainwindow.py for performance reasons..
- self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
+ self.setAttribute(core.Qt.WidgetAttribute.WA_StyledBackground, True)
self.setIndent(0)
self._context.tab.contents_size_changed.connect(self._move_to_elem)
@@ -134,7 +134,7 @@ class HintLabel(QLabel):
self.setText(unmatched)
self.adjustSize()
- @pyqtSlot()
+ @core.pyqtSlot()
def _move_to_elem(self) -> None:
"""Reposition the label to its element."""
if not self.elem.has_frame():
@@ -189,7 +189,7 @@ class HintContext:
hint_mode: str
add_history: bool
first: bool
- baseurl: QUrl
+ baseurl: core.QUrl
args: List[str]
group: str
@@ -247,14 +247,14 @@ class HintActions:
except webelem.Error as e:
raise HintingError(str(e))
- def yank(self, url: QUrl, context: HintContext) -> None:
+ def yank(self, url: core.QUrl, context: HintContext) -> None:
"""Yank an element to the clipboard or primary selection."""
sel = (context.target == Target.yank_primary and
utils.supports_selection())
- flags = QUrl.ComponentFormattingOption.FullyEncoded | QUrl.UrlFormattingOption.RemovePassword
+ flags = core.QUrl.ComponentFormattingOption.FullyEncoded | core.QUrl.UrlFormattingOption.RemovePassword
if url.scheme() == 'mailto':
- flags |= QUrl.UrlFormattingOption.RemoveScheme
+ flags |= core.QUrl.UrlFormattingOption.RemoveScheme
urlstr = url.toString(flags)
new_content = urlstr
@@ -274,16 +274,16 @@ class HintActions:
urlstr)
message.info(msg, replace='rapid-hints' if context.rapid else None)
- def run_cmd(self, url: QUrl, context: HintContext) -> None:
+ def run_cmd(self, url: core.QUrl, context: HintContext) -> None:
"""Run the command based on a hint URL."""
- urlstr = url.toString(QUrl.ComponentFormattingOption.FullyEncoded) # type: ignore[arg-type]
+ urlstr = url.toString(core.QUrl.ComponentFormattingOption.FullyEncoded) # type: ignore[arg-type]
args = context.get_args(urlstr)
commandrunner = runners.CommandRunner(self._win_id)
commandrunner.run_safely(' '.join(args))
- def preset_cmd_text(self, url: QUrl, context: HintContext) -> None:
+ def preset_cmd_text(self, url: core.QUrl, context: HintContext) -> None:
"""Preset a commandline text based on a hint URL."""
- flags = QUrl.ComponentFormattingOption.FullyEncoded
+ flags = core.QUrl.ComponentFormattingOption.FullyEncoded
urlstr = url.toDisplayString(flags) # type: ignore[arg-type]
args = context.get_args(urlstr)
text = ' '.join(args)
@@ -325,7 +325,7 @@ class HintActions:
cmd = context.args[0]
args = context.args[1:]
- flags = QUrl.ComponentFormattingOption.FullyEncoded
+ flags = core.QUrl.ComponentFormattingOption.FullyEncoded
env = {
'QUTE_MODE': 'hints',
@@ -349,7 +349,7 @@ class HintActions:
_context: HintContext) -> None:
elem.delete()
- def spawn(self, url: QUrl, context: HintContext) -> None:
+ def spawn(self, url: core.QUrl, context: HintContext) -> None:
"""Spawn a simple command from a hint.
Args:
@@ -357,7 +357,7 @@ class HintActions:
context: The HintContext to use.
"""
urlstr = url.toString(
- QUrl.ComponentFormattingOption.FullyEncoded | QUrl.UrlFormattingOption.RemovePassword)
+ core.QUrl.ComponentFormattingOption.FullyEncoded | core.QUrl.UrlFormattingOption.RemovePassword)
args = context.get_args(urlstr)
commandrunner = runners.CommandRunner(self._win_id)
commandrunner.run_safely('spawn ' + ' '.join(args))
@@ -367,7 +367,7 @@ _ElemsType = Sequence[webelem.AbstractWebElement]
_HintStringsType = MutableSequence[str]
-class HintManager(QObject):
+class HintManager(core.QObject):
"""Manage drawing hints over links or other elements.
@@ -402,9 +402,9 @@ class HintManager(QObject):
Target.delete: "Delete an element",
}
- set_text = pyqtSignal(str)
+ set_text = core.pyqtSignal(str)
- def __init__(self, win_id: int, parent: QObject = None) -> None:
+ def __init__(self, win_id: int, parent: core.QObject = None) -> None:
"""Constructor."""
super().__init__(parent)
self._win_id = win_id
@@ -858,7 +858,7 @@ class HintManager(QObject):
# unpacking gets us the first (and only) key in the dict.
self._fire(*visible)
- @pyqtSlot(str)
+ @core.pyqtSlot(str)
def handle_partial_key(self, keystr: str) -> None:
"""Handle a new partial keypress."""
if self._context is None:
@@ -1032,7 +1032,7 @@ class HintManager(QObject):
else:
self._fire(keystring)
- @pyqtSlot(usertypes.KeyMode)
+ @core.pyqtSlot(usertypes.KeyMode)
def on_mode_left(self, mode: usertypes.KeyMode) -> None:
"""Stop hinting when hinting mode was left."""
if mode != usertypes.KeyMode.hint or self._context is None: