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         QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
44         self._confirmGroup.setVisible(False)
45         bertos_utils.createBertosProject(self.wizard().project())
46         self._finalGroup.setVisible(True)
47         self._completed = True
48         QApplication.restoreOverrideCursor()
49         self.emit(SIGNAL("completeChanged()"))
50     
51     def isComplete(self):
52         return self._completed
53
54 class QWidgetGroup(QObject):
55     """
56     Container class, this class contains widgets and permit to set some
57     properties of the contained widgets at the same time.
58     """
59     def __init__(self, *elements):
60         self._widgets = []
61         for element in elements:
62             self._widgets.append(element)
63     
64     def addWidget(self, widget):
65         if widget not in self._widgets:
66             self._widgets.append(widget)
67     
68     def setVisible(self, visible):
69         for widget in self._widgets:
70             widget.setVisible(visible)
71     
72     def isVisible(self):
73         for widget in self._widgets:
74             if not widget.isVisible():
75                 return False
76         return True
77