mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-14 00:39:33 -05:00
OnionShareGui.adjust_size now recursively runs adjustSize() on all widgets
This commit is contained in:
parent
4bec79f494
commit
e29bb99f16
@ -445,8 +445,35 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
self.settings_action.setEnabled(not active)
|
||||
|
||||
def adjust_size(self):
|
||||
self.share_mode.adjustSize()
|
||||
self.receive_mode.adjustSize()
|
||||
"""
|
||||
Recursively adjust size on all widgets
|
||||
"""
|
||||
# Recursively adjust sizes for the modes
|
||||
def adjust_size_layout(layout):
|
||||
count = layout.count()
|
||||
for i in range(count):
|
||||
item = layout.itemAt(i)
|
||||
if item:
|
||||
child_widget = item.widget()
|
||||
if child_widget:
|
||||
adjust_size_widget(child_widget)
|
||||
child_layout = item.layout()
|
||||
if child_layout:
|
||||
adjust_size_layout(child_layout)
|
||||
|
||||
def adjust_size_widget(widget):
|
||||
layout = widget.layout()
|
||||
if layout:
|
||||
adjust_size_layout(layout)
|
||||
# Processing Qt events before adjusting size makes each .adjustSize() actually count
|
||||
self.qtapp.processEvents()
|
||||
widget.adjustSize()
|
||||
|
||||
# Adjust sizes of each mode
|
||||
for mode in [self.share_mode, self.receive_mode]:
|
||||
adjust_size_widget(mode)
|
||||
|
||||
# Adjust window size
|
||||
self.adjustSize()
|
||||
|
||||
def closeEvent(self, e):
|
||||
|
@ -94,11 +94,11 @@ class ReceiveMode(Mode):
|
||||
self.main_layout.addStretch()
|
||||
self.main_layout.addWidget(self.min_width_widget)
|
||||
|
||||
# Layout
|
||||
self.layout = QtWidgets.QHBoxLayout()
|
||||
self.layout.addLayout(self.main_layout)
|
||||
self.layout.addWidget(self.uploads)
|
||||
self.setLayout(self.layout)
|
||||
# Wrapper layout
|
||||
self.wrapper_layout = QtWidgets.QHBoxLayout()
|
||||
self.wrapper_layout.addLayout(self.main_layout)
|
||||
self.wrapper_layout.addWidget(self.uploads)
|
||||
self.setLayout(self.wrapper_layout)
|
||||
|
||||
def get_stop_server_shutdown_timeout_text(self):
|
||||
"""
|
||||
|
@ -122,11 +122,11 @@ class ShareMode(Mode):
|
||||
self.main_layout.addWidget(self.primary_action)
|
||||
self.main_layout.addWidget(self.min_width_widget)
|
||||
|
||||
# Layout
|
||||
self.layout = QtWidgets.QHBoxLayout()
|
||||
self.layout.addLayout(self.main_layout)
|
||||
self.layout.addWidget(self.downloads)
|
||||
self.setLayout(self.layout)
|
||||
# Wrapper layout
|
||||
self.wrapper_layout = QtWidgets.QHBoxLayout()
|
||||
self.wrapper_layout.addLayout(self.main_layout)
|
||||
self.wrapper_layout.addWidget(self.downloads)
|
||||
self.setLayout(self.wrapper_layout)
|
||||
|
||||
# Always start with focus on file selection
|
||||
self.file_selection.setFocus()
|
||||
|
Loading…
Reference in New Issue
Block a user