Changing position without restart now possible.

This commit is contained in:
Joel Torstensson 2015-04-09 11:39:41 +02:00
parent 2fa66ba250
commit cc2c7c09ea
3 changed files with 39 additions and 26 deletions

View File

@ -235,10 +235,9 @@ def data(readonly=False):
SettingValue(typ.Perc(), '100%'), SettingValue(typ.Perc(), '100%'),
"The default zoom level."), "The default zoom level."),
('downloads-at-top', ('downloads-position',
SettingValue(typ.Bool(), 'true'), SettingValue(typ.VerticalPosition(), 'north'),
"Whether to show downloaded files at top, " "Where to show the downloaded files."),
"false will show at bottom."),
('message-timeout', ('message-timeout',
SettingValue(typ.Int(), '2000'), SettingValue(typ.Int(), '2000'),
@ -1011,7 +1010,6 @@ def data(readonly=False):
DATA = data(readonly=True) DATA = data(readonly=True)
KEY_FIRST_COMMENT = """ KEY_FIRST_COMMENT = """
# vim: ft=conf # vim: ft=conf
# #

View File

@ -1264,6 +1264,13 @@ class Position(BaseType):
return self.MAPPING[value] return self.MAPPING[value]
class VerticalPosition(BaseType):
"""The position of the download bar."""
valid_values = ValidValues('north', 'south')
class UrlList(List): class UrlList(List):
"""A list of URLs.""" """A list of URLs."""

View File

@ -90,18 +90,24 @@ class MainWindow(QWidget):
self._vbox.setContentsMargins(0, 0, 0, 0) self._vbox.setContentsMargins(0, 0, 0, 0)
self._vbox.setSpacing(0) self._vbox.setSpacing(0)
if config.get('ui', 'downloads-at-top'): log.init.debug("Initializing downloads...")
self._init_downloadview() download_manager = downloads.DownloadManager(self.win_id, self)
self._init_tabbed_browser() objreg.register('download-manager', download_manager, scope='window',
else: window=self.win_id)
self._init_tabbed_browser()
self._init_downloadview() 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 # 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 # show/hide magic immediately which would mean it'd show up as a
# window. # window.
self.status = bar.StatusBar(self.win_id, parent=self) 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) self._completion = completionwidget.CompletionView(self.win_id, self)
@ -134,22 +140,24 @@ class MainWindow(QWidget):
"""Resize the completion if related config options changed.""" """Resize the completion if related config options changed."""
if section == 'completion' and option in ('height', 'shrink'): if section == 'completion' and option in ('height', 'shrink'):
self.resize_completion() self.resize_completion()
elif section == 'ui' and option == 'downloads-position':
self._add_widgets()
def _init_downloadview(self): def _add_widgets(self):
log.init.debug("Initializing downloads...") self._vbox.removeWidget(self._tabbed_browser)
download_manager = downloads.DownloadManager(self.win_id, self) self._vbox.removeWidget(self._downloadview)
objreg.register('download-manager', download_manager, scope='window', self._vbox.removeWidget(self.status)
window=self.win_id) position = config.get('ui', 'downloads-position')
if position == 'north':
self._downloadview = downloadview.DownloadView(self.win_id)
self._vbox.addWidget(self._downloadview) 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) 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)
def _load_state_geometry(self): def _load_state_geometry(self):
"""Load the geometry from the state file.""" """Load the geometry from the state file."""