15 |
15 |
16 class AddProjectUrlDialog(QDialog, Ui_AddProjectUrlDialog): |
16 class AddProjectUrlDialog(QDialog, Ui_AddProjectUrlDialog): |
17 """ |
17 """ |
18 Class implementing a dialog to enter the data for a project URL. |
18 Class implementing a dialog to enter the data for a project URL. |
19 """ |
19 """ |
|
20 |
20 def __init__(self, name="", url="", parent=None): |
21 def __init__(self, name="", url="", parent=None): |
21 """ |
22 """ |
22 Constructor |
23 Constructor |
23 |
24 |
24 @param name name of the project URL (defaults to "") |
25 @param name name of the project URL (defaults to "") |
25 @type str (optional) |
26 @type str (optional) |
26 @param url address of the project URL (defaults to "") |
27 @param url address of the project URL (defaults to "") |
27 @type str (optional) |
28 @type str (optional) |
28 @param parent reference to the parent widget (defaults to None) |
29 @param parent reference to the parent widget (defaults to None) |
29 @type QWidget (optional) |
30 @type QWidget (optional) |
30 """ |
31 """ |
31 super().__init__(parent) |
32 super().__init__(parent) |
32 self.setupUi(self) |
33 self.setupUi(self) |
33 |
34 |
34 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
35 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
35 |
36 |
36 self.nameComboBox.lineEdit().setClearButtonEnabled(True) |
37 self.nameComboBox.lineEdit().setClearButtonEnabled(True) |
37 self.nameComboBox.addItems([ |
38 self.nameComboBox.addItems( |
38 "", |
39 [ |
39 "Bug Tracker", |
40 "", |
40 "Change Log", |
41 "Bug Tracker", |
41 "Documentation", |
42 "Change Log", |
42 "Donation", |
43 "Documentation", |
43 "Download", |
44 "Donation", |
44 "Funding", |
45 "Download", |
45 "Homepage", |
46 "Funding", |
46 "Issues Tracker", |
47 "Homepage", |
47 "News", |
48 "Issues Tracker", |
48 "Release Notes", |
49 "News", |
49 ]) |
50 "Release Notes", |
50 |
51 ] |
|
52 ) |
|
53 |
51 self.nameComboBox.editTextChanged.connect(self.__updateOK) |
54 self.nameComboBox.editTextChanged.connect(self.__updateOK) |
52 self.urlEdit.textChanged.connect(self.__updateOK) |
55 self.urlEdit.textChanged.connect(self.__updateOK) |
53 |
56 |
54 self.nameComboBox.setEditText(name) |
57 self.nameComboBox.setEditText(name) |
55 self.urlEdit.setText(url) |
58 self.urlEdit.setText(url) |
56 |
59 |
57 msh = self.minimumSizeHint() |
60 msh = self.minimumSizeHint() |
58 self.resize(max(self.width(), msh.width()), msh.height()) |
61 self.resize(max(self.width(), msh.width()), msh.height()) |
59 |
62 |
60 @pyqtSlot() |
63 @pyqtSlot() |
61 def __updateOK(self): |
64 def __updateOK(self): |
62 """ |
65 """ |
63 Private slot to update the enabled state of the OK button. |
66 Private slot to update the enabled state of the OK button. |
64 """ |
67 """ |
65 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
68 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
66 bool(self.nameComboBox.currentText()) and |
69 bool(self.nameComboBox.currentText()) |
67 bool(self.urlEdit.text()) and |
70 and bool(self.urlEdit.text()) |
68 self.urlEdit.text().startswith(("http://", "https://")) |
71 and self.urlEdit.text().startswith(("http://", "https://")) |
69 ) |
72 ) |
70 |
73 |
71 def getUrl(self): |
74 def getUrl(self): |
72 """ |
75 """ |
73 Public method to get the data for the project URL. |
76 Public method to get the data for the project URL. |
74 |
77 |
75 @return tuple containing the name and address of the project URL |
78 @return tuple containing the name and address of the project URL |
76 @rtype tuple of (str, str) |
79 @rtype tuple of (str, str) |
77 """ |
80 """ |
78 return ( |
81 return ( |
79 self.nameComboBox.currentText(), |
82 self.nameComboBox.currentText(), |