Add menu in order to configure toolchain
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 23 Jul 2009 13:42:28 +0000 (13:42 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Thu, 23 Jul 2009 13:42:28 +0000 (13:42 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2763 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BEditingDialog.py
wizard/bertos_utils.py

index 82bac4ed5b5a206902af2f251975322554e3a475..6c714a5027654b5f577f3d9f8f2bd8774322194f 100644 (file)
@@ -53,8 +53,64 @@ class BEditingDialog(QDialog):
         layout = QVBoxLayout()
         self.module_page = BModulePage.BModulePage()
         layout.addWidget(self.module_page)
+        button_layout = QHBoxLayout()
+        self.advanced_button = QToolButton()
+        self.setupMenu()
+        self.advanced_button.setMenu(self.menu)
+        self.advanced_button.setPopupMode(QToolButton.InstantPopup)
+        self.advanced_button.setText(self.tr("Advanced"))
+        button_layout.addWidget(self.advanced_button)
+        button_layout.addStretch()
+        self.cancel_button = QPushButton(self.tr("Cancel"))
+        button_layout.addWidget(self.cancel_button)
+        self.apply_button = QPushButton(self.tr("Apply"))
+        button_layout.addWidget(self.apply_button)
+        layout.addLayout(button_layout)
         self.setLayout(layout)
 
+    def setupMenu(self):
+        self.menu = QMenu(self.tr("Advanced options"))
+        self.setupToolchainMenu()
+        self.menu.addMenu(self.toolchain_menu)
+        self.setupVersionMenu()
+        self.menu.addMenu(self.version_menu)
+
+    def setupToolchainMenu(self):
+        self.toolchain_menu = QMenu(self.tr("select toolchain"))
+        action_group = QActionGroup(self.toolchain_menu)
+        for toolchain in sorted(self.toolchains()):
+            action = self.toolchain_menu.addAction(toolchain)
+            action_group.addAction(action)
+            action.setCheckable(True)
+            action.setChecked(True if unicode(action.text()) == self.currentToolchain()["path"] else False)
+
+    def setupVersionMenu(self):
+        self.version_menu = QMenu(self.tr("select BeRTOS version"))
+        action_group = QActionGroup(self.version_menu)
+        for version in sorted(self.versions()):
+            action = self.version_menu.addAction(version)
+            action_group.addAction(action)
+            action.setCheckable(True)
+            action.setChecked(True if unicode(action.text()) == self.currentVersion() else False)
+
+    def toolchains(self):
+        return self.module_page.toolchains()
+    
+    def currentToolchain(self):
+        return self.module_page.projectInfo("TOOLCHAIN")
+    
+    def setCurrentToolchain(self, toolchain):
+        self.module_page.setProjectInfo("TOOLCHAIN", toolchain)
+
+    def versions(self):
+        return self.module_page.versions()
+
+    def currentVersion(self):
+        return self.module_page.projectInfo("SOURCES_PATH")
+    
+    def setCurrentVersion(self, version):
+        self.module_page.setProjectInfo("SOURCES_PATH", version)
+
 
 
 def main():
@@ -65,6 +121,7 @@ def main():
         sys.exit()
     app = QApplication([])
     app.project = loadBertosProject(project_file)
+    app.settings = QSettings("Develer", "Bertos Configurator")
     dialog = BEditingDialog()
     dialog.show()
     sys.exit(app.exec_())
index 5920070340452e18398db4a70057d9435b84250a..8a73185d71822b74f2881b1d0af0716697d2b821 100644 (file)
@@ -58,6 +58,7 @@ def loadBertosProject(project_file):
     project_info = BProject.BProject()
     project_info.setInfo("PROJECT_PATH", os.path.dirname(project_file))
     project_info.setInfo("SOURCES_PATH", project_data["SOURCES_PATH"])
+    project_info.setInfo("TOOLCHAIN", project_data["TOOLCHAIN"])
     loadSourceTree(project_info)
     cpu_name = project_data["CPU_NAME"]
     project_info.setInfo("CPU_NAME", cpu_name)