Add warning about closing a persistent tab

This commit is contained in:
Micah Lee 2019-10-27 16:01:30 -07:00
parent 216fbd4e87
commit 654fccc009
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
2 changed files with 51 additions and 44 deletions

View File

@ -117,7 +117,7 @@ class Tab(QtWidgets.QWidget):
self.timer.timeout.connect(self.timer_callback)
# Settings for this tab
self.tab_settings = {"persistence": False}
self.tab_settings = {"persistent": False}
# Persistence button
self.persistence_button = QtWidgets.QPushButton()
@ -502,15 +502,15 @@ class Tab(QtWidgets.QWidget):
def persistence_button_clicked(self):
self.common.log("Tab", "persistence_button_clicked")
if self.tab_settings["persistence"]:
self.tab_settings["persistence"] = False
if self.tab_settings["persistent"]:
self.tab_settings["persistent"] = False
else:
self.tab_settings["persistence"] = True
self.tab_settings["persistent"] = True
self.update_persistence_button()
def update_persistence_button(self):
self.common.log("Tab", "update_persistence_button")
if self.tab_settings["persistence"]:
if self.tab_settings["persistent"]:
self.persistence_button.setIcon(
QtGui.QIcon(
self.common.get_resource_path("images/persistent_enabled.png")
@ -528,6 +528,9 @@ class Tab(QtWidgets.QWidget):
if self.mode is None:
return True
if self.tab_settings["persistent"]:
dialog_text = strings._("gui_close_tab_warning_persistent_description")
else:
if self.mode == self.common.gui.MODE_SHARE:
server_status = self.share_mode.server_status
elif self.mode == self.common.gui.MODE_RECEIVE:
@ -538,15 +541,18 @@ class Tab(QtWidgets.QWidget):
if server_status.status == server_status.STATUS_STOPPED:
return True
else:
if self.mode == self.common.gui.MODE_SHARE:
dialog_text = strings._("gui_close_tab_warning_share_description")
elif self.mode == self.common.gui.MODE_RECEIVE:
dialog_text = strings._("gui_close_tab_warning_receive_description")
else:
dialog_text = strings._("gui_close_tab_warning_website_description")
# Open the warning dialog
self.common.log("Tab", "close_tab, opening warning dialog")
dialog = QtWidgets.QMessageBox()
dialog.setWindowTitle(strings._("gui_close_tab_warning_title"))
if self.mode == self.common.gui.MODE_SHARE:
dialog.setText(strings._("gui_close_tab_warning_share_description"))
elif self.mode == self.common.gui.MODE_RECEIVE:
dialog.setText(strings._("gui_close_tab_warning_receive_description"))
else:
dialog.setText(strings._("gui_close_tab_warning_website_description"))
dialog.setText(dialog_text)
dialog.setIcon(QtWidgets.QMessageBox.Critical)
dialog.addButton(
strings._("gui_close_tab_warning_close"), QtWidgets.QMessageBox.YesRole

View File

@ -189,6 +189,7 @@
"gui_new_tab_website_button": "Publish Website",
"gui_new_tab_website_description": "Host a static HTML onion website from your computer.",
"gui_close_tab_warning_title": "Are you sure?",
"gui_close_tab_warning_persistent_description": "This tab is persistent. If you close it you'll lose the onion address that it's using. Are you sure you want to close it?",
"gui_close_tab_warning_share_description": "You're in the process of sending files. Are you sure you want to close this tab?",
"gui_close_tab_warning_receive_description": "You're in the process of receiving files. Are you sure you want to close this tab?",
"gui_close_tab_warning_website_description": "You're actively hosting a website. Are you sure you want to close this tab?",