From aadb2a01f0ced1f31268adb6237f9ddd0bbc849a Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Wed, 5 Dec 2018 20:14:52 -0800 Subject: Only show onion settings if there is a Tor connection --- onionshare/common.py | 5 +++++ onionshare_gui/settings_dialog.py | 32 ++++++++++++++++++++++++++------ share/locale/en.json | 1 + 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/onionshare/common.py b/onionshare/common.py index ffa6529f..250972f9 100644 --- a/onionshare/common.py +++ b/onionshare/common.py @@ -373,6 +373,11 @@ class Common(object): 'settings_whats_this': """ QLabel { font-size: 12px; + }""", + + 'settings_connect_to_tor': """ + QLabel { + font-style: italic; }""" } diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py index 958d49fd..37cc9105 100644 --- a/onionshare_gui/settings_dialog.py +++ b/onionshare_gui/settings_dialog.py @@ -88,6 +88,10 @@ class SettingsDialog(QtWidgets.QDialog): self.shutdown_timeout_widget = QtWidgets.QWidget() self.shutdown_timeout_widget.setLayout(shutdown_timeout_layout) + # Label telling user to connect to Tor for onion service settings + connect_to_tor_label = QtWidgets.QLabel(strings._("gui_connect_to_tor_for_onion_settings")) + connect_to_tor_label.setStyleSheet(self.common.css['settings_connect_to_tor']) + # Whether or not to use legacy v2 onions self.use_legacy_v2_onions_checkbox = QtWidgets.QCheckBox() self.use_legacy_v2_onions_checkbox.setCheckState(QtCore.Qt.Unchecked) @@ -149,16 +153,32 @@ class SettingsDialog(QtWidgets.QDialog): self.hidservauth_copy_button.clicked.connect(self.hidservauth_copy_button_clicked) self.hidservauth_copy_button.hide() + # Onion settings widget + onion_settings_layout = QtWidgets.QVBoxLayout() + onion_settings_layout.setContentsMargins(0, 0, 0, 0) + onion_settings_layout.addWidget(self.use_legacy_v2_onions_widget) + onion_settings_layout.addWidget(self.save_private_key_widget) + onion_settings_layout.addWidget(self.use_stealth_widget) + onion_settings_layout.addWidget(hidservauth_details) + onion_settings_layout.addWidget(self.hidservauth_copy_button) + onion_settings_widget = QtWidgets.QWidget() + onion_settings_widget.setLayout(onion_settings_layout) + + # If we're connected to Tor, show onion service settings, show label if not + if self.onion.is_authenticated(): + connect_to_tor_label.hide() + onion_settings_widget.show() + else: + connect_to_tor_label.show() + onion_settings_widget.hide() + + # General options layout general_group_layout = QtWidgets.QVBoxLayout() general_group_layout.addWidget(self.public_mode_widget) general_group_layout.addWidget(self.shutdown_timeout_widget) - general_group_layout.addWidget(self.use_legacy_v2_onions_widget) - general_group_layout.addWidget(self.save_private_key_widget) - general_group_layout.addWidget(self.use_stealth_widget) - general_group_layout.addWidget(hidservauth_details) - general_group_layout.addWidget(self.hidservauth_copy_button) - + general_group_layout.addWidget(connect_to_tor_label) + general_group_layout.addWidget(onion_settings_widget) general_group = QtWidgets.QGroupBox(strings._("gui_settings_general_label")) general_group.setLayout(general_group_layout) diff --git a/share/locale/en.json b/share/locale/en.json index 7fb30df8..c38bfdff 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -135,6 +135,7 @@ "gui_server_started_after_timeout": "The auto-stop timer ran out before the server started.\nPlease make a new share.", "gui_server_timeout_expired": "The auto-stop timer already ran out.\nPlease update it to start sharing.", "share_via_onionshare": "OnionShare it", + "gui_connect_to_tor_for_onion_settings": "Connect to Tor to see onion service settings", "gui_use_legacy_v2_onions_checkbox": "Use legacy addresses", "gui_save_private_key_checkbox": "Use a persistent address (legacy)", "gui_share_url_description": "Anyone with this OnionShare address can download your files using the Tor Browser: ", -- cgit v1.2.3-54-g00ecf