X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2FBEditingDialog.py;h=1a9c34de830ecd0072856099a4866e6c0832a04c;hb=747233b80705146400952ab08bea94f04bf23ae6;hp=82bac4ed5b5a206902af2f251975322554e3a475;hpb=8ef766f0143a45c397a21a543f698e918d3e3785;p=bertos.git diff --git a/wizard/BEditingDialog.py b/wizard/BEditingDialog.py index 82bac4ed..1a9c34de 100644 --- a/wizard/BEditingDialog.py +++ b/wizard/BEditingDialog.py @@ -39,7 +39,9 @@ import os from PyQt4.QtCore import * from PyQt4.QtGui import * -from bertos_utils import loadBertosProject +from bertos_utils import loadBertosProject, bertosVersion, getToolchainName, createBertosProject +from toolchain_validation import validateToolchain +import qvariant_converter import BModulePage class BEditingDialog(QDialog): @@ -47,14 +49,109 @@ class BEditingDialog(QDialog): def __init__(self, parent=None): QDialog.__init__(self, parent) self.setupUi() + self.connectSignals() self.module_page.reloadData() def setupUi(self): 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")) + self.toolchain_actions = [] + action_group = QActionGroup(self.toolchain_menu) + for toolchain in sorted(self.toolchains()): + info = validateToolchain(toolchain) + if info[0]: + name = getToolchainName(info[1]) + else: + name = toolchain + action = self.toolchain_menu.addAction(name) + action_group.addAction(action) + action.setCheckable(True) + action.setChecked(True if toolchain == self.currentToolchain()["path"] else False) + action.setData(qvariant_converter.convertString(toolchain)) + self.toolchain_actions.append(action) + + def setupVersionMenu(self): + self.version_menu = QMenu(self.tr("select BeRTOS version")) + self.version_actions = [] + action_group = QActionGroup(self.version_menu) + versions = [(path, bertosVersion(path)) for path in self.versions()] + for path, version in versions: + action = self.version_menu.addAction(version) + action_group.addAction(action) + action.setCheckable(True) + action.setChecked(True if path == self.currentVersion() else False) + action.setData(qvariant_converter.convertString(path)) + self.version_actions.append(action) + + def connectSignals(self): + 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 + )) + self.connect(self.apply_button, SIGNAL("clicked()"), self.apply) + self.connect(self.cancel_button, SIGNAL("clicked()"), self.reject) + + def toolchainChanged(self, toolchain, activated): + if activated: + self.setCurrentToolchain(toolchain) + + def versionChanged(self, version, activated): + if activated: + self.setCurrentVersion(version) + + def apply(self): + createBertosProject(self.module_page.project(), edit=True) + self.accept() + + 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 +162,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_())