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

eric ide

mercurial