Add the CreateProject page
[bertos.git] / wizard / BCreationPage.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # Copyright 2009 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 from PyQt4.QtGui import *
13
14 from BWizardPage import *
15 import bertos_utils
16
17 from const import *
18
19 class BCreationPage(BWizardPage):
20     
21     def __init__(self):
22         BWizardPage.__init__(self, UI_LOCATION + "/project_creation.ui")
23         self.setTitle(self.tr("Create the BeRTOS project"))
24         self._setupUi()
25         self._connectSignals()
26     
27     def _setupUi(self):
28         self._confirmGroup = QWidgetGroup(self.pageContent.summaryTree,
29                                             self.pageContent.createButton)
30         self._workingGroup = QWidgetGroup(self.pageContent.spinnerLabel)
31         self._workingGroup.setVisible(False)
32         self._finalGroup = QWidgetGroup(self.pageContent.iconLabel,
33                                             self.pageContent.textLabel)
34         self._finalGroup.setVisible(False)
35     
36     def _connectSignals(self):
37         self.connect(self.pageContent.createButton, SIGNAL("clicked(bool)"), self._createProject)
38     
39     def _createProject(self):
40         self._confirmGroup.setVisible(False)
41         #self._workingGroup.setVisible(True)
42         #self._movie = QMovie("images/load_spinner.gif")
43         #print self._movie.isValid()
44         #self.pageContent.spinnerLabel.setMovie(self._movie)
45         #self._movie.start()
46         bertos_utils.createBertosProject(self.wizard().project())
47         #del self._movie
48         #self._workingGroup.setVisible(False)
49         self._finalGroup.setVisible(True)
50         self.emit(SIGNAL("completeChanged()"))
51     
52     def isComplete(self):
53         return self._finalGroup.isVisible()
54
55 class QWidgetGroup(QObject):
56     """
57     Container class, this class contains widgets and permit to set some
58     properties of the contained widgets at the same time.
59     """
60     def __init__(self, *elements):
61         self._widgets = []
62         for element in elements:
63             self._widgets.append(element)
64     
65     def addWidget(self, widget):
66         if widget not in self._widgets:
67             self._widgets.append(widget)
68     
69     def setVisible(self, visible):
70         for widget in self._widgets:
71             widget.setVisible(visible)
72     
73     def isVisible(self):
74         for widget in self._widgets:
75             if not widget.isVisible():
76                 return False
77         return True
78