Merge pull request #4508 from beelzebielsk/master

Implement pinned.tab.frozen setting (issue #4400)
This commit is contained in:
Jay Kamat 2019-01-09 23:49:16 -08:00 committed by GitHub
commit fdb4dd728f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 2 deletions

View File

@ -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.tabs.pinned.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."""

View File

@ -316,7 +316,7 @@ 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: elif curtab.navigation_blocked():
message.info("Tab is pinned!") message.info("Tab is pinned!")
else: else:
curtab.load_url(cur_url) curtab.load_url(cur_url)

View File

@ -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])

View File

@ -1768,6 +1768,11 @@ tabs.pinned.shrink:
type: Bool type: Bool
desc: Shrink pinned tabs down to their contents. desc: Shrink pinned tabs down to their contents.
tabs.pinned.frozen:
type: Bool
default: True
desc: Force pinned tabs to stay at fixed URL.
tabs.wrap: tabs.wrap:
default: true default: true
type: Bool type: Bool

View File

@ -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 tabs.pinned.frozen = false
When I set tabs.pinned.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 tabs.pinned.frozen = false
When I set url.start_pages to ["http://localhost:(port)/data/numbers/2.txt"]
And I set tabs.pinned.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