|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2011 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Confirmation dialog. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QDialog, QDialogButtonBox, QAbstractButton |
|
12 |
|
13 from Ui_ConfirmationDialog import Ui_ConfirmationDialog |
|
14 from ChangesPreviewDialog import ChangesPreviewDialog |
|
15 |
|
16 import Utilities |
|
17 |
|
18 |
|
19 class ConfirmationDialog(QDialog, Ui_ConfirmationDialog): |
|
20 """ |
|
21 Class implementing the Confirmation dialog. |
|
22 """ |
|
23 def __init__(self, changes, parent=None): |
|
24 """ |
|
25 Constructor |
|
26 |
|
27 @param changes reference to the Changes object |
|
28 (rope.base.change.ChangeSet) |
|
29 @param parent reference to the parent widget (QWidget) |
|
30 """ |
|
31 QDialog.__init__(self, parent) |
|
32 self.setupUi(self) |
|
33 |
|
34 self.__changes = changes |
|
35 |
|
36 self.description.setText( |
|
37 self.trUtf8("Shall the refactoring <b>{0}</b> be done?")\ |
|
38 .format(Utilities.html_encode(self.__changes.description))) |
|
39 |
|
40 self.__okButton = self.buttonBox.button(QDialogButtonBox.Ok) |
|
41 self.__previewButton = self.buttonBox.addButton( |
|
42 self.trUtf8("Preview"), QDialogButtonBox.ActionRole) |
|
43 self.__previewButton.setDefault(True) |
|
44 |
|
45 @pyqtSlot(QAbstractButton) |
|
46 def on_buttonBox_clicked(self, button): |
|
47 """ |
|
48 Private slot to act on the button pressed. |
|
49 |
|
50 @param button reference to the button pressed (QAbstractButton) |
|
51 """ |
|
52 if button == self.__previewButton: |
|
53 self.__previewChanges() |
|
54 |
|
55 def __previewChanges(self): |
|
56 """ |
|
57 Private method to preview the changes. |
|
58 """ |
|
59 dlg = ChangesPreviewDialog(self.__changes, self) |
|
60 if dlg.exec_() == QDialog.Accepted: |
|
61 self.accept() |