Merge branch 'master' of https://github.com/iordanisg/qutebrowser
This commit is contained in:
commit
1f4012cc1e
@ -465,11 +465,21 @@ class AbstractHistory:
|
|||||||
def current_idx(self):
|
def current_idx(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
def back(self):
|
def back(self, count):
|
||||||
raise NotImplementedError
|
idx = self.current_idx() - count
|
||||||
|
if idx >= 0:
|
||||||
|
self._go_to_item(self._item_at(idx))
|
||||||
|
else:
|
||||||
|
self._go_to_item(self._item_at(0))
|
||||||
|
raise WebTabError("At beginning of history.")
|
||||||
|
|
||||||
def forward(self):
|
def forward(self, count):
|
||||||
raise NotImplementedError
|
idx = self.current_idx() + count
|
||||||
|
if idx < len(self):
|
||||||
|
self._go_to_item(self._item_at(idx))
|
||||||
|
else:
|
||||||
|
self._go_to_item(self._item_at(len(self) - 1))
|
||||||
|
raise WebTabError("At end of history.")
|
||||||
|
|
||||||
def can_go_back(self):
|
def can_go_back(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
@ -477,6 +487,12 @@ class AbstractHistory:
|
|||||||
def can_go_forward(self):
|
def can_go_forward(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def _item_at(self, i):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def _go_to_item(self, item):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
"""Serialize into an opaque format understood by self.deserialize."""
|
"""Serialize into an opaque format understood by self.deserialize."""
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -540,15 +540,13 @@ class CommandDispatcher:
|
|||||||
else:
|
else:
|
||||||
widget = self._current_widget()
|
widget = self._current_widget()
|
||||||
|
|
||||||
for _ in range(count):
|
try:
|
||||||
if forward:
|
if forward:
|
||||||
if not widget.history.can_go_forward():
|
widget.history.forward(count)
|
||||||
raise cmdexc.CommandError("At end of history.")
|
|
||||||
widget.history.forward()
|
|
||||||
else:
|
else:
|
||||||
if not widget.history.can_go_back():
|
widget.history.back(count)
|
||||||
raise cmdexc.CommandError("At beginning of history.")
|
except browsertab.WebTabError as e:
|
||||||
widget.history.back()
|
raise cmdexc.CommandError(e)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
@cmdutils.argument('count', count=True)
|
@cmdutils.argument('count', count=True)
|
||||||
|
@ -411,18 +411,18 @@ class WebEngineHistory(browsertab.AbstractHistory):
|
|||||||
def current_idx(self):
|
def current_idx(self):
|
||||||
return self._history.currentItemIndex()
|
return self._history.currentItemIndex()
|
||||||
|
|
||||||
def back(self):
|
|
||||||
self._history.back()
|
|
||||||
|
|
||||||
def forward(self):
|
|
||||||
self._history.forward()
|
|
||||||
|
|
||||||
def can_go_back(self):
|
def can_go_back(self):
|
||||||
return self._history.canGoBack()
|
return self._history.canGoBack()
|
||||||
|
|
||||||
def can_go_forward(self):
|
def can_go_forward(self):
|
||||||
return self._history.canGoForward()
|
return self._history.canGoForward()
|
||||||
|
|
||||||
|
def _item_at(self, i):
|
||||||
|
return self._history.itemAt(i)
|
||||||
|
|
||||||
|
def _go_to_item(self, item):
|
||||||
|
return self._history.goToItem(item)
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
if not qtutils.version_check('5.9'):
|
if not qtutils.version_check('5.9'):
|
||||||
# WORKAROUND for
|
# WORKAROUND for
|
||||||
|
@ -506,18 +506,18 @@ class WebKitHistory(browsertab.AbstractHistory):
|
|||||||
def current_idx(self):
|
def current_idx(self):
|
||||||
return self._history.currentItemIndex()
|
return self._history.currentItemIndex()
|
||||||
|
|
||||||
def back(self):
|
|
||||||
self._history.back()
|
|
||||||
|
|
||||||
def forward(self):
|
|
||||||
self._history.forward()
|
|
||||||
|
|
||||||
def can_go_back(self):
|
def can_go_back(self):
|
||||||
return self._history.canGoBack()
|
return self._history.canGoBack()
|
||||||
|
|
||||||
def can_go_forward(self):
|
def can_go_forward(self):
|
||||||
return self._history.canGoForward()
|
return self._history.canGoForward()
|
||||||
|
|
||||||
|
def _item_at(self, i):
|
||||||
|
return self._history.itemAt(i)
|
||||||
|
|
||||||
|
def _go_to_item(self, item):
|
||||||
|
return self._history.goToItem(item)
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
return qtutils.serialize(self._history)
|
return qtutils.serialize(self._history)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user