tab API: Rename scroll to scroller

The scroll attribute did overwrite QWidget.scroll which is unfortunate.
This commit is contained in:
Florian Bruhin 2016-07-26 13:19:07 +02:00
parent 878fa26247
commit 3ccb691e9f
10 changed files with 35 additions and 35 deletions

View File

@ -495,7 +495,7 @@ class AbstractTab(QWidget):
objreg.register('tab', self, registry=self.registry) objreg.register('tab', self, registry=self.registry)
# self.history = AbstractHistory(self) # self.history = AbstractHistory(self)
# self.scroll = AbstractScroller(self, parent=self) # self.scroller = AbstractScroller(self, parent=self)
# self.caret = AbstractCaret(win_id=win_id, tab=self, mode_manager=..., # self.caret = AbstractCaret(win_id=win_id, tab=self, mode_manager=...,
# parent=self) # parent=self)
# self.zoom = AbstractZoom(win_id=win_id) # self.zoom = AbstractZoom(win_id=win_id)
@ -514,7 +514,7 @@ class AbstractTab(QWidget):
self._layout = WrapperLayout(widget, self) self._layout = WrapperLayout(widget, self)
self._widget = widget self._widget = widget
self.history._history = widget.history() self.history._history = widget.history()
self.scroll._init_widget(widget) self.scroller._init_widget(widget)
self.caret._widget = widget self.caret._widget = widget
self.zoom._widget = widget self.zoom._widget = widget
self.search._widget = widget self.search._widget = widget

View File

