|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2017 - 2019 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter the data for a built-in assignment to |
|
8 be ignored. |
|
9 """ |
|
10 |
|
11 from __future__ import unicode_literals |
|
12 |
|
13 from PyQt5.QtCore import pyqtSlot |
|
14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
15 |
|
16 from .Ui_CodeStyleAddBuiltinIgnoreDialog import \ |
|
17 Ui_CodeStyleAddBuiltinIgnoreDialog |
|
18 |
|
19 |
|
20 class CodeStyleAddBuiltinIgnoreDialog(QDialog, |
|
21 Ui_CodeStyleAddBuiltinIgnoreDialog): |
|
22 """ |
|
23 Class implementing a dialog to enter the data for a built-in assignment to |
|
24 be ignored. |
|
25 """ |
|
26 def __init__(self, parent=None): |
|
27 """ |
|
28 Constructor |
|
29 |
|
30 @param parent reference to the parent widget |
|
31 @type QWidget |
|
32 """ |
|
33 super(CodeStyleAddBuiltinIgnoreDialog, self).__init__(parent) |
|
34 self.setupUi(self) |
|
35 |
|
36 self.__updateOkButton |
|
37 |
|
38 msh = self.minimumSizeHint() |
|
39 self.resize(max(self.width(), msh.width()), msh.height()) |
|
40 |
|
41 def __updateOkButton(self): |
|
42 """ |
|
43 Private slot to set the state of the OK button. |
|
44 """ |
|
45 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( |
|
46 bool(self.leftEdit.text()) and |
|
47 bool(self.rightEdit.text())) |
|
48 |
|
49 @pyqtSlot(str) |
|
50 def on_leftEdit_textChanged(self, txt): |
|
51 """ |
|
52 Private slot to handle a change of the text of the left side edit. |
|
53 |
|
54 @param txt text of the line edit |
|
55 @type str |
|
56 """ |
|
57 self.__updateOkButton() |
|
58 |
|
59 @pyqtSlot(str) |
|
60 def on_rightEdit_textChanged(self, txt): |
|
61 """ |
|
62 Private slot to handle a change of the text of the right side edit. |
|
63 |
|
64 @param txt text of the line edit |
|
65 @type str |
|
66 """ |
|
67 self.__updateOkButton() |
|
68 |
|
69 def getData(self): |
|
70 """ |
|
71 Public method to get the entered data. |
|
72 |
|
73 @return tuple containing the left and right hand side of the assignment |
|
74 @rtype tuple of two str |
|
75 """ |
|
76 return self.leftEdit.text(), self.rightEdit.text() |