Move mode settings widget into the primary action layout, and tweak window size

This commit is contained in:
Micah Lee 2019-11-02 18:29:24 -07:00
parent f04452777d
commit 9f920f4353
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
6 changed files with 28 additions and 27 deletions

View File

@ -41,7 +41,7 @@ class MainWindow(QtWidgets.QMainWindow):
self.common.log("MainWindow", "__init__")
# Initialize the window
self.setMinimumWidth(820)
self.setMinimumWidth(1040)
self.setMinimumHeight(700)
self.setWindowTitle("OnionShare")
self.setWindowIcon(

View File

@ -86,12 +86,7 @@ class Mode(QtWidgets.QWidget):
self.starting_server_early.connect(self.start_server_early)
self.starting_server_error.connect(self.start_server_error)
# Header
# Note: It's up to the downstream Mode to add this to its layout
self.header_label = QtWidgets.QLabel()
self.header_label.setStyleSheet(self.common.gui.css["mode_header_label"])
self.header_label.setAlignment(QtCore.Qt.AlignHCenter)
# Mode settings widget
self.mode_settings_widget = ModeSettingsWidget(
self.common, self.tab.tab_id, self.tab.mode_settings
)
@ -100,26 +95,20 @@ class Mode(QtWidgets.QWidget):
self.server_status.update
)
header_layout = QtWidgets.QVBoxLayout()
header_layout.setContentsMargins(0, 0, 0, 0)
header_layout.addWidget(self.header_label)
header_layout.addWidget(self.mode_settings_widget)
self.header = QtWidgets.QWidget()
self.header.setLayout(header_layout)
# Header
# Note: It's up to the downstream Mode to add this to its layout
self.header_label = QtWidgets.QLabel()
self.header_label.setStyleSheet(self.common.gui.css["mode_header_label"])
self.header_label.setAlignment(QtCore.Qt.AlignHCenter)
# 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.addWidget(self.mode_settings_widget)
self.primary_action_layout.addWidget(self.server_status)
self.primary_action = QtWidgets.QWidget()
self.primary_action.setLayout(self.primary_action_layout)
# Hack to allow a minimum width on the main layout
# Note: It's up to the downstream Mode to add this to its layout
self.min_width_widget = QtWidgets.QWidget()
self.min_width_widget.setMinimumWidth(600)
def init(self):
"""
Add custom initialization here.

View File

@ -24,6 +24,7 @@ from onionshare.web import Web
from ..history import History, ToggleHistory, ReceiveHistoryItem
from .. import Mode
from ....widgets import MinimumWidthWidget
class ReceiveMode(Mode):
@ -111,7 +112,7 @@ class ReceiveMode(Mode):
self.main_layout.addWidget(receive_warning)
self.main_layout.addWidget(self.primary_action)
self.main_layout.addStretch()
self.main_layout.addWidget(self.min_width_widget)
self.main_layout.addWidget(MinimumWidthWidget(700))
# Column layout
self.column_layout = QtWidgets.QHBoxLayout()
@ -120,7 +121,7 @@ class ReceiveMode(Mode):
# Wrapper layout
self.wrapper_layout = QtWidgets.QVBoxLayout()
self.wrapper_layout.addWidget(self.header)
self.wrapper_layout.addWidget(self.header_label)
self.wrapper_layout.addLayout(self.column_layout)
self.setLayout(self.wrapper_layout)

View File

@ -29,7 +29,7 @@ from ..file_selection import FileSelection
from .threads import CompressThread
from .. import Mode
from ..history import History, ToggleHistory, ShareHistoryItem
from ....widgets import Alert
from ....widgets import Alert, MinimumWidthWidget
class ShareMode(Mode):
@ -137,7 +137,7 @@ class ShareMode(Mode):
self.main_layout.addLayout(top_bar_layout)
self.main_layout.addLayout(self.file_selection)
self.main_layout.addWidget(self.primary_action)
self.main_layout.addWidget(self.min_width_widget)
self.main_layout.addWidget(MinimumWidthWidget(700))
# Column layout
self.column_layout = QtWidgets.QHBoxLayout()
@ -146,7 +146,7 @@ class ShareMode(Mode):
# Wrapper layout
self.wrapper_layout = QtWidgets.QVBoxLayout()
self.wrapper_layout.addWidget(self.header)
self.wrapper_layout.addWidget(self.header_label)
self.wrapper_layout.addLayout(self.column_layout)
self.setLayout(self.wrapper_layout)

View File

@ -31,7 +31,7 @@ from onionshare.web import Web
from ..file_selection import FileSelection
from .. import Mode
from ..history import History, ToggleHistory
from ....widgets import Alert
from ....widgets import Alert, MinimumWidthWidget
class WebsiteMode(Mode):
@ -137,7 +137,7 @@ class WebsiteMode(Mode):
self.main_layout.addLayout(top_bar_layout)
self.main_layout.addLayout(self.file_selection)
self.main_layout.addWidget(self.primary_action)
self.main_layout.addWidget(self.min_width_widget)
self.main_layout.addWidget(MinimumWidthWidget(700))
# Column layout
self.column_layout = QtWidgets.QHBoxLayout()
@ -146,7 +146,7 @@ class WebsiteMode(Mode):
# Wrapper layout
self.wrapper_layout = QtWidgets.QVBoxLayout()
self.wrapper_layout.addWidget(self.header)
self.wrapper_layout.addWidget(self.header_label)
self.wrapper_layout.addLayout(self.column_layout)
self.setLayout(self.wrapper_layout)

View File

@ -79,3 +79,14 @@ class AddFileDialog(QtWidgets.QFileDialog):
def accept(self):
self.common.log("AddFileDialog", "accept")
QtWidgets.QDialog.accept(self)
class MinimumWidthWidget(QtWidgets.QWidget):
"""
An empty widget with a minimum width, just to force layouts to behave
"""
def __init__(self, width):
super(MinimumWidthWidget, self).__init__()
self.setMinimumWidth(width)