RefactoringRope/ConfirmationDialog.py

Sat, 12 Apr 2014 19:47:46 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 12 Apr 2014 19:47:46 +0200
changeset 74
0973b175e2ad
parent 62
1077db8d0589
child 76
936b2a98fe4e
permissions
-rw-r--r--

Fixed a window sizing issue.

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

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

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

from PyQt4.QtCore import pyqtSlot
from PyQt4.QtGui 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.trUtf8("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.trUtf8("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