Add status-position option
See #1257. I can't think of a good way to do widget-packing because tabs can be on the left or right.
This commit is contained in:
parent
e3c6a0b766
commit
965459ab36
@ -272,6 +272,10 @@ def data(readonly=False):
|
|||||||
SettingValue(typ.VerticalPosition(), 'top'),
|
SettingValue(typ.VerticalPosition(), 'top'),
|
||||||
"Where to show the downloaded files."),
|
"Where to show the downloaded files."),
|
||||||
|
|
||||||
|
('status-position',
|
||||||
|
SettingValue(typ.VerticalPosition(), 'bottom'),
|
||||||
|
"The position of the status bar."),
|
||||||
|
|
||||||
('message-timeout',
|
('message-timeout',
|
||||||
SettingValue(typ.Int(), '2000'),
|
SettingValue(typ.Int(), '2000'),
|
||||||
"Time (in ms) to show messages in the statusbar for."),
|
"Time (in ms) to show messages in the statusbar for."),
|
||||||
|
@ -202,22 +202,35 @@ class MainWindow(QWidget):
|
|||||||
self.resize_completion()
|
self.resize_completion()
|
||||||
elif section == 'ui' and option == 'downloads-position':
|
elif section == 'ui' and option == 'downloads-position':
|
||||||
self._add_widgets()
|
self._add_widgets()
|
||||||
|
elif section == 'ui' and option == 'status-position':
|
||||||
|
self._add_widgets()
|
||||||
|
self.resize_completion()
|
||||||
|
|
||||||
def _add_widgets(self):
|
def _add_widgets(self):
|
||||||
"""Add or readd all widgets to the VBox."""
|
"""Add or readd all widgets to the VBox."""
|
||||||
self._vbox.removeWidget(self.tabbed_browser)
|
self._vbox.removeWidget(self.tabbed_browser)
|
||||||
self._vbox.removeWidget(self._downloadview)
|
self._vbox.removeWidget(self._downloadview)
|
||||||
self._vbox.removeWidget(self.status)
|
self._vbox.removeWidget(self.status)
|
||||||
position = config.get('ui', 'downloads-position')
|
downloads_position = config.get('ui', 'downloads-position')
|
||||||
if position == 'top':
|
status_position = config.get('ui', 'status-position')
|
||||||
self._vbox.addWidget(self._downloadview)
|
widgets = [self.tabbed_browser]
|
||||||
self._vbox.addWidget(self.tabbed_browser)
|
|
||||||
elif position == 'bottom':
|
if status_position == 'top':
|
||||||
self._vbox.addWidget(self.tabbed_browser)
|
widgets.insert(0, self.status)
|
||||||
self._vbox.addWidget(self._downloadview)
|
elif status_position == 'bottom':
|
||||||
|
widgets.append(self.status)
|
||||||
else:
|
else:
|
||||||
raise ValueError("Invalid position {}!".format(position))
|
raise ValueError("Invalid position {}!".format(status_position))
|
||||||
self._vbox.addWidget(self.status)
|
|
||||||
|
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):
|
def _load_state_geometry(self):
|
||||||
"""Load the geometry from the state file."""
|
"""Load the geometry from the state file."""
|
||||||
@ -370,12 +383,19 @@ class MainWindow(QWidget):
|
|||||||
height = contents_height
|
height = contents_height
|
||||||
else:
|
else:
|
||||||
contents_height = -1
|
contents_height = -1
|
||||||
# hpoint now would be the bottom-left edge of the widget if it was on
|
status_position = config.get('ui', 'status-position')
|
||||||
# the top of the main window.
|
if status_position == 'bottom':
|
||||||
topleft_y = self.height() - self.status.height() - height
|
top = self.height() - self.status.height() - height
|
||||||
topleft_y = qtutils.check_overflow(topleft_y, 'int', fatal=False)
|
top = qtutils.check_overflow(top, 'int', fatal=False)
|
||||||
topleft = QPoint(0, topleft_y)
|
topleft = QPoint(0, top)
|
||||||
bottomright = self.status.geometry().topRight()
|
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)
|
rect = QRect(topleft, bottomright)
|
||||||
log.misc.debug('completion rect: {}'.format(rect))
|
log.misc.debug('completion rect: {}'.format(rect))
|
||||||
if rect.isValid():
|
if rect.isValid():
|
||||||
|
Loading…
Reference in New Issue
Block a user