15 |
15 |
16 class HyperlinkMarkupDialog(QDialog, Ui_HyperlinkMarkupDialog): |
16 class HyperlinkMarkupDialog(QDialog, Ui_HyperlinkMarkupDialog): |
17 """ |
17 """ |
18 Class implementing a dialog to enter data to insert a hyperlink. |
18 Class implementing a dialog to enter data to insert a hyperlink. |
19 """ |
19 """ |
20 def __init__(self, textMayBeEmpty, targetMayBeEmpty, noTitle=False, |
20 |
21 parent=None): |
21 def __init__(self, textMayBeEmpty, targetMayBeEmpty, noTitle=False, parent=None): |
22 """ |
22 """ |
23 Constructor |
23 Constructor |
24 |
24 |
25 @param textMayBeEmpty flag indicating, that the link text may |
25 @param textMayBeEmpty flag indicating, that the link text may |
26 be empty |
26 be empty |
27 @type bool |
27 @type bool |
28 @param targetMayBeEmpty flag indicating, that the link target may |
28 @param targetMayBeEmpty flag indicating, that the link target may |
29 be empty |
29 be empty |
33 @param parent reference to the parent widget |
33 @param parent reference to the parent widget |
34 @type QWidget |
34 @type QWidget |
35 """ |
35 """ |
36 super().__init__(parent) |
36 super().__init__(parent) |
37 self.setupUi(self) |
37 self.setupUi(self) |
38 |
38 |
39 self.__allowEmptyText = textMayBeEmpty |
39 self.__allowEmptyText = textMayBeEmpty |
40 self.__allowEmptyTarget = targetMayBeEmpty |
40 self.__allowEmptyTarget = targetMayBeEmpty |
41 |
41 |
42 self.titelEdit.setEnabled(not noTitle) |
42 self.titelEdit.setEnabled(not noTitle) |
43 |
43 |
44 self.__updateOkButton() |
44 self.__updateOkButton() |
45 |
45 |
46 msh = self.minimumSizeHint() |
46 msh = self.minimumSizeHint() |
47 self.resize(max(self.width(), msh.width()), msh.height()) |
47 self.resize(max(self.width(), msh.width()), msh.height()) |
48 |
48 |
49 def __updateOkButton(self): |
49 def __updateOkButton(self): |
50 """ |
50 """ |
51 Private method to update the state of the OK button. |
51 Private method to update the state of the OK button. |
52 """ |
52 """ |
53 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
53 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
54 (bool(self.textEdit.text()) or self.__allowEmptyText) and |
54 (bool(self.textEdit.text()) or self.__allowEmptyText) |
55 (bool(self.targetEdit.text()) or self.__allowEmptyTarget) |
55 and (bool(self.targetEdit.text()) or self.__allowEmptyTarget) |
56 ) |
56 ) |
57 |
57 |
58 @pyqtSlot(str) |
58 @pyqtSlot(str) |
59 def on_textEdit_textChanged(self, txt): |
59 def on_textEdit_textChanged(self, txt): |
60 """ |
60 """ |
61 Private slot handling a change of the link text. |
61 Private slot handling a change of the link text. |
62 |
62 |
63 @param txt link text |
63 @param txt link text |
64 @type str |
64 @type str |
65 """ |
65 """ |
66 self.__updateOkButton() |
66 self.__updateOkButton() |
67 |
67 |
68 @pyqtSlot(str) |
68 @pyqtSlot(str) |
69 def on_targetEdit_textChanged(self, txt): |
69 def on_targetEdit_textChanged(self, txt): |
70 """ |
70 """ |
71 Private slot handling a change of the link target. |
71 Private slot handling a change of the link target. |
72 |
72 |
73 @param txt link target |
73 @param txt link target |
74 @type str |
74 @type str |
75 """ |
75 """ |
76 self.__updateOkButton() |
76 self.__updateOkButton() |
77 |
77 |
78 def getData(self): |
78 def getData(self): |
79 """ |
79 """ |
80 Public method to get the entered data. |
80 Public method to get the entered data. |
81 |
81 |
82 @return tuple containing the link text, link target and the optional |
82 @return tuple containing the link text, link target and the optional |
83 link title |
83 link title |
84 @rtype tuple of (str, str, str) |
84 @rtype tuple of (str, str, str) |
85 """ |
85 """ |
86 return ( |
86 return (self.textEdit.text(), self.targetEdit.text(), self.titelEdit.text()) |
87 self.textEdit.text(), |
|
88 self.targetEdit.text(), |
|
89 self.titelEdit.text() |
|
90 ) |
|