Change the interface in order to discover automatically plugins
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 22 Apr 2009 10:12:15 +0000 (10:12 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 22 Apr 2009 10:12:15 +0000 (10:12 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@2618 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BOutputPage.py
wizard/ui/output_select.ui

index 55418d664de7f98dfd2f4bdfd57a45773c2ac905..ef3c305af5d1813ea149d8cc6ab757798267aee9 100644 (file)
@@ -15,6 +15,8 @@ from PyQt4.QtGui import *
 from BWizardPage import *
 import bertos_utils
 
+import plugins
+
 from const import *
 
 class BOutputPage(BWizardPage):
@@ -30,35 +32,47 @@ class BOutputPage(BWizardPage):
     
     def connectSignals(self):
         """
-        Connects the signals with the related slots.
+        Overload of the BWizardPage connectSignals method.
+        """
+        for plugin in self._plugin_dict:
+            self.connect(plugin, SIGNAL("stateChanged(int)"), self.modeChecked)
+    
+    def setupUi(self):
+        """
+        Overload of the BWizardPage setupUi method.
         """
-        self.connect(self.pageContent.codeliteCheckBox, SIGNAL("stateChanged(int)"), lambda checked: self.modeChecked(checked, "codelite"))
+        self._plugin_dict = {}
+        layout = QVBoxLayout()
+        for plugin in self.availablePlugins():
+            check = QCheckBox(plugin)
+            layout.addWidget(check)
+            check.setCheckState(Qt.Checked)
+            self._plugin_dict[check] = plugin
+        widget = QWidget()
+        widget.setLayout(layout)
+        self.pageContent.scrollArea.setWidget(widget)
     
     def reloadData(self):
         """
         Overload of the BWizardPage reloadData method.
         """
-        output = []
-        if self.pageContent.codeliteCheckBox.isChecked():
-            output.append("codelite")
-        else:
-            if "codelite" in output:
-                output.remove("codelite")
-        self.setProjectInfo("OUTPUT", output)
-    
+        self.modeChecked()
+        
     ####
     
     ## Slots ##
     
-    def modeChecked(self, checked, value):
+    def modeChecked(self):
         """
         Slot called when one of the mode checkbox is checked. It stores it.
         """
-        output_list = self.projectInfo("OUTPUT")
-        if checked == Qt.Checked:
-            output_list.append(value)
-        else:
-            output_list.remove(value)
-        self.setProjectInfo("OUTPUT", output_list)
+        plugins = []
+        for checkBox, plugin in self._plugin_dict.items():
+            if checkBox.checkState() == Qt.Checked:
+                plugins.append(plugin)
+        self.setProjectInfo("OUTPUT", plugins)
 
-    ####
\ No newline at end of file
+    ####
+    
+    def availablePlugins(self):
+        return plugins.__all__
\ No newline at end of file
index 3540d35714b68f7278f53015d2c6d14db93fecfa..aaccb714ec76f1b6b736c1292fbc8795698d5c80 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>359</width>
-    <height>372</height>
+    <width>349</width>
+    <height>270</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -19,7 +19,7 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_5">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <widget class="QFrame" name="frame">
      <property name="frameShape">
     </widget>
    </item>
    <item>
-    <widget class="QFrame" name="frame_4">
-     <property name="enabled">
+    <widget class="QScrollArea" name="scrollArea">
+     <property name="widgetResizable">
       <bool>true</bool>
      </property>
-     <property name="frameShape">
-      <enum>QFrame::StyledPanel</enum>
-     </property>
-     <property name="frameShadow">
-      <enum>QFrame::Raised</enum>
-     </property>
-     <layout class="QVBoxLayout" name="verticalLayout_4">
-      <item>
-       <widget class="QCheckBox" name="codeliteCheckBox">
-        <property name="text">
-         <string>CodeLite project</string>
-        </property>
-        <property name="checked">
-         <bool>true</bool>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <layout class="QHBoxLayout" name="horizontalLayout_4">
-        <item>
-         <spacer name="horizontalSpacer_2">
-          <property name="orientation">
-           <enum>Qt::Horizontal</enum>
-          </property>
-          <property name="sizeHint" stdset="0">
-           <size>
-            <width>40</width>
-            <height>20</height>
-           </size>
-          </property>
-         </spacer>
-        </item>
-        <item>
-         <widget class="QLabel" name="codeliteLabel">
-          <property name="enabled">
-           <bool>true</bool>
-          </property>
-          <property name="text">
-           <string>CodeLite project files and configurations</string>
-          </property>
-         </widget>
-        </item>
-       </layout>
-      </item>
-     </layout>
+     <widget class="QWidget" name="scrollAreaWidgetContents">
+      <property name="geometry">
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>321</width>
+        <height>152</height>
+       </rect>
+      </property>
+     </widget>
     </widget>
    </item>
   </layout>