diff --git a/onionshare_gui/mode/__init__.py b/onionshare_gui/mode/__init__.py index cfbb235b..0971ff32 100644 --- a/onionshare_gui/mode/__init__.py +++ b/onionshare_gui/mode/__init__.py @@ -36,7 +36,6 @@ class Mode(QtWidgets.QWidget): starting_server_step3 = QtCore.pyqtSignal() starting_server_error = QtCore.pyqtSignal(str) set_server_active = QtCore.pyqtSignal(bool) - adjust_size = QtCore.pyqtSignal(int) def __init__(self, common, qtapp, app, status_bar, server_status_label, system_tray, filenames=None, local_only=False): super(Mode, self).__init__() @@ -50,8 +49,6 @@ class Mode(QtWidgets.QWidget): self.filenames = filenames - self.setMinimumWidth(self.common.min_window_width) - # The web object gets created in init() self.web = None @@ -83,7 +80,7 @@ class Mode(QtWidgets.QWidget): # 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(self.common.min_window_width) + self.min_width_widget.setMinimumWidth(600) def init(self): """ @@ -332,23 +329,3 @@ class Mode(QtWidgets.QWidget): Handle REQUEST_UPLOAD_FINISHED event. """ pass - - def resize_window(self): - """ - We call this to force the OnionShare window to resize itself to be smaller. - For this to do anything, the Mode needs to override it and call: - - self.adjust_size.emit(min_width) - - It can calculate min_width (the new minimum window width) based on what - widgets are visible. - """ - pass - - def show(self): - """ - Always resize the window after showing this Mode widget. - """ - super(Mode, self).show() - self.qtapp.processEvents() - self.resize_window() diff --git a/onionshare_gui/mode/receive_mode/__init__.py b/onionshare_gui/mode/receive_mode/__init__.py index ffa259e7..66e0bbe7 100644 --- a/onionshare_gui/mode/receive_mode/__init__.py +++ b/onionshare_gui/mode/receive_mode/__init__.py @@ -196,12 +196,3 @@ class ReceiveMode(Mode): def update_primary_action(self): self.common.log('ReceiveMode', 'update_primary_action') - - # Resize window - self.resize_window() - - def resize_window(self): - min_width = self.common.min_window_width - if self.history.isVisible(): - min_width += 300 - self.adjust_size.emit(min_width) diff --git a/onionshare_gui/mode/share_mode/__init__.py b/onionshare_gui/mode/share_mode/__init__.py index 0bf094c0..b3d7c549 100644 --- a/onionshare_gui/mode/share_mode/__init__.py +++ b/onionshare_gui/mode/share_mode/__init__.py @@ -321,21 +321,12 @@ class ShareMode(Mode): self.primary_action.hide() self.info_label.hide() - # Resize window - self.resize_window() - def reset_info_counters(self): """ Set the info counters back to zero. """ self.history.reset() - def resize_window(self): - min_width = self.common.min_window_width - if self.history.isVisible(): - min_width += 300 - self.adjust_size.emit(min_width) - @staticmethod def _compute_total_size(filenames): total_size = 0 diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py index 35088ebe..9a71ae28 100644 --- a/onionshare_gui/onionshare_gui.py +++ b/onionshare_gui/onionshare_gui.py @@ -45,7 +45,7 @@ class OnionShareGui(QtWidgets.QMainWindow): self.common = common self.common.log('OnionShareGui', '__init__') - self.common.min_window_width = 460 + self.setMinimumWidth(700) self.onion = onion self.qtapp = qtapp @@ -133,7 +133,6 @@ class OnionShareGui(QtWidgets.QMainWindow): self.share_mode.server_status.url_copied.connect(self.copy_url) self.share_mode.server_status.hidservauth_copied.connect(self.copy_hidservauth) self.share_mode.set_server_active.connect(self.set_server_active) - self.share_mode.adjust_size.connect(self.adjust_size) # Receive mode self.receive_mode = ReceiveMode(self.common, qtapp, app, self.status_bar, self.server_status_label, self.system_tray, None, self.local_only) @@ -148,7 +147,6 @@ class OnionShareGui(QtWidgets.QMainWindow): self.receive_mode.server_status.url_copied.connect(self.copy_url) self.receive_mode.server_status.hidservauth_copied.connect(self.copy_hidservauth) self.receive_mode.set_server_active.connect(self.set_server_active) - self.receive_mode.adjust_size.connect(self.adjust_size) self.update_mode_switcher() self.update_server_status_indicator() @@ -169,9 +167,6 @@ class OnionShareGui(QtWidgets.QMainWindow): self.setCentralWidget(central_widget) self.show() - # Adjust window size, to start with a minimum window width - self.adjust_size(self.common.min_window_width) - # The server isn't active yet self.set_server_active(False) @@ -200,14 +195,12 @@ class OnionShareGui(QtWidgets.QMainWindow): self.receive_mode_button.setStyleSheet(self.common.css['mode_switcher_unselected_style']) self.receive_mode.hide() - self.adjust_size(self.common.min_window_width) self.share_mode.show() else: self.share_mode_button.setStyleSheet(self.common.css['mode_switcher_unselected_style']) self.receive_mode_button.setStyleSheet(self.common.css['mode_switcher_selected_style']) self.share_mode.hide() - self.adjust_size(self.common.min_window_width) self.receive_mode.show() self.update_server_status_indicator() @@ -450,40 +443,6 @@ class OnionShareGui(QtWidgets.QMainWindow): # Disable settings menu action when server is active self.settings_action.setEnabled(not active) - def adjust_size(self, min_width): - """ - Recursively adjust size on all widgets. min_width is the new minimum width - of the window. - """ - self.setMinimumWidth(min_width) - - 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) - widget.adjustSize() - - # Adjust sizes of each mode - for mode in [self.share_mode, self.receive_mode]: - self.qtapp.processEvents() - adjust_size_widget(mode) - - # Adjust window size - self.qtapp.processEvents() - self.adjustSize() - def closeEvent(self, e): self.common.log('OnionShareGui', 'closeEvent') try: