Remove the spinner (it isn't needed)
[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         self._completed = False
27     
28     def reloadData(self):
29         self._completed = False
30         self._setupUi()
31     
32     def _setupUi(self):
33         self._confirmGroup = QWidgetGroup(self.pageContent.summaryTree,
34                                             self.pageContent.createButton)
35         self._finalGroup = QWidgetGroup(self.pageContent.iconLabel,
36                                             self.pageContent.textLabel)
37         self._finalGroup.setVisible(False)
38     
39     def _connectSignals(self):
40         self.connect(self.pageContent.createButton, SIGNAL("clicked(bool)"), self._createProject)
41     
42     def _createProject(self):
43         self._confirmGroup.setVisible(False)
44         bertos_utils.createBertosProject(self.wizard().project())
45         self._finalGroup.setVisible(True)
46         self._completed = True
47         self.emit(SIGNAL("completeChanged()"))
48     
49     def isComplete(self):
50         return self._completed
51
52 class QWidgetGroup(QObject):
53     """
54     Container class, this class contains widgets and permit to set some
55     properties of the contained widgets at the same time.
56     """
57     def __init__(self, *elements):
58         self._widgets = []
59         for element in elements:
60             self._widgets.append(element)
61     
62     def addWidget(self, widget):
63         if widget not in self._widgets:
64             self._widgets.append(widget)
65     
66     def setVisible(self, visible):
67         for widget in self._widgets:
68             widget.setVisible(visible)
69     
70     def isVisible(self):
71         for widget in self._widgets:
72             if not widget.isVisible():
73                 return False
74         return True
75