RefactoringRope/ConfirmationDialog.py

Thu, 01 Jan 2015 13:27:20 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 01 Jan 2015 13:27:20 +0100
changeset 94
03d6a17c66ac
parent 87
1fbf5fdbe721
child 144
bfc6a3b38330
permissions
-rw-r--r--

Updated copyright for 2015.

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

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

"""
Module implementing the Confirmation dialog.
"""

from __future__ import unicode_literals

from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton

from Ui_ConfirmationDialog import Ui_ConfirmationDialog

import Utilities


class ConfirmationDialog(QDialog, Ui_ConfirmationDialog):
    """
    Class implementing the Confirmation dialog.
    """
    def __init__(self, changes, parent=None):
        """
        Constructor
        
        @param changes reference to the Changes object
            (rope.base.change.ChangeSet)
        @param parent reference to the parent widget (QWidget)
        """
        QDialog.__init__(self, parent)
        self.setupUi(self)
        
        self.__changes = changes
        
        self.description.setText(
            self.tr("Shall the refactoring <b>{0}</b> be done?")
                .format(Utilities.html_encode(self.__changes.description)))
        
        self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok)
        self.__previewButton = self.buttonBox.addButton(
            self.tr("Preview"), QDialogButtonBox.ActionRole)
        self.__previewButton.setDefault(True)
        
        msh = self.minimumSizeHint()
        self.resize(max(self.width(), msh.width()), msh.height())
    
    @pyqtSlot(QAbstractButton)
    def on_buttonBox_clicked(self, button):
        """
        Private slot to act on the button pressed.
        
        @param button reference to the button pressed (QAbstractButton)
        """
        if button == self.__previewButton:
            self.__previewChanges()
    
    def __previewChanges(self):
        """
        Private method to preview the changes.
        """
        from ChangesPreviewDialog import ChangesPreviewDialog
        dlg = ChangesPreviewDialog(self.__changes, self)
        if dlg.exec_() == QDialog.Accepted:
            self.accept()

eric ide

mercurial