Use QTextBrowser to show html text and images for boards and presets.
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 26 May 2010 15:40:26 +0000 (15:40 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Wed, 26 May 2010 15:40:26 +0000 (15:40 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3844 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BBoardPage.py
wizard/BProjectPresets.py
wizard/ui/board_select.ui
wizard/ui/preset_page.ui

index 85363bd203967093f7efc3f05946ceeaa40394b2..fd6fc9292e7a51afe8fe83fe9ec97fe813eb021a 100644 (file)
@@ -116,13 +116,9 @@ class BBoardPage(BWizardPage):
             info_dict = qvariant_converter.getDict(self.selected.data(Qt.UserRole))
             info_dict = qvariant_converter.getStringDict(info_dict["info"])
             description = info_dict.get("description", "")
-            image = os.path.join(info_dict["path"], ".image.png")
-            if os.path.exists(image):
-                self.pageContent.imageLabel.setPixmap(QPixmap(image))
-                self.pageContent.imageLabel.setVisible(True)
-            else:
-                self.pageContent.imageLabel.setVisible(False)
-            self.pageContent.descriptionLabel.setText(description)
+            path = unicode(QUrl.fromLocalFile(info_dict["path"]).toString())
+            description = description.replace("$path", path)
+            self.pageContent.descriptionArea.setHtml(description)
 
     def customButtonClicked(self):
         self.setProjectInfo("PROJECT_FROM_PRESET", False)
index 818f0fa75e7d7b79023a666b5918c3574426e9f5..ee6d0a06baed57a4e4f463e8ce319690da688cd2 100644 (file)
@@ -87,13 +87,10 @@ class BProjectPresetsPage(QWidget):
         if self.selected:
             preset_path = qvariant_converter.getString(self.selected.data(Qt.UserRole))
             preset = self.preset_data["children"][preset_path]
-            self.pageContent.descriptionLabel.setText(preset["info"].get("description", ""))
-            image = os.path.join(preset["info"]["path"], const.PREDEFINED_BOARD_IMAGE_FILE)
-            if os.path.exists(image):
-                self.pageContent.imageLabel.setPixmap(QPixmap(image))
-                self.pageContent.imageLabel.setVisible(True)
-            else:
-                self.pageContent.imageLabel.setVisible(False)
+            description = preset["info"].get("description", "")
+            path = unicode(QUrl.fromLocalFile(preset_path).toString())
+            description = description.replace("$path", path)
+            self.pageContent.descriptionArea.setHtml(description)
     
     @property
     def selected(self):
index 6731a70eca18f100734cd3e4fd03533100e2d83a..80cc0de26e06d495219873f87932d29e156777d9 100644 (file)
@@ -60,7 +60,7 @@
        <item>
         <widget class="QPushButton" name="customButton">
          <property name="toolTip">
-          <string>&lt;p&gt;&lt;strong&gt;Custom board project &lt;/strong&gt;- select me when your board is not preset into the list above.&lt;/p&gt;</string>
+          <string>&lt;p&gt;&lt;strong&gt;Custom board project &lt;/strong&gt;- select me when your board is not present into the list above.&lt;/p&gt;</string>
          </property>
          <property name="text">
           <string>Custom Board</string>
     </layout>
    </item>
    <item>
-    <widget class="QScrollArea" name="scrollArea">
-     <property name="widgetResizable">
+    <widget class="QTextBrowser" name="descriptionArea">
+     <property name="openExternalLinks">
       <bool>true</bool>
      </property>
-     <widget class="QWidget" name="scrollAreaWidgetContents">
-      <property name="geometry">
-       <rect>
-        <x>0</x>
-        <y>0</y>
-        <width>316</width>
-        <height>336</height>
-       </rect>
-      </property>
-      <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
-       <item>
-        <widget class="QLabel" name="imageLabel">
-         <property name="text">
-          <string/>
-         </property>
-         <property name="wordWrap">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <widget class="QLabel" name="descriptionLabel">
-         <property name="text">
-          <string/>
-         </property>
-         <property name="wordWrap">
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item>
-        <spacer name="verticalSpacer">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>40</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-      </layout>
-     </widget>
     </widget>
    </item>
   </layout>
index 00dcfcfbedd0d72440ada1fe0ed506487b0ffd97..0da7fc65db25e7b463309f98924f5bc495fae54d 100644 (file)
@@ -13,7 +13,7 @@
   <property name="windowTitle">
    <string>Form</string>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout_2">
+  <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1">
    <item>
     <widget class="QLabel" name="categoryDescription">
      <property name="text">
@@ -22,7 +22,7 @@
     </widget>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout" stretch="2,3">
+    <layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
      <item>
       <widget class="QListWidget" name="presetList">
        <property name="minimumSize">
       </widget>
      </item>
      <item>
-      <widget class="QScrollArea" name="scrollArea">
-       <property name="widgetResizable">
+      <widget class="QTextBrowser" name="descriptionArea">
+       <property name="openExternalLinks">
         <bool>true</bool>
        </property>
-       <widget class="QWidget" name="scrollAreaWidgetContents">
-        <property name="geometry">
-         <rect>
-          <x>0</x>
-          <y>0</y>
-          <width>311</width>
-          <height>431</height>
-         </rect>
-        </property>
-        <layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,1">
-         <item>
-          <widget class="QLabel" name="imageLabel">
-           <property name="text">
-            <string/>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <widget class="QLabel" name="descriptionLabel">
-           <property name="text">
-            <string/>
-           </property>
-           <property name="wordWrap">
-            <bool>true</bool>
-           </property>
-          </widget>
-         </item>
-         <item>
-          <spacer name="verticalSpacer">
-           <property name="orientation">
-            <enum>Qt::Vertical</enum>
-           </property>
-           <property name="sizeHint" stdset="0">
-            <size>
-             <width>20</width>
-             <height>40</height>
-            </size>
-           </property>
-          </spacer>
-         </item>
-        </layout>
-       </widget>
       </widget>
      </item>
     </layout>