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