|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2002 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing a dialog to enter options used to start a project in |
|
8 the VCS. |
|
9 """ |
|
10 |
|
11 import os |
|
12 |
|
13 from PyQt5.QtCore import QDir, pyqtSlot |
|
14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
|
15 |
|
16 from E5Gui.E5PathPicker import E5PathPickerModes |
|
17 |
|
18 from .Ui_SvnOptionsDialog import Ui_SvnOptionsDialog |
|
19 from .Config import ConfigSvnProtocols |
|
20 |
|
21 import Utilities |
|
22 |
|
23 |
|
24 class SvnOptionsDialog(QDialog, Ui_SvnOptionsDialog): |
|
25 """ |
|
26 Class implementing a dialog to enter options used to start a project in the |
|
27 repository. |
|
28 """ |
|
29 def __init__(self, vcs, project, parent=None): |
|
30 """ |
|
31 Constructor |
|
32 |
|
33 @param vcs reference to the version control object |
|
34 @param project reference to the project object |
|
35 @param parent parent widget (QWidget) |
|
36 """ |
|
37 super().__init__(parent) |
|
38 self.setupUi(self) |
|
39 |
|
40 self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode) |
|
41 |
|
42 self.project = project |
|
43 |
|
44 self.protocolCombo.addItems(ConfigSvnProtocols) |
|
45 |
|
46 hd = Utilities.toNativeSeparators(QDir.homePath()) |
|
47 hd = os.path.join(hd, 'subversionroot') |
|
48 self.vcsUrlPicker.setText(hd) |
|
49 |
|
50 self.vcs = vcs |
|
51 |
|
52 self.localPath = hd |
|
53 self.networkPath = "localhost/" |
|
54 self.localProtocol = True |
|
55 |
|
56 msh = self.minimumSizeHint() |
|
57 self.resize(max(self.width(), msh.width()), msh.height()) |
|
58 |
|
59 @pyqtSlot() |
|
60 def on_vcsUrlPicker_pickerButtonClicked(self): |
|
61 """ |
|
62 Private slot to display a repository browser dialog. |
|
63 """ |
|
64 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog |
|
65 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self) |
|
66 dlg.start( |
|
67 self.protocolCombo.currentText() + self.vcsUrlPicker.text()) |
|
68 if dlg.exec() == QDialog.DialogCode.Accepted: |
|
69 url = dlg.getSelectedUrl() |
|
70 if url: |
|
71 protocol = url.split("://")[0] |
|
72 path = url.split("://")[1] |
|
73 self.protocolCombo.setCurrentIndex( |
|
74 self.protocolCombo.findText(protocol + "://")) |
|
75 self.vcsUrlPicker.setText(path) |
|
76 |
|
77 @pyqtSlot(int) |
|
78 def on_protocolCombo_activated(self, index): |
|
79 """ |
|
80 Private slot to switch the status of the directory selection button. |
|
81 |
|
82 @param index index of the selected entry |
|
83 @type int |
|
84 """ |
|
85 protocol = self.protocolCombo.itemText(index) |
|
86 if protocol == "file://": |
|
87 self.networkPath = self.vcsUrlPicker.text() |
|
88 self.vcsUrlPicker.setText(self.localPath) |
|
89 self.vcsUrlLabel.setText(self.tr("Pat&h:")) |
|
90 self.localProtocol = True |
|
91 else: |
|
92 if self.localProtocol: |
|
93 self.localPath = self.vcsUrlPicker.text() |
|
94 self.vcsUrlPicker.setText(self.networkPath) |
|
95 self.vcsUrlLabel.setText(self.tr("&URL:")) |
|
96 self.localProtocol = False |
|
97 |
|
98 @pyqtSlot(str) |
|
99 def on_vcsUrlPicker_textChanged(self, txt): |
|
100 """ |
|
101 Private slot to handle changes of the URL. |
|
102 |
|
103 @param txt current text of the line edit (string) |
|
104 """ |
|
105 enable = "://" not in txt |
|
106 self.buttonBox.button( |
|
107 QDialogButtonBox.StandardButton.Ok).setEnabled(enable) |
|
108 |
|
109 def getData(self): |
|
110 """ |
|
111 Public slot to retrieve the data entered into the dialog. |
|
112 |
|
113 @return a dictionary containing the data entered |
|
114 """ |
|
115 scheme = self.protocolCombo.currentText() |
|
116 url = self.vcsUrlPicker.text() |
|
117 vcsdatadict = { |
|
118 "url": '{0}{1}'.format(scheme, url), |
|
119 "message": self.vcsLogEdit.text(), |
|
120 "standardLayout": self.layoutCheckBox.isChecked(), |
|
121 } |
|
122 return vcsdatadict |