eric6/Plugins/VcsPlugins/vcsGit/GitAddRemoteDialog.py

Tue, 10 Sep 2019 19:30:07 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 10 Sep 2019 19:30:07 +0200
changeset 7229
53054eb5b15a
parent 6942
2602857055c5
child 7360
9190402e4505
permissions
-rw-r--r--

Removed obsolete "from __future__ import ..." statements.

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

eric ide

mercurial