Merge branch 'status-position' of https://github.com/blyxxyz/qutebrowser into blyxxyz-status-position

This commit is contained in:
Florian Bruhin 2016-07-06 13:56:55 +02:00
commit 794a275383
3 changed files with 51 additions and 15 deletions

View File

@ -33,6 +33,7 @@
|<<ui-zoom-levels,zoom-levels>>|The available zoom levels, separated by commas.
|<<ui-default-zoom,default-zoom>>|The default zoom level.
|<<ui-downloads-position,downloads-position>>|Where to show the downloaded files.
|<<ui-status-position,status-position>>|The position of the status bar.
|<<ui-message-timeout,message-timeout>>|Time (in ms) to show messages in the statusbar for.
|<<ui-message-unfocused,message-unfocused>>|Whether to show messages in unfocused windows.
|<<ui-confirm-quit,confirm-quit>>|Whether to confirm quitting the application.
@ -516,6 +517,17 @@ Valid values:
Default: +pass:[top]+
[[ui-status-position]]
=== status-position
The position of the status bar.
Valid values:
* +top+
* +bottom+
Default: +pass:[bottom]+
[[ui-message-timeout]]
=== message-timeout
Time (in ms) to show messages in the statusbar for.

View File

@ -272,6 +272,10 @@ def data(readonly=False):
SettingValue(typ.VerticalPosition(), 'top'),
"Where to show the downloaded files."),
('status-position',
SettingValue(typ.VerticalPosition(), 'bottom'),
"The position of the status bar."),
('message-timeout',
SettingValue(typ.Int(), '2000'),
"Time (in ms) to show messages in the statusbar for."),

View File

@ -202,22 +202,35 @@ class MainWindow(QWidget):
self.resize_completion()
elif section == 'ui' and option == 'downloads-position':
self._add_widgets()
elif section == 'ui' and option == 'status-position':
self._add_widgets()
self.resize_completion()
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)
position = config.get('ui', 'downloads-position')
if position == 'top':
self._vbox.addWidget(self._downloadview)
self._vbox.addWidget(self.tabbed_browser)
elif position == 'bottom':
self._vbox.addWidget(self.tabbed_browser)
self._vbox.addWidget(self._downloadview)
downloads_position = config.get('ui', 'downloads-position')
status_position = config.get('ui', 'status-position')
widgets = [self.tabbed_browser]
if status_position == 'top':
widgets.insert(0, self.status)
elif status_position == 'bottom':
widgets.append(self.status)
else:
raise ValueError("Invalid position {}!".format(position))
self._vbox.addWidget(self.status)
raise ValueError("Invalid position {}!".format(status_position))
if downloads_position == 'top':
widgets.insert(0, self._downloadview)
elif downloads_position == 'bottom':
widgets.append(self._downloadview)
else:
raise ValueError("Invalid position {}!".format(downloads_position))
for widget in widgets:
self._vbox.addWidget(widget)
def _load_state_geometry(self):
"""Load the geometry from the state file."""
@ -370,12 +383,19 @@ class MainWindow(QWidget):
height = contents_height
else:
contents_height = -1
# hpoint now would be the bottom-left edge of the widget if it was on
# the top of the main window.
topleft_y = self.height() - self.status.height() - height
topleft_y = qtutils.check_overflow(topleft_y, 'int', fatal=False)
topleft = QPoint(0, topleft_y)
bottomright = self.status.geometry().topRight()
status_position = config.get('ui', 'status-position')
if status_position == 'bottom':
top = self.height() - self.status.height() - height
top = qtutils.check_overflow(top, 'int', fatal=False)
topleft = QPoint(0, top)
bottomright = self.status.geometry().topRight()
elif status_position == 'top':
topleft = self.status.geometry().bottomLeft()
bottom = self.status.height() + height
bottom = qtutils.check_overflow(bottom, 'int', fatal=False)
bottomright = QPoint(self.width(), bottom)
else:
raise ValueError("Invalid position {}!".format(status_position))
rect = QRect(topleft, bottomright)
log.misc.debug('completion rect: {}'.format(rect))
if rect.isValid():