5668:9ddb22979968 | 5669:63295be38bc6 |
---|---|
11 | 11 |
12 import os | 12 import os |
13 import shutil | 13 import shutil |
14 import copy | 14 import copy |
15 | 15 |
16 from PyQt5.QtCore import pyqtSlot, QDir, QFileInfo, QObject | 16 from PyQt5.QtCore import pyqtSlot, QDir, QFileInfo, QObject, QCoreApplication |
17 from PyQt5.QtWidgets import QDialog, QInputDialog, QToolBar | 17 from PyQt5.QtWidgets import QDialog, QInputDialog, QToolBar |
18 | 18 |
19 from E5Gui.E5Action import E5Action | 19 from E5Gui.E5Action import E5Action |
20 from E5Gui import E5MessageBox | 20 from E5Gui import E5MessageBox |
21 from E5Gui.E5Application import e5App | 21 from E5Gui.E5Application import e5App |
64 def initActions(self): | 64 def initActions(self): |
65 """ | 65 """ |
66 Public method to generate the action objects. | 66 Public method to generate the action objects. |
67 """ | 67 """ |
68 self.vcsNewAct = E5Action( | 68 self.vcsNewAct = E5Action( |
69 self.tr('New from repository'), | 69 QCoreApplication.translate( |
70 "VcsProjectHelper", 'New from repository'), | |
70 UI.PixmapCache.getIcon("vcsCheckout.png"), | 71 UI.PixmapCache.getIcon("vcsCheckout.png"), |
71 self.tr('&New from repository...'), | 72 QCoreApplication.translate( |
73 "VcsProjectHelper", '&New from repository...'), | |
72 0, 0, self, 'vcs_new') | 74 0, 0, self, 'vcs_new') |
73 self.vcsNewAct.setStatusTip(self.tr( | 75 self.vcsNewAct.setStatusTip(QCoreApplication.translate( |
76 "VcsProjectHelper", | |
74 'Create a new project from the VCS repository' | 77 'Create a new project from the VCS repository' |
75 )) | 78 )) |
76 self.vcsNewAct.setWhatsThis(self.tr( | 79 self.vcsNewAct.setWhatsThis(QCoreApplication.translate( |
80 "VcsProjectHelper", | |
77 """<b>New from repository</b>""" | 81 """<b>New from repository</b>""" |
78 """<p>This creates a new local project from the VCS""" | 82 """<p>This creates a new local project from the VCS""" |
79 """ repository.</p>""" | 83 """ repository.</p>""" |
80 )) | 84 )) |
81 self.vcsNewAct.triggered.connect(self._vcsCheckout) | 85 self.vcsNewAct.triggered.connect(self._vcsCheckout) |
82 self.actions.append(self.vcsNewAct) | 86 self.actions.append(self.vcsNewAct) |
83 | 87 |
84 self.vcsExportAct = E5Action( | 88 self.vcsExportAct = E5Action( |
85 self.tr('Export from repository'), | 89 QCoreApplication.translate( |
90 "VcsProjectHelper", 'Export from repository'), | |
86 UI.PixmapCache.getIcon("vcsExport.png"), | 91 UI.PixmapCache.getIcon("vcsExport.png"), |
87 self.tr('&Export from repository...'), | 92 QCoreApplication.translate( |
93 "VcsProjectHelper", '&Export from repository...'), | |
88 0, 0, self, 'vcs_export') | 94 0, 0, self, 'vcs_export') |
89 self.vcsExportAct.setStatusTip(self.tr( | 95 self.vcsExportAct.setStatusTip(QCoreApplication.translate( |
96 "VcsProjectHelper", | |
90 'Export a project from the repository' | 97 'Export a project from the repository' |
91 )) | 98 )) |
92 self.vcsExportAct.setWhatsThis(self.tr( | 99 self.vcsExportAct.setWhatsThis(QCoreApplication.translate( |
100 "VcsProjectHelper", | |
93 """<b>Export from repository</b>""" | 101 """<b>Export from repository</b>""" |
94 """<p>This exports a project from the repository.</p>""" | 102 """<p>This exports a project from the repository.</p>""" |
95 )) | 103 )) |
96 self.vcsExportAct.triggered.connect(self._vcsExport) | 104 self.vcsExportAct.triggered.connect(self._vcsExport) |
97 self.actions.append(self.vcsExportAct) | 105 self.actions.append(self.vcsExportAct) |
98 | 106 |
99 self.vcsAddAct = E5Action( | 107 self.vcsAddAct = E5Action( |
100 self.tr('Add to repository'), | 108 QCoreApplication.translate( |
109 "VcsProjectHelper", 'Add to repository'), | |
101 UI.PixmapCache.getIcon("vcsCommit.png"), | 110 UI.PixmapCache.getIcon("vcsCommit.png"), |
102 self.tr('&Add to repository...'), | 111 QCoreApplication.translate( |
112 "VcsProjectHelper", '&Add to repository...'), | |
103 0, 0, self, 'vcs_add') | 113 0, 0, self, 'vcs_add') |
104 self.vcsAddAct.setStatusTip(self.tr( | 114 self.vcsAddAct.setStatusTip(QCoreApplication.translate( |
115 "VcsProjectHelper", | |
105 'Add the local project to the VCS repository' | 116 'Add the local project to the VCS repository' |
106 )) | 117 )) |
107 self.vcsAddAct.setWhatsThis(self.tr( | 118 self.vcsAddAct.setWhatsThis(QCoreApplication.translate( |
119 "VcsProjectHelper", | |
108 """<b>Add to repository</b>""" | 120 """<b>Add to repository</b>""" |
109 """<p>This adds (imports) the local project to the VCS""" | 121 """<p>This adds (imports) the local project to the VCS""" |
110 """ repository.</p>""" | 122 """ repository.</p>""" |
111 )) | 123 )) |
112 self.vcsAddAct.triggered.connect(self._vcsImport) | 124 self.vcsAddAct.triggered.connect(self._vcsImport) |
144 @param ui reference to the main window (UserInterface) | 156 @param ui reference to the main window (UserInterface) |
145 @param toolbarManager reference to a toolbar manager object | 157 @param toolbarManager reference to a toolbar manager object |
146 (E5ToolBarManager) | 158 (E5ToolBarManager) |
147 @return the toolbar generated (QToolBar) | 159 @return the toolbar generated (QToolBar) |
148 """ | 160 """ |
149 tb = QToolBar(self.tr("VCS"), ui) | 161 tb = QToolBar(QCoreApplication.translate("VcsProjectHelper", "VCS"), |
162 ui) | |
150 tb.setIconSize(UI.Config.ToolBarIconSize) | 163 tb.setIconSize(UI.Config.ToolBarIconSize) |
151 tb.setObjectName("VersionControlToolbar") | 164 tb.setObjectName("VersionControlToolbar") |
152 tb.setToolTip(self.tr('VCS')) | 165 tb.setToolTip(QCoreApplication.translate("VcsProjectHelper", 'VCS')) |
153 | 166 |
154 tb.addAction(self.vcsNewAct) | 167 tb.addAction(self.vcsNewAct) |
155 tb.addAction(self.vcsExportAct) | 168 tb.addAction(self.vcsExportAct) |
156 tb.addSeparator() | 169 tb.addSeparator() |
157 tb.addAction(self.vcsAddAct) | 170 tb.addAction(self.vcsAddAct) |
188 keys = sorted(vcsSystemsDict.keys()) | 201 keys = sorted(vcsSystemsDict.keys()) |
189 for key in keys: | 202 for key in keys: |
190 vcsSystemsDisplay.append(vcsSystemsDict[key]) | 203 vcsSystemsDisplay.append(vcsSystemsDict[key]) |
191 vcsSelected, ok = QInputDialog.getItem( | 204 vcsSelected, ok = QInputDialog.getItem( |
192 None, | 205 None, |
193 self.tr("New Project"), | 206 QCoreApplication.translate("VcsProjectHelper", "New Project"), |
194 self.tr("Select version control system for the project"), | 207 QCoreApplication.translate( |
208 "VcsProjectHelper", | |
209 "Select version control system for the project"), | |
195 vcsSystemsDisplay, | 210 vcsSystemsDisplay, |
196 0, False) | 211 0, False) |
197 if not ok: | 212 if not ok: |
198 return | 213 return |
199 for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()): | 214 for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()): |
213 self.project.vcs = self.project.initVCS(vcsSystem) | 228 self.project.vcs = self.project.initVCS(vcsSystem) |
214 # edit VCS command options | 229 # edit VCS command options |
215 if self.project.vcs.vcsSupportCommandOptions(): | 230 if self.project.vcs.vcsSupportCommandOptions(): |
216 vcores = E5MessageBox.yesNo( | 231 vcores = E5MessageBox.yesNo( |
217 self.parent(), | 232 self.parent(), |
218 self.tr("New Project"), | 233 QCoreApplication.translate( |
219 self.tr( | 234 "VcsProjectHelper", "New Project"), |
235 QCoreApplication.translate( | |
236 "VcsProjectHelper", | |
220 """Would you like to edit the VCS command""" | 237 """Would you like to edit the VCS command""" |
221 """ options?""")) | 238 """ options?""")) |
222 else: | 239 else: |
223 vcores = False | 240 vcores = False |
224 if vcores: | 241 if vcores: |
232 try: | 249 try: |
233 os.makedirs(projectdir) | 250 os.makedirs(projectdir) |
234 except EnvironmentError: | 251 except EnvironmentError: |
235 E5MessageBox.critical( | 252 E5MessageBox.critical( |
236 self.parent(), | 253 self.parent(), |
237 self.tr("Create project directory"), | 254 QCoreApplication.translate( |
238 self.tr( | 255 "VcsProjectHelper", |
256 "Create project directory"), | |
257 QCoreApplication.translate( | |
258 "VcsProjectHelper", | |
239 "<p>The project directory <b>{0}</b> could not" | 259 "<p>The project directory <b>{0}</b> could not" |
240 " be created.</p>").format(projectdir)) | 260 " be created.</p>").format(projectdir)) |
241 self.project.pdata["VCS"] = 'None' | 261 self.project.pdata["VCS"] = 'None' |
242 self.project.vcs = self.project.initVCS() | 262 self.project.vcs = self.project.initVCS() |
243 return | 263 return |
261 self.project.newProject.emit() | 281 self.project.newProject.emit() |
262 else: | 282 else: |
263 pfilenamelist = d.entryList(filters) | 283 pfilenamelist = d.entryList(filters) |
264 pfilename, ok = QInputDialog.getItem( | 284 pfilename, ok = QInputDialog.getItem( |
265 None, | 285 None, |
266 self.tr("New project from repository"), | 286 QCoreApplication.translate( |
267 self.tr("Select a project file to open."), | 287 "VcsProjectHelper", |
288 "New project from repository"), | |
289 QCoreApplication.translate( | |
290 "VcsProjectHelper", | |
291 "Select a project file to open."), | |
268 pfilenamelist, 0, False) | 292 pfilenamelist, 0, False) |
269 if ok: | 293 if ok: |
270 self.project.openProject( | 294 self.project.openProject( |
271 QFileInfo(d, pfilename).absoluteFilePath()) | 295 QFileInfo(d, pfilename).absoluteFilePath()) |
272 self.project.newProject.emit() | 296 self.project.newProject.emit() |
276 self.project.setDirty(True) | 300 self.project.setDirty(True) |
277 self.project.saveProject() | 301 self.project.saveProject() |
278 else: | 302 else: |
279 res = E5MessageBox.yesNo( | 303 res = E5MessageBox.yesNo( |
280 self.parent(), | 304 self.parent(), |
281 self.tr("New project from repository"), | 305 QCoreApplication.translate( |
282 self.tr( | 306 "VcsProjectHelper", |
307 "New project from repository"), | |
308 QCoreApplication.translate( | |
309 "VcsProjectHelper", | |
283 "The project retrieved from the repository" | 310 "The project retrieved from the repository" |
284 " does not contain an eric project file" | 311 " does not contain an eric project file" |
285 " (*.e4p). Create it?"), | 312 " (*.e4p). Create it?"), |
286 yesDefault=True) | 313 yesDefault=True) |
287 if res: | 314 if res: |
308 self.project.saveProject() | 335 self.project.saveProject() |
309 self.project.openProject(self.project.pfile) | 336 self.project.openProject(self.project.pfile) |
310 if not export: | 337 if not export: |
311 res = E5MessageBox.yesNo( | 338 res = E5MessageBox.yesNo( |
312 self.parent(), | 339 self.parent(), |
313 self.tr( | 340 QCoreApplication.translate( |
341 "VcsProjectHelper", | |
314 "New project from repository"), | 342 "New project from repository"), |
315 self.tr( | 343 QCoreApplication.translate( |
344 "VcsProjectHelper", | |
316 "Shall the project file be added" | 345 "Shall the project file be added" |
317 " to the repository?"), | 346 " to the repository?"), |
318 yesDefault=True) | 347 yesDefault=True) |
319 if res: | 348 if res: |
320 self.project.vcs.vcsAdd( | 349 self.project.vcs.vcsAdd( |
321 self.project.pfile) | 350 self.project.pfile) |
322 else: | 351 else: |
323 E5MessageBox.critical( | 352 E5MessageBox.critical( |
324 self.parent(), | 353 self.parent(), |
325 self.tr("New project from repository"), | 354 QCoreApplication.translate( |
326 self.tr( | 355 "VcsProjectHelper", "New project from repository"), |
356 QCoreApplication.translate( | |
357 "VcsProjectHelper", | |
327 """The project could not be retrieved from""" | 358 """The project could not be retrieved from""" |
328 """ the repository.""")) | 359 """ the repository.""")) |
329 self.project.pdata["VCS"] = 'None' | 360 self.project.pdata["VCS"] = 'None' |
330 self.project.vcs = self.project.initVCS() | 361 self.project.vcs = self.project.initVCS() |
331 else: | 362 else: |
376 keys = sorted(list(vcsSystemsDict.keys())) | 407 keys = sorted(list(vcsSystemsDict.keys())) |
377 for key in keys: | 408 for key in keys: |
378 vcsSystemsDisplay.append(vcsSystemsDict[key]) | 409 vcsSystemsDisplay.append(vcsSystemsDict[key]) |
379 vcsSelected, ok = QInputDialog.getItem( | 410 vcsSelected, ok = QInputDialog.getItem( |
380 None, | 411 None, |
381 self.tr("Import Project"), | 412 QCoreApplication.translate("VcsProjectHelper", "Import Project"), |
382 self.tr("Select version control system for the project"), | 413 QCoreApplication.translate( |
414 "VcsProjectHelper", | |
415 "Select version control system for the project"), | |
383 vcsSystemsDisplay, | 416 vcsSystemsDisplay, |
384 0, False) | 417 0, False) |
385 if not ok: | 418 if not ok: |
386 return | 419 return |
387 for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()): | 420 for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()): |
397 vcsDataDict = vcsdlg.getData() | 430 vcsDataDict = vcsdlg.getData() |
398 # edit VCS command options | 431 # edit VCS command options |
399 if self.project.vcs.vcsSupportCommandOptions(): | 432 if self.project.vcs.vcsSupportCommandOptions(): |
400 vcores = E5MessageBox.yesNo( | 433 vcores = E5MessageBox.yesNo( |
401 self.parent(), | 434 self.parent(), |
402 self.tr("Import Project"), | 435 QCoreApplication.translate( |
403 self.tr( | 436 "VcsProjectHelper", "Import Project"), |
437 QCoreApplication.translate( | |
438 "VcsProjectHelper", | |
404 """Would you like to edit the VCS command""" | 439 """Would you like to edit the VCS command""" |
405 """ options?""")) | 440 """ options?""")) |
406 else: | 441 else: |
407 vcores = False | 442 vcores = False |
408 if vcores: | 443 if vcores: |
432 """ | 467 """ |
433 shouldReopen = self.vcs.vcsUpdate(self.project.ppath) | 468 shouldReopen = self.vcs.vcsUpdate(self.project.ppath) |
434 if shouldReopen: | 469 if shouldReopen: |
435 res = E5MessageBox.yesNo( | 470 res = E5MessageBox.yesNo( |
436 self.parent(), | 471 self.parent(), |
437 self.tr("Update"), | 472 QCoreApplication.translate("VcsProjectHelper", "Update"), |
438 self.tr("""The project should be reread. Do this now?"""), | 473 QCoreApplication.translate( |
474 "VcsProjectHelper", | |
475 """The project should be reread. Do this now?"""), | |
439 yesDefault=True) | 476 yesDefault=True) |
440 if res: | 477 if res: |
441 self.project.reopenProject() | 478 self.project.reopenProject() |
442 | 479 |
443 def _vcsCommit(self): | 480 def _vcsCommit(self): |
458 Depending on the parameters set in the vcs object the project | 495 Depending on the parameters set in the vcs object the project |
459 may be removed from the local disk as well. | 496 may be removed from the local disk as well. |
460 """ | 497 """ |
461 res = E5MessageBox.yesNo( | 498 res = E5MessageBox.yesNo( |
462 self.parent(), | 499 self.parent(), |
463 self.tr("Remove project from repository"), | 500 QCoreApplication.translate( |
464 self.tr( | 501 "VcsProjectHelper", |
502 "Remove project from repository"), | |
503 QCoreApplication.translate( | |
504 "VcsProjectHelper", | |
465 "Dou you really want to remove this project from" | 505 "Dou you really want to remove this project from" |
466 " the repository (and disk)?")) | 506 " the repository (and disk)?")) |
467 if res: | 507 if res: |
468 self.vcs.vcsRemove(self.project.ppath, True) | 508 self.vcs.vcsRemove(self.project.ppath, True) |
469 self._vcsCommit() | 509 self._vcsCommit() |
529 """ | 569 """ |
530 shouldReopen = self.vcs.vcsSwitch(self.project.ppath) | 570 shouldReopen = self.vcs.vcsSwitch(self.project.ppath) |
531 if shouldReopen: | 571 if shouldReopen: |
532 res = E5MessageBox.yesNo( | 572 res = E5MessageBox.yesNo( |
533 self.parent(), | 573 self.parent(), |
534 self.tr("Switch"), | 574 QCoreApplication.translate("VcsProjectHelper", "Switch"), |
535 self.tr("""The project should be reread. Do this now?"""), | 575 QCoreApplication.translate( |
576 "VcsProjectHelper", | |
577 """The project should be reread. Do this now?"""), | |
536 yesDefault=True) | 578 yesDefault=True) |
537 if res: | 579 if res: |
538 self.project.reopenProject() | 580 self.project.reopenProject() |
539 | 581 |
540 def _vcsMerge(self): | 582 def _vcsMerge(self): |