Set window title based on page

This commit is contained in:
Florian Bruhin 2014-06-23 17:18:36 +02:00
parent bf94dec074
commit da0bfb4861
3 changed files with 7 additions and 1 deletions

View File

@ -48,7 +48,6 @@ Improvements / minor features
- Show size of widgets in __repr__ - Show size of widgets in __repr__
- Ask whether to close when downloads are running or maybe if form fields are - Ask whether to close when downloads are running or maybe if form fields are
unsubmitted (book page 187) unsubmitted (book page 187)
- Update window title
- Completion in statusbar like dwb - Completion in statusbar like dwb
- SSL-symbol in statusbar? - SSL-symbol in statusbar?
- Commandline argument to delete config - Commandline argument to delete config

View File

@ -86,6 +86,7 @@ class MainWindow(QWidget):
self.downloadview.show() self.downloadview.show()
self.tabs = TabbedBrowser() self.tabs = TabbedBrowser()
self.tabs.title_changed.connect(self.setWindowTitle)
self._vbox.addWidget(self.tabs) self._vbox.addWidget(self.tabs)
self.completion = CompletionView(self) self.completion = CompletionView(self)

View File

@ -77,6 +77,8 @@ class TabbedBrowser(TabWidget):
start_download: Emitted when any tab wants to start downloading start_download: Emitted when any tab wants to start downloading
something. something.
current_tab_changed: The current tab changed to the emitted WebView. current_tab_changed: The current tab changed to the emitted WebView.
title_changed: Emitted when the application title should be changed.
arg: The new title as string.
""" """
cur_progress = pyqtSignal(int) cur_progress = pyqtSignal(int)
@ -94,6 +96,7 @@ class TabbedBrowser(TabWidget):
resized = pyqtSignal('QRect') resized = pyqtSignal('QRect')
got_cmd = pyqtSignal(str) got_cmd = pyqtSignal(str)
current_tab_changed = pyqtSignal(WebView) current_tab_changed = pyqtSignal(WebView)
title_changed = pyqtSignal(str)
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent) super().__init__(parent)
@ -364,6 +367,8 @@ class TabbedBrowser(TabWidget):
if idx == -1: if idx == -1:
raise ValueError("Tab {} not found!".format(tab)) raise ValueError("Tab {} not found!".format(tab))
self.setTabText(idx, text) self.setTabText(idx, text)
if idx == self.currentIndex():
self.title_changed.emit('{} - qutebrowser'.format(text))
else: else:
log.webview.debug("ignoring title change") log.webview.debug("ignoring title change")
@ -411,6 +416,7 @@ class TabbedBrowser(TabWidget):
self.last_focused = self.now_focused self.last_focused = self.now_focused
self.now_focused = tab self.now_focused = tab
self.current_tab_changed.emit(tab) self.current_tab_changed.emit(tab)
self.title_changed.emit('{} - qutebrowser'.format(self.tabText(idx)))
def resizeEvent(self, e): def resizeEvent(self, e):
"""Extend resizeEvent of QWidget to emit a resized signal afterwards. """Extend resizeEvent of QWidget to emit a resized signal afterwards.