Remove custom/predefined choice from the folder page and add a new page.
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 24 May 2010 09:53:26 +0000 (09:53 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 24 May 2010 09:53:26 +0000 (09:53 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3794 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BFolderPage.py
wizard/BProject.py
wizard/BTypePage.py [new file with mode: 0644]
wizard/BVersionPage.py
wizard/BWizard.py
wizard/bertos.py
wizard/ui/dir_select.ui
wizard/ui/project_type_select.ui [new file with mode: 0644]

index 50cb2cd6b38db3de9c6d38a6bc2e4ccbc483342b..9944677c7bc267d6f4a5796f4e765cd83b25200e 100644 (file)
@@ -67,8 +67,6 @@ class BFolderPage(BWizardPage):
             self.setProjectInfo("PROJECT_NAME", os.path.basename(unicode(self.pageContent.projectPath.text())))
             self.setProjectInfo("PROJECT_SRC_PATH", os.path.join(self.projectInfo("PROJECT_PATH"), self.projectInfo("PROJECT_NAME")))
             self.setProjectInfo("PROJECT_HW_PATH", os.path.join(self.projectInfo("PROJECT_PATH"), self.projectInfo("PROJECT_NAME")))
-            self.setProjectInfo("ROUTE", self.next_page)
-            self.setProjectInfo("PROJECT_FROM_PRESET", self.from_preset)
             return True
         else:
             return False
@@ -90,7 +88,7 @@ class BFolderPage(BWizardPage):
         self.connect(self.pageContent.nameEdit, SIGNAL("textChanged(const QString)"), self.nameChanged)
         self.connect(self.pageContent.directoryEdit, SIGNAL("textChanged(const QString)"), self.directoryChanged)
         self.connect(self.pageContent.directoryButton, SIGNAL("clicked()"), self.selectDirectory)
-        self.connect(self.pageContent.customButton, SIGNAL("toggled(bool)"), self.isComplete)
+        self.connect(self.pageContent.customButton, SIGNAL("toggled(bool)"), self.isComplete)
     
     ####
 
@@ -129,20 +127,6 @@ class BFolderPage(BWizardPage):
             self.pageContent.directoryEdit.setText(QDir.toNativeSeparators(directory))
 
     ####
-
-    @property
-    def next_page(self):
-        """
-        Contains the next page class.
-        """
-        if self.from_preset:
-            return BBoardPage
-        else:
-            return BCpuPage
-
-    @property
-    def from_preset(self):
-        return self.pageContent.predefinedButton.isChecked()
     
     def initializeAttributes(self):
         """
index b31c3f114fcc6e280d729e789094b918d91c4b6c..c2f6613a5f5fe0557ae8837f2bace3dc1f7e3e04 100644 (file)
@@ -226,7 +226,10 @@ class BProject(object):
 
     def _loadPresetInfo(self, preset_spec_file):
         D = {}
-        execfile(preset_spec_file, {}, D)
+        try:
+            execfile(preset_spec_file, {}, D)
+        except IOError, e:
+            pass
         return D
 
     def loadModuleData(self, edit=False):
diff --git a/wizard/BTypePage.py b/wizard/BTypePage.py
new file mode 100644 (file)
index 0000000..0968156
--- /dev/null
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# This file is part of slimqc.
+#
+# Bertos is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+# As a special exception, you may use this file as part of a free software
+# library without restriction.  Specifically, if other files instantiate
+# templates or use macros or inline functions from this file, or you compile
+# this file and link it with other files to produce an executable, this
+# file does not by itself cause the resulting executable to be covered by
+# the GNU General Public License.  This exception does not however
+# invalidate any other reasons why the executable file might be covered by
+# the GNU General Public License.
+#
+# Copyright 2010 Develer S.r.l. (http://www.develer.com/)
+#
+# $Id$
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
+
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+
+from BWizardPage import BWizardPage
+
+from BBoardPage import BBoardPage
+from BCpuPage import BCpuPage
+
+from const import UI_LOCATION
+
+class BTypePage(BWizardPage):
+    def __init__(self):
+        BWizardPage.__init__(self, UI_LOCATION + "/project_type_select.ui")
+        self.setTitle(self.tr("Select the project type"))
+
+    ## Overloaded QWizardPage methods ##
+
+    def isComplete(self):
+        self.setProjectInfo("PROJECT_FROM_PRESET", self.from_preset)
+        return True
+
+    def nextId(self):
+        if self.from_preset:
+            return self.wizard().pageIndex(BBoardPage)
+        else:
+            return self.wizard().pageIndex(BCpuPage)
+
+    ####
+
+    ## Overloaded BWizardPage methods ##
+
+    def connectSignals(self):
+        self.connect(self.pageContent.predefinedButton, SIGNAL("toggled(bool)"), self, SIGNAL("completeChanged()"))
+
+    def reloadData(self):
+        self.project.loadProjectPresets()
+        self.pageContent.predefinedButton.setEnabled(len(self.has_presets) > 0)
+        self.pageContent.predefinedButton.setChecked(len(self.has_presets) > 0)
+        self.pageContent.customButton.setChecked(len(self.has_presets) == 0)
+
+    ####
+
+    @property
+    def from_preset(self):
+        return self.pageContent.predefinedButton.isChecked()
+
+    @property
+    def has_presets(self):
+        preset_tree = self.project.info("PRESET_TREE")
+        return isinstance(preset_tree, dict) and preset_tree.get("children", [])
\ No newline at end of file
index 680577c53f245e86ea7cae1509a38f727428b392..23f6fb01b299efac4cb2848238fca03deedd31d4 100644 (file)
@@ -69,14 +69,6 @@ class BVersionPage(BWizardPage):
             return True
         else:
             return False
-
-    def nextId(self):
-        """
-        Overload of the QWizard nextId method.
-        """
-        # Pick up the class stored into the project in the 'folder' step
-        page_class = self.projectInfo("ROUTE")
-        return self.wizard().pageIndex(page_class)
     
     ####
     
index 4b7ab45deed1bc1c3c85c09603eeb8863374c775..55f913d65339bc8fb6998debc56a2a377b13e896 100644 (file)
@@ -40,6 +40,7 @@ from PyQt4.QtGui import *
 
 import BFolderPage
 import BVersionPage
+import BTypePage
 import BCpuPage
 import BToolchainPage
 import BModulePage
index f04c16f639c163f9ac2a410b9464891fe0ec98c6..65e578ccdaa4e787a4f5d4731a89b3b44ce464fe 100755 (executable)
@@ -48,6 +48,7 @@ from BWizard import BWizard
 
 from BIntroPage import BIntroPage
 from BFolderPage import BFolderPage
+from BTypePage import BTypePage
 from BBoardPage import BBoardPage
 from BRoutePage import BRoutePage
 from BOpenPage import BOpenPage
@@ -67,7 +68,7 @@ from LoadException import VersionException, ToolchainException
 
 def newProject():
     QApplication.instance().project = BProject()
-    page_list = [BIntroPage, BFolderPage, BVersionPage, BBoardPage, BRoutePage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
+    page_list = [BIntroPage, BFolderPage, BVersionPage, BTypePage, BBoardPage, BRoutePage, BCpuPage, BToolchainPage, BModulePage, BOutputPage, BCreationPage, BFinalPage]
     wizard = BWizard(page_list)
     wizard.show()
     wizard.exec_()
index a0f2d5bd07282a4152cabb22211329a9a7e045bb..6e60aab99efd3df2640e2ee2a6f5f624e5010ba7 100644 (file)
      </property>
     </widget>
    </item>
-   <item>
-    <widget class="QGroupBox" name="groupBox">
-     <property name="title">
-      <string>Board type</string>
-     </property>
-     <property name="checkable">
-      <bool>false</bool>
-     </property>
-     <layout class="QVBoxLayout" name="verticalLayout_3">
-      <item>
-       <widget class="QRadioButton" name="customButton">
-        <property name="text">
-         <string>Custom board</string>
-        </property>
-        <property name="checked">
-         <bool>true</bool>
-        </property>
-       </widget>
-      </item>
-      <item>
-       <widget class="QRadioButton" name="predefinedButton">
-        <property name="text">
-         <string>Predefined board</string>
-        </property>
-       </widget>
-      </item>
-     </layout>
-    </widget>
-   </item>
   </layout>
  </widget>
  <resources>
diff --git a/wizard/ui/project_type_select.ui b/wizard/ui/project_type_select.ui
new file mode 100644 (file)
index 0000000..be438c2
--- /dev/null
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_2">
+   <item>
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Project type</string>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QRadioButton" name="predefinedButton">
+        <property name="text">
+         <string>Predefined board</string>
+        </property>
+        <property name="checked">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QRadioButton" name="customButton">
+        <property name="text">
+         <string>Custom board</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>