From 2fa66ba2500b1a4a12049b2072dcde938cf66831 Mon Sep 17 00:00:00 2001 From: Joel Torstensson Date: Wed, 25 Mar 2015 00:09:45 +0100 Subject: [PATCH 1/4] Added option for downloadview placement. --- qutebrowser/config/configdata.py | 5 ++++ qutebrowser/mainwindow/mainwindow.py | 35 +++++++++++++++++----------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 1d332e62a..b03a4f52d 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -235,6 +235,11 @@ def data(readonly=False): SettingValue(typ.Perc(), '100%'), "The default zoom level."), + ('downloads-at-top', + SettingValue(typ.Bool(), 'true'), + "Whether to show downloaded files at top, " + "false will show at bottom."), + ('message-timeout', SettingValue(typ.Int(), '2000'), "Time (in ms) to show messages in the statusbar for."), diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index dbcead867..8f48c9155 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -90,19 +90,12 @@ class MainWindow(QWidget): self._vbox.setContentsMargins(0, 0, 0, 0) self._vbox.setSpacing(0) - log.init.debug("Initializing downloads...") - download_manager = downloads.DownloadManager(self.win_id, self) - objreg.register('download-manager', download_manager, scope='window', - window=self.win_id) - - self._downloadview = downloadview.DownloadView(self.win_id) - self._vbox.addWidget(self._downloadview) - self._downloadview.show() - - self._tabbed_browser = tabbedbrowser.TabbedBrowser(self.win_id) - objreg.register('tabbed-browser', self._tabbed_browser, scope='window', - window=self.win_id) - self._vbox.addWidget(self._tabbed_browser) + if config.get('ui', 'downloads-at-top'): + self._init_downloadview() + self._init_tabbed_browser() + else: + self._init_tabbed_browser() + self._init_downloadview() # We need to set an explicit parent for StatusBar because it does some # show/hide magic immediately which would mean it'd show up as a @@ -142,6 +135,22 @@ class MainWindow(QWidget): if section == 'completion' and option in ('height', 'shrink'): self.resize_completion() + def _init_downloadview(self): + log.init.debug("Initializing downloads...") + download_manager = downloads.DownloadManager(self.win_id, self) + objreg.register('download-manager', download_manager, scope='window', + window=self.win_id) + + self._downloadview = downloadview.DownloadView(self.win_id) + self._vbox.addWidget(self._downloadview) + self._downloadview.show() + + def _init_tabbed_browser(self): + self._tabbed_browser = tabbedbrowser.TabbedBrowser(self.win_id) + objreg.register('tabbed-browser', self._tabbed_browser, scope='window', + window=self.win_id) + self._vbox.addWidget(self._tabbed_browser) + def _load_state_geometry(self): """Load the geometry from the state file.""" state_config = objreg.get('state-config') From cc2c7c09ea60ea2ff3eed1b0a42ba82356f1749e Mon Sep 17 00:00:00 2001 From: Joel Torstensson Date: Thu, 9 Apr 2015 11:39:41 +0200 Subject: [PATCH 2/4] Changing position without restart now possible. --- qutebrowser/config/configdata.py | 8 ++--- qutebrowser/config/configtypes.py | 7 ++++ qutebrowser/mainwindow/mainwindow.py | 50 ++++++++++++++++------------ 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index b03a4f52d..35c7dbaea 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -235,10 +235,9 @@ def data(readonly=False): SettingValue(typ.Perc(), '100%'), "The default zoom level."), - ('downloads-at-top', - SettingValue(typ.Bool(), 'true'), - "Whether to show downloaded files at top, " - "false will show at bottom."), + ('downloads-position', + SettingValue(typ.VerticalPosition(), 'north'), + "Where to show the downloaded files."), ('message-timeout', SettingValue(typ.Int(), '2000'), @@ -1011,7 +1010,6 @@ def data(readonly=False): DATA = data(readonly=True) - KEY_FIRST_COMMENT = """ # vim: ft=conf # diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index b0523f5f4..55159d538 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -1264,6 +1264,13 @@ class Position(BaseType): return self.MAPPING[value] +class VerticalPosition(BaseType): + + """The position of the download bar.""" + + valid_values = ValidValues('north', 'south') + + class UrlList(List): """A list of URLs.""" diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index 8f48c9155..ff50ab354 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -90,18 +90,24 @@ class MainWindow(QWidget): self._vbox.setContentsMargins(0, 0, 0, 0) self._vbox.setSpacing(0) - if config.get('ui', 'downloads-at-top'): - self._init_downloadview() - self._init_tabbed_browser() - else: - self._init_tabbed_browser() - self._init_downloadview() + log.init.debug("Initializing downloads...") + download_manager = downloads.DownloadManager(self.win_id, self) + objreg.register('download-manager', download_manager, scope='window', + window=self.win_id) + + self._downloadview = downloadview.DownloadView(self.win_id) + self._downloadview.show() + + self._tabbed_browser = tabbedbrowser.TabbedBrowser(self.win_id) + objreg.register('tabbed-browser', self._tabbed_browser, scope='window', + window=self.win_id) # We need to set an explicit parent for StatusBar because it does some # show/hide magic immediately which would mean it'd show up as a # window. self.status = bar.StatusBar(self.win_id, parent=self) - self._vbox.addWidget(self.status) + + self._add_widgets() self._completion = completionwidget.CompletionView(self.win_id, self) @@ -134,22 +140,24 @@ 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 == 'downloads-position': + self._add_widgets() - def _init_downloadview(self): - log.init.debug("Initializing downloads...") - download_manager = downloads.DownloadManager(self.win_id, self) - objreg.register('download-manager', download_manager, scope='window', - window=self.win_id) + def _add_widgets(self): + self._vbox.removeWidget(self._tabbed_browser) + self._vbox.removeWidget(self._downloadview) + self._vbox.removeWidget(self.status) + position = config.get('ui', 'downloads-position') + if position == 'north': + self._vbox.addWidget(self._downloadview) + self._vbox.addWidget(self._tabbed_browser) + elif position == 'south': + self._vbox.addWidget(self._tabbed_browser) + self._vbox.addWidget(self._downloadview) + else: + raise ValueError("Invalid position {}!".format(position)) + self._vbox.addWidget(self.status) - self._downloadview = downloadview.DownloadView(self.win_id) - self._vbox.addWidget(self._downloadview) - self._downloadview.show() - - def _init_tabbed_browser(self): - self._tabbed_browser = tabbedbrowser.TabbedBrowser(self.win_id) - objreg.register('tabbed-browser', self._tabbed_browser, scope='window', - window=self.win_id) - self._vbox.addWidget(self._tabbed_browser) def _load_state_geometry(self): """Load the geometry from the state file.""" From 12c83b721fabc365113f0dd656cb7070895dcfc1 Mon Sep 17 00:00:00 2001 From: Joel Torstensson Date: Thu, 9 Apr 2015 12:49:32 +0200 Subject: [PATCH 3/4] Fixed some style errors. --- qutebrowser/config/configdata.py | 5 +++-- qutebrowser/mainwindow/mainwindow.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 35c7dbaea..96e146ada 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -236,8 +236,8 @@ def data(readonly=False): "The default zoom level."), ('downloads-position', - SettingValue(typ.VerticalPosition(), 'north'), - "Where to show the downloaded files."), + SettingValue(typ.VerticalPosition(), 'north'), + "Where to show the downloaded files."), ('message-timeout', SettingValue(typ.Int(), '2000'), @@ -1010,6 +1010,7 @@ def data(readonly=False): DATA = data(readonly=True) + KEY_FIRST_COMMENT = """ # vim: ft=conf # diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py index ff50ab354..c619a6f47 100644 --- a/qutebrowser/mainwindow/mainwindow.py +++ b/qutebrowser/mainwindow/mainwindow.py @@ -144,6 +144,7 @@ class MainWindow(QWidget): self._add_widgets() def _add_widgets(self): + """Add or readd all widgets to the VBox.""" self._vbox.removeWidget(self._tabbed_browser) self._vbox.removeWidget(self._downloadview) self._vbox.removeWidget(self.status) @@ -158,7 +159,6 @@ class MainWindow(QWidget): raise ValueError("Invalid position {}!".format(position)) self._vbox.addWidget(self.status) - def _load_state_geometry(self): """Load the geometry from the state file.""" state_config = objreg.get('state-config') From 2a796d9aa432bbaf5401a501b1854ee615009be6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 9 Apr 2015 12:54:59 +0200 Subject: [PATCH 4/4] Regenerate docs. --- doc/help/settings.asciidoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 93d290e34..b774461b2 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -31,6 +31,7 @@ |Setting|Description |<>|The available zoom levels, separated by commas. |<>|The default zoom level. +|<>|Where to show the downloaded files. |<>|Time (in ms) to show messages in the statusbar for. |<>|Whether to show messages in unfocused windows. |<>|Whether to confirm quitting the application. @@ -441,6 +442,17 @@ The default zoom level. Default: +pass:[100%]+ +[[ui-downloads-position]] +=== downloads-position +Where to show the downloaded files. + +Valid values: + + * +north+ + * +south+ + +Default: +pass:[north]+ + [[ui-message-timeout]] === message-timeout Time (in ms) to show messages in the statusbar for.