CodeLite: add a small delay during the debugger initialization.
[bertos.git] / wizard / BOutputPage.py
1 #!/usr/bin/env python
2 # encoding: utf-8
3 #
4 # This file is part of BeRTOS.
5 #
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.
10 #
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.
15 #
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
19 #
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.
28 #
29 # Copyright 2008 Develer S.r.l. (http://www.develer.com/)
30 #
31 # $Id$
32 #
33 # Author: Lorenzo Berni <duplo@develer.com>
34 #
35
36 import os
37
38 from PyQt4.QtGui import *
39 from BWizardPage import *
40 import bertos_utils
41
42 import plugins
43
44 from const import *
45
46 class BOutputPage(BWizardPage):
47     """
48     Page of the wizard that show a little summary of the previous decisions.
49     """
50     
51     def __init__(self):
52         BWizardPage.__init__(self, UI_LOCATION + "/output_select.ui")
53         self.setTitle(self.tr("Choose the project output"))
54     
55     ## Overloaded BWizardPage methods. ##
56     
57     def connectSignals(self):
58         """
59         Overload of the BWizardPage connectSignals method.
60         """
61         for plugin in self._plugin_dict:
62             self.connect(plugin, SIGNAL("stateChanged(int)"), self.modeChecked)
63     
64     def setupUi(self):
65         """
66         Overload of the BWizardPage setupUi method.
67         """
68         self._plugin_dict = {}
69         scrollLayout = QVBoxLayout()
70         group, check = self.createNewOutput("BeRTOS Build System",
71                                             "Classic BeRTOS makefile based project",
72                                             True, False)
73         scrollLayout.addWidget(group)
74         plugin_list = self.plugins()
75         for plugin in self.availablePlugins():
76             module = bertos_utils.loadPlugin(plugin)
77             selected = False
78             if plugin in plugin_list: selected = True
79             group, check = self.createNewOutput(module.PLUGIN_NAME,
80                                                 module.PLUGIN_DESCRIPTION,
81                                                 selected, True)
82             scrollLayout.addWidget(group)
83             self._plugin_dict[check] = plugin
84         scrollLayout.addStretch()
85         widget = QWidget()
86         widget.setLayout(scrollLayout)
87         self.pageContent.scrollArea.setWidget(widget)
88     
89     def reloadData(self):
90         """
91         Overload of the BWizardPage reloadData method.
92         """
93         self.modeChecked()
94         
95     ####
96     
97     ## Slots ##
98     
99     def modeChecked(self):
100         """
101         Slot called when one of the mode checkbox is checked. It stores it.
102         """
103         plugins = []
104         for checkBox, plugin in self._plugin_dict.items():
105             if checkBox.checkState() == Qt.Checked:
106                 plugins.append(plugin)
107         self.setPlugins(plugins)
108         self.setProjectInfo("OUTPUT", plugins)
109
110     ####
111     
112     def availablePlugins(self):
113         """
114         Returns the list of the available plugins.
115         """
116         return plugins.plugin_list
117     
118     def createNewOutput(self, name, description, checked=True, enabled=True):
119         """
120         Create a groupBox for the given pieces of information. Returns the
121         groupBox and the checkBox
122         """
123         check = QCheckBox(description)
124         if checked:
125             check.setCheckState(Qt.Checked)
126         else:
127             check.setCheckState(Qt.Unchecked)
128         groupLayout = QVBoxLayout()
129         groupLayout.addWidget(check)
130         group = QGroupBox(name)
131         group.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
132         group.setLayout(groupLayout)
133         group.setEnabled(enabled)
134         return group, check