Add option to configure if js statusbar messages should be shown

This commit is contained in:
Florian Bruhin 2014-06-03 19:17:35 +02:00
parent 0274a36780
commit 40009970df
4 changed files with 19 additions and 6 deletions

1
TODO
View File

@ -43,7 +43,6 @@ Improvements / minor features
- Get rid of webkit config section
http://paste.the-compiler.org/view/542f9b74
- Add an option to configure if javascript may set statusbar
- Reimplement tabbar to paint it by ourselves to look like dwb
- Save cookies in Netscape format so it can be used by wget.
http://www.cookiecentral.com/faq/#3.5

View File

@ -388,7 +388,8 @@ class QuteBrowser(QApplication):
# config
self.config.style_changed.connect(style.invalidate_caches)
for obj in [tabs, completion, self.mainwindow, self.cmd_history,
websettings, kp['normal'], self.modeman, status]:
websettings, kp['normal'], self.modeman, status,
status.txt]:
self.config.changed.connect(obj.on_config_changed)
# statusbar

View File

@ -218,6 +218,10 @@ DATA = OrderedDict([
('confirm-quit',
SettingValue(types.ConfirmQuit(), 'never'),
"Whether to confirm quitting the application."),
('display-statusbar-messages',
SettingValue(types.Bool(), 'false'),
"Whether to display javascript statusbar messages."),
)),
('network', sect.KeyValue(

View File

@ -19,6 +19,7 @@
from PyQt5.QtCore import pyqtSlot
import qutebrowser.config.config as config
from qutebrowser.widgets.statusbar.textbase import TextBase
@ -79,10 +80,12 @@ class Text(TextBase):
def _update_text(self):
"""Update QLabel text when needed."""
for text in [self.temptext, self.jstext, self.normaltext]:
if text:
self.setText(text)
break
if self.temptext:
self.setText(self.temptext)
elif self.jstext and config.get('ui', 'display-statusbar-messages'):
self.setText(self.jstext)
elif self.normaltext:
self.setText(self.normaltext)
else:
self.setText('')
@ -101,3 +104,9 @@ class Text(TextBase):
"""Set the correct jstext when the current tab changed."""
tab = self.sender().widget(idx)
self.jstext = tab.statusbar_message
@pyqtSlot(str, str)
def on_config_changed(self, section, option):
"""Update text if display-statusbar-messages option changed."""
if (section, option) == ('ui', 'display-statusbar-messages'):
self._update_text()