Mon, 07 Nov 2022 17:19:58 +0100
Corrected/acknowledged some bad import style and removed some obsolete code.
8900 | 1 | # -*- coding: utf-8 -*- |
2 | ||
3 | # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> | |
4 | # | |
5 | ||
6 | """ | |
7 | Module implementing a dialog to edit the bookmark properties. | |
8 | """ | |
9 | ||
10 | from PyQt6.QtCore import pyqtSlot | |
11 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox | |
12 | ||
13 | from .Ui_HelpBookmarkPropertiesDialog import Ui_HelpBookmarkPropertiesDialog | |
14 | ||
15 | ||
16 | class HelpBookmarkPropertiesDialog(QDialog, Ui_HelpBookmarkPropertiesDialog): | |
17 | """ | |
18 | Class implementing a dialog to edit the bookmark properties. | |
19 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
20 | |
8900 | 21 | def __init__(self, title="", url="", parent=None): |
22 | """ | |
23 | Constructor | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
24 | |
8900 | 25 | @param title title for the bookmark (defaults to "") |
26 | @type str (optional) | |
27 | @param url URL for the bookmark (defaults to "") | |
28 | @type str (optional) | |
29 | @param parent reference to the parent widget (defaults to None) | |
30 | @type QWidget (optional) | |
31 | """ | |
32 | super().__init__(parent) | |
33 | self.setupUi(self) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
34 | |
8900 | 35 | self.titleEdit.textChanged.connect(self.__updateOkButton) |
36 | self.urlEdit.textChanged.connect(self.__updateOkButton) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
37 | |
8900 | 38 | self.titleEdit.setText(title) |
39 | self.urlEdit.setText(url) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
40 | |
8900 | 41 | msh = self.minimumSizeHint() |
42 | self.resize(max(self.width(), msh.width()), msh.height()) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | |
8900 | 44 | @pyqtSlot() |
45 | def __updateOkButton(self): | |
46 | """ | |
47 | Private method to set the enabled state of the OK button. | |
48 | """ | |
49 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
50 | bool(self.titleEdit.text().strip()) and bool(self.urlEdit.text().strip()) |
8900 | 51 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | |
8900 | 53 | def getData(self): |
54 | """ | |
8902 | 55 | Public method to retrieve the entered data. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
56 | |
8900 | 57 | @return tuple containing the title and URL for the bookmark |
58 | @rtype tuple of (str, str) | |
59 | """ | |
60 | return ( | |
61 | self.titleEdit.text().strip(), | |
62 | self.urlEdit.text().strip(), | |
63 | ) |