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, createBertosProject
43 from BToolchainPage import BToolchainPage
44 from BVersionPage import BVersionPage
45 import qvariant_converter
48 class BEditingDialog(QDialog):
50 def __init__(self, parent=None):
51 QDialog.__init__(self, parent)
54 self.module_page.reloadData()
57 layout = QVBoxLayout()
58 self.module_page = BModulePage.BModulePage()
59 layout.addWidget(self.module_page)
60 button_layout = QHBoxLayout()
61 self.advanced_button = QToolButton()
63 self.advanced_button.setMenu(self.menu)
64 self.advanced_button.setPopupMode(QToolButton.InstantPopup)
65 self.advanced_button.setText(self.tr("Advanced"))
66 button_layout.addWidget(self.advanced_button)
67 button_layout.addStretch()
68 self.cancel_button = QPushButton(self.tr("Cancel"))
69 button_layout.addWidget(self.cancel_button)
70 self.apply_button = QPushButton(self.tr("Apply"))
71 button_layout.addWidget(self.apply_button)
72 layout.addLayout(button_layout)
73 self.setLayout(layout)
76 self.menu = QMenu(self.tr("Advanced options"))
77 self.change_toolchain = QAction(self.tr("Change toolchain"), self)
78 self.change_bertos_version = QAction(self.tr("Change BeRTOS version"), self)
79 self.menu.addAction(self.change_toolchain)
80 self.menu.addAction(self.change_bertos_version)
82 def connectSignals(self):
83 self.connect(self.change_toolchain, SIGNAL("triggered(bool)"), self.changeToolchain)
84 self.connect(self.change_bertos_version, SIGNAL("triggered(bool)"), self.changeBertosVersion)
85 self.connect(self.apply_button, SIGNAL("clicked()"), self.apply)
86 self.connect(self.cancel_button, SIGNAL("clicked()"), self.reject)
88 def changeToolchain(self):
90 layout = QVBoxLayout()
91 toolchain_page = BToolchainPage()
92 toolchain_page.reloadData()
93 layout.addWidget(toolchain_page)
94 button_layout = QHBoxLayout()
95 button_layout.addStretch()
96 cancel_button = QPushButton(self.tr("Cancel"))
97 button_layout.addWidget(cancel_button)
98 ok_button = QPushButton(self.tr("Ok"))
99 button_layout.addWidget(ok_button)
100 dialog.connect(cancel_button, SIGNAL("clicked()"), dialog.reject)
101 layout.addLayout(button_layout)
102 dialog.setLayout(layout)
103 dialog.connect(ok_button, SIGNAL("clicked()"), dialog.accept)
106 def changeBertosVersion(self):
108 layout = QVBoxLayout()
109 version_page = BVersionPage()
110 version_page.reloadData()
111 layout.addWidget(version_page)
112 button_layout = QHBoxLayout()
113 button_layout.addStretch()
114 cancel_button = QPushButton(self.tr("Cancel"))
115 button_layout.addWidget(cancel_button)
116 ok_button = QPushButton(self.tr("Ok"))
117 button_layout.addWidget(ok_button)
118 dialog.connect(cancel_button, SIGNAL("clicked()"), dialog.reject)
119 layout.addLayout(button_layout)
120 dialog.setLayout(layout)
121 dialog.connect(ok_button, SIGNAL("clicked()"), dialog.accept)
125 createBertosProject(self.module_page.project(), edit=True)
128 def toolchains(self):
129 return self.module_page.toolchains()
131 def currentToolchain(self):
132 return self.module_page.projectInfo("TOOLCHAIN")
134 def setCurrentToolchain(self, toolchain):
135 self.module_page.setProjectInfo("TOOLCHAIN", toolchain)
138 return self.module_page.versions()
140 def currentVersion(self):
141 return self.module_page.projectInfo("SOURCES_PATH")
143 def setCurrentVersion(self, version):
144 self.module_page.setProjectInfo("SOURCES_PATH", version)
149 if len(sys.argv) > 1:
150 project_file = sys.argv[1]
152 print "Invalid usage: use <command> project_file"
154 app = QApplication([])
155 app.project = loadBertosProject(project_file)
156 app.settings = QSettings("Develer", "Bertos Configurator")
157 dialog = BEditingDialog()
159 sys.exit(app.exec_())
161 if __name__ == "__main__":