|
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 PyQt4.QtCore import pyqtSlot, QUrl |
|
9 from PyQt4.QtGui import QDialog, QLineEdit |
|
10 |
|
11 from .Ui_HgRepoConfigDataDialog import Ui_HgRepoConfigDataDialog |
|
12 |
|
13 import UI.PixmapCache |
|
14 |
|
15 |
|
16 class HgRepoConfigDataDialog(QDialog, Ui_HgRepoConfigDataDialog): |
|
17 """ |
|
18 Class implementing a dialog to enter data needed for the initial creation |
|
19 of a repository configuration file (hgrc). |
|
20 """ |
|
21 def __init__(self, parent=None): |
|
22 """ |
|
23 Constructor |
|
24 |
|
25 @param parent reference to the parent widget (QWidget) |
|
26 """ |
|
27 super().__init__(parent) |
|
28 self.setupUi(self) |
|
29 |
|
30 self.defaultShowPasswordButton.setIcon( |
|
31 UI.PixmapCache.getIcon("showPassword.png")) |
|
32 self.defaultPushShowPasswordButton.setIcon( |
|
33 UI.PixmapCache.getIcon("showPassword.png")) |
|
34 |
|
35 self.resize(self.width(), self.minimumSizeHint().height()) |
|
36 |
|
37 @pyqtSlot(bool) |
|
38 def on_defaultShowPasswordButton_clicked(self, checked): |
|
39 """ |
|
40 Private slot to switch the default password visibility |
|
41 of the default password. |
|
42 """ |
|
43 if checked: |
|
44 self.defaultPasswordEdit.setEchoMode(QLineEdit.Normal) |
|
45 else: |
|
46 self.defaultPasswordEdit.setEchoMode(QLineEdit.Password) |
|
47 |
|
48 @pyqtSlot(bool) |
|
49 def on_defaultPushShowPasswordButton_clicked(self, checked): |
|
50 """ |
|
51 Private slot to switch the default password visibility |
|
52 of the default push password. |
|
53 """ |
|
54 if checked: |
|
55 self.defaultPushPasswordEdit.setEchoMode(QLineEdit.Normal) |
|
56 else: |
|
57 self.defaultPushPasswordEdit.setEchoMode(QLineEdit.Password) |
|
58 |
|
59 def getData(self): |
|
60 """ |
|
61 Public method to get the data entered into the dialog. |
|
62 |
|
63 @return tuple giving the default and default push URLs (tuple of |
|
64 two strings) |
|
65 """ |
|
66 defaultUrl = QUrl.fromUserInput(self.defaultUrlEdit.text()) |
|
67 username = self.defaultUserEdit.text() |
|
68 password = self.defaultPasswordEdit.text() |
|
69 if username: |
|
70 defaultUrl.setUserName(username) |
|
71 if password: |
|
72 defaultUrl.setPassword(password) |
|
73 if not defaultUrl.isValid(): |
|
74 defaultUrl = "" |
|
75 else: |
|
76 defaultUrl = defaultUrl.toString() |
|
77 |
|
78 defaultPushUrl = QUrl.fromUserInput(self.defaultPushUrlEdit.text()) |
|
79 username = self.defaultPushUserEdit.text() |
|
80 password = self.defaultPushPasswordEdit.text() |
|
81 if username: |
|
82 defaultPushUrl.setUserName(username) |
|
83 if password: |
|
84 defaultPushUrl.setPassword(password) |
|
85 if not defaultPushUrl.isValid(): |
|
86 defaultPushUrl = "" |
|
87 else: |
|
88 defaultPushUrl = defaultPushUrl.toString() |
|
89 |
|
90 return defaultUrl, defaultPushUrl |