Use tab.AbstractTab for signals/slots
This commit is contained in:
parent
7444f83dbf
commit
09f025628f
@ -22,7 +22,7 @@
|
||||
from collections import defaultdict
|
||||
from PyQt5.QtCore import Qt, QTimer, pyqtSlot
|
||||
|
||||
from qutebrowser.browser.webkit import webview
|
||||
from qutebrowser.browser import tab as tabmod
|
||||
from qutebrowser.config import config, configdata
|
||||
from qutebrowser.utils import objreg, log, qtutils, utils
|
||||
from qutebrowser.commands import cmdutils
|
||||
@ -193,7 +193,7 @@ class TabCompletionModel(base.BaseCompletionModel):
|
||||
"""Add hooks to new windows."""
|
||||
window.tabbed_browser.new_tab.connect(self.on_new_tab)
|
||||
|
||||
@pyqtSlot(webview.WebView)
|
||||
@pyqtSlot(tabmod.AbstractTab)
|
||||
def on_new_tab(self, tab):
|
||||
"""Add hooks to new tabs."""
|
||||
tab.url_text_changed.connect(self.rebuild)
|
||||
|
@ -21,8 +21,8 @@
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
|
||||
from qutebrowser.browser import tab as tabmod
|
||||
from qutebrowser.mainwindow.statusbar import textbase
|
||||
from qutebrowser.browser.webkit import webview
|
||||
|
||||
|
||||
class Percentage(textbase.TextBase):
|
||||
@ -51,7 +51,7 @@ class Percentage(textbase.TextBase):
|
||||
else:
|
||||
self.setText('[{:2}%]'.format(y))
|
||||
|
||||
@pyqtSlot(webview.WebView)
|
||||
@pyqtSlot(tabmod.AbstractTab)
|
||||
def on_tab_changed(self, tab):
|
||||
"""Update scroll position when tab changed."""
|
||||
self.set_perc(*tab.scroll.pos_perc())
|
||||
|
@ -22,7 +22,7 @@
|
||||
from PyQt5.QtCore import pyqtSlot, QSize
|
||||
from PyQt5.QtWidgets import QProgressBar, QSizePolicy
|
||||
|
||||
from qutebrowser.browser.webkit import webview
|
||||
from qutebrowser.browser import tab as tabmod
|
||||
from qutebrowser.config import style
|
||||
from qutebrowser.utils import utils, usertypes
|
||||
|
||||
@ -59,7 +59,7 @@ class Progress(QProgressBar):
|
||||
self.setValue(0)
|
||||
self.show()
|
||||
|
||||
@pyqtSlot(webview.WebView)
|
||||
@pyqtSlot(tabmod.AbstractTab)
|
||||
def on_tab_changed(self, tab):
|
||||
"""Set the correct value when the current tab changed."""
|
||||
if self is None: # pragma: no branch
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
|
||||
from qutebrowser.browser import tab as tabmod
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.mainwindow.statusbar import textbase
|
||||
from qutebrowser.utils import usertypes, log, objreg
|
||||
from qutebrowser.browser.webkit import webview
|
||||
|
||||
|
||||
class Text(textbase.TextBase):
|
||||
@ -99,7 +99,7 @@ class Text(textbase.TextBase):
|
||||
"""Clear jstext when page loading started."""
|
||||
self._jstext = ''
|
||||
|
||||
@pyqtSlot(webview.WebView)
|
||||
@pyqtSlot(tabmod.AbstractTab)
|
||||
def on_tab_changed(self, tab):
|
||||
"""Set the correct jstext when the current tab changed."""
|
||||
self._jstext = tab.statusbar_message
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtProperty, Qt, QUrl
|
||||
|
||||
from qutebrowser.browser.webkit import webview
|
||||
from qutebrowser.browser import tab as tabmod
|
||||
from qutebrowser.mainwindow.statusbar import textbase
|
||||
from qutebrowser.config import style
|
||||
from qutebrowser.utils import usertypes
|
||||
@ -160,7 +160,7 @@ class UrlText(textbase.TextBase):
|
||||
self._hover_url = None
|
||||
self._update_url()
|
||||
|
||||
@pyqtSlot(webview.WebView)
|
||||
@pyqtSlot(tabmod.AbstractTab)
|
||||
def on_tab_changed(self, tab):
|
||||
"""Update URL if the tab changed."""
|
||||
self._hover_url = None
|
||||
|
@ -30,7 +30,8 @@ from qutebrowser.config import config
|
||||
from qutebrowser.keyinput import modeman
|
||||
from qutebrowser.mainwindow import tabwidget
|
||||
from qutebrowser.browser import signalfilter
|
||||
from qutebrowser.browser.webkit import webview, webkittab
|
||||
from qutebrowser.browser import tab as tabmod
|
||||
from qutebrowser.browser.webkit import webkittab
|
||||
from qutebrowser.utils import (log, usertypes, utils, qtutils, objreg,
|
||||
urlutils, message)
|
||||
|
||||
@ -86,7 +87,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
resized: Emitted when the browser window has resized, so the completion
|
||||
widget can adjust its size to it.
|
||||
arg: The new size.
|
||||
current_tab_changed: The current tab changed to the emitted WebView.
|
||||
current_tab_changed: The current tab changed to the emitted tab.
|
||||
new_tab: Emits the new WebView and its index when a new tab is opened.
|
||||
"""
|
||||
|
||||
@ -100,8 +101,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
cur_load_status_changed = pyqtSignal(str)
|
||||
close_window = pyqtSignal()
|
||||
resized = pyqtSignal('QRect')
|
||||
current_tab_changed = pyqtSignal(webview.WebView)
|
||||
new_tab = pyqtSignal(webview.WebView, int)
|
||||
current_tab_changed = pyqtSignal(tabmod.AbstractTab)
|
||||
new_tab = pyqtSignal(tabmod.AbstractTab, int)
|
||||
|
||||
def __init__(self, win_id, parent=None):
|
||||
super().__init__(win_id, parent)
|
||||
@ -338,7 +339,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
return
|
||||
self.close_tab(tab)
|
||||
|
||||
@pyqtSlot(webview.WebView)
|
||||
@pyqtSlot(tabmod.AbstractTab)
|
||||
def on_window_close_requested(self, widget):
|
||||
"""Close a tab with a widget given."""
|
||||
try:
|
||||
@ -487,7 +488,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
modeman.maybe_leave(self._win_id, usertypes.KeyMode.hint,
|
||||
'load started')
|
||||
|
||||
@pyqtSlot(webview.WebView, str)
|
||||
@pyqtSlot(tabmod.AbstractTab, str)
|
||||
def on_title_changed(self, tab, text):
|
||||
"""Set the title of a tab.
|
||||
|
||||
@ -511,7 +512,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
if idx == self.currentIndex():
|
||||
self.update_window_title()
|
||||
|
||||
@pyqtSlot(webview.WebView, str)
|
||||
@pyqtSlot(tabmod.AbstractTab, str)
|
||||
def on_url_text_changed(self, tab, url):
|
||||
"""Set the new URL as title if there's no title yet.
|
||||
|
||||
@ -527,7 +528,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
||||
if not self.page_title(idx):
|
||||
self.set_page_title(idx, url)
|
||||
|
||||
@pyqtSlot(webview.WebView, QIcon)
|
||||
@pyqtSlot(tabmod.AbstractTab, QIcon)
|
||||
def on_icon_changed(self, tab, icon):
|
||||
"""Set the icon of a tab.
|
||||
|
||||
|
@ -30,7 +30,7 @@ from PyQt5.QtNetwork import (QNetworkRequest, QAbstractNetworkCache,
|
||||
from PyQt5.QtWidgets import QCommonStyle, QLineEdit
|
||||
|
||||
from qutebrowser.browser import tab
|
||||
from qutebrowser.browser.webkit import webview, history
|
||||
from qutebrowser.browser.webkit import history
|
||||
from qutebrowser.config import configexc
|
||||
from qutebrowser.utils import usertypes
|
||||
from qutebrowser.mainwindow import mainwindow
|
||||
@ -542,7 +542,7 @@ class TabbedBrowserStub(QObject):
|
||||
|
||||
"""Stub for the tabbed-browser object."""
|
||||
|
||||
new_tab = pyqtSignal(webview.WebView, int)
|
||||
new_tab = pyqtSignal(tab.AbstractTab, int)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
Loading…
Reference in New Issue
Block a user