- for toolchain_action in self.toolchain_actions:
- self.connect(toolchain_action, SIGNAL("toggled(bool)"), lambda x, toolchain_action=toolchain_action: self.toolchainChanged(
- qvariant_converter.getString(toolchain_action.data()),
- x
- ))
- for version_action in self.version_actions:
- self.connect(version_action, SIGNAL("toggled(bool)"), lambda x, version_action=version_action: self.versionChanged(
- qvariant_converter.getString(version_action.data()),
- x
- ))
-
- def toolchainChanged(self, toolchain, activated):
- if activated:
- self.setCurrentToolchain(toolchain)
-
- def versionChanged(self, version, activated):
- if activated:
- self.setCurrentVersion(version)
+ self.connect(self.change_toolchain, SIGNAL("triggered(bool)"), self.changeToolchain)
+ self.connect(self.change_bertos_version, SIGNAL("triggered(bool)"), self.changeBertosVersion)
+ self.connect(self.apply_button, SIGNAL("clicked()"), self.apply)
+ self.connect(self.cancel_button, SIGNAL("clicked()"), self.reject)
+ self.connect(self.cpu_frequency_spinbox, SIGNAL("valueChanged(double)"), self.frequencyChanged)
+
+ def setFrequency(self):
+ frequency = long(self.module_page.projectInfo("SELECTED_FREQ"))
+ self.cpu_frequency_spinbox.setValue(frequency)
+
+ def frequencyChanged(self, frequency):
+ frequency = unicode(long(frequency))
+ self.module_page.setProjectInfo("SELECTED_FREQ", frequency)
+
+ def changeToolchain(self):
+ dialog = BToolchainDialog()
+ if dialog.exec_():
+ toolchain = qvariant_converter.getStringDict(dialog.toolchain_page.currentItem().data(Qt.UserRole))
+ dialog.toolchain_page.setProjectInfo("TOOLCHAIN", toolchain)
+
+ def changeBertosVersion(self):
+ current_version = self.module_page.projectInfo("BERTOS_PATH")
+ dialog = BVersionDialog()
+ if dialog.exec_():
+ version = qvariant_converter.getString(dialog.version_page.currentItem().data(Qt.UserRole))
+ if QMessageBox.question(
+ dialog.version_page,
+ self.tr("BeRTOS version update"),
+ self.tr("Changing the BeRTOS version will destroy all the modification done on the BeRTOS sources"),
+ QMessageBox.Ok | QMessageBox.Cancel
+ ) == QMessageBox.Ok:
+ try:
+ qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
+ dialog.version_page.setProjectInfo("BERTOS_PATH", version)
+ dialog.version_page.setProjectInfo("OLD_BERTOS_PATH", current_version)
+ enabled_modules = bertos_utils.enabledModules(dialog.version_page.project)
+ old_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
+ dialog.version_page.project.loadSourceTree()
+ QApplication.instance().project.reloadCpuInfo()
+ QApplication.instance().project.loadModuleData()
+ new_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
+ merged_configuration = {}
+ for conf in new_configuration:
+ if conf in old_configuration:
+ configuration = bertos_utils.updateConfigurationValues(new_configuration[conf], old_configuration[conf])
+ else:
+ configuration = new_configuration[conf]
+ merged_configuration[conf] = configuration
+ dialog.version_page.setProjectInfo("CONFIGURATIONS", merged_configuration)
+ dialog.version_page.project.setEnabledModules(enabled_modules)
+ self.module_page.fillModuleTree()
+ finally:
+ qApp.restoreOverrideCursor()
+ else:
+ # Rollback version to the previous selected one.
+ dialog.version_page.setProjectInfo("BERTOS_PATH", current_version)
+
+ def apply(self):
+ try:
+ qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
+ QApplication.instance().project.createBertosProject()
+ finally:
+ qApp.restoreOverrideCursor()
+ self.accept()