diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc index d94b011ab..cedd7ff70 100644 --- a/doc/changelog.asciidoc +++ b/doc/changelog.asciidoc @@ -67,6 +67,7 @@ Added - `:config-clear` to remove all configured options - `:config-source` to (re-)read a `config.py` file - `:config-edit` to open the `config.py` file in an editor +- New `:version` command which opens `qute://version`. Changed ~~~~~~~ diff --git a/doc/help/commands.asciidoc b/doc/help/commands.asciidoc index 3056da700..5ba7fae89 100644 --- a/doc/help/commands.asciidoc +++ b/doc/help/commands.asciidoc @@ -91,6 +91,7 @@ It is possible to run or bind multiple commands by separating them with `;;`. |<>|Switch to the previous tab, or switch [count] tabs back. |<>|Unbind a keychain. |<>|Re-open a closed tab. +|<>|Show version information. |<>|Show the source of the current page in a new tab. |<>|Close all windows except for the current one. |<>|Yank something to the clipboard or primary selection. @@ -1015,6 +1016,10 @@ Unbind a keychain. === undo Re-open a closed tab. +[[version]] +=== version +Show version information. + [[view-source]] === view-source Show the source of the current page in a new tab. diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index 5c85aae10..bf1e94586 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -342,3 +342,12 @@ def window_only(current_win_id): def nop(): """Do nothing.""" return + + +@cmdutils.register() +@cmdutils.argument('win_id', win_id=True) +def version(win_id): + """Show version information.""" + tabbed_browser = objreg.get('tabbed-browser', scope='window', + window=win_id) + tabbed_browser.openurl(QUrl('qute://version'), newtab=True) diff --git a/tests/unit/misc/test_utilcmds.py b/tests/unit/misc/test_utilcmds.py index dfb99115d..9c679774a 100644 --- a/tests/unit/misc/test_utilcmds.py +++ b/tests/unit/misc/test_utilcmds.py @@ -25,10 +25,11 @@ import signal import time import pytest +from PyQt5.QtCore import QUrl from qutebrowser.misc import utilcmds from qutebrowser.commands import cmdexc -from qutebrowser.utils import utils +from qutebrowser.utils import utils, objreg @contextlib.contextmanager @@ -142,3 +143,16 @@ def test_window_only(mocker, monkeypatch): assert not test_windows[0].closed assert not test_windows[1].closed assert test_windows[2].closed + + +@pytest.fixture +def tabbed_browser(stubs, win_registry): + tb = stubs.TabbedBrowserStub() + objreg.register('tabbed-browser', tb, scope='window', window=0) + yield tb + objreg.delete('tabbed-browser', scope='window', window=0) + + +def test_version(tabbed_browser): + utilcmds.version(win_id=0) + assert tabbed_browser.opened_url == QUrl('qute://version')