25 class SvnNewProjectOptionsDialog(QDialog, Ui_SvnNewProjectOptionsDialog): |
25 class SvnNewProjectOptionsDialog(QDialog, Ui_SvnNewProjectOptionsDialog): |
26 """ |
26 """ |
27 Class implementing the Options Dialog for a new project from the |
27 Class implementing the Options Dialog for a new project from the |
28 repository. |
28 repository. |
29 """ |
29 """ |
|
30 |
30 def __init__(self, vcs, parent=None): |
31 def __init__(self, vcs, parent=None): |
31 """ |
32 """ |
32 Constructor |
33 Constructor |
33 |
34 |
34 @param vcs reference to the version control object |
35 @param vcs reference to the version control object |
35 @param parent parent widget (QWidget) |
36 @param parent parent widget (QWidget) |
36 """ |
37 """ |
37 super().__init__(parent) |
38 super().__init__(parent) |
38 self.setupUi(self) |
39 self.setupUi(self) |
39 |
40 |
40 self.vcsProjectDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
41 self.vcsProjectDirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
41 self.vcsUrlPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
42 self.vcsUrlPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) |
42 |
43 |
43 self.protocolCombo.addItems(ConfigSvnProtocols) |
44 self.protocolCombo.addItems(ConfigSvnProtocols) |
44 |
45 |
45 hd = Utilities.toNativeSeparators(QDir.homePath()) |
46 hd = Utilities.toNativeSeparators(QDir.homePath()) |
46 hd = os.path.join(hd, 'subversionroot') |
47 hd = os.path.join(hd, "subversionroot") |
47 self.vcsUrlPicker.setText(hd) |
48 self.vcsUrlPicker.setText(hd) |
48 |
49 |
49 self.vcs = vcs |
50 self.vcs = vcs |
50 |
51 |
51 self.localPath = hd |
52 self.localPath = hd |
52 self.networkPath = "localhost/" |
53 self.networkPath = "localhost/" |
53 self.localProtocol = True |
54 self.localProtocol = True |
54 |
55 |
55 ipath = ( |
56 ipath = Preferences.getMultiProject("Workspace") or Utilities.getHomeDir() |
56 Preferences.getMultiProject("Workspace") or |
|
57 Utilities.getHomeDir() |
|
58 ) |
|
59 self.__initPaths = [ |
57 self.__initPaths = [ |
60 Utilities.fromNativeSeparators(ipath), |
58 Utilities.fromNativeSeparators(ipath), |
61 Utilities.fromNativeSeparators(ipath) + "/", |
59 Utilities.fromNativeSeparators(ipath) + "/", |
62 ] |
60 ] |
63 self.vcsProjectDirPicker.setText(self.__initPaths[0]) |
61 self.vcsProjectDirPicker.setText(self.__initPaths[0]) |
64 |
62 |
65 self.resize(self.width(), self.minimumSizeHint().height()) |
63 self.resize(self.width(), self.minimumSizeHint().height()) |
66 |
64 |
67 self.buttonBox.button( |
65 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
68 QDialogButtonBox.StandardButton.Ok).setEnabled(False) |
66 |
69 |
|
70 msh = self.minimumSizeHint() |
67 msh = self.minimumSizeHint() |
71 self.resize(max(self.width(), msh.width()), msh.height()) |
68 self.resize(max(self.width(), msh.width()), msh.height()) |
72 |
69 |
73 @pyqtSlot(str) |
70 @pyqtSlot(str) |
74 def on_vcsProjectDirPicker_textChanged(self, txt): |
71 def on_vcsProjectDirPicker_textChanged(self, txt): |
75 """ |
72 """ |
76 Private slot to handle a change of the project directory. |
73 Private slot to handle a change of the project directory. |
77 |
74 |
78 @param txt name of the project directory (string) |
75 @param txt name of the project directory (string) |
79 """ |
76 """ |
80 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
77 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
81 bool(txt) and |
78 bool(txt) and Utilities.fromNativeSeparators(txt) not in self.__initPaths |
82 Utilities.fromNativeSeparators(txt) not in self.__initPaths) |
79 ) |
83 |
80 |
84 @pyqtSlot() |
81 @pyqtSlot() |
85 def on_vcsUrlPicker_pickerButtonClicked(self): |
82 def on_vcsUrlPicker_pickerButtonClicked(self): |
86 """ |
83 """ |
87 Private slot to display a repository browser dialog. |
84 Private slot to display a repository browser dialog. |
88 """ |
85 """ |
89 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog |
86 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog |
|
87 |
90 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self) |
88 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self) |
91 dlg.start( |
89 dlg.start(self.protocolCombo.currentText() + self.vcsUrlPicker.text()) |
92 self.protocolCombo.currentText() + self.vcsUrlPicker.text()) |
|
93 if dlg.exec() == QDialog.DialogCode.Accepted: |
90 if dlg.exec() == QDialog.DialogCode.Accepted: |
94 url = dlg.getSelectedUrl() |
91 url = dlg.getSelectedUrl() |
95 if url: |
92 if url: |
96 protocol = url.split("://")[0] |
93 protocol = url.split("://")[0] |
97 path = url.split("://")[1] |
94 path = url.split("://")[1] |
98 self.protocolCombo.setCurrentIndex( |
95 self.protocolCombo.setCurrentIndex( |
99 self.protocolCombo.findText(protocol + "://")) |
96 self.protocolCombo.findText(protocol + "://") |
|
97 ) |
100 self.vcsUrlPicker.setText(path) |
98 self.vcsUrlPicker.setText(path) |
101 |
99 |
102 def on_layoutCheckBox_toggled(self, checked): |
100 def on_layoutCheckBox_toggled(self, checked): |
103 """ |
101 """ |
104 Private slot to handle the change of the layout checkbox. |
102 Private slot to handle the change of the layout checkbox. |
105 |
103 |
106 @param checked flag indicating the state of the checkbox (boolean) |
104 @param checked flag indicating the state of the checkbox (boolean) |
107 """ |
105 """ |
108 self.vcsTagLabel.setEnabled(checked) |
106 self.vcsTagLabel.setEnabled(checked) |
109 self.vcsTagEdit.setEnabled(checked) |
107 self.vcsTagEdit.setEnabled(checked) |
110 if not checked: |
108 if not checked: |
111 self.vcsTagEdit.clear() |
109 self.vcsTagEdit.clear() |
112 |
110 |
113 @pyqtSlot(int) |
111 @pyqtSlot(int) |
114 def on_protocolCombo_activated(self, index): |
112 def on_protocolCombo_activated(self, index): |
115 """ |
113 """ |
116 Private slot to switch the status of the directory selection button. |
114 Private slot to switch the status of the directory selection button. |
117 |
115 |
118 @param index index of the selected entry |
116 @param index index of the selected entry |
119 @type int |
117 @type int |
120 """ |
118 """ |
121 protocol = self.protocolCombo.itemText(index) |
119 protocol = self.protocolCombo.itemText(index) |
122 if protocol == "file://": |
120 if protocol == "file://": |
130 self.localPath = self.vcsUrlPicker.text() |
128 self.localPath = self.vcsUrlPicker.text() |
131 self.vcsUrlPicker.setText(self.networkPath) |
129 self.vcsUrlPicker.setText(self.networkPath) |
132 self.vcsUrlLabel.setText(self.tr("&URL:")) |
130 self.vcsUrlLabel.setText(self.tr("&URL:")) |
133 self.localProtocol = False |
131 self.localProtocol = False |
134 self.vcsUrlPicker.setMode(EricPathPickerModes.CUSTOM_MODE) |
132 self.vcsUrlPicker.setMode(EricPathPickerModes.CUSTOM_MODE) |
135 |
133 |
136 @pyqtSlot(str) |
134 @pyqtSlot(str) |
137 def on_vcsUrlPicker_textChanged(self, txt): |
135 def on_vcsUrlPicker_textChanged(self, txt): |
138 """ |
136 """ |
139 Private slot to handle changes of the URL. |
137 Private slot to handle changes of the URL. |
140 |
138 |
141 @param txt current text of the line edit (string) |
139 @param txt current text of the line edit (string) |
142 """ |
140 """ |
143 enable = "://" not in txt |
141 enable = "://" not in txt |
144 self.buttonBox.button( |
142 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable) |
145 QDialogButtonBox.StandardButton.Ok).setEnabled(enable) |
143 |
146 |
|
147 def getData(self): |
144 def getData(self): |
148 """ |
145 """ |
149 Public slot to retrieve the data entered into the dialog. |
146 Public slot to retrieve the data entered into the dialog. |
150 |
147 |
151 @return a tuple of a string (project directory) and a dictionary |
148 @return a tuple of a string (project directory) and a dictionary |
152 containing the data entered. |
149 containing the data entered. |
153 """ |
150 """ |
154 scheme = self.protocolCombo.currentText() |
151 scheme = self.protocolCombo.currentText() |
155 url = self.vcsUrlPicker.text() |
152 url = self.vcsUrlPicker.text() |
156 vcsdatadict = { |
153 vcsdatadict = { |
157 "url": '{0}{1}'.format(scheme, url), |
154 "url": "{0}{1}".format(scheme, url), |
158 "tag": self.vcsTagEdit.text(), |
155 "tag": self.vcsTagEdit.text(), |
159 "standardLayout": self.layoutCheckBox.isChecked(), |
156 "standardLayout": self.layoutCheckBox.isChecked(), |
160 } |
157 } |
161 return (self.vcsProjectDirPicker.text(), vcsdatadict) |
158 return (self.vcsProjectDirPicker.text(), vcsdatadict) |