eric6/UI/UserInterface.py

branch
jsonfiles
changeset 8011
630a173cb137
parent 8009
29818ac4853c
child 8019
5fb467ac4233
equal deleted inserted replaced
8010:7ce2b8bb0d9b 8011:630a173cb137
50 import Globals 50 import Globals
51 51
52 import UI.PixmapCache 52 import UI.PixmapCache
53 53
54 from Sessions.SessionFile import SessionFile 54 from Sessions.SessionFile import SessionFile
55
56 from Tasks.TasksFile import TasksFile
55 57
56 from E5Network.E5NetworkProxyFactory import ( 58 from E5Network.E5NetworkProxyFactory import (
57 E5NetworkProxyFactory, proxyAuthenticationRequired 59 E5NetworkProxyFactory, proxyAuthenticationRequired
58 ) 60 )
59 try: 61 try:
612 self.__inVersionCheck = False 614 self.__inVersionCheck = False
613 self.__versionCheckProgress = None 615 self.__versionCheckProgress = None
614 616
615 # create the various JSON file interfaces 617 # create the various JSON file interfaces
616 self.__sessionFile = SessionFile(True) 618 self.__sessionFile = SessionFile(True)
619 self.__tasksFile = TasksFile(True)
617 620
618 # Initialize the actions, menus, toolbars and statusbar 621 # Initialize the actions, menus, toolbars and statusbar
619 splash.showMessage(self.tr("Initializing Actions...")) 622 splash.showMessage(self.tr("Initializing Actions..."))
620 self.__initActions() 623 self.__initActions()
621 splash.showMessage(self.tr("Initializing Menus...")) 624 splash.showMessage(self.tr("Initializing Menus..."))
6475 6478
6476 self.utScriptAct.setEnabled(False) 6479 self.utScriptAct.setEnabled(False)
6477 6480
6478 def __writeTasks(self): 6481 def __writeTasks(self):
6479 """ 6482 """
6480 Private slot to write the tasks data to an XML file (.e6t). 6483 Private slot to write the tasks data to a JSON file (.etj).
6481 """ 6484 """
6482 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.e6t") 6485 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.etj")
6483 f = QFile(fn) 6486 self.__tasksFile.writeFile(fn)
6484 ok = f.open(QIODevice.WriteOnly) 6487
6485 if not ok:
6486 E5MessageBox.critical(
6487 self,
6488 self.tr("Save tasks"),
6489 self.tr(
6490 "<p>The tasks file <b>{0}</b> could not be written.</p>")
6491 .format(fn))
6492 return
6493
6494 from E5XML.TasksWriter import TasksWriter
6495 TasksWriter(f, False).writeXML()
6496 f.close()
6497
6498 def __readTasks(self): 6488 def __readTasks(self):
6499 """ 6489 """
6500 Private slot to read in the tasks file (.e6t). 6490 Private slot to read in the tasks file (.etj or .e6t).
6501 """ 6491 """
6502 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.e6t") 6492 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.etj")
6503 if not os.path.exists(fn): 6493 if os.path.exists(fn):
6504 # try again with the old extension 6494 # try new style JSON file first
6505 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.e4t") 6495 self.__tasksFile.readFile(fn)
6506 if not os.path.exists(fn):
6507 return
6508 f = QFile(fn)
6509 if f.open(QIODevice.ReadOnly):
6510 from E5XML.TasksReader import TasksReader
6511 reader = TasksReader(f, viewer=self.taskViewer)
6512 reader.readXML()
6513 f.close()
6514 else: 6496 else:
6515 E5MessageBox.critical( 6497 # try old style XML file second
6516 self, 6498 fn = os.path.join(Utilities.getConfigDir(), "eric6tasks.e6t")
6517 self.tr("Read tasks"), 6499 if os.path.exists(fn):
6518 self.tr( 6500 f = QFile(fn)
6519 "<p>The tasks file <b>{0}</b> could not be read.</p>") 6501 if f.open(QIODevice.ReadOnly):
6520 .format(fn)) 6502 from E5XML.TasksReader import TasksReader
6503 reader = TasksReader(f, viewer=self.taskViewer)
6504 reader.readXML()
6505 f.close()
6506 else:
6507 E5MessageBox.critical(
6508 self,
6509 self.tr("Read Tasks"),
6510 self.tr(
6511 "<p>The tasks file <b>{0}</b> could not be"
6512 " read.</p>")
6513 .format(fn))
6521 6514
6522 def __writeSession(self, filename="", crashSession=False): 6515 def __writeSession(self, filename="", crashSession=False):
6523 """ 6516 """
6524 Private slot to write the session data to a JSON file (.esj). 6517 Private slot to write the session data to a JSON file (.esj).
6525 6518

eric ide

mercurial