@ -542,7 +542,7 @@ class CommandDispatcher:
dy *= count dy *= count
cmdutils.check_overflow(dx, 'int') cmdutils.check_overflow(dx, 'int')
cmdutils.check_overflow(dy, 'int') cmdutils.check_overflow(dy, 'int')
self._current_widget().scroll.delta(dx, dy) self._current_widget().scroller.delta(dx, dy)
@cmdutils.register(instance='command-dispatcher', hide=True, @cmdutils.register(instance='command-dispatcher', hide=True,
scope='window') scope='window')
@ -557,14 +557,14 @@ class CommandDispatcher:
""" """
tab = self._current_widget() tab = self._current_widget()
funcs = { funcs = {
'up': tab.scroll.up, 'up': tab.scroller.up,
'down': tab.scroll.down, 'down': tab.scroller.down,
'left': tab.scroll.left, 'left': tab.scroller.left,
'right': tab.scroll.right, 'right': tab.scroller.right,
'top': tab.scroll.top, 'top': tab.scroller.top,
'bottom': tab.scroll.bottom, 'bottom': tab.scroller.bottom,
'page-up': tab.scroll.page_up, 'page-up': tab.scroller.page_up,
'page-down': tab.scroll.page_down, 'page-down': tab.scroller.page_down,
} }
try: try:
func = funcs[direction] func = funcs[direction]
@ -609,7 +609,7 @@ class CommandDispatcher:
x = None x = None
y = perc y = perc
self._current_widget().scroll.to_perc(x, y) self._current_widget().scroller.to_perc(x, y)
@cmdutils.register(instance='command-dispatcher', hide=True, @cmdutils.register(instance='command-dispatcher', hide=True,
scope='window') scope='window')
@ -637,15 +637,15 @@ class CommandDispatcher:
# See https://github.com/The-Compiler/qutebrowser/issues/701 # See https://github.com/The-Compiler/qutebrowser/issues/701
return return
if bottom_navigate is not None and tab.scroll.at_bottom(): if bottom_navigate is not None and tab.scroller.at_bottom():
self.navigate(bottom_navigate) self.navigate(bottom_navigate)
return return
elif top_navigate is not None and tab.scroll.at_top(): elif top_navigate is not None and tab.scroller.at_top():
self.navigate(top_navigate) self.navigate(top_navigate)
return return
try: try:
tab.scroll.delta_page(count * x, count * y) tab.scroller.delta_page(count * x, count * y)
except OverflowError: except OverflowError:
raise cmdexc.CommandError( raise cmdexc.CommandError(
"Numeric argument is too large for internal int " "Numeric argument is too large for internal int "
@ -1513,10 +1513,10 @@ class CommandDispatcher:
if found: if found:
# Check if the scroll position got smaller and show info. # Check if the scroll position got smaller and show info.
if not going_up and tab.scroll.pos_px().y() < old_scroll_pos.y(): if not going_up and tab.scroller.pos_px().y() < old_scroll_pos.y():
message.info(self._win_id, "Search hit BOTTOM, continuing " message.info(self._win_id, "Search hit BOTTOM, continuing "
"at TOP", immediately=True) "at TOP", immediately=True)
elif going_up and tab.scroll.pos_px().y() > old_scroll_pos.y(): elif going_up and tab.scroller.pos_px().y() > old_scroll_pos.y():
message.info(self._win_id, "Search hit TOP, continuing at " message.info(self._win_id, "Search hit TOP, continuing at "
"BOTTOM", immediately=True) "BOTTOM", immediately=True)
else: else:
@ -1545,7 +1545,7 @@ class CommandDispatcher:
if text: if text:
cb = functools.partial(self._search_cb, tab=tab, cb = functools.partial(self._search_cb, tab=tab,
old_scroll_pos=tab.scroll.pos_px(), old_scroll_pos=tab.scroller.pos_px(),
options=options, text=text, prev=False) options=options, text=text, prev=False)
else: else:
cb = None cb = None
@ -1580,7 +1580,7 @@ class CommandDispatcher:
return return
cb = functools.partial(self._search_cb, tab=tab, cb = functools.partial(self._search_cb, tab=tab,
old_scroll_pos=tab.scroll.pos_px(), old_scroll_pos=tab.scroller.pos_px(),
options=window_options, text=window_text, options=window_options, text=window_text,
prev=False) prev=False)
@ -1615,7 +1615,7 @@ class CommandDispatcher:
return return
cb = functools.partial(self._search_cb, tab=tab, cb = functools.partial(self._search_cb, tab=tab,
old_scroll_pos=tab.scroll.pos_px(), old_scroll_pos=tab.scroller.pos_px(),
options=window_options, text=window_text, options=window_options, text=window_text,
prev=True) prev=True)

View File

@ -330,7 +330,7 @@ class WebEngineTab(browsertab.AbstractTab):
super().__init__(win_id) super().__init__(win_id)
widget = webview.WebEngineView() widget = webview.WebEngineView()
self.history = WebEngineHistory(self) self.history = WebEngineHistory(self)
self.scroll = WebEngineScroller(self, parent=self) self.scroller = WebEngineScroller(self, parent=self)
self.caret = WebEngineCaret(win_id=win_id, mode_manager=mode_manager, self.caret = WebEngineCaret(win_id=win_id, mode_manager=mode_manager,
tab=self, parent=self) tab=self, parent=self)
self.zoom = WebEngineZoom(win_id=win_id, parent=self) self.zoom = WebEngineZoom(win_id=win_id, parent=self)

View File

@ -485,9 +485,9 @@ class WebKitHistory(browsertab.AbstractHistory):
if 'zoom' in cur_data: if 'zoom' in cur_data:
self._tab.zoom.set_factor(cur_data['zoom']) self._tab.zoom.set_factor(cur_data['zoom'])
if ('scroll-pos' in cur_data and if ('scroll-pos' in cur_data and
self._tab.scroll.pos_px() == QPoint(0, 0)): self._tab.scroller.pos_px() == QPoint(0, 0)):
QTimer.singleShot(0, functools.partial( QTimer.singleShot(0, functools.partial(
self._tab.scroll.to_point, cur_data['scroll-pos'])) self._tab.scroller.to_point, cur_data['scroll-pos']))
class WebKitTab(browsertab.AbstractTab): class WebKitTab(browsertab.AbstractTab):
@ -498,7 +498,7 @@ class WebKitTab(browsertab.AbstractTab):
super().__init__(win_id) super().__init__(win_id)
widget = webview.WebView(win_id, self.tab_id, tab=self) widget = webview.WebView(win_id, self.tab_id, tab=self)
self.history = WebKitHistory(self) self.history = WebKitHistory(self)
self.scroll = WebKitScroller(self, parent=self) self.scroller = WebKitScroller(self, parent=self)
self.caret = WebKitCaret(win_id=win_id, mode_manager=mode_manager, self.caret = WebKitCaret(win_id=win_id, mode_manager=mode_manager,
tab=self, parent=self) tab=self, parent=self)
self.zoom = WebKitZoom(win_id=win_id, parent=self) self.zoom = WebKitZoom(win_id=win_id, parent=self)
@ -580,7 +580,7 @@ class WebKitTab(browsertab.AbstractTab):
page.linkHovered.connect(self.link_hovered) page.linkHovered.connect(self.link_hovered)
page.loadProgress.connect(self._on_load_progress) page.loadProgress.connect(self._on_load_progress)
frame.loadStarted.connect(self._on_load_started) frame.loadStarted.connect(self._on_load_started)
view.scroll_pos_changed.connect(self.scroll.perc_changed) view.scroll_pos_changed.connect(self.scroller.perc_changed)
view.titleChanged.connect(self.title_changed) view.titleChanged.connect(self.title_changed)
view.urlChanged.connect(self._on_url_changed) view.urlChanged.connect(self._on_url_changed)
view.shutting_down.connect(self.shutting_down) view.shutting_down.connect(self.shutting_down)

View File

@ -54,4 +54,4 @@ class Percentage(textbase.TextBase):
@pyqtSlot(browsertab.AbstractTab) @pyqtSlot(browsertab.AbstractTab)
def on_tab_changed(self, tab): def on_tab_changed(self, tab):
"""Update scroll position when tab changed.""" """Update scroll position when tab changed."""
self.set_perc(*tab.scroll.pos_perc()) self.set_perc(*tab.scroller.pos_perc())

View File

@ -175,9 +175,9 @@ class TabbedBrowser(tabwidget.TabWidget):
self._filter.create(self.cur_load_finished, tab)) self._filter.create(self.cur_load_finished, tab))
tab.load_started.connect( tab.load_started.connect(
self._filter.create(self.cur_load_started, tab)) self._filter.create(self.cur_load_started, tab))
tab.scroll.perc_changed.connect( tab.scroller.perc_changed.connect(
self._filter.create(self.cur_scroll_perc_changed, tab)) self._filter.create(self.cur_scroll_perc_changed, tab))
tab.scroll.perc_changed.connect(self.on_scroll_pos_changed) tab.scroller.perc_changed.connect(self.on_scroll_pos_changed)
tab.url_changed.connect( tab.url_changed.connect(
self._filter.create(self.cur_url_changed, tab)) self._filter.create(self.cur_url_changed, tab))
tab.load_status_changed.connect( tab.load_status_changed.connect(
@ -646,7 +646,7 @@ class TabbedBrowser(tabwidget.TabWidget):
if key != "'": if key != "'":
message.error(self._win_id, "Failed to set mark: url invalid") message.error(self._win_id, "Failed to set mark: url invalid")
return return
point = self.currentWidget().scroll.pos_px() point = self.currentWidget().scroller.pos_px()
if key.isupper(): if key.isupper():
self._global_marks[key] = point, url self._global_marks[key] = point, url
@ -676,7 +676,7 @@ class TabbedBrowser(tabwidget.TabWidget):
def callback(ok): def callback(ok):
if ok: if ok:
self.cur_load_finished.disconnect(callback) self.cur_load_finished.disconnect(callback)
tab.scroll.to_point(point) tab.scroller.to_point(point)
self.openurl(url, newtab=False) self.openurl(url, newtab=False)
self.cur_load_finished.connect(callback) self.cur_load_finished.connect(callback)
@ -692,6 +692,6 @@ class TabbedBrowser(tabwidget.TabWidget):
# "'" would just jump to the current position every time # "'" would just jump to the current position every time
self.set_mark("'") self.set_mark("'")
tab.scroll.to_point(point) tab.scroller.to_point(point)
else: else:
message.error(self._win_id, "Mark {} is not set".format(key)) message.error(self._win_id, "Mark {} is not set".format(key))

View File

@ -126,7 +126,7 @@ class TabWidget(QTabWidget):
except qtutils.QtValueError: except qtutils.QtValueError:
fields['host'] = '' fields['host'] = ''
y = tab.scroll.pos_perc()[1] y = tab.scroller.pos_perc()[1]
if y is None: if y is None:
scroll_pos = '???' scroll_pos = '???'
elif y <= 0: elif y <= 0:

View File

@ -168,7 +168,7 @@ class SessionManager(QObject):
user_data = None user_data = None
if tab.history.current_idx() == idx: if tab.history.current_idx() == idx:
pos = tab.scroll.pos_px() pos = tab.scroller.pos_px()
data['zoom'] = tab.zoom.factor() data['zoom'] = tab.zoom.factor()
data['scroll-pos'] = {'x': pos.x(), 'y': pos.y()} data['scroll-pos'] = {'x': pos.x(), 'y': pos.y()}
elif user_data is not None: elif user_data is not None:

View File

@ -250,7 +250,7 @@ class FakeWebTab(browsertab.AbstractTab):
self._title = title self._title = title
self._url = url self._url = url
self._progress = progress self._progress = progress
self.scroll = FakeWebTabScroller(self, scroll_pos_perc) self.scroller = FakeWebTabScroller(self, scroll_pos_perc)
def url(self): def url(self):
return self._url return self._url

View File

@ -104,7 +104,7 @@ def test_tab(qtbot, view, config_stub, tab_registry):
mode_manager = modeman.ModeManager(0) mode_manager = modeman.ModeManager(0)
tab_w.history = browsertab.AbstractHistory(tab_w) tab_w.history = browsertab.AbstractHistory(tab_w)
tab_w.scroll = browsertab.AbstractScroller(tab_w, parent=tab_w) tab_w.scroller = browsertab.AbstractScroller(tab_w, parent=tab_w)
tab_w.caret = browsertab.AbstractCaret(win_id=tab_w.win_id, tab_w.caret = browsertab.AbstractCaret(win_id=tab_w.win_id,
mode_manager=mode_manager, mode_manager=mode_manager,
tab=tab_w, parent=tab_w) tab=tab_w, parent=tab_w)