From 8d7249ebc62abbd23bf29f629e20cfefb5335e01 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 27 Aug 2015 22:07:14 +0200 Subject: [PATCH] Implement statusbar padding. --- CHANGELOG.asciidoc | 2 ++ qutebrowser/config/configdata.py | 4 ++++ qutebrowser/mainwindow/mainwindow.py | 2 ++ qutebrowser/mainwindow/statusbar/bar.py | 11 +++++++++-- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 7c0ba2a27..a547b1971 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -27,6 +27,8 @@ Added the current item in the completion (for quickmarks/bookmarks). - New settings `tabs -> padding` and `tabs -> indicator-tabbing` to control the size/padding of the tabbar. +- New setting `ui -> statusbar-padding` to control the size/padding of the + status bar. - New setting `network -> referer-header` to configure when the referer should be sent (by default it's only sent while on the same domain). - New setting `tabs -> show` which supersedes the old `tabs -> hide-*` options diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 659f84dbb..4a1c46ed2 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -293,6 +293,10 @@ def data(readonly=False): SettingValue(typ.Bool(), 'false'), "Whether to hide the statusbar unless a message is shown."), + ('statusbar-padding', + SettingValue(typ.Padding(), '1,1,0,0'), + "Padding for statusbar (top, bottom, left, right)."), + ('window-title-format', SettingValue(typ.FormatString(fields=['perc', 'perc_raw', 'title', 'title_sep', 'id']), diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index b97eed133..8b13f4e24 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -190,6 +190,8 @@ class MainWindow(QWidget): """Resize the completion if related config options changed.""" if section == 'completion' and option in ('height', 'shrink'): self.resize_completion() + elif section == 'ui' and option == 'statusbar-padding': + self.resize_completion() elif section == 'ui' and option == 'downloads-position': self._add_widgets() diff --git a/qutebrowser/mainwindow/statusbar/bar.py b/qutebrowser/mainwindow/statusbar/bar.py index fa16c24a4..b4066060d 100644 --- a/qutebrowser/mainwindow/statusbar/bar.py +++ b/qutebrowser/mainwindow/statusbar/bar.py @@ -180,7 +180,8 @@ class StatusBar(QWidget): self._stopwatch = QTime() self._hbox = QHBoxLayout(self) - self._hbox.setContentsMargins(0, 0, 0, 0) + self.set_hbox_padding() + objreg.get('config').changed.connect(self.set_hbox_padding) self._hbox.setSpacing(5) self._stack = QStackedLayout() @@ -246,6 +247,11 @@ class StatusBar(QWidget): else: self.show() + @config.change_filter('ui', 'statusbar-padding') + def set_hbox_padding(self): + padding = config.get('ui', 'statusbar-padding') + self._hbox.setContentsMargins(padding.left, 0, padding.right, 0) + @pyqtProperty(str) def severity(self): """Getter for self.severity, so it can be used as Qt property. @@ -558,6 +564,7 @@ class StatusBar(QWidget): def minimumSizeHint(self): """Set the minimum height to the text height plus some padding.""" + padding = config.get('ui', 'statusbar-padding') width = super().minimumSizeHint().width() - height = self.fontMetrics().height() + 3 + height = self.fontMetrics().height() + padding.top + padding.bottom return QSize(width, height)