12 import copy |
12 import copy |
13 |
13 |
14 from PyQt6.QtCore import pyqtSlot, QDir, QFileInfo, QObject, QCoreApplication |
14 from PyQt6.QtCore import pyqtSlot, QDir, QFileInfo, QObject, QCoreApplication |
15 from PyQt6.QtWidgets import QDialog, QInputDialog, QToolBar |
15 from PyQt6.QtWidgets import QDialog, QInputDialog, QToolBar |
16 |
16 |
17 from E5Gui.E5Action import E5Action |
17 from E5Gui.EricAction import EricAction |
18 from E5Gui import E5MessageBox |
18 from E5Gui import EricMessageBox |
19 from E5Gui.E5Application import e5App |
19 from E5Gui.EricApplication import ericApp |
20 |
20 |
21 import Preferences |
21 import Preferences |
22 import UI.PixmapCache |
22 import UI.PixmapCache |
23 import UI.Config |
23 import UI.Config |
24 |
24 |
61 |
61 |
62 def initActions(self): |
62 def initActions(self): |
63 """ |
63 """ |
64 Public method to generate the action objects. |
64 Public method to generate the action objects. |
65 """ |
65 """ |
66 self.vcsNewAct = E5Action( |
66 self.vcsNewAct = EricAction( |
67 QCoreApplication.translate( |
67 QCoreApplication.translate( |
68 "VcsProjectHelper", 'New from repository'), |
68 "VcsProjectHelper", 'New from repository'), |
69 UI.PixmapCache.getIcon("vcsCheckout"), |
69 UI.PixmapCache.getIcon("vcsCheckout"), |
70 QCoreApplication.translate( |
70 QCoreApplication.translate( |
71 "VcsProjectHelper", '&New from repository...'), |
71 "VcsProjectHelper", '&New from repository...'), |
81 """ repository.</p>""" |
81 """ repository.</p>""" |
82 )) |
82 )) |
83 self.vcsNewAct.triggered.connect(self._vcsCheckout) |
83 self.vcsNewAct.triggered.connect(self._vcsCheckout) |
84 self.actions.append(self.vcsNewAct) |
84 self.actions.append(self.vcsNewAct) |
85 |
85 |
86 self.vcsExportAct = E5Action( |
86 self.vcsExportAct = EricAction( |
87 QCoreApplication.translate( |
87 QCoreApplication.translate( |
88 "VcsProjectHelper", 'Export from repository'), |
88 "VcsProjectHelper", 'Export from repository'), |
89 UI.PixmapCache.getIcon("vcsExport"), |
89 UI.PixmapCache.getIcon("vcsExport"), |
90 QCoreApplication.translate( |
90 QCoreApplication.translate( |
91 "VcsProjectHelper", '&Export from repository...'), |
91 "VcsProjectHelper", '&Export from repository...'), |
100 """<p>This exports a project from the repository.</p>""" |
100 """<p>This exports a project from the repository.</p>""" |
101 )) |
101 )) |
102 self.vcsExportAct.triggered.connect(self._vcsExport) |
102 self.vcsExportAct.triggered.connect(self._vcsExport) |
103 self.actions.append(self.vcsExportAct) |
103 self.actions.append(self.vcsExportAct) |
104 |
104 |
105 self.vcsAddAct = E5Action( |
105 self.vcsAddAct = EricAction( |
106 QCoreApplication.translate( |
106 QCoreApplication.translate( |
107 "VcsProjectHelper", 'Add to repository'), |
107 "VcsProjectHelper", 'Add to repository'), |
108 UI.PixmapCache.getIcon("vcsCommit"), |
108 UI.PixmapCache.getIcon("vcsCommit"), |
109 QCoreApplication.translate( |
109 QCoreApplication.translate( |
110 "VcsProjectHelper", '&Add to repository...'), |
110 "VcsProjectHelper", '&Add to repository...'), |
140 """ |
140 """ |
141 Public slot to initialize the VCS toolbar. |
141 Public slot to initialize the VCS toolbar. |
142 |
142 |
143 @param ui reference to the main window (UserInterface) |
143 @param ui reference to the main window (UserInterface) |
144 @param toolbarManager reference to a toolbar manager object |
144 @param toolbarManager reference to a toolbar manager object |
145 (E5ToolBarManager) |
145 (EricToolBarManager) |
146 @return the toolbar generated (QToolBar) |
146 @return the toolbar generated (QToolBar) |
147 """ |
147 """ |
148 return None # __IGNORE_WARNING_M831__ |
148 return None # __IGNORE_WARNING_M831__ |
149 |
149 |
150 def initBasicToolbar(self, ui, toolbarManager): |
150 def initBasicToolbar(self, ui, toolbarManager): |
151 """ |
151 """ |
152 Public slot to initialize the basic VCS toolbar. |
152 Public slot to initialize the basic VCS toolbar. |
153 |
153 |
154 @param ui reference to the main window (UserInterface) |
154 @param ui reference to the main window (UserInterface) |
155 @param toolbarManager reference to a toolbar manager object |
155 @param toolbarManager reference to a toolbar manager object |
156 (E5ToolBarManager) |
156 (EricToolBarManager) |
157 @return the toolbar generated (QToolBar) |
157 @return the toolbar generated (QToolBar) |
158 """ |
158 """ |
159 tb = QToolBar(QCoreApplication.translate("VcsProjectHelper", "VCS"), |
159 tb = QToolBar(QCoreApplication.translate("VcsProjectHelper", "VCS"), |
160 ui) |
160 ui) |
161 tb.setIconSize(UI.Config.ToolBarIconSize) |
161 tb.setIconSize(UI.Config.ToolBarIconSize) |
187 should be performed |
187 should be performed |
188 """ |
188 """ |
189 if not self.project or not self.project.checkDirty(): |
189 if not self.project or not self.project.checkDirty(): |
190 return |
190 return |
191 |
191 |
192 vcsSystemsDict = e5App().getObject( |
192 vcsSystemsDict = ericApp().getObject( |
193 "PluginManager").getPluginDisplayStrings("version_control") |
193 "PluginManager").getPluginDisplayStrings("version_control") |
194 if not vcsSystemsDict: |
194 if not vcsSystemsDict: |
195 # no version control system found |
195 # no version control system found |
196 return |
196 return |
197 |
197 |
224 vcsdlg = vcs.vcsNewProjectOptionsDialog() |
224 vcsdlg = vcs.vcsNewProjectOptionsDialog() |
225 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
225 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
226 projectdir, vcsDataDict = vcsdlg.getData() |
226 projectdir, vcsDataDict = vcsdlg.getData() |
227 # edit VCS command options |
227 # edit VCS command options |
228 if vcs.vcsSupportCommandOptions(): |
228 if vcs.vcsSupportCommandOptions(): |
229 vcores = E5MessageBox.yesNo( |
229 vcores = EricMessageBox.yesNo( |
230 self.parent(), |
230 self.parent(), |
231 QCoreApplication.translate( |
231 QCoreApplication.translate( |
232 "VcsProjectHelper", "New Project"), |
232 "VcsProjectHelper", "New Project"), |
233 QCoreApplication.translate( |
233 QCoreApplication.translate( |
234 "VcsProjectHelper", |
234 "VcsProjectHelper", |
245 # create the project directory if it doesn't exist already |
245 # create the project directory if it doesn't exist already |
246 if not os.path.isdir(projectdir): |
246 if not os.path.isdir(projectdir): |
247 try: |
247 try: |
248 os.makedirs(projectdir) |
248 os.makedirs(projectdir) |
249 except OSError: |
249 except OSError: |
250 E5MessageBox.critical( |
250 EricMessageBox.critical( |
251 self.parent(), |
251 self.parent(), |
252 QCoreApplication.translate( |
252 QCoreApplication.translate( |
253 "VcsProjectHelper", |
253 "VcsProjectHelper", |
254 "Create project directory"), |
254 "Create project directory"), |
255 QCoreApplication.translate( |
255 QCoreApplication.translate( |
298 self.project.pdata["VCS"] = 'None' |
298 self.project.pdata["VCS"] = 'None' |
299 self.project.vcs = self.project.initVCS() |
299 self.project.vcs = self.project.initVCS() |
300 self.project.setDirty(True) |
300 self.project.setDirty(True) |
301 self.project.saveProject() |
301 self.project.saveProject() |
302 else: |
302 else: |
303 res = E5MessageBox.yesNo( |
303 res = EricMessageBox.yesNo( |
304 self.parent(), |
304 self.parent(), |
305 QCoreApplication.translate( |
305 QCoreApplication.translate( |
306 "VcsProjectHelper", |
306 "VcsProjectHelper", |
307 "New project from repository"), |
307 "New project from repository"), |
308 QCoreApplication.translate( |
308 QCoreApplication.translate( |
335 self.project.newProjectAddFiles(ms) |
335 self.project.newProjectAddFiles(ms) |
336 self.project.createProjectManagementDir() |
336 self.project.createProjectManagementDir() |
337 self.project.saveProject() |
337 self.project.saveProject() |
338 self.project.openProject(self.project.pfile) |
338 self.project.openProject(self.project.pfile) |
339 if not export: |
339 if not export: |
340 res = E5MessageBox.yesNo( |
340 res = EricMessageBox.yesNo( |
341 self.parent(), |
341 self.parent(), |
342 QCoreApplication.translate( |
342 QCoreApplication.translate( |
343 "VcsProjectHelper", |
343 "VcsProjectHelper", |
344 "New project from repository"), |
344 "New project from repository"), |
345 QCoreApplication.translate( |
345 QCoreApplication.translate( |
349 yesDefault=True) |
349 yesDefault=True) |
350 if res: |
350 if res: |
351 self.project.vcs.vcsAdd( |
351 self.project.vcs.vcsAdd( |
352 self.project.pfile) |
352 self.project.pfile) |
353 else: |
353 else: |
354 E5MessageBox.critical( |
354 EricMessageBox.critical( |
355 self.parent(), |
355 self.parent(), |
356 QCoreApplication.translate( |
356 QCoreApplication.translate( |
357 "VcsProjectHelper", "New project from repository"), |
357 "VcsProjectHelper", "New project from repository"), |
358 QCoreApplication.translate( |
358 QCoreApplication.translate( |
359 "VcsProjectHelper", |
359 "VcsProjectHelper", |
393 pdata_vcs = self.project.pdata["VCS"] |
393 pdata_vcs = self.project.pdata["VCS"] |
394 pdata_vcsoptions = copy.deepcopy(self.project.pdata["VCSOPTIONS"]) |
394 pdata_vcsoptions = copy.deepcopy(self.project.pdata["VCSOPTIONS"]) |
395 pdata_vcsother = copy.deepcopy(self.project.pdata["VCSOTHERDATA"]) |
395 pdata_vcsother = copy.deepcopy(self.project.pdata["VCSOTHERDATA"]) |
396 vcs = self.project.vcs |
396 vcs = self.project.vcs |
397 vcsHelper = self.project.vcsProjectHelper |
397 vcsHelper = self.project.vcsProjectHelper |
398 vcsSystemsDict = e5App().getObject( |
398 vcsSystemsDict = ericApp().getObject( |
399 "PluginManager").getPluginDisplayStrings("version_control") |
399 "PluginManager").getPluginDisplayStrings("version_control") |
400 if not vcsSystemsDict: |
400 if not vcsSystemsDict: |
401 # no version control system found |
401 # no version control system found |
402 return |
402 return |
403 |
403 |
430 self.project, self.project.name, 1) |
430 self.project, self.project.name, 1) |
431 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
431 if vcsdlg.exec() == QDialog.DialogCode.Accepted: |
432 vcsDataDict = vcsdlg.getData() |
432 vcsDataDict = vcsdlg.getData() |
433 # edit VCS command options |
433 # edit VCS command options |
434 if self.project.vcs.vcsSupportCommandOptions(): |
434 if self.project.vcs.vcsSupportCommandOptions(): |
435 vcores = E5MessageBox.yesNo( |
435 vcores = EricMessageBox.yesNo( |
436 self.parent(), |
436 self.parent(), |
437 QCoreApplication.translate( |
437 QCoreApplication.translate( |
438 "VcsProjectHelper", "Import Project"), |
438 "VcsProjectHelper", "Import Project"), |
439 QCoreApplication.translate( |
439 QCoreApplication.translate( |
440 "VcsProjectHelper", |
440 "VcsProjectHelper", |
473 # just in case |
473 # just in case |
474 return |
474 return |
475 |
475 |
476 shouldReopen = self.vcs.vcsUpdate(self.project.ppath) |
476 shouldReopen = self.vcs.vcsUpdate(self.project.ppath) |
477 if shouldReopen: |
477 if shouldReopen: |
478 res = E5MessageBox.yesNo( |
478 res = EricMessageBox.yesNo( |
479 self.parent(), |
479 self.parent(), |
480 QCoreApplication.translate("VcsProjectHelper", "Update"), |
480 QCoreApplication.translate("VcsProjectHelper", "Update"), |
481 QCoreApplication.translate( |
481 QCoreApplication.translate( |
482 "VcsProjectHelper", |
482 "VcsProjectHelper", |
483 """The project should be reread. Do this now?"""), |
483 """The project should be reread. Do this now?"""), |
611 # just in case |
611 # just in case |
612 return |
612 return |
613 |
613 |
614 shouldReopen = self.vcs.vcsSwitch(self.project.ppath) |
614 shouldReopen = self.vcs.vcsSwitch(self.project.ppath) |
615 if shouldReopen: |
615 if shouldReopen: |
616 res = E5MessageBox.yesNo( |
616 res = EricMessageBox.yesNo( |
617 self.parent(), |
617 self.parent(), |
618 QCoreApplication.translate("VcsProjectHelper", "Switch"), |
618 QCoreApplication.translate("VcsProjectHelper", "Switch"), |
619 QCoreApplication.translate( |
619 QCoreApplication.translate( |
620 "VcsProjectHelper", |
620 "VcsProjectHelper", |
621 """The project should be reread. Do this now?"""), |
621 """The project should be reread. Do this now?"""), |