src/eric7/Plugins/VcsPlugins/vcsGit/GitAddRemoteDialog.py

branch
eric7
changeset 9209
b99e7fd55fd3
parent 8881
54e42bc2437a
child 9221
bf71ee032bb4
equal deleted inserted replaced
9208:3fc8dfeb6ebe 9209:b99e7fd55fd3
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the data of a remote repository.
8 """
9
10 from PyQt6.QtCore import pyqtSlot, QUrl
11 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
12
13 from .Ui_GitAddRemoteDialog import Ui_GitAddRemoteDialog
14
15
16 class GitAddRemoteDialog(QDialog, Ui_GitAddRemoteDialog):
17 """
18 Class implementing a dialog to enter the data of a remote repository.
19 """
20 def __init__(self, parent=None):
21 """
22 Constructor
23
24 @param parent reference to the parent widget
25 @type QWidget
26 """
27 super().__init__(parent)
28 self.setupUi(self)
29
30 self.__updateOK()
31
32 msh = self.minimumSizeHint()
33 self.resize(max(self.width(), msh.width()), msh.height())
34
35 def __updateOK(self):
36 """
37 Private method to update the status of the OK button.
38 """
39 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
40 self.nameEdit.text() != "" and
41 self.urlEdit.text() != "")
42
43 @pyqtSlot(str)
44 def on_nameEdit_textChanged(self, txt):
45 """
46 Private slot handling changes of the entered name.
47
48 @param txt current text
49 @type str
50 """
51 self.__updateOK()
52
53 @pyqtSlot(str)
54 def on_urlEdit_textChanged(self, txt):
55 """
56 Private slot handling changes of the entered URL.
57
58 @param txt current text
59 @type str
60 """
61 self.__updateOK()
62
63 @pyqtSlot(str)
64 def on_userEdit_textChanged(self, txt):
65 """
66 Private slot handling changes of the entered user name.
67
68 @param txt current text
69 @type str
70 """
71 self.passwordEdit.setEnabled(bool(txt))
72
73 def getData(self):
74 """
75 Public method to get the entered data.
76
77 @return tuple with name and URL of the remote repository
78 @rtype tuple of (str, str)
79 """
80 url = QUrl.fromUserInput(self.urlEdit.text())
81 userName = self.userEdit.text()
82 if userName:
83 url.setUserName(userName)
84 password = self.passwordEdit.text()
85 if password:
86 url.setPassword(password)
87
88 return self.nameEdit.text(), url.toString()

eric ide

mercurial