From 39dd0862d4c02391fa32bf5fd97b0ec721425abb Mon Sep 17 00:00:00 2001
From: Micah Lee <micah@micahflee.com>
Date: Sat, 29 Sep 2018 15:12:05 -0700
Subject: [PATCH] Increase minimum window with to 460, and store it in a
 variable to stop repeating myself

---
 onionshare_gui/mode.py                  | 4 ++--
 onionshare_gui/onionshare_gui.py        | 4 +++-
 onionshare_gui/receive_mode/__init__.py | 2 +-
 onionshare_gui/share_mode/__init__.py   | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/onionshare_gui/mode.py b/onionshare_gui/mode.py
index 0fba029b..1a961149 100644
--- a/onionshare_gui/mode.py
+++ b/onionshare_gui/mode.py
@@ -50,7 +50,7 @@ class Mode(QtWidgets.QWidget):
 
         self.filenames = filenames
 
-        self.setMinimumWidth(450)
+        self.setMinimumWidth(self.common.min_window_width)
 
         # The web object gets created in init()
         self.web = None
@@ -83,7 +83,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(450)
+        self.min_width_widget.setMinimumWidth(self.common.min_window_width)
 
     def init(self):
         """
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index dd15fe12..ced53ede 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -45,6 +45,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
 
         self.common = common
         self.common.log('OnionShareGui', '__init__')
+        self.common.min_window_width = 460
 
         self.onion = onion
         self.qtapp = qtapp
@@ -169,7 +170,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
         self.show()
 
         # Adjust window size, to start with a minimum window width
-        self.adjust_size(450)
+        self.adjust_size(self.common.min_window_width)
 
         # The server isn't active yet
         self.set_server_active(False)
@@ -474,6 +475,7 @@ class OnionShareGui(QtWidgets.QMainWindow):
 
         # Adjust sizes of each mode
         for mode in [self.share_mode, self.receive_mode]:
+            self.qtapp.processEvents()
             adjust_size_widget(mode)
 
         # Adjust window size
diff --git a/onionshare_gui/receive_mode/__init__.py b/onionshare_gui/receive_mode/__init__.py
index 2f61b2ca..6430382b 100644
--- a/onionshare_gui/receive_mode/__init__.py
+++ b/onionshare_gui/receive_mode/__init__.py
@@ -194,7 +194,7 @@ class ReceiveMode(Mode):
         self.resize_window()
 
     def resize_window(self):
-        min_width = 450
+        min_width = self.common.min_window_width
         if self.uploads.isVisible():
             min_width += 300
         self.adjust_size.emit(min_width)
diff --git a/onionshare_gui/share_mode/__init__.py b/onionshare_gui/share_mode/__init__.py
index 58801c45..c44e8beb 100644
--- a/onionshare_gui/share_mode/__init__.py
+++ b/onionshare_gui/share_mode/__init__.py
@@ -317,7 +317,7 @@ class ShareMode(Mode):
         self.downloads.reset()
 
     def resize_window(self):
-        min_width = 450
+        min_width = self.common.min_window_width
         if self.downloads.isVisible():
             min_width += 300
         self.adjust_size.emit(min_width)