mirror of
https://github.com/borgbase/vorta
synced 2025-01-03 05:36:19 +00:00
Add option to disable exit dialog. By @samuel-w (#681)
This commit is contained in:
parent
bbc5b85b81
commit
a47af86d64
2 changed files with 29 additions and 11 deletions
|
@ -14,7 +14,7 @@
|
|||
from playhouse.migrate import SqliteMigrator, migrate
|
||||
|
||||
from vorta.i18n import trans_late
|
||||
from vorta.utils import slugify
|
||||
from vorta.utils import slugify, is_system_tray_available
|
||||
|
||||
SCHEMA_VERSION = 16
|
||||
|
||||
|
@ -249,6 +249,16 @@ def get_misc_settings():
|
|||
'Include pre-release versions when checking for updates')
|
||||
},
|
||||
]
|
||||
if not is_system_tray_available():
|
||||
settings += [{
|
||||
'key': 'enable_background_question', 'value': True, 'type': 'checkbox',
|
||||
'label': trans_late('settings',
|
||||
'Display background exit dialog')
|
||||
},
|
||||
{
|
||||
'key': 'disable_background_state', 'value': False, 'type': 'internal',
|
||||
'label': 'Previous background exit button state'
|
||||
}]
|
||||
return settings
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
from PyQt5 import QtCore, uic
|
||||
from PyQt5.QtWidgets import QShortcut, QMessageBox
|
||||
from PyQt5.QtWidgets import QShortcut, QMessageBox, QCheckBox
|
||||
from PyQt5.QtGui import QKeySequence
|
||||
|
||||
from vorta.borg.borg_thread import BorgThread
|
||||
from vorta.i18n import trans_late
|
||||
from vorta.models import BackupProfileModel, SettingsModel
|
||||
from vorta.utils import borg_compat, get_asset, is_system_tray_available, get_network_status_monitor
|
||||
from vorta.views.utils import get_colored_icon
|
||||
|
@ -190,12 +189,21 @@ def closeEvent(self, event):
|
|||
.execute()
|
||||
|
||||
if not is_system_tray_available():
|
||||
run_in_background = QMessageBox.question(self,
|
||||
trans_late("MainWindow QMessagebox",
|
||||
"Quit"),
|
||||
trans_late("MainWindow QMessagebox",
|
||||
"Should Vorta continue to run in the background?"),
|
||||
QMessageBox.Yes | QMessageBox.No)
|
||||
if run_in_background == QMessageBox.No:
|
||||
if SettingsModel.get(key="enable_background_question").value:
|
||||
msg = QMessageBox()
|
||||
msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
|
||||
msg.setParent(self, QtCore.Qt.Sheet)
|
||||
msg.setText(self.tr("Should Vorta continue to run in the background?"))
|
||||
msg.button(QMessageBox.Yes).clicked.connect(
|
||||
lambda: self.miscTab.save_setting("disable_background_state", True))
|
||||
msg.button(QMessageBox.No).clicked.connect(lambda: (self.miscTab.save_setting(
|
||||
"disable_background_state", False), self.app.quit()))
|
||||
msg.setWindowTitle(self.tr("Quit"))
|
||||
dont_show_box = QCheckBox(self.tr("Don't show this again"))
|
||||
dont_show_box.clicked.connect(lambda x: self.miscTab.save_setting("enable_background_question", not x))
|
||||
dont_show_box.setTristate(False)
|
||||
msg.setCheckBox(dont_show_box)
|
||||
msg.exec()
|
||||
elif not SettingsModel.get(key="disable_background_state").value:
|
||||
self.app.quit()
|
||||
event.accept()
|
||||
|
|
Loading…
Reference in a new issue