Add option to disable exit dialog. By @samuel-w (#681)

This commit is contained in:
samuel-w 2021-01-18 02:32:58 -06:00 committed by GitHub
parent bbc5b85b81
commit a47af86d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 11 deletions

View File

@ -14,7 +14,7 @@ import peewee as pw
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
@ -358,7 +368,7 @@ def init_db(con=None):
with db.atomic():
size = 1000
for i in range(0, len(data), size):
ArchiveModel.insert_many(data[i:i + size], fields=fields).execute()
ArchiveModel.insert_many(data[i: i + size], fields=fields).execute()
_apply_schema_update(current_schema, 13)

View File

@ -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 @@ class MainWindow(MainWindowBase, MainWindowUI):
.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()