8044:874fdd14d3a2 | 8142:43248bafe9b2 |
---|---|
48 import Preferences | 48 import Preferences |
49 import Utilities | 49 import Utilities |
50 import Globals | 50 import Globals |
51 | 51 |
52 import UI.PixmapCache | 52 import UI.PixmapCache |
53 | |
54 from Sessions.SessionFile import SessionFile | |
55 | |
56 from Tasks.TasksFile import TasksFile | |
53 | 57 |
54 from E5Network.E5NetworkProxyFactory import ( | 58 from E5Network.E5NetworkProxyFactory import ( |
55 E5NetworkProxyFactory, proxyAuthenticationRequired | 59 E5NetworkProxyFactory, proxyAuthenticationRequired |
56 ) | 60 ) |
57 try: | 61 try: |
248 from VirtualEnv.VirtualenvManager import VirtualenvManager | 252 from VirtualEnv.VirtualenvManager import VirtualenvManager |
249 self.virtualenvManager = VirtualenvManager(self) | 253 self.virtualenvManager = VirtualenvManager(self) |
250 # register it early because it is needed very soon | 254 # register it early because it is needed very soon |
251 e5App().registerObject("VirtualEnvManager", self.virtualenvManager) | 255 e5App().registerObject("VirtualEnvManager", self.virtualenvManager) |
252 | 256 |
253 # Generate the debug server object | |
254 from Debugger.DebugServer import DebugServer | |
255 debugServer = DebugServer(self.__originalPathString) | |
256 | |
257 # Create the background service object | |
258 from Utilities.BackgroundService import BackgroundService | |
259 self.backgroundService = BackgroundService() | |
260 | |
261 # Generate an empty project object and multi project object | 257 # Generate an empty project object and multi project object |
262 from Project.Project import Project | 258 from Project.Project import Project |
263 self.project = Project(self) | 259 self.project = Project(self) |
264 e5App().registerObject("Project", self.project) | 260 e5App().registerObject("Project", self.project) |
265 | 261 |
266 from MultiProject.MultiProject import MultiProject | 262 from MultiProject.MultiProject import MultiProject |
267 self.multiProject = MultiProject(self.project, self) | 263 self.multiProject = MultiProject(self.project, self) |
264 | |
265 # Generate the debug server object | |
266 from Debugger.DebugServer import DebugServer | |
267 debugServer = DebugServer(self.__originalPathString, | |
268 project=self.project) | |
269 | |
270 # Create the background service object | |
271 from Utilities.BackgroundService import BackgroundService | |
272 self.backgroundService = BackgroundService() | |
268 | 273 |
269 splash.showMessage(self.tr("Initializing Plugin Manager...")) | 274 splash.showMessage(self.tr("Initializing Plugin Manager...")) |
270 | 275 |
271 # Initialize the Plugin Manager (Plugins are initialized later | 276 # Initialize the Plugin Manager (Plugins are initialized later |
272 from PluginManager.PluginManager import PluginManager | 277 from PluginManager.PluginManager import PluginManager |
608 # list of web addresses serving the versions file | 613 # list of web addresses serving the versions file |
609 self.__httpAlternatives = Preferences.getUI("VersionsUrls6") | 614 self.__httpAlternatives = Preferences.getUI("VersionsUrls6") |
610 self.__inVersionCheck = False | 615 self.__inVersionCheck = False |
611 self.__versionCheckProgress = None | 616 self.__versionCheckProgress = None |
612 | 617 |
618 # create the various JSON file interfaces | |
619 self.__sessionFile = SessionFile(True) | |
620 self.__tasksFile = TasksFile(True) | |
621 | |
613 # Initialize the actions, menus, toolbars and statusbar | 622 # Initialize the actions, menus, toolbars and statusbar |
614 splash.showMessage(self.tr("Initializing Actions...")) | 623 splash.showMessage(self.tr("Initializing Actions...")) |
615 self.__initActions() | 624 self.__initActions() |
616 splash.showMessage(self.tr("Initializing Menus...")) | 625 splash.showMessage(self.tr("Initializing Menus...")) |
617 self.__initMenus() | 626 self.__initMenus() |
1366 @param args list of files to open<br /> | 1375 @param args list of files to open<br /> |
1367 The args are processed one at a time. All arguments after a | 1376 The args are processed one at a time. All arguments after a |
1368 '--' option are considered debug arguments to the program | 1377 '--' option are considered debug arguments to the program |
1369 for the debugger. All files named before the '--' option | 1378 for the debugger. All files named before the '--' option |
1370 are opened in a text editor, unless the argument ends in | 1379 are opened in a text editor, unless the argument ends in |
1371 .e4p, then it is opened as a project file. If it ends in | 1380 .epj or .e4p, then it is opened as a project file. If it |
1372 .e4m or .e5m, it is opened as a multiproject. | 1381 ends in .emj, .e4m or .e5m, it is opened as a multi project. |
1373 """ | 1382 """ |
1374 # check and optionally read a crash session and ignore any arguments | 1383 # check and optionally read a crash session and ignore any arguments |
1375 if self.__readCrashSession(): | 1384 if self.__readCrashSession(): |
1376 return | 1385 return |
1377 | 1386 |
1427 ext = os.path.splitext(arg)[1] | 1436 ext = os.path.splitext(arg)[1] |
1428 ext = os.path.normcase(ext) | 1437 ext = os.path.normcase(ext) |
1429 except IndexError: | 1438 except IndexError: |
1430 ext = "" | 1439 ext = "" |
1431 | 1440 |
1432 if ext in ['.e4p']: | 1441 if ext in ('.epj', '.e4p'): |
1433 self.project.openProject(arg) | 1442 self.project.openProject(arg) |
1434 opens += 1 | 1443 opens += 1 |
1435 elif ext in ['.e4m', '.e5m']: | 1444 elif ext in ('.emj', '.e4m', '.e5m'): |
1436 self.multiProject.openMultiProject(arg) | 1445 self.multiProject.openMultiProject(arg) |
1437 opens += 1 | 1446 opens += 1 |
1438 else: | 1447 else: |
1439 self.viewmanager.openFiles(arg) | 1448 self.viewmanager.openFiles(arg) |
1440 opens += 1 | 1449 opens += 1 |
3317 """ | 3326 """ |
3318 Private slot to create the toolbars. | 3327 Private slot to create the toolbars. |
3319 """ | 3328 """ |
3320 filetb = self.viewmanager.initFileToolbar(self.toolbarManager) | 3329 filetb = self.viewmanager.initFileToolbar(self.toolbarManager) |
3321 edittb = self.viewmanager.initEditToolbar(self.toolbarManager) | 3330 edittb = self.viewmanager.initEditToolbar(self.toolbarManager) |
3322 searchtb, quicksearchtb = self.viewmanager.initSearchToolbars( | 3331 searchtb = self.viewmanager.initSearchToolbar(self.toolbarManager) |
3323 self.toolbarManager) | |
3324 viewtb = self.viewmanager.initViewToolbar(self.toolbarManager) | 3332 viewtb = self.viewmanager.initViewToolbar(self.toolbarManager) |
3325 starttb, debugtb = self.debuggerUI.initToolbars(self.toolbarManager) | 3333 starttb, debugtb = self.debuggerUI.initToolbars(self.toolbarManager) |
3326 multiprojecttb = self.multiProject.initToolbar(self.toolbarManager) | 3334 multiprojecttb = self.multiProject.initToolbar(self.toolbarManager) |
3327 projecttb, vcstb = self.project.initToolbars(self.toolbarManager) | 3335 projecttb, vcstb = self.project.initToolbars(self.toolbarManager) |
3328 toolstb = QToolBar(self.tr("Tools"), self) | 3336 toolstb = QToolBar(self.tr("Tools"), self) |
3439 | 3447 |
3440 # add the various toolbars | 3448 # add the various toolbars |
3441 self.addToolBar(filetb) | 3449 self.addToolBar(filetb) |
3442 self.addToolBar(edittb) | 3450 self.addToolBar(edittb) |
3443 self.addToolBar(searchtb) | 3451 self.addToolBar(searchtb) |
3444 self.addToolBar(quicksearchtb) | |
3445 self.addToolBar(viewtb) | 3452 self.addToolBar(viewtb) |
3446 self.addToolBar(starttb) | 3453 self.addToolBar(starttb) |
3447 self.addToolBar(debugtb) | 3454 self.addToolBar(debugtb) |
3448 self.addToolBar(multiprojecttb) | 3455 self.addToolBar(multiprojecttb) |
3449 self.addToolBar(projecttb) | 3456 self.addToolBar(projecttb) |
3457 self.addToolBar(profilestb) | 3464 self.addToolBar(profilestb) |
3458 self.addToolBar(pluginstb) | 3465 self.addToolBar(pluginstb) |
3459 | 3466 |
3460 # hide toolbars not wanted in the initial layout | 3467 # hide toolbars not wanted in the initial layout |
3461 searchtb.hide() | 3468 searchtb.hide() |
3462 quicksearchtb.hide() | |
3463 viewtb.hide() | 3469 viewtb.hide() |
3464 debugtb.hide() | 3470 debugtb.hide() |
3465 multiprojecttb.hide() | 3471 multiprojecttb.hide() |
3466 helptb.hide() | 3472 helptb.hide() |
3467 spellingtb.hide() | 3473 spellingtb.hide() |
3486 self.__toolbars["unittest"] = [unittesttb.windowTitle(), unittesttb, | 3492 self.__toolbars["unittest"] = [unittesttb.windowTitle(), unittesttb, |
3487 ""] | 3493 ""] |
3488 self.__toolbars["view_profiles"] = [profilestb.windowTitle(), | 3494 self.__toolbars["view_profiles"] = [profilestb.windowTitle(), |
3489 profilestb, ""] | 3495 profilestb, ""] |
3490 self.__toolbars["plugins"] = [pluginstb.windowTitle(), pluginstb, ""] | 3496 self.__toolbars["plugins"] = [pluginstb.windowTitle(), pluginstb, ""] |
3491 self.__toolbars["quicksearch"] = [quicksearchtb.windowTitle(), | |
3492 quicksearchtb, ""] | |
3493 self.__toolbars["multiproject"] = [multiprojecttb.windowTitle(), | 3497 self.__toolbars["multiproject"] = [multiprojecttb.windowTitle(), |
3494 multiprojecttb, ""] | 3498 multiprojecttb, ""] |
3495 self.__toolbars["spelling"] = [spellingtb.windowTitle(), spellingtb, | 3499 self.__toolbars["spelling"] = [spellingtb.windowTitle(), spellingtb, |
3496 ""] | 3500 ""] |
3497 self.__toolbars["vcs"] = [vcstb.windowTitle(), vcstb, "vcs"] | 3501 self.__toolbars["vcs"] = [vcstb.windowTitle(), vcstb, "vcs"] |
5983 # connection unsuccessful | 5987 # connection unsuccessful |
5984 return False | 5988 return False |
5985 elif res == 0: | 5989 elif res == 0: |
5986 # successful | 5990 # successful |
5987 break | 5991 break |
5992 elif res == -1: | |
5993 # web browser did not start | |
5994 continue | |
5988 else: | 5995 else: |
5989 return False | 5996 return False |
5990 | 5997 |
5991 process.finished.connect(self.__webBrowserFinished) | 5998 process.finished.connect(self.__webBrowserFinished) |
5992 self.__webBrowserProcess = process | 5999 self.__webBrowserProcess = process |
5993 | 6000 |
5994 else: | 6001 else: |
5995 clientArgs.append("--newtab={0}".format(home)) | 6002 clientArgs.append("--newtab={0}".format(home)) |
5996 | 6003 |
5997 if clientArgs: | 6004 if clientArgs and self.__webBrowserClient: |
5998 self.__webBrowserClient.processArgs(clientArgs, disconnect=False) | 6005 self.__webBrowserClient.processArgs(clientArgs, disconnect=False) |
5999 | 6006 |
6000 return True | 6007 return True |
6001 | 6008 |
6002 def __connectToWebBrowser(self, process): | 6009 def __connectToWebBrowser(self, process): |
6285 """ | 6292 """ |
6286 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( | 6293 fn, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
6287 None, | 6294 None, |
6288 self.tr("Export Keyboard Shortcuts"), | 6295 self.tr("Export Keyboard Shortcuts"), |
6289 "", | 6296 "", |
6290 self.tr("Keyboard shortcut file (*.e4k)"), | 6297 self.tr("Keyboard Shortcuts File (*.ekj);;" |
6298 "XML Keyboard Shortcuts File (*.e4k)"), | |
6291 "", | 6299 "", |
6292 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) | 6300 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
6293 | 6301 |
6294 if not fn: | 6302 if not fn: |
6295 return | 6303 return |
6298 if not ext: | 6306 if not ext: |
6299 ex = selectedFilter.split("(*")[1].split(")")[0] | 6307 ex = selectedFilter.split("(*")[1].split(")")[0] |
6300 if ex: | 6308 if ex: |
6301 fn += ex | 6309 fn += ex |
6302 | 6310 |
6303 from Preferences import Shortcuts | 6311 if os.path.exists(fn): |
6304 Shortcuts.exportShortcuts(fn) | 6312 ok = E5MessageBox.yesNo( |
6313 self, | |
6314 self.tr("Export Keyboard Shortcuts"), | |
6315 self.tr("""<p>The keyboard shortcuts file <b>{0}</b> exists""" | |
6316 """ already. Overwrite it?</p>""").format(fn)) | |
6317 else: | |
6318 ok = True | |
6319 | |
6320 if ok: | |
6321 from Preferences import Shortcuts | |
6322 Shortcuts.exportShortcuts(fn) | |
6305 | 6323 |
6306 def __importShortcuts(self): | 6324 def __importShortcuts(self): |
6307 """ | 6325 """ |
6308 Private slot to import the keyboard shortcuts. | 6326 Private slot to import the keyboard shortcuts. |
6309 """ | 6327 """ |
6310 fn = E5FileDialog.getOpenFileName( | 6328 fn = E5FileDialog.getOpenFileName( |
6311 None, | 6329 None, |
6312 self.tr("Import Keyboard Shortcuts"), | 6330 self.tr("Import Keyboard Shortcuts"), |
6313 "", | 6331 "", |
6314 self.tr("Keyboard shortcut file (*.e4k)")) | 6332 self.tr("Keyboard Shortcuts File (*.ekj);;" |
6333 "XML Keyboard shortcut file (*.e4k)")) | |
6315 | 6334 |
6316 if fn: | 6335 if fn: |
6317 from Preferences import Shortcuts | 6336 from Preferences import Shortcuts |
6318 Shortcuts.importShortcuts(fn) | 6337 Shortcuts.importShortcuts(fn) |
6319 | 6338 |
6469 | 6488 |
6470 self.utScriptAct.setEnabled(False) | 6489 self.utScriptAct.setEnabled(False) |
6471 | 6490 |
6472 def __writeTasks(self): | 6491 def __writeTasks(self): |
6473 """ | 6492 """ |
6474 Private slot to write the tasks data to an XML file (.e6t). | 6493 Private slot to write the tasks data to a JSON file (.etj). |
6475 """ | 6494 """ |
6476 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.e6t") | 6495 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.etj") |
6477 f = QFile(fn) | 6496 self.__tasksFile.writeFile(fn) |
6478 ok = f.open(QIODevice.WriteOnly) | 6497 |
6479 if not ok: | |
6480 E5MessageBox.critical( | |
6481 self, | |
6482 self.tr("Save tasks"), | |
6483 self.tr( | |
6484 "<p>The tasks file <b>{0}</b> could not be written.</p>") | |
6485 .format(fn)) | |
6486 return | |
6487 | |
6488 from E5XML.TasksWriter import TasksWriter | |
6489 TasksWriter(f, False).writeXML() | |
6490 f.close() | |
6491 | |
6492 def __readTasks(self): | 6498 def __readTasks(self): |
6493 """ | 6499 """ |
6494 Private slot to read in the tasks file (.e6t). | 6500 Private slot to read in the tasks file (.etj or .e6t). |
6495 """ | 6501 """ |
6496 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.e6t") | 6502 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.etj") |
6497 if not os.path.exists(fn): | 6503 if os.path.exists(fn): |
6498 # try again with the old extension | 6504 # try new style JSON file first |
6499 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.e4t") | 6505 self.__tasksFile.readFile(fn) |
6500 if not os.path.exists(fn): | |
6501 return | |
6502 f = QFile(fn) | |
6503 if f.open(QIODevice.ReadOnly): | |
6504 from E5XML.TasksReader import TasksReader | |
6505 reader = TasksReader(f, viewer=self.taskViewer) | |
6506 reader.readXML() | |
6507 f.close() | |
6508 else: | 6506 else: |
6509 E5MessageBox.critical( | 6507 # try old style XML file second |
6510 self, | 6508 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.e6t") |
6511 self.tr("Read tasks"), | 6509 if os.path.exists(fn): |
6512 self.tr( | 6510 f = QFile(fn) |
6513 "<p>The tasks file <b>{0}</b> could not be read.</p>") | 6511 if f.open(QIODevice.ReadOnly): |
6514 .format(fn)) | 6512 from E5XML.TasksReader import TasksReader |
6513 reader = TasksReader(f, viewer=self.taskViewer) | |
6514 reader.readXML() | |
6515 f.close() | |
6516 else: | |
6517 E5MessageBox.critical( | |
6518 self, | |
6519 self.tr("Read Tasks"), | |
6520 self.tr( | |
6521 "<p>The tasks file <b>{0}</b> could not be" | |
6522 " read.</p>") | |
6523 .format(fn)) | |
6515 | 6524 |
6516 def __writeSession(self, filename="", crashSession=False): | 6525 def __writeSession(self, filename="", crashSession=False): |
6517 """ | 6526 """ |
6518 Private slot to write the session data to an XML file (.e5s). | 6527 Private slot to write the session data to a JSON file (.esj). |
6519 | 6528 |
6520 @param filename name of a session file to write | 6529 @param filename name of a session file to write |
6521 @type str | 6530 @type str |
6522 @param crashSession flag indicating to write a crash session file | 6531 @param crashSession flag indicating to write a crash session file |
6523 @type bool | 6532 @type bool |
6524 @return flag indicating success | 6533 @return flag indicating success |
6525 @rtype bool | 6534 @rtype bool |
6526 """ | 6535 """ |
6527 res = False | |
6528 if filename: | 6536 if filename: |
6529 fn = filename | 6537 fn = filename |
6530 elif crashSession: | 6538 elif crashSession: |
6531 fn = os.path.join(Utilities.getConfigDir(), | 6539 fn = os.path.join(Utilities.getConfigDir(), |
6532 "eric6_crash_session.e5s") | 6540 "eric6_crash_session.esj") |
6533 else: | 6541 else: |
6534 fn = os.path.join(Utilities.getConfigDir(), | 6542 fn = os.path.join(Utilities.getConfigDir(), |
6535 "eric6session.e5s") | 6543 "eric6session.esj") |
6536 f = QFile(fn) | 6544 |
6537 if f.open(QIODevice.WriteOnly): | 6545 if fn.endswith(".esj"): |
6538 from E5XML.SessionWriter import SessionWriter | 6546 res = self.__sessionFile.writeFile(fn) |
6539 SessionWriter(f, None).writeXML() | |
6540 f.close() | |
6541 res = True | |
6542 else: | 6547 else: |
6543 E5MessageBox.critical( | |
6544 self, | |
6545 self.tr("Save session"), | |
6546 self.tr("<p>The session file <b>{0}</b> could not be" | |
6547 " written.</p>") | |
6548 .format(fn)) | |
6549 return res | |
6550 | |
6551 def __readSession(self, filename=""): | |
6552 """ | |
6553 Private slot to read in the session file (.e5s or .e4s). | |
6554 | |
6555 @param filename name of a session file to read | |
6556 @type str | |
6557 @return flag indicating success | |
6558 @rtype bool | |
6559 """ | |
6560 if filename: | |
6561 fn = filename | |
6562 else: | |
6563 fn = os.path.join(Utilities.getConfigDir(), | |
6564 "eric6session.e5s") | |
6565 if not os.path.exists(fn): | |
6566 fn = os.path.join(Utilities.getConfigDir(), | |
6567 "eric6session.e4s") | |
6568 if not os.path.exists(fn): | |
6569 E5MessageBox.critical( | |
6570 self, | |
6571 self.tr("Read session"), | |
6572 self.tr("<p>The session file <b>{0}</b> could not" | |
6573 " be read.</p>") | |
6574 .format(fn)) | |
6575 fn = "" | |
6576 | |
6577 res = False | |
6578 if fn: | |
6579 f = QFile(fn) | 6548 f = QFile(fn) |
6580 if f.open(QIODevice.ReadOnly): | 6549 if f.open(QIODevice.WriteOnly): |
6581 from E5XML.SessionReader import SessionReader | 6550 from E5XML.SessionWriter import SessionWriter |
6582 self.__readingSession = True | 6551 SessionWriter(f, None).writeXML() |
6583 reader = SessionReader(f, True) | |
6584 reader.readXML() | |
6585 self.__readingSession = False | |
6586 f.close() | 6552 f.close() |
6587 res = True | 6553 res = True |
6588 else: | 6554 else: |
6589 E5MessageBox.critical( | 6555 E5MessageBox.critical( |
6590 self, | 6556 self, |
6591 self.tr("Read session"), | 6557 self.tr("Save Session"), |
6592 self.tr("<p>The session file <b>{0}</b> could not be" | 6558 self.tr("<p>The session file <b>{0}</b> could not be" |
6593 " read.</p>") | 6559 " written.</p>") |
6594 .format(fn)) | 6560 .format(fn)) |
6561 res = False | |
6562 | |
6563 return res | |
6564 | |
6565 def __readSession(self, filename=""): | |
6566 """ | |
6567 Private slot to read in the session file (.esj or .e5s). | |
6568 | |
6569 @param filename name of a session file to read | |
6570 @type str | |
6571 @return flag indicating success | |
6572 @rtype bool | |
6573 """ | |
6574 if filename: | |
6575 fn = filename | |
6576 else: | |
6577 fn = os.path.join(Utilities.getConfigDir(), | |
6578 "eric6session.esj") | |
6579 if not os.path.exists(fn): | |
6580 fn = os.path.join(Utilities.getConfigDir(), | |
6581 "eric6session.e5s") | |
6582 if not os.path.exists(fn): | |
6583 E5MessageBox.critical( | |
6584 self, | |
6585 self.tr("Read Session"), | |
6586 self.tr("<p>The session file <b>{0}</b> could not" | |
6587 " be read.</p>") | |
6588 .format(fn)) | |
6589 fn = "" | |
6590 | |
6591 res = False | |
6592 if fn: | |
6593 if fn.endswith(".esj"): | |
6594 # new JSON based format | |
6595 self.__readingSession = True | |
6596 res = self.__sessionFile.readFile(fn) | |
6597 self.__readingSession = False | |
6598 else: | |
6599 # old XML based format | |
6600 f = QFile(fn) | |
6601 if f.open(QIODevice.ReadOnly): | |
6602 from E5XML.SessionReader import SessionReader | |
6603 self.__readingSession = True | |
6604 reader = SessionReader(f, True) | |
6605 reader.readXML() | |
6606 self.__readingSession = False | |
6607 f.close() | |
6608 res = True | |
6609 else: | |
6610 E5MessageBox.critical( | |
6611 self, | |
6612 self.tr("Read session"), | |
6613 self.tr("<p>The session file <b>{0}</b> could not be" | |
6614 " read.</p>") | |
6615 .format(fn)) | |
6595 | 6616 |
6596 # Write a crash session after a session was read. | 6617 # Write a crash session after a session was read. |
6597 self.__writeCrashSession() | 6618 self.__writeCrashSession() |
6598 | 6619 |
6599 return res | 6620 return res |
6602 """ | 6623 """ |
6603 Private slot to save a session to disk. | 6624 Private slot to save a session to disk. |
6604 """ | 6625 """ |
6605 sessionFile, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( | 6626 sessionFile, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
6606 self, | 6627 self, |
6607 self.tr("Save session"), | 6628 self.tr("Save Session"), |
6608 Utilities.getHomeDir(), | 6629 Utilities.getHomeDir(), |
6609 self.tr("eric Session Files (*.e5s)"), | 6630 self.tr("eric Session Files (*.esj);;" |
6631 "eric XML Session Files (*.e5s)"), | |
6610 "") | 6632 "") |
6611 | 6633 |
6612 if not sessionFile: | 6634 if not sessionFile: |
6613 return | 6635 return |
6614 | 6636 |
6626 """ | 6648 """ |
6627 sessionFile = E5FileDialog.getOpenFileName( | 6649 sessionFile = E5FileDialog.getOpenFileName( |
6628 self, | 6650 self, |
6629 self.tr("Load session"), | 6651 self.tr("Load session"), |
6630 Utilities.getHomeDir(), | 6652 Utilities.getHomeDir(), |
6631 self.tr("eric Session Files (*.e5s)")) | 6653 self.tr("eric Session Files (*.esj);;" |
6654 "eric XML Session Files (*.e5s)")) | |
6632 | 6655 |
6633 if not sessionFile: | 6656 if not sessionFile: |
6634 return | 6657 return |
6635 | 6658 |
6636 self.__readSession(filename=sessionFile) | 6659 self.__readSession(filename=sessionFile) |
6637 | 6660 |
6638 def __deleteCrashSession(self): | 6661 def __deleteCrashSession(self): |
6639 """ | 6662 """ |
6640 Private slot to delete the crash session file. | 6663 Private slot to delete the crash session file. |
6641 """ | 6664 """ |
6642 fn = os.path.join(Utilities.getConfigDir(), | 6665 for ext in (".esj", ".e5s"): |
6643 "eric6_crash_session.e5s") | 6666 fn = os.path.join(Utilities.getConfigDir(), |
6644 if os.path.exists(fn): | 6667 f"eric6_crash_session{ext}") |
6645 try: | 6668 if os.path.exists(fn): |
6646 os.remove(fn) | 6669 try: |
6647 except OSError: | 6670 os.remove(fn) |
6648 # ignore it silently | 6671 except OSError: |
6649 pass | 6672 # ignore it silently |
6673 pass | |
6650 | 6674 |
6651 def __writeCrashSession(self): | 6675 def __writeCrashSession(self): |
6652 """ | 6676 """ |
6653 Private slot to write a crash session file. | 6677 Private slot to write a crash session file. |
6654 """ | 6678 """ |
6671 not self.__disableCrashSession and | 6695 not self.__disableCrashSession and |
6672 not self.__noCrashOpenAtStartup and | 6696 not self.__noCrashOpenAtStartup and |
6673 Preferences.getUI("OpenCrashSessionOnStartup") | 6697 Preferences.getUI("OpenCrashSessionOnStartup") |
6674 ): | 6698 ): |
6675 fn = os.path.join(Utilities.getConfigDir(), | 6699 fn = os.path.join(Utilities.getConfigDir(), |
6676 "eric6_crash_session.e5s") | 6700 "eric6_crash_session.esj") |
6677 if os.path.exists(fn): | 6701 if os.path.exists(fn): |
6678 yes = E5MessageBox.yesNo( | 6702 yes = E5MessageBox.yesNo( |
6679 self, | 6703 self, |
6680 self.tr("Crash Session found!"), | 6704 self.tr("Crash Session found!"), |
6681 self.tr("""A session file of a crashed session was""" | 6705 self.tr("""A session file of a crashed session was""" |