mirror of
https://github.com/onionshare/onionshare.git
synced 2025-06-24 14:30:29 -04:00
Confirm when user tries to close the GUI window (fixes #264)
This commit is contained in:
parent
7b8e9e1e6f
commit
cb3d39fb4f
2 changed files with 19 additions and 2 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue