eric7/Plugins/WizardPlugins/SetupWizard/AddProjectUrlDialog.py

branch
eric7
changeset 9201
2f1ccadee231
child 9202
81388c6065e8
equal deleted inserted replaced
9199:831e08e94960 9201:2f1ccadee231
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data for a project URL.
8 """
9
10 from PyQt6.QtCore import pyqtSlot
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_AddProjectUrlDialog import Ui_AddProjectUrlDialog
14
15
16 class AddProjectUrlDialog(QDialog, Ui_AddProjectUrlDialog):
17 """
18 Class implementing a dialog to enter the data for a project URL.
19 """
20 def __init__(self, name="", url="", parent=None):
21 """
22 Constructor
23
24 @param name name of the project URL (defaults to "")
25 @type str (optional)
26 @param url address of the project URL (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.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
35
36 self.nameComboBox.lineEdit().setClearButtonEnabled(True)
37 self.nameComboBox.addItems([
38 "",
39 "Bug Tracker",
40 "Change Log",
41 "Documentation",
42 "Donation",
43 "Download",
44 "Funding",
45 "Homepage",
46 "Issues Tracker",
47 "News",
48 "Release Notes",
49 ])
50
51 self.nameComboBox.editTextChanged.connect(self.__updateOK)
52 self.urlEdit.textChanged.connect(self.__updateOK)
53
54 self.nameComboBox.setEditText(name)
55 self.urlEdit.setText(url)
56
57 msh = self.minimumSizeHint()
58 self.resize(max(self.width(), msh.width()), msh.height())
59
60 @pyqtSlot()
61 def __updateOK(self):
62 """
63 Private slot to update the enabled state of the OK button.
64 """
65 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
66 bool(self.nameComboBox.currentText()) and bool(self.urlEdit.text())
67 )
68
69 def getUrl(self):
70 """
71 Public method to get the data for the project URL.
72
73 @return tuple containing the name and address of the project URL
74 @rtype tuple of (str, str)
75 """
76 return (
77 self.nameComboBox.currentText(),
78 self.urlEdit.text(),
79 )

eric ide

mercurial