[Pkg-privacy-commits] [onionshare] 142/256: Added autoupdate settings to Settings, and also to the settings dialog

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:29 UTC 2017


This is an automated email from the git hooks/post-receive script.

ulrike pushed a commit to branch master
in repository onionshare.

commit 4b11bd00c5f4b379893a5296bfa903d02790bcc7
Author: Micah Lee <micah at micahflee.com>
Date:   Sat Apr 15 15:24:08 2017 -0700

    Added autoupdate settings to Settings, and also to the settings dialog
---
 onionshare/settings.py            |  4 ++-
 onionshare_gui/settings_dialog.py | 68 +++++++++++++++++++++++++++++++++------
 share/locale/en.json              |  5 +++
 3 files changed, 66 insertions(+), 11 deletions(-)

diff --git a/onionshare/settings.py b/onionshare/settings.py
index 0132a1c..2e0b68e 100644
--- a/onionshare/settings.py
+++ b/onionshare/settings.py
@@ -42,7 +42,9 @@ class Settings(object):
             'auth_type': 'no_auth',
             'auth_password': '',
             'close_after_first_download': True,
-            'use_stealth': False
+            'use_stealth': False,
+            'use_autoupdate': True,
+            'autoupdate_timestamp': None
         }
         self._settings = {}
         self.fill_in_defaults()
diff --git a/onionshare_gui/settings_dialog.py b/onionshare_gui/settings_dialog.py
index 5e7f957..447a97d 100644
--- a/onionshare_gui/settings_dialog.py
+++ b/onionshare_gui/settings_dialog.py
@@ -38,6 +38,8 @@ class SettingsDialog(QtWidgets.QDialog):
         self.setWindowTitle(strings._('gui_settings_window_title', True))
         self.setWindowIcon(QtGui.QIcon(helpers.get_resource_path('images/logo.png')))
 
+        system = platform.system()
+
         # Sharing options
 
         # Close after first download
@@ -67,6 +69,32 @@ class SettingsDialog(QtWidgets.QDialog):
         stealth_group = QtWidgets.QGroupBox(strings._("gui_settings_stealth_label", True))
         stealth_group.setLayout(stealth_group_layout)
 
+        # Automatic updates options
+
+        # Autoupdate
+        self.autoupdate_checkbox = QtWidgets.QCheckBox()
+        self.autoupdate_checkbox.setCheckState(QtCore.Qt.Unchecked)
+        self.autoupdate_checkbox.setText(strings._("gui_settings_autoupdate_option", True))
+
+        # Last update time
+        self.autoupdate_timestamp = QtWidgets.QLabel()
+
+        # Check for updates button
+        self.check_for_updates_button = QtWidgets.QPushButton(strings._('gui_settings_autoupdate_check_button', True))
+        self.check_for_updates_button.clicked.connect(self.check_for_updates)
+
+        # Autoupdate options layout
+        autoupdate_group_layout = QtWidgets.QVBoxLayout()
+        autoupdate_group_layout.addWidget(self.autoupdate_checkbox)
+        autoupdate_group_layout.addWidget(self.autoupdate_timestamp)
+        autoupdate_group_layout.addWidget(self.check_for_updates_button)
+        autoupdate_group = QtWidgets.QGroupBox(strings._("gui_settings_autoupdate_label", True))
+        autoupdate_group.setLayout(autoupdate_group_layout)
+
+        # Autoupdate is only available for Windows and Mac (Linux updates using package manager)
+        if system != 'Windows' and system != 'Darwin':
+            autoupdate_group.hide()
+
         # Connection type: either automatic, control port, or socket file
 
         # Bundled Tor
@@ -74,8 +102,7 @@ class SettingsDialog(QtWidgets.QDialog):
         self.connection_type_bundled_radio.toggled.connect(self.connection_type_bundled_toggled)
 
         # Bundled Tor doesn't work on dev mode in Windows or Mac
-        p = platform.system()
-        if (p == 'Windows' or p == 'Darwin') and getattr(sys, 'onionshare_dev_mode', False):
+        if (system == 'Windows' or system == 'Darwin') and getattr(sys, 'onionshare_dev_mode', False):
             self.connection_type_bundled_radio.setEnabled(False)
 
         # Automatic
@@ -140,11 +167,6 @@ class SettingsDialog(QtWidgets.QDialog):
         self.authenticate_group = QtWidgets.QGroupBox(strings._("gui_settings_authenticate_label", True))
         self.authenticate_group.setLayout(authenticate_group_layout)
 
-        # Tor networkconnection status
-        self.tor_status = QtWidgets.QLabel()
-        self.tor_status.setStyleSheet('color: #666666; padding-top: 10px')
-        self.tor_status.hide()
-
         # Test tor settings button
         self.connection_type_test_button = QtWidgets.QPushButton(strings._('gui_settings_connection_type_test_button', True))
         self.connection_type_test_button.clicked.connect(self.test_tor_clicked)
