Improve the ui
[bertos.git] / wizard / BFinalPage.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
16 from BWizardPage import *
17 import bertos_utils
18
19 from const import *
20
21 class BFinalPage(BWizardPage):
22     """
23     Last page of the wizard. It creates the project and show a success message.
24     """
25     
26     def __init__(self):
27         BWizardPage.__init__(self, UI_LOCATION + "/final_page.ui")
28         self.setTitle(self.tr("Project created successfully"))
29     
30     ## Overloaded BWizardPage methods ##
31         
32     def reloadData(self):
33         """
34         Overload of the BWizardPage reloadData method.
35         """
36         QApplication.instance().setOverrideCursor(Qt.WaitCursor)
37         bertos_utils.createBertosProject(self.project())
38         QApplication.instance().restoreOverrideCursor()
39         if os.name == "nt":
40             output = self.projectInfo("OUTPUT")
41             import winreg_importer
42             command_lines = winreg_importer.getCommandLines()
43             layout = QVBoxLayout()
44             self._plugin_dict = {}
45             for plugin in output:
46                 if plugin in command_lines:
47                     module = bertos_utils.loadPlugin(plugin)
48                     checked = len(output) == 1
49                     group, check  = self.createNewOutput(self, module.NAME, module.DESCRIPTION, checked)
50                     self._plugin_dict[check] = plugin
51             widget = QWidget()
52             widget.setLayout(layout)
53             if len(self._plugin_dict) > 0:
54                 self.pageContent.scrollArea.setVisible(True)
55             self.pageContent.scrollArea.setWidget(widget)
56     
57     def setupUi(self):
58         """
59         Overload of the BWizardPage setupUi method.
60         """
61         self.pageContent.scrollArea.setVisible(False)
62     
63     ####
64     
65     def createNewOutput(self, name, description, checked=True, enabled=True):
66         """
67         Create a groupBox for the given pieces of information. Returns the
68         groupBox and the checkBox
69         """
70         check = QCheckBox(description)
71         if checked:
72             check.setCheckState(Qt.Checked)
73         else:
74             check.setCheckState(Qt.Unchecked)
75         groupLayout = QVBoxLayout()
76         groupLayout.addWidget(check)
77         group = QGroupBox(name)
78         group.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Maximum)
79         group.setLayout(groupLayout)
80         group.setEnabled(enabled)
81         return group, check