Make BWizard generic: now it can be used for both creating and editing projects
[bertos.git] / wizard / bertos.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
5 # All rights reserved.
6 #
7 # $Id:$
8 #
9 # Author: Lorenzo Berni <duplo@develer.com>
10 #
11
12 import os
13 import sys
14 from distutils.dep_util import newer
15
16 from PyQt4.QtCore import *
17 from PyQt4.QtGui import *
18
19 import BProject
20
21 import BStartPage
22 import BWizard
23
24 from BFolderPage import BFolderPage
25 from BVersionPage import BVersionPage
26 from BCpuPage import BCpuPage
27 from BToolchainPage import BToolchainPage
28 from BModulePage import BModulePage
29 from BOutputPage import BOutputPage
30 from BCreationPage import BCreationPage
31 from BFinalPage import BFinalPage
32
33 import bertos_utils
34
35 def newProject():
36     page_list = [BFolderPage, BVersionPage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
37     wizard = BWizard.BWizard(page_list)
38     wizard.show()
39     wizard.exec_()
40     
41 def editProject():
42     page_list = [BVersionPage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
43     wizard = BWizard.BWizard(page_list)
44     wizard.show()
45     wizard.exec_()
46
47 def showStartPage():
48     QApplication.instance().dialog = BStartPage.BStartPage()
49     QApplication.instance().connect(QApplication.instance().dialog, SIGNAL("newProject"), newProject)
50     QApplication.instance().connect(QApplication.instance().dialog, SIGNAL("editProject"), editProject)
51     QApplication.instance().dialog.show()
52
53 def main():
54     app = QApplication(sys.argv)
55     app.settings = QSettings("Develer", "Bertos Configurator")
56     app.project = BProject.BProject()
57     if newer("bertos.qrc", "bertos.rcc"):
58         os.system("rcc -binary bertos.qrc > bertos.rcc")
59     QResource.registerResource("bertos.rcc")
60     showStartPage()
61     sys.exit(app.exec_())
62
63 if __name__ == '__main__':
64     main()
65