From f23e2a8a9070773f7599f132115f8838a3d5dbdc Mon Sep 17 00:00:00 2001 From: Micah Lee <micah@micahflee.com> Date: Mon, 5 Feb 2018 18:20:09 -0800 Subject: [PATCH] Progressively hide shutdown timer-related UI, so only relevant widgets are shown at any time --- onionshare_gui/server_status.py | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/onionshare_gui/server_status.py b/onionshare_gui/server_status.py index 7d4576f1..e4e5431c 100644 --- a/onionshare_gui/server_status.py +++ b/onionshare_gui/server_status.py @@ -66,10 +66,16 @@ class ServerStatus(QtWidgets.QVBoxLayout): self.server_shutdown_timeout.setCurrentSectionIndex(4) self.server_shutdown_timeout_label.hide() self.server_shutdown_timeout.hide() - shutdown_timeout_layout_group = QtWidgets.QHBoxLayout() - shutdown_timeout_layout_group.addWidget(self.server_shutdown_timeout_checkbox) - shutdown_timeout_layout_group.addWidget(self.server_shutdown_timeout_label) - shutdown_timeout_layout_group.addWidget(self.server_shutdown_timeout) + shutdown_timeout_layout = QtWidgets.QHBoxLayout() + shutdown_timeout_layout.addWidget(self.server_shutdown_timeout_label) + shutdown_timeout_layout.addWidget(self.server_shutdown_timeout) + + # Shutdown timeout container, so it can all be hidden and shown as a group + shutdown_timeout_container_layout = QtWidgets.QVBoxLayout() + shutdown_timeout_container_layout.addWidget(self.server_shutdown_timeout_checkbox) + shutdown_timeout_container_layout.addLayout(shutdown_timeout_layout) + self.server_shutdown_timeout_container = QtWidgets.QWidget() + self.server_shutdown_timeout_container.setLayout(shutdown_timeout_container_layout) # Server layout self.status_image_stopped = QtGui.QImage(common.get_resource_path('images/server_stopped.png')) @@ -101,7 +107,7 @@ class ServerStatus(QtWidgets.QVBoxLayout): # Add the widgets self.addLayout(server_layout) self.addLayout(url_layout) - self.addLayout(shutdown_timeout_layout_group) + self.addWidget(self.server_shutdown_timeout_container) self.update() @@ -173,6 +179,17 @@ class ServerStatus(QtWidgets.QVBoxLayout): self.server_button.hide() else: self.server_button.show() + + if self.status == self.STATUS_STOPPED: + self.server_shutdown_timeout_checkbox.show() + self.server_shutdown_timeout_container.show() + else: + self.server_shutdown_timeout_checkbox.hide() + if self.server_shutdown_timeout_checkbox.isChecked(): + self.server_shutdown_timeout_container.show() + else: + self.server_shutdown_timeout_container.hide() + if self.status == self.STATUS_STOPPED: self.server_button.setStyleSheet(button_stopped_style) self.server_button.setEnabled(True)