[Pkg-privacy-commits] [onionshare] 44/66: Confirm when user tries to close the GUI window (fixes #264)

Ulrike Uhlig u-guest at moszumanska.debian.org
Wed Apr 13 22:17:51 UTC 2016


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

u-guest pushed a commit to branch master
in repository onionshare.

commit cb3d39fb4f4dbe1e1ef89fc8d5ef724b20a8b30e
Author: Micah Lee <micah at micahflee.com>
Date:   Sun Apr 10 19:28:22 2016 -0700

    Confirm when user tries to close the GUI window (fixes #264)
---
 locale/en.json                   |  3 ++-
 onionshare_gui/onionshare_gui.py | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/locale/en.json b/locale/en.json
index 2215c02..ad44b2e 100644
--- a/locale/en.json
+++ b/locale/en.json
@@ -45,5 +45,6 @@
     "gui_download_progress_complete": "%p%, Time Elapsed: {0:s}",
     "gui_download_progress_starting": "{0:s}, %p% (Computing ETA)",
     "gui_download_progress_eta": "{0:s}, ETA: {1:s}, %p%",
-    "version_string": "Onionshare {0:s} | https://onionshare.org/"
+    "version_string": "Onionshare {0:s} | https://onionshare.org/",
+    "gui_quit_warning": "Are you sure you want to quit?\nThe URL you are sharing won't exist anymore."
 }
diff --git a/onionshare_gui/onionshare_gui.py b/onionshare_gui/onionshare_gui.py
index 5aa54c0..d05cd6a 100644
--- a/onionshare_gui/onionshare_gui.py
+++ b/onionshare_gui/onionshare_gui.py
@@ -244,7 +244,23 @@ class OnionShareGui(QtWidgets.QMainWindow):
         self.status_bar.clearMessage()
 
     def closeEvent(self, e):
-        self.stop_server()
+        if self.server_status.status != self.server_status.STATUS_STOPPED:
+            dialog = QtWidgets.QMessageBox()
+            dialog.setText(strings._('gui_quit_warning', True))
+            quit_button = dialog.addButton("Quit", QtWidgets.QMessageBox.YesRole)
+            dont_quit_button = dialog.addButton("Don't Quit", QtWidgets.QMessageBox.NoRole)
+            #dialog.setStandardButtons(QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
+            dialog.setDefaultButton(dont_quit_button)
+            reply = dialog.exec_()
+            print("reply: {}".format(reply))
+
+            # Quit
+            if reply == 0:
+                self.stop_server()
+                e.accept()
+            # Don't Quit
+            else:
+                e.ignore()
 
 
 def alert(msg, icon=QtWidgets.QMessageBox.NoIcon):

-- 
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