1# -*- coding: utf-8 -*- 2 3# Copyright (c) 2004 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> 4# 5 6""" 7Module implementing a dialog to confirm deletion of multiple files. 8""" 9 10from PyQt5.QtWidgets import QDialog, QDialogButtonBox 11 12from .Ui_DeleteFilesConfirmationDialog import Ui_DeleteFilesConfirmationDialog 13 14 15class DeleteFilesConfirmationDialog(QDialog, Ui_DeleteFilesConfirmationDialog): 16 """ 17 Class implementing a dialog to confirm deletion of multiple files. 18 """ 19 def __init__(self, parent, caption, message, files): 20 """ 21 Constructor 22 23 @param parent parent of this dialog (QWidget) 24 @param caption window title for the dialog (string) 25 @param message message to be shown (string) 26 @param files list of filenames to be shown (list of strings) 27 """ 28 super().__init__(parent) 29 self.setupUi(self) 30 self.setModal(True) 31 32 self.buttonBox.button( 33 QDialogButtonBox.StandardButton.Yes).setAutoDefault(False) 34 self.buttonBox.button( 35 QDialogButtonBox.StandardButton.No).setDefault(True) 36 self.buttonBox.button( 37 QDialogButtonBox.StandardButton.No).setFocus() 38 39 self.setWindowTitle(caption) 40 self.message.setText(message) 41 42 self.filesList.addItems(files) 43 44 def on_buttonBox_clicked(self, button): 45 """ 46 Private slot called by a button of the button box clicked. 47 48 @param button button that was clicked (QAbstractButton) 49 """ 50 if button == self.buttonBox.button( 51 QDialogButtonBox.StandardButton.Yes 52 ): 53 self.accept() 54 elif button == self.buttonBox.button( 55 QDialogButtonBox.StandardButton.No 56 ): 57 self.reject() 58