Re-sort some functions
This commit is contained in:
parent
1a68bdb9a9
commit
af1ba0edf6
@ -93,6 +93,22 @@ class BrowserTab(QWebView):
|
||||
default=config.get('general', 'defaultzoom'),
|
||||
mode=NeighborList.BLOCK)
|
||||
|
||||
def _on_destroyed(self, sender):
|
||||
"""Called when a subsystem has been destroyed during shutdown.
|
||||
|
||||
Args:
|
||||
sender: The object which called the callback.
|
||||
"""
|
||||
self._destroyed[sender] = True
|
||||
dbgout = '\n'.join(['{}: {}'.format(k.__class__.__name__, v)
|
||||
for (k, v) in self._destroyed.items()])
|
||||
logging.debug("{} has been destroyed, new status:\n{}".format(
|
||||
sender.__class__.__name__, dbgout))
|
||||
if all(self._destroyed.values()):
|
||||
if self._shutdown_callback is not None:
|
||||
logging.debug("Everything destroyed, calling callback")
|
||||
self._shutdown_callback()
|
||||
|
||||
def openurl(self, url):
|
||||
"""Open an URL in the browser.
|
||||
|
||||
@ -125,26 +141,6 @@ class BrowserTab(QWebView):
|
||||
self.setZoomFactor(float(level) / 100)
|
||||
message.info("Zoom level: {}%".format(level))
|
||||
|
||||
@pyqtSlot(str)
|
||||
def on_link_clicked(self, url):
|
||||
"""Handle a link.
|
||||
|
||||
Called from the linkClicked signal. Checks if it should open it in a
|
||||
tab (middle-click or control) or not, and does so.
|
||||
|
||||
Args:
|
||||
url: The url to handle, as string or QUrl.
|
||||
|
||||
Emit:
|
||||
open_tab: Emitted if window should be opened in a new tab.
|
||||
"""
|
||||
if self._open_target == "tab":
|
||||
self.open_tab.emit(url, False)
|
||||
elif self._open_target == "bgtab":
|
||||
self.open_tab.emit(url, True)
|
||||
else:
|
||||
self.openurl(url)
|
||||
|
||||
def shutdown(self, callback=None):
|
||||
"""Shut down the tab cleanly and remove it.
|
||||
|
||||
@ -181,6 +177,26 @@ class BrowserTab(QWebView):
|
||||
netman.deleteLater()
|
||||
logging.debug("Tab shutdown scheduled")
|
||||
|
||||
@pyqtSlot(str)
|
||||
def on_link_clicked(self, url):
|
||||
"""Handle a link.
|
||||
|
||||
Called from the linkClicked signal. Checks if it should open it in a
|
||||
tab (middle-click or control) or not, and does so.
|
||||
|
||||
Args:
|
||||
url: The url to handle, as string or QUrl.
|
||||
|
||||
Emit:
|
||||
open_tab: Emitted if window should be opened in a new tab.
|
||||
"""
|
||||
if self._open_target == "tab":
|
||||
self.open_tab.emit(url, False)
|
||||
elif self._open_target == "bgtab":
|
||||
self.open_tab.emit(url, True)
|
||||
else:
|
||||
self.openurl(url)
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def on_config_changed(self, section, option):
|
||||
"""Update tab config when config was changed."""
|
||||
@ -202,22 +218,6 @@ class BrowserTab(QWebView):
|
||||
"""
|
||||
self._force_open_target = target
|
||||
|
||||
def _on_destroyed(self, sender):
|
||||
"""Called when a subsystem has been destroyed during shutdown.
|
||||
|
||||
Args:
|
||||
sender: The object which called the callback.
|
||||
"""
|
||||
self._destroyed[sender] = True
|
||||
dbgout = '\n'.join(['{}: {}'.format(k.__class__.__name__, v)
|
||||
for (k, v) in self._destroyed.items()])
|
||||
logging.debug("{} has been destroyed, new status:\n{}".format(
|
||||
sender.__class__.__name__, dbgout))
|
||||
if all(self._destroyed.values()):
|
||||
if self._shutdown_callback is not None:
|
||||
logging.debug("Everything destroyed, calling callback")
|
||||
self._shutdown_callback()
|
||||
|
||||
def paintEvent(self, e):
|
||||
"""Extend paintEvent to emit a signal if the scroll position changed.
|
||||
|
||||
|
@ -146,7 +146,7 @@ class TabbedBrowser(TabWidget):
|
||||
tab.hintmanager.set_mode.connect(self.set_mode)
|
||||
tab.hintmanager.set_cmd_text.connect(self.set_cmd_text)
|
||||
# misc
|
||||
tab.titleChanged.connect(self._titleChanged_handler)
|
||||
tab.titleChanged.connect(self.on_title_changed)
|
||||
tab.open_tab.connect(self.tabopen)
|
||||
|
||||
def cntwidget(self, count=None):
|
||||
@ -167,27 +167,6 @@ class TabbedBrowser(TabWidget):
|
||||
else:
|
||||
return None
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def on_config_changed(self, section, option):
|
||||
"""Update tab config when config was changed."""
|
||||
super().on_config_changed(section, option)
|
||||
for tab in self._tabs:
|
||||
tab.on_config_changed(section, option)
|
||||
|
||||
def _titleChanged_handler(self, text):
|
||||
"""Set the title of a tab.
|
||||
|
||||
Slot for the titleChanged signal of any tab.
|
||||
|
||||
Args:
|
||||
text: The text to set.
|
||||
"""
|
||||
logging.debug('title changed to "{}"'.format(text))
|
||||
if text:
|
||||
self.setTabText(self.indexOf(self.sender()), text)
|
||||
else:
|
||||
logging.debug('ignoring title change')
|
||||
|
||||
def shutdown(self):
|
||||
"""Try to shut down all tabs cleanly.
|
||||
|
||||
@ -358,6 +337,28 @@ class TabbedBrowser(TabWidget):
|
||||
"""
|
||||
self.paste(sel, True)
|
||||
|
||||
@pyqtSlot(str, str)
|
||||
def on_config_changed(self, section, option):
|
||||
"""Update tab config when config was changed."""
|
||||
super().on_config_changed(section, option)
|
||||
for tab in self._tabs:
|
||||
tab.on_config_changed(section, option)
|
||||
|
||||
@pyqtSlot(str)
|
||||
def on_title_changed(self, text):
|
||||
"""Set the title of a tab.
|
||||
|
||||
Slot for the titleChanged signal of any tab.
|
||||
|
||||
Args:
|
||||
text: The text to set.
|
||||
"""
|
||||
logging.debug('title changed to "{}"'.format(text))
|
||||
if text:
|
||||
self.setTabText(self.indexOf(self.sender()), text)
|
||||
else:
|
||||
logging.debug('ignoring title change')
|
||||
|
||||
def keyPressEvent(self, e):
|
||||
"""Extend TabWidget (QWidget)'s keyPressEvent to emit a signal.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user