UI/DeleteFilesConfirmationDialog.py

Fri, 01 Jan 2016 12:13:13 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 01 Jan 2016 12:13:13 +0100
branch
6_1_x
changeset 4632
ca310db386ed
parent 4021
195a471c327b
child 5389
9b1c800daff3
permissions
-rw-r--r--

Updated copyright for 2016.

# -*- coding: utf-8 -*-

# Copyright (c) 2004 - 2016 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing a dialog to confirm deletion of multiple files.
"""

from __future__ import unicode_literals

from PyQt5.QtWidgets import QDialog, QDialogButtonBox

from .Ui_DeleteFilesConfirmationDialog import Ui_DeleteFilesConfirmationDialog


class DeleteFilesConfirmationDialog(QDialog, Ui_DeleteFilesConfirmationDialog):
    """
    Class implementing a dialog to confirm deletion of multiple files.
    """
    def __init__(self, parent, caption, message, files):
        """
        Constructor
        
        @param parent parent of this dialog (QWidget)
        @param caption window title for the dialog (string)
        @param message message to be shown (string)
        @param files list of filenames to be shown (list of strings)
        """
        super(DeleteFilesConfirmationDialog, self).__init__(parent)
        self.setupUi(self)
        self.setModal(True)
        
        self.buttonBox.button(QDialogButtonBox.Yes).setAutoDefault(False)
        self.buttonBox.button(QDialogButtonBox.No).setDefault(True)
        self.buttonBox.button(QDialogButtonBox.No).setFocus()
        
        self.setWindowTitle(caption)
        self.message.setText(message)
        
        self.filesList.addItems(files)

    def on_buttonBox_clicked(self, button):
        """
        Private slot called by a button of the button box clicked.
        
        @param button button that was clicked (QAbstractButton)
        """
        if button == self.buttonBox.button(QDialogButtonBox.Yes):
            self.accept()
        elif button == self.buttonBox.button(QDialogButtonBox.No):
            self.reject()

eric ide

mercurial