@@ -158,7 +180,6 @@ class SettingsDialog(QtWidgets.QDialog):
         connection_type_group_layout.addWidget(self.connection_type_control_port_extras)
         connection_type_group_layout.addWidget(self.connection_type_socket_file_extras)
         connection_type_group_layout.addWidget(self.authenticate_group)
-        connection_type_group_layout.addWidget(self.tor_status)
         connection_type_group_layout.addWidget(self.connection_type_test_button)
         connection_type_group = QtWidgets.QGroupBox(strings._("gui_settings_connection_type_label", True))
         connection_type_group.setLayout(connection_type_group_layout)
@@ -172,15 +193,22 @@ class SettingsDialog(QtWidgets.QDialog):
         buttons_layout.addWidget(self.save_button)
         buttons_layout.addWidget(self.cancel_button)
 
+        # Tor network connection status
+        self.tor_status = QtWidgets.QLabel()
+        self.tor_status.setStyleSheet('background-color: #ffffff; color: #000000; padding: 10px')
+        self.tor_status.hide()
+
         # Layout
         layout = QtWidgets.QVBoxLayout()
         layout.addWidget(sharing_group)
         layout.addWidget(stealth_group)
+        layout.addWidget(autoupdate_group)
         layout.addWidget(connection_type_group)
         layout.addStretch()
         layout.addLayout(buttons_layout)
+        layout.addWidget(self.tor_status)
         self.setLayout(layout)
-
+        self.cancel_button.setFocus()
 
         # Load settings, and fill them in
         settings = Settings()
@@ -198,6 +226,20 @@ class SettingsDialog(QtWidgets.QDialog):
         else:
             self.stealth_checkbox.setCheckState(QtCore.Qt.Unchecked)
 
+        use_autoupdate = settings.get('use_autoupdate')
+        if use_autoupdate:
+            self.autoupdate_checkbox.setCheckState(QtCore.Qt.Checked)
+        else:
+            self.autoupdate_checkbox.setCheckState(QtCore.Qt.Unchecked)
+
+        autoupdate_timestamp = settings.get('autoupdate_timestamp')
+        if autoupdate_timestamp:
+            dt = datetime.datetime.fromtimestamp(autoupdate_timestamp)
+            last_checked = dt.strftime('%B %d, %Y %H:%M')
+        else:
+            last_checked = strings._('gui_settings_autoupdate_timestamp_never', True)
+        self.autoupdate_timestamp.setText(strings._('gui_settings_autoupdate_timestamp', True).format(last_checked))
+
         connection_type = settings.get('connection_type')
         if connection_type == 'bundled':
             if self.connection_type_bundled_radio.isEnabled():
@@ -279,7 +321,7 @@ class SettingsDialog(QtWidgets.QDialog):
 
     def test_tor_clicked(self):
         """
-        Test Settings button clicked. With the given settings, see if we can
+        Test Tor Settings button clicked. With the given settings, see if we can
         successfully connect and authenticate to Tor.
         """
         settings = self.settings_from_fields()
@@ -321,6 +363,12 @@ class SettingsDialog(QtWidgets.QDialog):
             if settings.get('connection_type') == 'bundled':
                 bundled_cleanup()
 
+    def check_for_updates(self):
+        """
+        Check for Updates button clicked. Manually force an update check.
+        """
+        pass
+
     def save_clicked(self):
         """
         Save button clicked. Save current settings to disk.
diff --git a/share/locale/en.json b/share/locale/en.json
index b288cec..0d5ba84 100644
--- a/share/locale/en.json
+++ b/share/locale/en.json
@@ -59,6 +59,11 @@
     "gui_settings_stealth_label": "Stealth (advanced)",
     "gui_settings_stealth_option": "Create stealth onion services",
     "gui_settings_stealth_option_details": "This makes OnionShare more secure, but also more difficult for the recipient to connect to it.<br><a href=\"https://github.com/micahflee/onionshare/wiki/Stealth-Onion-Services\">More information</a>.",
+    "gui_settings_autoupdate_label": "Automatic updates",
+    "gui_settings_autoupdate_option": "Notify me when updates are available",
+    "gui_settings_autoupdate_timestamp": "Last checked: {}",
+    "gui_settings_autoupdate_timestamp_never": "Never",
+    "gui_settings_autoupdate_check_button": "Check For Updates",
     "gui_settings_sharing_label": "Sharing options",
     "gui_settings_close_after_first_download_option": "Stop sharing after first download",
     "gui_settings_connection_type_label": "How should OnionShare connect to Tor?",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list