Some modifications from initial feedback
Moved pin information from BrowserTab to TabData. Changed attribute from pin to pinned. Changed "ifs" to implicit check boolen value. Removed blancked line on before else statement.
This commit is contained in:
parent
29d1c0d68b
commit
f8dffb4e5c
@ -86,6 +86,7 @@ class TabData:
|
||||
viewing_source: Set if we're currently showing a source view.
|
||||
open_target: How the next clicked link should be opened.
|
||||
override_target: Override for open_target for fake clicks (like hints).
|
||||
pinned: Flag to pin the tab
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
@ -94,6 +95,7 @@ class TabData:
|
||||
self.inspector = None
|
||||
self.open_target = usertypes.ClickTarget.normal
|
||||
self.override_target = None
|
||||
self.pinned = False
|
||||
|
||||
def combined_target(self):
|
||||
if self.override_target is not None:
|
||||
@ -560,7 +562,6 @@ class AbstractTab(QWidget):
|
||||
self._mouse_event_filter = mouse.MouseEventFilter(
|
||||
self, widget_class=self.WIDGET_CLASS, parent=self)
|
||||
self.backend = None
|
||||
self.pin = False
|
||||
|
||||
# FIXME:qtwebengine Should this be public api via self.hints?
|
||||
# Also, should we get it out of objreg?
|
||||
|
@ -229,7 +229,7 @@ class CommandDispatcher:
|
||||
if tab is None:
|
||||
return
|
||||
|
||||
if tab.pin is True:
|
||||
if tab.data.pinned:
|
||||
result = message.ask("Are you sure you want to close a pinned tab?",
|
||||
mode=usertypes.PromptMode.yesno, default=False)
|
||||
|
||||
@ -251,13 +251,19 @@ class CommandDispatcher:
|
||||
@cmdutils.argument('index')
|
||||
@cmdutils.argument('count', count=True)
|
||||
def tab_pin(self, index=None, count=None):
|
||||
"""Pin/Unpin the current tab.
|
||||
|
||||
Args:
|
||||
index: Location where the tab should be pinned/unpinned.
|
||||
count: The tab index to pin or unpin
|
||||
"""
|
||||
tab = self._cntwidget(count)
|
||||
if tab is None:
|
||||
return
|
||||
|
||||
tab.pin = not tab.pin
|
||||
tab.data.pinned = not tab.data.pinned
|
||||
|
||||
if tab.pin is True:
|
||||
if tab.data.pinned:
|
||||
index = 1 if index is None else int(index)
|
||||
else:
|
||||
index = self._count() if index is None else int(index)
|
||||
@ -307,9 +313,8 @@ class CommandDispatcher:
|
||||
else:
|
||||
# Explicit count with a tab that doesn't exist.
|
||||
return
|
||||
elif curtab.pin is True:
|
||||
elif curtab.data.pinned:
|
||||
message.info("Tab is pinned!")
|
||||
|
||||
else:
|
||||
curtab.openurl(cur_url)
|
||||
|
||||
|
@ -125,7 +125,7 @@ class TabWidget(QTabWidget):
|
||||
fields['title'] = page_title
|
||||
fields['title_sep'] = ' - ' if page_title else ''
|
||||
fields['perc_raw'] = tab.progress()
|
||||
fields['pin'] = tab.pin
|
||||
fields['pin'] = tab.data.pinned
|
||||
|
||||
if tab.load_status() == usertypes.LoadStatus.loading:
|
||||
fields['perc'] = '[{}%] '.format(tab.progress())
|
||||
@ -448,7 +448,7 @@ class TabBar(QTabBar):
|
||||
#TODO: relative size and/or configured one
|
||||
try:
|
||||
tab = objreg.get('tab', scope='tab', window=self._win_id, tab=index)
|
||||
if tab.pin is True:
|
||||
if tab.data.pinned:
|
||||
size = QSize(40, height)
|
||||
qtutils.ensure_valid(size)
|
||||
return size
|
||||
|
@ -206,7 +206,7 @@ class SessionManager(QObject):
|
||||
pos = user_data['scroll-pos']
|
||||
data['scroll-pos'] = {'x': pos.x(), 'y': pos.y()}
|
||||
|
||||
data['pin'] = tab.pin
|
||||
data['pin'] = tab.data.pinned
|
||||
|
||||
return data
|
||||
|
||||
@ -336,7 +336,7 @@ class SessionManager(QObject):
|
||||
user_data['scroll-pos'] = QPoint(pos['x'], pos['y'])
|
||||
|
||||
if 'pin' in histentry:
|
||||
new_tab.pin = histentry['pin']
|
||||
new_tab.data.pinned = histentry['pin']
|
||||
|
||||
active = histentry.get('active', False)
|
||||
url = QUrl.fromEncoded(histentry['url'].encode('ascii'))
|
||||
|
Loading…
Reference in New Issue
Block a user