Plugins/VcsPlugins/vcsMercurial/HgRepoConfigDataDialog.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3311
b4775920f5b8
child 3656
441956d8fce5
equal deleted inserted replaced
3456:96232974dcdb 3484:645c12de6b0c
1 # -*- coding: utf-8 -*-
2
3 """
4 Module implementing a dialog to enter data needed for the initial creation
5 of a repository configuration file (hgrc).
6 """
7
8 from __future__ import unicode_literals
9
10 from PyQt4.QtCore import pyqtSlot, QUrl
11 from PyQt4.QtGui import QDialog, QLineEdit
12
13 from .Ui_HgRepoConfigDataDialog import Ui_HgRepoConfigDataDialog
14
15 import UI.PixmapCache
16
17 from .LargefilesExtension import getDefaults as getLargefilesDefaults
18
19
20 class HgRepoConfigDataDialog(QDialog, Ui_HgRepoConfigDataDialog):
21 """
22 Class implementing a dialog to enter data needed for the initial creation
23 of a repository configuration file (hgrc).
24 """
25 def __init__(self, withLargefiles=False, largefilesData=None, parent=None):
26 """
27 Constructor
28
29 @param withLargefiles flag indicating to configure the largefiles
30 section (boolean)
31 @param largefilesData dictionary with data for the largefiles
32 section (dict)
33 @param parent reference to the parent widget (QWidget)
34 """
35 super(HgRepoConfigDataDialog, self).__init__(parent)
36 self.setupUi(self)
37
38 self.defaultShowPasswordButton.setIcon(
39 UI.PixmapCache.getIcon("showPassword.png"))
40 self.defaultPushShowPasswordButton.setIcon(
41 UI.PixmapCache.getIcon("showPassword.png"))
42
43 self.__withLargefiles = withLargefiles
44 if withLargefiles:
45 if largefilesData is None:
46 largefilesData = getLargefilesDefaults()
47 self.lfFileSizeSpinBox.setValue(largefilesData["minsize"])
48 self.lfFilePatternsEdit.setText(
49 " ".join(largefilesData["pattern"]))
50 else:
51 self.largefilesGroup.setVisible(False)
52
53 self.resize(self.width(), self.minimumSizeHint().height())
54
55 @pyqtSlot(bool)
56 def on_defaultShowPasswordButton_clicked(self, checked):
57 """
58 Private slot to switch the default password visibility
59 of the default password.
60
61 @param checked state of the push button (boolean)
62 """
63 if checked:
64 self.defaultPasswordEdit.setEchoMode(QLineEdit.Normal)
65 else:
66 self.defaultPasswordEdit.setEchoMode(QLineEdit.Password)
67
68 @pyqtSlot(bool)
69 def on_defaultPushShowPasswordButton_clicked(self, checked):
70 """
71 Private slot to switch the default password visibility
72 of the default push password.
73
74 @param checked state of the push button (boolean)
75 """
76 if checked:
77 self.defaultPushPasswordEdit.setEchoMode(QLineEdit.Normal)
78 else:
79 self.defaultPushPasswordEdit.setEchoMode(QLineEdit.Password)
80
81 def getData(self):
82 """
83 Public method to get the data entered into the dialog.
84
85 @return tuple giving the default and default push URLs (tuple of
86 two strings)
87 """
88 defaultUrl = QUrl.fromUserInput(self.defaultUrlEdit.text())
89 username = self.defaultUserEdit.text()
90 password = self.defaultPasswordEdit.text()
91 if username:
92 defaultUrl.setUserName(username)
93 if password:
94 defaultUrl.setPassword(password)
95 if not defaultUrl.isValid():
96 defaultUrl = ""
97 else:
98 defaultUrl = defaultUrl.toString()
99
100 defaultPushUrl = QUrl.fromUserInput(self.defaultPushUrlEdit.text())
101 username = self.defaultPushUserEdit.text()
102 password = self.defaultPushPasswordEdit.text()
103 if username:
104 defaultPushUrl.setUserName(username)
105 if password:
106 defaultPushUrl.setPassword(password)
107 if not defaultPushUrl.isValid():
108 defaultPushUrl = ""
109 else:
110 defaultPushUrl = defaultPushUrl.toString()
111
112 return defaultUrl, defaultPushUrl
113
114 def getLargefilesData(self):
115 """
116 Public method to get the data for the largefiles extension.
117
118 @return tuple with the minimum file size (integer) and file patterns
119 (list of string). None as value denote to use the default value.
120 """
121 if self.__withLargefiles:
122 lfDefaults = getLargefilesDefaults()
123 if self.lfFileSizeSpinBox.value() == lfDefaults["minsize"]:
124 minsize = None
125 else:
126 minsize = self.lfFileSizeSpinBox.value()
127 patterns = self.lfFilePatternsEdit.text().split()
128 if set(patterns) == set(lfDefaults["pattern"]):
129 patterns = None
130
131 return minsize, patterns
132 else:
133 return None, None

eric ide

mercurial