extend the delete function with a yes/no dialog
This commit is contained in:
parent
8c9f7bc329
commit
52d7215094
|
@ -3,7 +3,8 @@ import sys
|
||||||
|
|
||||||
from PyQt5 import uic
|
from PyQt5 import uic
|
||||||
from PyQt5.QtCore import QCoreApplication
|
from PyQt5.QtCore import QCoreApplication
|
||||||
from PyQt5.QtWidgets import QMainWindow, QFileSystemModel, QFileDialog
|
from PyQt5.QtWidgets import (QMainWindow, QFileSystemModel, QFileDialog,
|
||||||
|
QMessageBox)
|
||||||
|
|
||||||
from config import Config
|
from config import Config
|
||||||
from helper import (BorgException, show_error, convert_size, open_path,
|
from helper import (BorgException, show_error, convert_size, open_path,
|
||||||
|
@ -153,15 +154,16 @@ class MainWindow(QMainWindow):
|
||||||
show_error(error)
|
show_error(error)
|
||||||
|
|
||||||
if archive_name:
|
if archive_name:
|
||||||
try:
|
if self.yes_no("Do you want to delete this archive?"):
|
||||||
thread = borg.DeleteThread(archive_name)
|
try:
|
||||||
dialog = ProgressDialog(thread)
|
thread = borg.DeleteThread(archive_name)
|
||||||
dialog.label_info.setText(
|
dialog = ProgressDialog(thread)
|
||||||
"Borg-Qt is currently deleting a backup.")
|
dialog.label_info.setText(
|
||||||
dialog.exec_()
|
"Borg-Qt is currently deleting a backup.")
|
||||||
self.update_ui()
|
dialog.exec_()
|
||||||
except BorgException as e:
|
self.update_ui()
|
||||||
show_error(e)
|
except BorgException as e:
|
||||||
|
show_error(e)
|
||||||
|
|
||||||
def _update_archives(self):
|
def _update_archives(self):
|
||||||
"""Lists all the archive names in the UI."""
|
"""Lists all the archive names in the UI."""
|
||||||
|
@ -217,3 +219,12 @@ class MainWindow(QMainWindow):
|
||||||
remove_path(mount_path)
|
remove_path(mount_path)
|
||||||
else:
|
else:
|
||||||
open_path(mount_path)
|
open_path(mount_path)
|
||||||
|
|
||||||
|
def yes_no(self, question):
|
||||||
|
button_reply = QMessageBox.question(self, 'Borg-Qt', question,
|
||||||
|
QMessageBox.Yes |
|
||||||
|
QMessageBox.No, QMessageBox.No)
|
||||||
|
if button_reply == QMessageBox.Yes:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in New Issue