13 import os |
13 import os |
14 |
14 |
15 from PyQt5.QtCore import QDir, pyqtSlot |
15 from PyQt5.QtCore import QDir, pyqtSlot |
16 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
16 from PyQt5.QtWidgets import QDialog, QDialogButtonBox |
17 |
17 |
18 from E5Gui.E5Completers import E5DirCompleter |
18 from E5Gui.E5PathPicker import E5PathPickerModes |
19 from E5Gui import E5FileDialog |
|
20 |
19 |
21 from .Ui_SvnOptionsDialog import Ui_SvnOptionsDialog |
20 from .Ui_SvnOptionsDialog import Ui_SvnOptionsDialog |
22 from .Config import ConfigSvnProtocols |
21 from .Config import ConfigSvnProtocols |
23 |
22 |
24 import Utilities |
23 import Utilities |
25 import UI.PixmapCache |
|
26 |
24 |
27 |
25 |
28 class SvnOptionsDialog(QDialog, Ui_SvnOptionsDialog): |
26 class SvnOptionsDialog(QDialog, Ui_SvnOptionsDialog): |
29 """ |
27 """ |
30 Class implementing a dialog to enter options used to start a project in the |
28 Class implementing a dialog to enter options used to start a project in the |
39 @param parent parent widget (QWidget) |
37 @param parent parent widget (QWidget) |
40 """ |
38 """ |
41 super(SvnOptionsDialog, self).__init__(parent) |
39 super(SvnOptionsDialog, self).__init__(parent) |
42 self.setupUi(self) |
40 self.setupUi(self) |
43 |
41 |
44 self.vcsUrlButton.setIcon(UI.PixmapCache.getIcon("open.png")) |
42 self.vcsUrlPicker.setMode(E5PathPickerModes.DirectoryMode) |
45 |
|
46 self.vcsDirectoryCompleter = E5DirCompleter(self.vcsUrlEdit) |
|
47 |
43 |
48 self.project = project |
44 self.project = project |
49 |
45 |
50 self.protocolCombo.addItems(ConfigSvnProtocols) |
46 self.protocolCombo.addItems(ConfigSvnProtocols) |
51 |
47 |
52 hd = Utilities.toNativeSeparators(QDir.homePath()) |
48 hd = Utilities.toNativeSeparators(QDir.homePath()) |
53 hd = os.path.join(hd, 'subversionroot') |
49 hd = os.path.join(hd, 'subversionroot') |
54 self.vcsUrlEdit.setText(hd) |
50 self.vcsUrlPicker.setText(hd) |
55 |
51 |
56 self.vcs = vcs |
52 self.vcs = vcs |
57 |
53 |
58 self.localPath = hd |
54 self.localPath = hd |
59 self.networkPath = "localhost/" |
55 self.networkPath = "localhost/" |
61 |
57 |
62 msh = self.minimumSizeHint() |
58 msh = self.minimumSizeHint() |
63 self.resize(max(self.width(), msh.width()), msh.height()) |
59 self.resize(max(self.width(), msh.width()), msh.height()) |
64 |
60 |
65 @pyqtSlot() |
61 @pyqtSlot() |
66 def on_vcsUrlButton_clicked(self): |
62 def on_vcsUrlPicker_pickerButtonClicked(self): |
67 """ |
63 """ |
68 Private slot to display a selection dialog. |
64 Private slot to display a repository browser dialog. |
69 """ |
65 """ |
70 if self.protocolCombo.currentText() == "file://": |
66 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog |
71 directory = E5FileDialog.getExistingDirectory( |
67 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self) |
72 self, |
68 dlg.start( |
73 self.tr("Select Repository-Directory"), |
69 self.protocolCombo.currentText() + self.vcsUrlPicker.text()) |
74 self.vcsUrlEdit.text(), |
70 if dlg.exec_() == QDialog.Accepted: |
75 E5FileDialog.Options(E5FileDialog.ShowDirsOnly)) |
71 url = dlg.getSelectedUrl() |
76 |
72 if url: |
77 if directory: |
73 protocol = url.split("://")[0] |
78 self.vcsUrlEdit.setText( |
74 path = url.split("://")[1] |
79 Utilities.toNativeSeparators(directory)) |
75 self.protocolCombo.setCurrentIndex( |
80 else: |
76 self.protocolCombo.findText(protocol + "://")) |
81 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog |
77 self.vcsUrlPicker.setText(path) |
82 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self) |
|
83 dlg.start( |
|
84 self.protocolCombo.currentText() + self.vcsUrlEdit.text()) |
|
85 if dlg.exec_() == QDialog.Accepted: |
|
86 url = dlg.getSelectedUrl() |
|
87 if url: |
|
88 protocol = url.split("://")[0] |
|
89 path = url.split("://")[1] |
|
90 self.protocolCombo.setCurrentIndex( |
|
91 self.protocolCombo.findText(protocol + "://")) |
|
92 self.vcsUrlEdit.setText(path) |
|
93 |
78 |
94 @pyqtSlot(str) |
79 @pyqtSlot(str) |
95 def on_protocolCombo_activated(self, protocol): |
80 def on_protocolCombo_activated(self, protocol): |
96 """ |
81 """ |
97 Private slot to switch the status of the directory selection button. |
82 Private slot to switch the status of the directory selection button. |
98 |
83 |
99 @param protocol selected protocol (string) |
84 @param protocol selected protocol (string) |
100 """ |
85 """ |
101 if protocol == "file://": |
86 if protocol == "file://": |
102 self.networkPath = self.vcsUrlEdit.text() |
87 self.networkPath = self.vcsUrlPicker.text() |
103 self.vcsUrlEdit.setText(self.localPath) |
88 self.vcsUrlPicker.setText(self.localPath) |
104 self.vcsUrlLabel.setText(self.tr("Pat&h:")) |
89 self.vcsUrlLabel.setText(self.tr("Pat&h:")) |
105 self.localProtocol = True |
90 self.localProtocol = True |
106 else: |
91 else: |
107 if self.localProtocol: |
92 if self.localProtocol: |
108 self.localPath = self.vcsUrlEdit.text() |
93 self.localPath = self.vcsUrlPicker.text() |
109 self.vcsUrlEdit.setText(self.networkPath) |
94 self.vcsUrlPicker.setText(self.networkPath) |
110 self.vcsUrlLabel.setText(self.tr("&URL:")) |
95 self.vcsUrlLabel.setText(self.tr("&URL:")) |
111 self.localProtocol = False |
96 self.localProtocol = False |
112 |
97 |
113 @pyqtSlot(str) |
98 @pyqtSlot(str) |
114 def on_vcsUrlEdit_textChanged(self, txt): |
99 def on_vcsUrlPicker_textChanged(self, txt): |
115 """ |
100 """ |
116 Private slot to handle changes of the URL. |
101 Private slot to handle changes of the URL. |
117 |
102 |
118 @param txt current text of the line edit (string) |
103 @param txt current text of the line edit (string) |
119 """ |
104 """ |
125 Public slot to retrieve the data entered into the dialog. |
110 Public slot to retrieve the data entered into the dialog. |
126 |
111 |
127 @return a dictionary containing the data entered |
112 @return a dictionary containing the data entered |
128 """ |
113 """ |
129 scheme = self.protocolCombo.currentText() |
114 scheme = self.protocolCombo.currentText() |
130 url = self.vcsUrlEdit.text() |
115 url = self.vcsUrlPicker.text() |
131 vcsdatadict = { |
116 vcsdatadict = { |
132 "url": '{0}{1}'.format(scheme, url), |
117 "url": '{0}{1}'.format(scheme, url), |
133 "message": self.vcsLogEdit.text(), |
118 "message": self.vcsLogEdit.text(), |
134 "standardLayout": self.layoutCheckBox.isChecked(), |
119 "standardLayout": self.layoutCheckBox.isChecked(), |
135 } |
120 } |