Rename tabs.new_position/_explicit to .related/.unrelated
This commit is contained in:
parent
441b3a4df4
commit
ac64ea287a
@ -286,7 +286,7 @@ def process_pos_args(args, via_ipc=False, cwd=None, target_arg=None):
|
||||
else:
|
||||
background = open_target in ['tab-bg', 'tab-bg-silent']
|
||||
tabbed_browser.tabopen(url, background=background,
|
||||
explicit=True)
|
||||
related=False)
|
||||
|
||||
|
||||
def _open_startpage(win_id=None):
|
||||
|
@ -110,7 +110,7 @@ class CommandDispatcher:
|
||||
return widget
|
||||
|
||||
def _open(self, url, tab=False, background=False, window=False,
|
||||
explicit=True, private=None):
|
||||
related=False, private=None):
|
||||
"""Helper function to open a page.
|
||||
|
||||
Args:
|
||||
@ -131,9 +131,9 @@ class CommandDispatcher:
|
||||
tabbed_browser = self._new_tabbed_browser(private)
|
||||
tabbed_browser.tabopen(url)
|
||||
elif tab:
|
||||
tabbed_browser.tabopen(url, background=False, explicit=explicit)
|
||||
tabbed_browser.tabopen(url, background=False, related=related)
|
||||
elif background:
|
||||
tabbed_browser.tabopen(url, background=True, explicit=explicit)
|
||||
tabbed_browser.tabopen(url, background=True, related=related)
|
||||
else:
|
||||
widget = self._current_widget()
|
||||
widget.openurl(url)
|
||||
@ -288,7 +288,7 @@ class CommandDispatcher:
|
||||
maxsplit=0, scope='window')
|
||||
@cmdutils.argument('url', completion=usertypes.Completion.url)
|
||||
@cmdutils.argument('count', count=True)
|
||||
def openurl(self, url=None, implicit=False,
|
||||
def openurl(self, url=None, related=False,
|
||||
bg=False, tab=False, window=False, count=None, secure=False,
|
||||
private=False):
|
||||
"""Open a URL in the current/[count]th tab.
|
||||
@ -300,8 +300,8 @@ class CommandDispatcher:
|
||||
bg: Open in a new background tab.
|
||||
tab: Open in a new tab.
|
||||
window: Open in a new window.
|
||||
implicit: If opening a new tab, treat the tab as implicit (like
|
||||
clicking on a link).
|
||||
related: If opening a new tab, position the tab as related to the
|
||||
current one (like clicking on a link).
|
||||
count: The tab index to open the URL in, or None.
|
||||
secure: Force HTTPS.
|
||||
private: Open a new window in private browsing mode.
|
||||
@ -319,7 +319,7 @@ class CommandDispatcher:
|
||||
bg = True
|
||||
|
||||
if tab or bg or window or private:
|
||||
self._open(cur_url, tab, bg, window, explicit=not implicit,
|
||||
self._open(cur_url, tab, bg, window, related=related,
|
||||
private=private)
|
||||
else:
|
||||
curtab = self._cntwidget(count)
|
||||
@ -629,7 +629,7 @@ class CommandDispatcher:
|
||||
tab=tab, background=bg, window=window)
|
||||
elif where in ['up', 'increment', 'decrement']:
|
||||
new_url = handlers[where](url, count)
|
||||
self._open(new_url, tab, bg, window, explicit=False)
|
||||
self._open(new_url, tab, bg, window, related=True)
|
||||
else: # pragma: no cover
|
||||
raise ValueError("Got called with invalid value {} for "
|
||||
"`where'.".format(where))
|
||||
|
@ -1048,15 +1048,15 @@ tabs.mousewheel_switching:
|
||||
type: Bool
|
||||
desc: Switch between tabs using the mouse wheel.
|
||||
|
||||
tabs.new_position:
|
||||
tabs.new_position.related:
|
||||
default: next
|
||||
type: NewTabPosition
|
||||
desc: How new tabs are positioned.
|
||||
desc: How new tabs opened from another tab are positioned.
|
||||
|
||||
tabs.new_position_explicit:
|
||||
tabs.new_position.unrelated:
|
||||
default: last
|
||||
type: NewTabPosition
|
||||
desc: How new tabs opened explicitly are positioned.
|
||||
desc: "How new tabs which aren't opened from another tab are positioned."
|
||||
|
||||
tabs.padding:
|
||||
default:
|
||||
|
@ -385,7 +385,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
|
||||
@pyqtSlot('QUrl')
|
||||
@pyqtSlot('QUrl', bool)
|
||||
def tabopen(self, url=None, background=None, explicit=False, idx=None, *,
|
||||
def tabopen(self, url=None, background=None, related=True, idx=None, *,
|
||||
ignore_tabs_are_windows=False):
|
||||
"""Open a new tab with a given URL.
|
||||
|
||||
@ -396,12 +396,13 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
url: The URL to open as QUrl or None for an empty tab.
|
||||
background: Whether to open the tab in the background.
|
||||
if None, the background-tabs setting decides.
|
||||
explicit: Whether the tab was opened explicitly.
|
||||
If this is set, the new position might be different. With
|
||||
the default settings we handle it like Chromium does:
|
||||
- Tabs from clicked links etc. are to the right of
|
||||
the current.
|
||||
- Explicitly opened tabs are at the very right.
|
||||
related: Whether the tab was opened from another existing tab.
|
||||
If this is set, the new position might be different. With
|
||||
the default settings we handle it like Chromium does:
|
||||
- Tabs from clicked links etc. are to the right of
|
||||
the current (related=True).
|
||||
- Explicitly opened tabs are at the very right
|
||||
(related=False)
|
||||
idx: The index where the new tab should be opened.
|
||||
ignore_tabs_are_windows: If given, never open a new window, even
|
||||
with tabs-are-windows set.
|
||||
@ -412,8 +413,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
if url is not None:
|
||||
qtutils.ensure_valid(url)
|
||||
log.webview.debug("Creating new tab with URL {}, background {}, "
|
||||
"explicit {}, idx {}".format(
|
||||
url, background, explicit, idx))
|
||||
"related {}, idx {}".format(
|
||||
url, background, related, idx))
|
||||
|
||||
if (config.val.tabs.tabs_are_windows and self.count() > 0 and
|
||||
not ignore_tabs_are_windows):
|
||||
@ -422,14 +423,15 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
window.show()
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=window.win_id)
|
||||
return tabbed_browser.tabopen(url, background, explicit)
|
||||
return tabbed_browser.tabopen(url=url, background=background,
|
||||
related=related)
|
||||
|
||||
tab = browsertab.create(win_id=self._win_id, private=self.private,
|
||||
parent=self)
|
||||
self._connect_tab_signals(tab)
|
||||
|
||||
if idx is None:
|
||||
idx = self._get_new_tab_idx(explicit)
|
||||
idx = self._get_new_tab_idx(related)
|
||||
self.insertTab(idx, tab, "")
|
||||
|
||||
if url is not None:
|
||||
@ -456,19 +458,19 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
self.new_tab.emit(tab, idx)
|
||||
return tab
|
||||
|
||||
def _get_new_tab_idx(self, explicit):
|
||||
def _get_new_tab_idx(self, related):
|
||||
"""Get the index of a tab to insert.
|
||||
|
||||
Args:
|
||||
explicit: Whether the tab was opened explicitly.
|
||||
related: Whether the tab was opened from another tab (as a "child")
|
||||
|
||||
Return:
|
||||
The index of the new tab.
|
||||
"""
|
||||
if explicit:
|
||||
pos = config.val.tabs.new_position_explicit
|
||||
if related:
|
||||
pos = config.val.tabs.new_position.related
|
||||
else:
|
||||
pos = config.val.tabs.new_position
|
||||
pos = config.val.tabs.new_position.unrelated
|
||||
if pos == 'prev':
|
||||
idx = self._tab_insert_idx_left
|
||||
# On first sight, we'd think we have to decrement
|
||||
|
@ -77,10 +77,10 @@ Feature: Opening pages
|
||||
- active: true
|
||||
url: http://localhost:*/data/numbers/6.txt
|
||||
|
||||
Scenario: Opening in a new tab (explicit)
|
||||
Scenario: Opening in a new tab (unrelated)
|
||||
Given I open about:blank
|
||||
When I set tabs.new_position_explicit to next
|
||||
And I set tabs.new_position to prev
|
||||
When I set tabs.new_position.unrelated to next
|
||||
And I set tabs.new_position.related to prev
|
||||
And I run :tab-only
|
||||
And I run :open -t http://localhost:(port)/data/numbers/7.txt
|
||||
And I wait until data/numbers/7.txt is loaded
|
||||
@ -88,12 +88,12 @@ Feature: Opening pages
|
||||
- about:blank
|
||||
- data/numbers/7.txt (active)
|
||||
|
||||
Scenario: Opening in a new tab (implicit)
|
||||
Scenario: Opening in a new tab (related)
|
||||
Given I open about:blank
|
||||
When I set tabs.new_position_explicit to next
|
||||
And I set tabs.new_position to prev
|
||||
When I set tabs.new_position.unrelated to next
|
||||
And I set tabs.new_position.related to prev
|
||||
And I run :tab-only
|
||||
And I run :open -t -i http://localhost:(port)/data/numbers/8.txt
|
||||
And I run :open -t --related http://localhost:(port)/data/numbers/8.txt
|
||||
And I wait until data/numbers/8.txt is loaded
|
||||
Then the following tabs should be open:
|
||||
- data/numbers/8.txt (active)
|
||||
|
@ -846,8 +846,8 @@ Feature: Tab management
|
||||
- data/hints/html/simple.html (active)
|
||||
- data/hello.txt
|
||||
|
||||
Scenario: opening tab with tabs.new_position prev
|
||||
When I set tabs.new_position to prev
|
||||
Scenario: opening tab with tabs.new_position.related prev
|
||||
When I set tabs.new_position.related to prev
|
||||
And I set tabs.background to false
|
||||
And I open about:blank
|
||||
And I open data/hints/html/simple.html in a new tab
|
||||
@ -858,8 +858,8 @@ Feature: Tab management
|
||||
- data/hello.txt (active)
|
||||
- data/hints/html/simple.html
|
||||
|
||||
Scenario: opening tab with tabs.new_position next
|
||||
When I set tabs.new_position to next
|
||||
Scenario: opening tab with tabs.new_position.related next
|
||||
When I set tabs.new_position.related to next
|
||||
And I set tabs.background to false
|
||||
And I open about:blank
|
||||
And I open data/hints/html/simple.html in a new tab
|
||||
@ -870,8 +870,8 @@ Feature: Tab management
|
||||
- data/hints/html/simple.html
|
||||
- data/hello.txt (active)
|
||||
|
||||
Scenario: opening tab with tabs.new_position first
|
||||
When I set tabs.new_position to first
|
||||
Scenario: opening tab with tabs.new_position.related first
|
||||
When I set tabs.new_position.related to first
|
||||
And I set tabs.background to false
|
||||
And I open about:blank
|
||||
And I open data/hints/html/simple.html in a new tab
|
||||
@ -882,8 +882,8 @@ Feature: Tab management
|
||||
- about:blank
|
||||
- data/hints/html/simple.html
|
||||
|
||||
Scenario: opening tab with tabs.new_position last
|
||||
When I set tabs.new_position to last
|
||||
Scenario: opening tab with tabs.new_position.related last
|
||||
When I set tabs.new_position.related to last
|
||||
And I set tabs.background to false
|
||||
And I open data/hints/html/simple.html
|
||||
And I open about:blank in a new tab
|
||||
|
@ -104,7 +104,7 @@ def cmdutils_patch(monkeypatch, stubs):
|
||||
|
||||
@cmdutils.argument('url', completion=usertypes.Completion.url)
|
||||
@cmdutils.argument('count', count=True)
|
||||
def openurl(url=None, implicit=False, bg=False, tab=False, window=False,
|
||||
def openurl(url=None, related=False, bg=False, tab=False, window=False,
|
||||
count=None):
|
||||
"""docstring."""
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user