Make :reload and :stop work

This commit is contained in:
Florian Bruhin 2016-06-14 13:39:51 +02:00
parent 6a42e0c96c
commit 2d590c581d
4 changed files with 30 additions and 5 deletions

View File

@ -281,10 +281,7 @@ class CommandDispatcher:
"""
tab = self._cntwidget(count)
if tab is not None:
if force:
tab.page().triggerAction(QWebPage.ReloadAndBypassCache)
else:
tab.reload()
tab.reload(force=force)
@cmdutils.register(instance='command-dispatcher', scope='window')
@cmdutils.argument('count', count=True)

View File

@ -151,6 +151,12 @@ class AbstractTab(QWidget):
def openurl(self, url):
raise NotImplementedError
def reload(self, *, force=False):
raise NotImplementedError
def stop(self):
raise NotImplementedError
def dump_async(self, callback=None, *, plain=False):
"""Dump the current page to a file ascync.

View File

@ -22,9 +22,10 @@
from PyQt5.QtCore import pyqtSlot
try:
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage
except ImportError:
QWebEngineView = None
QWebEnginePage = None
from qutebrowser.browser import tab
from qutebrowser.utils import usertypes, qtutils
@ -93,6 +94,16 @@ class WebEngineViewTab(tab.AbstractTab):
# TODO
pass
def reload(self, *, force=False):
if force:
action = QWebEnginePage.ReloadAndBypassCache
else:
action = QWebEnginePage.Reload
self._widget.triggerPageAction(action)
def stop(self):
self._widget.stop()
def _connect_signals(self):
view = self._widget
page = view.page()

View File

@ -20,6 +20,7 @@
"""Wrapper over our (QtWebKit) WebView."""
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWebKitWidgets import QWebPage
from qutebrowser.browser import tab
from qutebrowser.browser.webkit import webview
@ -99,6 +100,16 @@ class WebViewTab(tab.AbstractTab):
def shutdown(self):
self._widget.shutdown()
def reload(self, *, force=False):
if force:
action = QWebPage.ReloadAndBypassCache
else:
action = QWebPage.Reload
self._widget.triggerPageAction(action)
def stop(self):
self._widget.stop()
def _connect_signals(self):
view = self._widget
page = view.page()