From 284679885874a9418ed4ada47bbff286b37968cf Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Sat, 20 May 2017 13:56:20 +1000 Subject: [PATCH 1/3] Add help button to settings dialog, which takes user to the wiki --- onionshare_gui/settings_dialog.py | 19 ++++++++++++++++++- share/locale/en.json | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py index 79a35101..64e47dd4 100644 --- a/onionshare_gui/settings_dialog.py +++ b/onionshare_gui/settings_dialog.py @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ from PyQt5 import QtCore, QtWidgets, QtGui -import sys, platform, datetime +import os, sys, platform, datetime, webbrowser from onionshare import strings, common from onionshare.settings import Settings @@ -213,10 +213,13 @@ class SettingsDialog(QtWidgets.QDialog): self.save_button.clicked.connect(self.save_clicked) self.cancel_button = QtWidgets.QPushButton(strings._('gui_settings_button_cancel', True)) self.cancel_button.clicked.connect(self.cancel_clicked) + self.help_button = QtWidgets.QPushButton(strings._('gui_settings_button_help', True)) + self.help_button.clicked.connect(self.help_clicked) buttons_layout = QtWidgets.QHBoxLayout() buttons_layout.addStretch() buttons_layout.addWidget(self.save_button) buttons_layout.addWidget(self.cancel_button) + buttons_layout.addWidget(self.help_button) # Tor network connection status self.tor_status = QtWidgets.QLabel() @@ -490,6 +493,20 @@ class SettingsDialog(QtWidgets.QDialog): common.log('SettingsDialog', 'cancel_clicked') self.close() + def help_clicked(self): + """ + Help button clicked. + """ + common.log('SettingsDialog', 'help_clicked') + help_site = 'https://github.com/micahflee/onionshare/wiki' + system = platform.system() + if system == 'Darwin': + # Work around bug in webbrowser on OS X + # see http://bugs.python.org/issue30392 + os.system('open {}'.format(help_site)) + else: + webbrowser.open(help_site) + def settings_from_fields(self): """ Return a Settings object that's full of values from the settings dialog. diff --git a/share/locale/en.json b/share/locale/en.json index 701b067c..c1c14263 100644 --- a/share/locale/en.json +++ b/share/locale/en.json @@ -81,6 +81,7 @@ "gui_settings_cookie_label": "Cookie path", "gui_settings_button_save": "Save", "gui_settings_button_cancel": "Cancel", + "gui_settings_button_help": "Help", "settings_saved": "Settings saved to {}", "settings_error_unknown": "Can't connect to Tor controller because the settings don't make sense.", "settings_error_automatic": "Can't connect to Tor controller. Is Tor Browser running in the background? If you don't have it you can get it from:\nhttps://www.torproject.org/.", From aa7e609e14e79cbb2421b8450fa6aa3300877ee3 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Sat, 20 May 2017 14:04:52 +1000 Subject: [PATCH 2/3] move the help button to the left --- onionshare_gui/settings_dialog.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py index 64e47dd4..5086477f 100644 --- a/onionshare_gui/settings_dialog.py +++ b/onionshare_gui/settings_dialog.py @@ -216,10 +216,10 @@ class SettingsDialog(QtWidgets.QDialog): self.help_button = QtWidgets.QPushButton(strings._('gui_settings_button_help', True)) self.help_button.clicked.connect(self.help_clicked) buttons_layout = QtWidgets.QHBoxLayout() + buttons_layout.addWidget(self.help_button) buttons_layout.addStretch() buttons_layout.addWidget(self.save_button) buttons_layout.addWidget(self.cancel_button) - buttons_layout.addWidget(self.help_button) # Tor network connection status self.tor_status = QtWidgets.QLabel() From 8bc280ff7a48c7b4311e63552b1e93baaa446bfa Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Tue, 23 May 2017 08:30:24 +1000 Subject: [PATCH 3/3] Refactor help button to use QDesktopServices.openUrl() --- onionshare_gui/settings_dialog.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py index 5086477f..b1967247 100644 --- a/onionshare_gui/settings_dialog.py +++ b/onionshare_gui/settings_dialog.py @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . """ from PyQt5 import QtCore, QtWidgets, QtGui -import os, sys, platform, datetime, webbrowser +import sys, platform, datetime from onionshare import strings, common from onionshare.settings import Settings @@ -499,13 +499,7 @@ class SettingsDialog(QtWidgets.QDialog): """ common.log('SettingsDialog', 'help_clicked') help_site = 'https://github.com/micahflee/onionshare/wiki' - system = platform.system() - if system == 'Darwin': - # Work around bug in webbrowser on OS X - # see http://bugs.python.org/issue30392 - os.system('open {}'.format(help_site)) - else: - webbrowser.open(help_site) + QtGui.QDesktopServices.openUrl(QtCore.QUrl(help_site)) def settings_from_fields(self): """