From: duplo Date: Fri, 24 Jul 2009 15:34:54 +0000 (+0000) Subject: Add lambda function in order to handle toolchain and version changing X-Git-Tag: 2.2.0~199 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=0177979cf7775a8244c071bd87fcc953063f548c;p=bertos.git Add lambda function in order to handle toolchain and version changing git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2769 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BEditingDialog.py b/wizard/BEditingDialog.py index b2007fc6..0bf8ea68 100644 --- a/wizard/BEditingDialog.py +++ b/wizard/BEditingDialog.py @@ -80,6 +80,7 @@ class BEditingDialog(QDialog): 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) @@ -92,9 +93,11 @@ class BEditingDialog(QDialog): 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: @@ -103,13 +106,27 @@ class BEditingDialog(QDialog): action.setCheckable(True) action.setChecked(True if path == self.currentVersion() else False) action.setData(qvariant_converter.convertString(path)) - self.connect(action, SIGNAL("triggered(bool)"), lambda: self.versionChanged(path)) - - def toolchainChanged(self, toolchain): - print toolchain - - def versionChanged(self, version): - print version + 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 + )) + + def toolchainChanged(self, toolchain, activated): + if activated: + self.setCurrentToolchain(toolchain) + + def versionChanged(self, version, activated): + if activated: + self.setCurrentVersion(version) def toolchains(self): return self.module_page.toolchains()