mirror of
https://github.com/onionshare/onionshare.git
synced 2025-02-14 21:51:32 -05:00
OnionShareGui.adjust_size now recursively runs adjustSize() on all widgets
This commit is contained in:
parent
e1bd0b5bab
commit
7bd5f686a9
@ -445,8 +445,35 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
|||||||
self.settings_action.setEnabled(not active)
|
self.settings_action.setEnabled(not active)
|
||||||
|
|
||||||
def adjust_size(self):
|
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()
|
self.adjustSize()
|
||||||
|
|
||||||
def closeEvent(self, e):
|
def closeEvent(self, e):
|
||||||
|
@ -94,11 +94,11 @@ class ReceiveMode(Mode):
|
|||||||
self.main_layout.addStretch()
|
self.main_layout.addStretch()
|
||||||
self.main_layout.addWidget(self.min_width_widget)
|
self.main_layout.addWidget(self.min_width_widget)
|
||||||
|
|
||||||
# Layout
|
# Wrapper layout
|
||||||
self.layout = QtWidgets.QHBoxLayout()
|
self.wrapper_layout = QtWidgets.QHBoxLayout()
|
||||||
self.layout.addLayout(self.main_layout)
|
self.wrapper_layout.addLayout(self.main_layout)
|
||||||
self.layout.addWidget(self.uploads)
|
self.wrapper_layout.addWidget(self.uploads)
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.wrapper_layout)
|
||||||
|
|
||||||
def get_stop_server_shutdown_timeout_text(self):
|
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.primary_action)
|
||||||
self.main_layout.addWidget(self.min_width_widget)
|
self.main_layout.addWidget(self.min_width_widget)
|
||||||
|
|
||||||
# Layout
|
# Wrapper layout
|
||||||
self.layout = QtWidgets.QHBoxLayout()
|
self.wrapper_layout = QtWidgets.QHBoxLayout()
|
||||||
self.layout.addLayout(self.main_layout)
|
self.wrapper_layout.addLayout(self.main_layout)
|
||||||
self.layout.addWidget(self.downloads)
|
self.wrapper_layout.addWidget(self.downloads)
|
||||||
self.setLayout(self.layout)
|
self.setLayout(self.wrapper_layout)
|
||||||
|
|
||||||
# Always start with focus on file selection
|
# Always start with focus on file selection
|
||||||
self.file_selection.setFocus()
|
self.file_selection.setFocus()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user