diff options
author | Florian Bruhin <me@the-compiler.org> | 2023-07-19 17:07:04 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2023-07-19 17:08:24 +0200 |
commit | 92dea988c01e74596cc6ed698e88ac56df392c14 (patch) | |
tree | 3fa4099b4ead84d5f057e532c44b3c605979fe04 /qutebrowser/utils/utils.py | |
parent | 3b04cb1d99244516b21084545d06daa7e58cd756 (diff) | |
download | qutebrowser-92dea988c01e74596cc6ed698e88ac56df392c14.tar.gz qutebrowser-92dea988c01e74596cc6ed698e88ac56df392c14.zip |
Initial upgrade to new PyQt6 stubs
Diffstat (limited to 'qutebrowser/utils/utils.py')
-rw-r--r-- | qutebrowser/utils/utils.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index 6b450aa29..dd3cf6ac3 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -519,6 +519,13 @@ def sanitize_filename(name: str, return name +def _clipboard() -> QClipboard: + """Get the QClipboard and make sure it's not None.""" + clipboard = QApplication.clipboard() + assert clipboard is not None + return clipboard + + def set_clipboard(data: str, selection: bool = False) -> None: """Set the clipboard to some given data.""" global fake_clipboard @@ -530,7 +537,7 @@ def set_clipboard(data: str, selection: bool = False) -> None: fake_clipboard = data else: mode = QClipboard.Mode.Selection if selection else QClipboard.Mode.Clipboard - QApplication.clipboard().setText(data, mode=mode) + _clipboard().setText(data, mode=mode) def get_clipboard(selection: bool = False, fallback: bool = False) -> str: @@ -556,7 +563,7 @@ def get_clipboard(selection: bool = False, fallback: bool = False) -> str: fake_clipboard = None else: mode = QClipboard.Mode.Selection if selection else QClipboard.Mode.Clipboard - data = QApplication.clipboard().text(mode=mode) + data = _clipboard().text(mode=mode) target = "Primary selection" if selection else "Clipboard" if not data.strip(): @@ -568,7 +575,7 @@ def get_clipboard(selection: bool = False, fallback: bool = False) -> str: def supports_selection() -> bool: """Check if the OS supports primary selection.""" - return QApplication.clipboard().supportsSelection() + return _clipboard().supportsSelection() def open_file(filename: str, cmdline: str = None) -> None: |