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 self.vcs = vcs |
46 self.vcs = vcs |
46 |
47 |
47 hd = Utilities.toNativeSeparators(QDir.homePath()) |
48 hd = Utilities.toNativeSeparators(QDir.homePath()) |
48 hd = os.path.join(hd, 'subversionroot') |
49 hd = os.path.join(hd, "subversionroot") |
49 self.vcsUrlPicker.setText(hd) |
50 self.vcsUrlPicker.setText(hd) |
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 def on_vcsUrlPicker_pickerButtonClicked(self): |
81 def on_vcsUrlPicker_pickerButtonClicked(self): |
85 """ |
82 """ |
86 Private slot to display a repository browser dialog. |
83 Private slot to display a repository browser dialog. |
87 """ |
84 """ |
88 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog |
85 from .SvnRepoBrowserDialog import SvnRepoBrowserDialog |
|
86 |
89 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self) |
87 dlg = SvnRepoBrowserDialog(self.vcs, mode="select", parent=self) |
90 dlg.start( |
88 dlg.start(self.protocolCombo.currentText() + self.vcsUrlPicker.text()) |
91 self.protocolCombo.currentText() + self.vcsUrlPicker.text()) |
|
92 if dlg.exec() == QDialog.DialogCode.Accepted: |
89 if dlg.exec() == QDialog.DialogCode.Accepted: |
93 url = dlg.getSelectedUrl() |
90 url = dlg.getSelectedUrl() |
94 if url: |
91 if url: |
95 protocol = url.split("://")[0] |
92 protocol = url.split("://")[0] |
96 path = url.split("://")[1] |
93 path = url.split("://")[1] |
97 self.protocolCombo.setCurrentIndex( |
94 self.protocolCombo.setCurrentIndex( |
98 self.protocolCombo.findText(protocol + "://")) |
95 self.protocolCombo.findText(protocol + "://") |
|
96 ) |
99 self.vcsUrlPicker.setText(path) |
97 self.vcsUrlPicker.setText(path) |
100 |
98 |
101 def on_layoutCheckBox_toggled(self, checked): |
99 def on_layoutCheckBox_toggled(self, checked): |
102 """ |
100 """ |
103 Private slot to handle the change of the layout checkbox. |
101 Private slot to handle the change of the layout checkbox. |
104 |
102 |
105 @param checked flag indicating the state of the checkbox (boolean) |
103 @param checked flag indicating the state of the checkbox (boolean) |
106 """ |
104 """ |
107 self.vcsTagLabel.setEnabled(checked) |
105 self.vcsTagLabel.setEnabled(checked) |
108 self.vcsTagEdit.setEnabled(checked) |
106 self.vcsTagEdit.setEnabled(checked) |
109 if not checked: |
107 if not checked: |
110 self.vcsTagEdit.clear() |
108 self.vcsTagEdit.clear() |
111 |
109 |
112 @pyqtSlot(int) |
110 @pyqtSlot(int) |
113 def on_protocolCombo_activated(self, index): |
111 def on_protocolCombo_activated(self, index): |
114 """ |
112 """ |
115 Private slot to switch the status of the directory selection button. |
113 Private slot to switch the status of the directory selection button. |
116 |
114 |
117 @param index index of the selected entry |
115 @param index index of the selected entry |
118 @type int |
116 @type int |
119 """ |
117 """ |
120 protocol = self.protocolCombo.itemText(index) |
118 protocol = self.protocolCombo.itemText(index) |
121 if protocol == "file://": |
119 if protocol == "file://": |
129 self.localPath = self.vcsUrlPicker.text() |
127 self.localPath = self.vcsUrlPicker.text() |
130 self.vcsUrlPicker.setText(self.networkPath) |
128 self.vcsUrlPicker.setText(self.networkPath) |
131 self.vcsUrlLabel.setText(self.tr("&URL:")) |
129 self.vcsUrlLabel.setText(self.tr("&URL:")) |
132 self.localProtocol = False |
130 self.localProtocol = False |
133 self.vcsUrlPicker.setMode(EricPathPickerModes.CUSTOM_MODE) |
131 self.vcsUrlPicker.setMode(EricPathPickerModes.CUSTOM_MODE) |
134 |
132 |
135 @pyqtSlot(str) |
133 @pyqtSlot(str) |
136 def on_vcsUrlPicker_textChanged(self, txt): |
134 def on_vcsUrlPicker_textChanged(self, txt): |
137 """ |
135 """ |
138 Private slot to handle changes of the URL. |
136 Private slot to handle changes of the URL. |
139 |
137 |
140 @param txt current text of the line edit (string) |
138 @param txt current text of the line edit (string) |
141 """ |
139 """ |
142 enable = "://" not in txt |
140 enable = "://" not in txt |
143 self.buttonBox.button( |
141 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable) |
144 QDialogButtonBox.StandardButton.Ok).setEnabled(enable) |
142 |
145 |
|
146 def getData(self): |
143 def getData(self): |
147 """ |
144 """ |
148 Public slot to retrieve the data entered into the dialog. |
145 Public slot to retrieve the data entered into the dialog. |
149 |
146 |
150 @return a tuple of a string (project directory) and a dictionary |
147 @return a tuple of a string (project directory) and a dictionary |
151 containing the data entered. |
148 containing the data entered. |
152 """ |
149 """ |
153 scheme = self.protocolCombo.currentText() |
150 scheme = self.protocolCombo.currentText() |
154 url = self.vcsUrlPicker.text() |
151 url = self.vcsUrlPicker.text() |
155 vcsdatadict = { |
152 vcsdatadict = { |
156 "url": '{0}{1}'.format(scheme, url), |
153 "url": "{0}{1}".format(scheme, url), |
157 "tag": self.vcsTagEdit.text(), |
154 "tag": self.vcsTagEdit.text(), |
158 "standardLayout": self.layoutCheckBox.isChecked(), |
155 "standardLayout": self.layoutCheckBox.isChecked(), |
159 } |
156 } |
160 return (self.vcsProjectDirPicker.text(), vcsdatadict) |
157 return (self.vcsProjectDirPicker.text(), vcsdatadict) |