Implement pinned.tab.frozen setting (issue #4400)
Implement a new setting, `pinned.tab.frozen` (boolean), which when false allows a user to navigate to new URLs in a pinned tab (default behavior is to have `pinned.tab.frozen = true`, in which no navigation is allowed). issue URL: https://github.com/qutebrowser/qutebrowser/issues/4400 Changes to be committed: modified: qutebrowser/browser/browsertab.py Add `navigation_blocked` method to AbstractTab, which returns true if navigation is allowed on a tab. modified: qutebrowser/browser/commands.py Change `openurl` to use `navigation_blocked` method of a tab to determine behavior while navigating a pinned tab. modified: qutebrowser/components/misccommands.py Change `home` to use `navigation_blocked` method of a tab to determine behavior while navigating a pinned tab. modified: qutebrowser/config/configdata.yml Add `pinned.tab.frozen` config. modified: tests/end2end/features/tabs.feature Add tests for :open and :home on pinned tabs with `pinned.tab.frozen` set to false
This commit is contained in:
parent
060489f1bc
commit
24a1104dc7
@ -943,6 +943,10 @@ class AbstractTab(QWidget):
|
|||||||
evt.posted = True
|
evt.posted = True
|
||||||
QApplication.postEvent(recipient, evt)
|
QApplication.postEvent(recipient, evt)
|
||||||
|
|
||||||
|
def navigation_blocked(self) -> bool:
|
||||||
|
"""Test if navigation is allowed on the current tab."""
|
||||||
|
return self.data.pinned and config.val.pinned.tab.frozen
|
||||||
|
|
||||||
@pyqtSlot(QUrl)
|
@pyqtSlot(QUrl)
|
||||||
def _on_before_load_started(self, url: QUrl) -> None:
|
def _on_before_load_started(self, url: QUrl) -> None:
|
||||||
"""Adjust the title if we are going to visit a URL soon."""
|
"""Adjust the title if we are going to visit a URL soon."""
|
||||||
|
@ -316,10 +316,11 @@ class CommandDispatcher:
|
|||||||
else:
|
else:
|
||||||
# Explicit count with a tab that doesn't exist.
|
# Explicit count with a tab that doesn't exist.
|
||||||
return
|
return
|
||||||
elif curtab.data.pinned:
|
|
||||||
message.info("Tab is pinned!")
|
|
||||||
else:
|
else:
|
||||||
curtab.load_url(cur_url)
|
if curtab.navigation_blocked():
|
||||||
|
message.info("Tab is pinned!")
|
||||||
|
else:
|
||||||
|
curtab.load_url(cur_url)
|
||||||
|
|
||||||
def _parse_url(self, url, *, force_search=False):
|
def _parse_url(self, url, *, force_search=False):
|
||||||
"""Parse a URL or quickmark or search query.
|
"""Parse a URL or quickmark or search query.
|
||||||
|
@ -118,7 +118,7 @@ def printpage(tab: apitypes.Tab,
|
|||||||
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
@cmdutils.argument('tab', value=cmdutils.Value.cur_tab)
|
||||||
def home(tab: apitypes.Tab) -> None:
|
def home(tab: apitypes.Tab) -> None:
|
||||||
"""Open main startpage in current tab."""
|
"""Open main startpage in current tab."""
|
||||||
if tab.data.pinned:
|
if tab.navigation_blocked():
|
||||||
message.info("Tab is pinned!")
|
message.info("Tab is pinned!")
|
||||||
else:
|
else:
|
||||||
tab.load_url(config.val.url.start_pages[0])
|
tab.load_url(config.val.url.start_pages[0])
|
||||||
|
@ -2917,3 +2917,8 @@ bindings.commands:
|
|||||||
|
|
||||||
* register: Entered when qutebrowser is waiting for a register name/key for
|
* register: Entered when qutebrowser is waiting for a register name/key for
|
||||||
commands like `:set-mark`.
|
commands like `:set-mark`.
|
||||||
|
|
||||||
|
pinned.tab.frozen:
|
||||||
|
type: Bool
|
||||||
|
default: True
|
||||||
|
desc: If true, then pinned tabs cannot have their URL changed.
|
||||||
|
@ -1289,6 +1289,14 @@ Feature: Tab management
|
|||||||
And the following tabs should be open:
|
And the following tabs should be open:
|
||||||
- data/numbers/1.txt (active) (pinned)
|
- data/numbers/1.txt (active) (pinned)
|
||||||
|
|
||||||
|
Scenario: :tab-pin open url with pinned.tab.frozen = false
|
||||||
|
When I set pinned.tab.frozen to false
|
||||||
|
And I open data/numbers/1.txt
|
||||||
|
And I run :tab-pin
|
||||||
|
And I open data/numbers/2.txt
|
||||||
|
Then the following tabs should be open:
|
||||||
|
- data/numbers/2.txt (active) (pinned)
|
||||||
|
|
||||||
Scenario: :home on a pinned tab
|
Scenario: :home on a pinned tab
|
||||||
When I open data/numbers/1.txt
|
When I open data/numbers/1.txt
|
||||||
And I run :tab-pin
|
And I run :tab-pin
|
||||||
@ -1297,6 +1305,16 @@ Feature: Tab management
|
|||||||
And the following tabs should be open:
|
And the following tabs should be open:
|
||||||
- data/numbers/1.txt (active) (pinned)
|
- data/numbers/1.txt (active) (pinned)
|
||||||
|
|
||||||
|
Scenario: :home on a pinned tab with pinned.tab.frozen = false
|
||||||
|
When I set url.start_pages to ["http://localhost:(port)/data/numbers/2.txt"]
|
||||||
|
And I set pinned.tab.frozen to false
|
||||||
|
And I open data/numbers/1.txt
|
||||||
|
And I run :tab-pin
|
||||||
|
And I run :home
|
||||||
|
Then data/numbers/2.txt should be loaded
|
||||||
|
And the following tabs should be open:
|
||||||
|
- data/numbers/2.txt (active) (pinned)
|
||||||
|
|
||||||
Scenario: Cloning a pinned tab
|
Scenario: Cloning a pinned tab
|
||||||
When I open data/numbers/1.txt
|
When I open data/numbers/1.txt
|
||||||
And I run :tab-pin
|
And I run :tab-pin
|
||||||
|
Loading…
Reference in New Issue
Block a user