4 # This file is part of BeRTOS.
6 # Bertos is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 # As a special exception, you may use this file as part of a free software
21 # library without restriction. Specifically, if other files instantiate
22 # templates or use macros or inline functions from this file, or you compile
23 # this file and link it with other files to produce an executable, this
24 # file does not by itself cause the resulting executable to be covered by
25 # the GNU General Public License. This exception does not however
26 # invalidate any other reasons why the executable file might be covered by
27 # the GNU General Public License.
29 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
33 # Author: Lorenzo Berni <duplo@develer.com>
39 from PyQt4.QtCore import *
40 from PyQt4.QtGui import *
42 from bertos_utils import loadBertosProject, bertosVersion, getToolchainName
43 from toolchain_validation import validateToolchain
46 class BEditingDialog(QDialog):
48 def __init__(self, parent=None):
49 QDialog.__init__(self, parent)
51 self.module_page.reloadData()
54 layout = QVBoxLayout()
55 self.module_page = BModulePage.BModulePage()
56 layout.addWidget(self.module_page)
57 button_layout = QHBoxLayout()
58 self.advanced_button = QToolButton()
60 self.advanced_button.setMenu(self.menu)
61 self.advanced_button.setPopupMode(QToolButton.InstantPopup)
62 self.advanced_button.setText(self.tr("Advanced"))
63 button_layout.addWidget(self.advanced_button)
64 button_layout.addStretch()
65 self.cancel_button = QPushButton(self.tr("Cancel"))
66 button_layout.addWidget(self.cancel_button)
67 self.apply_button = QPushButton(self.tr("Apply"))
68 button_layout.addWidget(self.apply_button)
69 layout.addLayout(button_layout)
70 self.setLayout(layout)
73 self.menu = QMenu(self.tr("Advanced options"))
74 self.setupToolchainMenu()
75 self.menu.addMenu(self.toolchain_menu)
76 self.setupVersionMenu()
77 self.menu.addMenu(self.version_menu)
79 def setupToolchainMenu(self):
80 self.toolchain_menu = QMenu(self.tr("select toolchain"))
81 action_group = QActionGroup(self.toolchain_menu)
82 for toolchain in sorted(self.toolchains()):
83 info = validateToolchain(toolchain)
85 name = getToolchainName(info[1])
88 action = self.toolchain_menu.addAction(name)
89 action_group.addAction(action)
90 action.setCheckable(True)
91 action.setChecked(True if toolchain == self.currentToolchain()["path"] else False)
93 def setupVersionMenu(self):
94 self.version_menu = QMenu(self.tr("select BeRTOS version"))
95 action_group = QActionGroup(self.version_menu)
96 for version in sorted([bertosVersion(v) for v in self.versions()]):
97 action = self.version_menu.addAction(version)
98 action_group.addAction(action)
99 action.setCheckable(True)
100 action.setChecked(True if unicode(action.text()) == self.currentVersion() else False)
102 def toolchains(self):
103 return self.module_page.toolchains()
105 def currentToolchain(self):
106 return self.module_page.projectInfo("TOOLCHAIN")
108 def setCurrentToolchain(self, toolchain):
109 self.module_page.setProjectInfo("TOOLCHAIN", toolchain)
112 return self.module_page.versions()
114 def currentVersion(self):
115 return self.module_page.projectInfo("SOURCES_PATH")
117 def setCurrentVersion(self, version):
118 self.module_page.setProjectInfo("SOURCES_PATH", version)
123 if len(sys.argv) > 1:
124 project_file = sys.argv[1]
126 print "Invalid usage: use <command> project_file"
128 app = QApplication([])
129 app.project = loadBertosProject(project_file)
130 app.settings = QSettings("Develer", "Bertos Configurator")
131 dialog = BEditingDialog()
133 sys.exit(app.exec_())
135 if __name__ == "__main__":