Refactor how Mode layouts work, so the downstream Mode has more control over the UI

This commit is contained in:
Micah Lee 2018-09-28 12:51:30 -07:00
parent 2ffcdbb108
commit fc1902c1ee
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
3 changed files with 29 additions and 20 deletions

View File

@ -72,24 +72,17 @@ class Mode(QtWidgets.QWidget):
self.starting_server_step3.connect(self.start_server_step3) self.starting_server_step3.connect(self.start_server_step3)
self.starting_server_error.connect(self.start_server_error) self.starting_server_error.connect(self.start_server_error)
# Primary action layout # Primary action
# Note: It's up to the downstream Mode to add this to its layout
self.primary_action_layout = QtWidgets.QVBoxLayout() self.primary_action_layout = QtWidgets.QVBoxLayout()
self.primary_action_layout.addWidget(self.server_status) self.primary_action_layout.addWidget(self.server_status)
self.primary_action = QtWidgets.QWidget() self.primary_action = QtWidgets.QWidget()
self.primary_action.setLayout(self.primary_action_layout) self.primary_action.setLayout(self.primary_action_layout)
# Layout # Hack to allow a minimum width on the main layout
self.layout = QtWidgets.QVBoxLayout() # Note: It's up to the downstream Mode to add this to its layout
self.layout.addWidget(self.primary_action) self.min_width_widget = QtWidgets.QWidget()
# Hack to allow a minimum width on self.layout self.min_width_widget.setMinimumWidth(450)
min_width_widget = QtWidgets.QWidget()
min_width_widget.setMinimumWidth(450)
self.layout.addWidget(min_width_widget)
self.horizontal_layout_wrapper = QtWidgets.QHBoxLayout()
self.horizontal_layout_wrapper.addLayout(self.layout)
self.setLayout(self.horizontal_layout_wrapper)
def init(self): def init(self):
""" """

View File

@ -76,11 +76,19 @@ class ReceiveMode(Mode):
self.receive_info.setMinimumHeight(80) self.receive_info.setMinimumHeight(80)
self.receive_info.setWordWrap(True) self.receive_info.setWordWrap(True)
# Main layout
self.main_layout = QtWidgets.QVBoxLayout()
self.main_layout.addWidget(self.info_widget)
self.main_layout.addWidget(self.receive_info)
self.main_layout.addWidget(self.primary_action)
self.main_layout.addStretch()
self.main_layout.addWidget(self.min_width_widget)
# Layout # Layout
self.layout.insertWidget(0, self.receive_info) self.layout = QtWidgets.QHBoxLayout()
self.layout.insertWidget(0, self.info_widget) self.layout.addLayout(self.main_layout)
self.layout.addStretch() self.layout.addWidget(self.uploads)
self.horizontal_layout_wrapper.addWidget(self.uploads) self.setLayout(self.layout)
def get_stop_server_shutdown_timeout_text(self): def get_stop_server_shutdown_timeout_text(self):
""" """

View File

@ -106,10 +106,18 @@ class ShareMode(Mode):
# Status bar, zip progress bar # Status bar, zip progress bar
self._zip_progress_bar = None self._zip_progress_bar = None
# Main layout
self.main_layout = QtWidgets.QVBoxLayout()
self.main_layout.addWidget(self.info_widget)
self.main_layout.addLayout(self.file_selection)
self.main_layout.addWidget(self.primary_action)
self.main_layout.addWidget(self.min_width_widget)
# Layout # Layout
self.layout.insertLayout(0, self.file_selection) self.layout = QtWidgets.QHBoxLayout()
self.layout.insertWidget(0, self.info_widget) self.layout.addLayout(self.main_layout)
self.horizontal_layout_wrapper.addWidget(self.downloads) self.layout.addWidget(self.downloads)
self.setLayout(self.layout)
# Always start with focus on file selection # Always start with focus on file selection
self.file_selection.setFocus() self.file_selection.setFocus()