Show loading percentage in window title.
This commit is contained in:
parent
594438e4d8
commit
cd39be62ee
@ -128,12 +128,20 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
w.append(self.widget(i))
|
w.append(self.widget(i))
|
||||||
return w
|
return w
|
||||||
|
|
||||||
def _change_app_title(self, text):
|
def _update_window_title(self):
|
||||||
"""Change the window title based on the tab text."""
|
"""Change the window title to match the current tab."""
|
||||||
if not text:
|
idx = self.currentIndex()
|
||||||
title = 'qutebrowser'
|
tabtitle = self.tabText(idx)
|
||||||
|
widget = self.widget(idx)
|
||||||
|
|
||||||
|
if widget.load_status == webview.LoadStatus.loading:
|
||||||
|
title = '[{}%] '.format(widget.progress)
|
||||||
else:
|
else:
|
||||||
title = '{} - qutebrowser'.format(text)
|
title = ''
|
||||||
|
if not tabtitle:
|
||||||
|
title += 'qutebrowser'
|
||||||
|
else:
|
||||||
|
title += '{} - qutebrowser'.format(tabtitle)
|
||||||
self.window().setWindowTitle(title)
|
self.window().setWindowTitle(title)
|
||||||
|
|
||||||
def _connect_tab_signals(self, tab):
|
def _connect_tab_signals(self, tab):
|
||||||
@ -404,7 +412,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def on_load_started(self, tab):
|
def on_load_started(self, tab):
|
||||||
"""Clear icon when a tab started loading.
|
"""Clear icon and update title when a tab started loading.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
tab: The tab where the signal belongs to.
|
tab: The tab where the signal belongs to.
|
||||||
@ -419,6 +427,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
log.webview.debug("Got invalid tab {}!".format(tab))
|
log.webview.debug("Got invalid tab {}!".format(tab))
|
||||||
return
|
return
|
||||||
self.setTabIcon(idx, QIcon())
|
self.setTabIcon(idx, QIcon())
|
||||||
|
if idx == self.currentIndex():
|
||||||
|
self._update_window_title()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def on_cur_load_started(self):
|
def on_cur_load_started(self):
|
||||||
@ -454,7 +464,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
return
|
return
|
||||||
self.setTabText(idx, text.replace('&', '&&'))
|
self.setTabText(idx, text.replace('&', '&&'))
|
||||||
if idx == self.currentIndex():
|
if idx == self.currentIndex():
|
||||||
self._change_app_title(text)
|
self._update_window_title()
|
||||||
|
|
||||||
@pyqtSlot(webview.WebView, str)
|
@pyqtSlot(webview.WebView, str)
|
||||||
def on_url_text_changed(self, tab, url):
|
def on_url_text_changed(self, tab, url):
|
||||||
@ -526,7 +536,7 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
scope='window', window=self._win_id)
|
scope='window', window=self._win_id)
|
||||||
self._now_focused = tab
|
self._now_focused = tab
|
||||||
self.current_tab_changed.emit(tab)
|
self.current_tab_changed.emit(tab)
|
||||||
self._change_app_title(self.tabText(idx))
|
self._update_window_title()
|
||||||
self._tab_insert_idx_left = self.currentIndex()
|
self._tab_insert_idx_left = self.currentIndex()
|
||||||
self._tab_insert_idx_right = self.currentIndex() + 1
|
self._tab_insert_idx_right = self.currentIndex() + 1
|
||||||
|
|
||||||
@ -547,6 +557,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
system = config.get('colors', 'tabs.indicator.system')
|
system = config.get('colors', 'tabs.indicator.system')
|
||||||
color = utils.interpolate_color(start, stop, perc, system)
|
color = utils.interpolate_color(start, stop, perc, system)
|
||||||
self.tabBar().set_tab_indicator_color(idx, color)
|
self.tabBar().set_tab_indicator_color(idx, color)
|
||||||
|
if idx == self.currentIndex():
|
||||||
|
self._update_window_title()
|
||||||
|
|
||||||
def on_load_finished(self, tab):
|
def on_load_finished(self, tab):
|
||||||
"""Adjust tab indicator when loading finished.
|
"""Adjust tab indicator when loading finished.
|
||||||
@ -568,6 +580,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
system = config.get('colors', 'tabs.indicator.system')
|
system = config.get('colors', 'tabs.indicator.system')
|
||||||
color = utils.interpolate_color(start, stop, 100, system)
|
color = utils.interpolate_color(start, stop, 100, system)
|
||||||
self.tabBar().set_tab_indicator_color(idx, color)
|
self.tabBar().set_tab_indicator_color(idx, color)
|
||||||
|
if idx == self.currentIndex():
|
||||||
|
self._update_window_title()
|
||||||
|
|
||||||
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user