+from BProject import BProject
+
+from BWizard import BWizard
+
+from BIntroPage import BIntroPage
+from BFolderPage import BFolderPage
+from BBoardPage import BBoardPage
+from BProjectPresets import BProjectPresets
+from BOpenPage import BOpenPage
+from BVersionPage import BVersionPage
+from BCpuPage import BCpuPage
+from BToolchainPage import BToolchainPage
+from BModulePage import BModulePage
+from BCreationPage import BCreationPage
+from BFinalPage import BFinalPage
+
+from BEditingDialog import BEditingDialog, BVersionDialog, BToolchainDialog
+
+from const import DATA_DIR
+
+from LoadException import VersionException, ToolchainException
+
+def newProject():
+ QApplication.instance().project = BProject()
+ page_list = [BIntroPage, BFolderPage, BVersionPage, BBoardPage, BProjectPresets, BCpuPage, BToolchainPage, BModulePage, BCreationPage, BFinalPage]
+ wizard = BWizard(page_list)
+ wizard.show()
+ wizard.exec_()
+ project = QApplication.instance().project
+ to_be_opened = project.info("TO_BE_OPENED")
+ command_lines = project.info("COMMAND_LINES")
+ relevant_files = project.info("RELEVANT_FILES")
+ if to_be_opened:
+ for ide in to_be_opened:
+ command_line = command_lines[ide]
+ relevant_file = relevant_files[ide]
+ QProcess.startDetached(command_line, [relevant_file,])
+ sys.exit()
+
+def editProject(project_file):
+ info_dict = {}
+ # Progress dialog.
+ p_dialog = QProgressDialog(QApplication.instance().tr("Wait project loading"), QApplication.instance().tr("Cancel"), 0, 0)
+ while(True):
+ p_dialog.show()
+ # Empty project is the default fallback.
+ QApplication.instance().project = BProject()
+ try:
+ QApplication.instance().project = BProject(project_file, info_dict)
+ except VersionException:
+ p_dialog.hide()
+ QMessageBox.critical(
+ None,
+ QObject().tr("BeRTOS version not found!"),
+ QObject().tr("The selected BeRTOS version was not found, please select another one...")
+ )
+ dialog = BVersionDialog()
+ if dialog.exec_():
+ version = dialog.version_page.currentVersion()
+ info_dict["BERTOS_PATH"] = version
+ continue
+ except ToolchainException, exc:
+ p_dialog.hide()
+ QMessageBox.critical(
+ None,
+ QObject().tr("Toolchain not found!"),
+ QObject().tr("The selected toolchain was not found, please select another one...")
+ )
+ QApplication.instance().project = exc.partial_project
+ dialog = BToolchainDialog()
+ if dialog.exec_():
+ toolchain = dialog.toolchain_page.currentToolchain()
+ info_dict["TOOLCHAIN"] = toolchain
+ continue
+ break
+ dialog = BEditingDialog()
+ p_dialog.hide()
+ dialog.exec_()