|
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 """ |
|
20 def __init__(self, title="", url="", parent=None): |
|
21 """ |
|
22 Constructor |
|
23 |
|
24 @param title title for the bookmark (defaults to "") |
|
25 @type str (optional) |
|
26 @param url URL for the bookmark (defaults to "") |
|
27 @type str (optional) |
|
28 @param parent reference to the parent widget (defaults to None) |
|
29 @type QWidget (optional) |
|
30 """ |
|
31 super().__init__(parent) |
|
32 self.setupUi(self) |
|
33 |
|
34 self.titleEdit.textChanged.connect(self.__updateOkButton) |
|
35 self.urlEdit.textChanged.connect(self.__updateOkButton) |
|
36 |
|
37 self.titleEdit.setText(title) |
|
38 self.urlEdit.setText(url) |
|
39 |
|
40 msh = self.minimumSizeHint() |
|
41 self.resize(max(self.width(), msh.width()), msh.height()) |
|
42 |
|
43 @pyqtSlot() |
|
44 def __updateOkButton(self): |
|
45 """ |
|
46 Private method to set the enabled state of the OK button. |
|
47 """ |
|
48 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
|
49 bool(self.titleEdit.text().strip()) and |
|
50 bool(self.urlEdit.text().strip()) |
|
51 ) |
|
52 |
|
53 def getData(self): |
|
54 """ |
|
55 Public method to retrieve the entered data |
|
56 |
|
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 ) |