tab API: Rename scroll to scroller
The scroll attribute did overwrite QWidget.scroll which is unfortunate.
This commit is contained in:
parent
878fa26247
commit
3ccb691e9f
@ -495,7 +495,7 @@ class AbstractTab(QWidget):
|
||||
objreg.register('tab', self, registry=self.registry)
|
||||
|
||||
# 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=...,
|
||||
# parent=self)
|
||||
# self.zoom = AbstractZoom(win_id=win_id)
|
||||
@ -514,7 +514,7 @@ class AbstractTab(QWidget):
|
||||
self._layout = WrapperLayout(widget, self)
|
||||
self._widget = widget
|
||||
self.history._history = widget.history()
|
||||
self.scroll._init_widget(widget)
|
||||
self.scroller._init_widget(widget)
|
||||
self.caret._widget = widget
|
||||
self.zoom._widget = widget
|
||||
self.search._widget = widget
|
||||
|
@ -542,7 +542,7 @@ class CommandDispatcher:
|
||||
dy *= count
|
||||
cmdutils.check_overflow(dx, '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,
|
||||
scope='window')
|
||||
@ -557,14 +557,14 @@ class CommandDispatcher:
|
||||
"""
|
||||
tab = self._current_widget()
|
||||
funcs = {
|
||||
'up': tab.scroll.up,
|
||||
'down': tab.scroll.down,
|
||||
'left': tab.scroll.left,
|
||||
'right': tab.scroll.right,
|
||||
'top': tab.scroll.top,
|
||||
'bottom': tab.scroll.bottom,
|
||||
'page-up': tab.scroll.page_up,
|
||||
'page-down': tab.scroll.page_down,
|
||||
'up': tab.scroller.up,
|
||||
'down': tab.scroller.down,
|
||||
'left': tab.scroller.left,
|
||||
'right': tab.scroller.right,
|
||||
'top': tab.scroller.top,
|
||||
'bottom': tab.scroller.bottom,
|
||||
'page-up': tab.scroller.page_up,
|
||||
'page-down': tab.scroller.page_down,
|
||||
}
|
||||
try:
|
||||
func = funcs[direction]
|
||||
@ -609,7 +609,7 @@ class CommandDispatcher:
|
||||
x = None
|
||||
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,
|
||||
scope='window')
|
||||
@ -637,15 +637,15 @@ class CommandDispatcher:
|
||||
# See https://github.com/The-Compiler/qutebrowser/issues/701
|
||||
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)
|
||||
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)
|
||||
return
|
||||
|
||||
try:
|
||||
tab.scroll.delta_page(count * x, count * y)
|
||||
tab.scroller.delta_page(count * x, count * y)
|
||||
except OverflowError:
|
||||
raise cmdexc.CommandError(
|
||||
"Numeric argument is too large for internal int "
|
||||
@ -1513,10 +1513,10 @@ class CommandDispatcher:
|
||||
|
||||
if found:
|
||||
# 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 "
|
||||
"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 "
|
||||
"BOTTOM", immediately=True)
|
||||
else:
|
||||
@ -1545,7 +1545,7 @@ class CommandDispatcher:
|
||||
|
||||
if text:
|
||||
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)
|
||||
else:
|
||||
cb = None
|
||||
@ -1580,7 +1580,7 @@ class CommandDispatcher:
|
||||
return
|
||||
|
||||
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,
|
||||
prev=False)
|
||||
|
||||
@ -1615,7 +1615,7 @@ class CommandDispatcher:
|
||||
return
|
||||
|
||||
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,
|
||||
prev=True)
|
||||
|
||||
|
@ -330,7 +330,7 @@ class WebEngineTab(browsertab.AbstractTab):
|
||||
super().__init__(win_id)
|
||||
widget = webview.WebEngineView()
|
||||
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,
|
||||
tab=self, parent=self)
|
||||
self.zoom = WebEngineZoom(win_id=win_id, parent=self)
|
||||
|
@ -485,9 +485,9 @@ class WebKitHistory(browsertab.AbstractHistory):
|
||||
if 'zoom' in cur_data:
|
||||
self._tab.zoom.set_factor(cur_data['zoom'])
|
||||
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(
|
||||
self._tab.scroll.to_point, cur_data['scroll-pos']))
|
||||
self._tab.scroller.to_point, cur_data['scroll-pos']))
|
||||
|
||||
|
||||
class WebKitTab(browsertab.AbstractTab):
|
||||
@ -498,7 +498,7 @@ class WebKitTab(browsertab.AbstractTab):
|
||||
super().__init__(win_id)
|
||||
widget = webview.WebView(win_id, self.tab_id, tab=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,
|
||||
tab=self, 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.loadProgress.connect(self._on_load_progress)
|
||||
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.urlChanged.connect(self._on_url_changed)
|
||||
view.shutting_down.connect(self.shutting_down)
|
||||
|
@ -54,4 +54,4 @@ class Percentage(textbase.TextBase):
|
||||
@pyqtSlot(browsertab.AbstractTab)
|
||||
def on_tab_changed(self, tab):
|
||||
"""Update scroll position when tab changed."""
|
||||
self.set_perc(*tab.scroll.pos_perc())
|
||||
self.set_perc(*tab.scroller.pos_perc())
|
||||
|
@ -175,9 +175,9 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
self._filter.create(self.cur_load_finished, tab))
|
||||
tab.load_started.connect(
|
||||
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))
|
||||
tab.scroll.perc_changed.connect(self.on_scroll_pos_changed)
|
||||
tab.scroller.perc_changed.connect(self.on_scroll_pos_changed)
|
||||
tab.url_changed.connect(
|
||||
self._filter.create(self.cur_url_changed, tab))
|
||||
tab.load_status_changed.connect(
|
||||
@ -646,7 +646,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
if key != "'":
|
||||
message.error(self._win_id, "Failed to set mark: url invalid")
|
||||
return
|
||||
point = self.currentWidget().scroll.pos_px()
|
||||
point = self.currentWidget().scroller.pos_px()
|
||||
|
||||
if key.isupper():
|
||||
self._global_marks[key] = point, url
|
||||
@ -676,7 +676,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
def callback(ok):
|
||||
if ok:
|
||||
self.cur_load_finished.disconnect(callback)
|
||||
tab.scroll.to_point(point)
|
||||
tab.scroller.to_point(point)
|
||||
|
||||
self.openurl(url, newtab=False)
|
||||
self.cur_load_finished.connect(callback)
|
||||
@ -692,6 +692,6 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
# "'" would just jump to the current position every time
|
||||
self.set_mark("'")
|
||||
|
||||
tab.scroll.to_point(point)
|
||||
tab.scroller.to_point(point)
|
||||
else:
|
||||
message.error(self._win_id, "Mark {} is not set".format(key))
|
||||
|
@ -126,7 +126,7 @@ class TabWidget(QTabWidget):
|
||||
except qtutils.QtValueError:
|
||||
fields['host'] = ''
|
||||
|
||||
y = tab.scroll.pos_perc()[1]
|
||||
y = tab.scroller.pos_perc()[1]
|
||||
if y is None:
|
||||
scroll_pos = '???'
|
||||
elif y <= 0:
|
||||
|
@ -168,7 +168,7 @@ class SessionManager(QObject):
|
||||
user_data = None
|
||||
|
||||
if tab.history.current_idx() == idx:
|
||||
pos = tab.scroll.pos_px()
|
||||
pos = tab.scroller.pos_px()
|
||||
data['zoom'] = tab.zoom.factor()
|
||||
data['scroll-pos'] = {'x': pos.x(), 'y': pos.y()}
|
||||
elif user_data is not None:
|
||||
|
@ -250,7 +250,7 @@ class FakeWebTab(browsertab.AbstractTab):
|
||||
self._title = title
|
||||
self._url = url
|
||||
self._progress = progress
|
||||
self.scroll = FakeWebTabScroller(self, scroll_pos_perc)
|
||||
self.scroller = FakeWebTabScroller(self, scroll_pos_perc)
|
||||
|
||||
def url(self):
|
||||
return self._url
|
||||
|
@ -104,7 +104,7 @@ def test_tab(qtbot, view, config_stub, tab_registry):
|
||||
mode_manager = modeman.ModeManager(0)
|
||||
|
||||
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,
|
||||
mode_manager=mode_manager,
|
||||
tab=tab_w, parent=tab_w)
|
||||
|
Loading…
Reference in New Issue
Block a user