Change the interface in order to discover automatically plugins
[bertos.git] / wizard / BOutputPage.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 import os
13
14 from PyQt4.QtGui import *
15 from BWizardPage import *
16 import bertos_utils
17
18 import plugins
19
20 from const import *
21
22 class BOutputPage(BWizardPage):
23     """
24     Page of the wizard that show a little summary of the previous decisions.
25     """
26     
27     def __init__(self):
28         BWizardPage.__init__(self, UI_LOCATION + "/output_select.ui")
29         self.setTitle(self.tr("Choose the project output"))
30     
31     ## Overloaded BWizardPage methods. ##
32     
33     def connectSignals(self):
34         """
35         Overload of the BWizardPage connectSignals method.
36         """
37         for plugin in self._plugin_dict:
38             self.connect(plugin, SIGNAL("stateChanged(int)"), self.modeChecked)
39     
40     def setupUi(self):
41         """
42         Overload of the BWizardPage setupUi method.
43         """
44         self._plugin_dict = {}
45         layout = QVBoxLayout()
46         for plugin in self.availablePlugins():
47             check = QCheckBox(plugin)
48             layout.addWidget(check)
49             check.setCheckState(Qt.Checked)
50             self._plugin_dict[check] = plugin
51         widget = QWidget()
52         widget.setLayout(layout)
53         self.pageContent.scrollArea.setWidget(widget)
54     
55     def reloadData(self):
56         """
57         Overload of the BWizardPage reloadData method.
58         """
59         self.modeChecked()
60         
61     ####
62     
63     ## Slots ##
64     
65     def modeChecked(self):
66         """
67         Slot called when one of the mode checkbox is checked. It stores it.
68         """
69         plugins = []
70         for checkBox, plugin in self._plugin_dict.items():
71             if checkBox.checkState() == Qt.Checked:
72                 plugins.append(plugin)
73         self.setProjectInfo("OUTPUT", plugins)
74
75     ####
76     
77     def availablePlugins(self):
78         return plugins.__all__