# Author: Lorenzo Berni <duplo@develer.com>
#
+import os
+
from PyQt4.QtCore import *
from PyQt4.QtGui import *
####
def _fillPresetTree(self):
+ self.pageContent.boardTree.clear()
self.project.loadProjectPresets()
preset_tree = self.project.info("PRESET_TREE")
for obj in preset_tree['children']:
def _createPresetNode(self, parent, obj):
item_name = obj['info'].get('name', obj['info']['filename'])
item = QTreeWidgetItem(parent, [item_name])
+ item.setIcon(0, QIcon(self._getNodeIcon(obj)))
children_dict = obj['children']
for child in children_dict:
self._createPresetNode(item, child)
+
+ def _getNodeIcon(self, obj):
+ icon_file = os.path.join(obj['info']['path'], const.PREDEFINED_BOARD_ICON_FILE)
+ if os.path.exists(icon_file):
+ return icon_file
+ elif obj['children']:
+ return const.PREDEFINED_BOARD_DEFAULT_DIR_ICON
+ else:
+ return const.PREDEFINED_BOARD_DEFAULT_PROJECT_ICON
_tree = {}
_tree['info'] = self._loadPresetInfo(os.path.join(path, const.PREDEFINED_BOARD_SPEC_FILE))
_tree['info']['filename'] = os.path.basename(path)
+ _tree['info']['path'] = path
_tree['children'] = []
entries = set(os.listdir(path))
for entry in entries:
<file>images/folderopen.png</file>
<file>images/appicon.png</file>
<file>images/logo.png</file>
+ <file>images/default_dir_icon.png</file>
+ <file>images/default_project_icon.png</file>
</qresource>
</RCC>
PREDEFINED_BOARDS_DIR = 'predefined_boards'
PREDEFINED_BOARD_SPEC_FILE = '.spec'
+PREDEFINED_BOARD_ICON_FILE = '.icon.png'
+
+# Predefined icons in resouces
+PREDEFINED_BOARD_DEFAULT_DIR_ICON = ':images/default_dir_icon.png'
+PREDEFINED_BOARD_DEFAULT_PROJECT_ICON = ':images/default_project_icon.png'
# PREDEFINED_BOARD_SPEC_INFO = {
# 'name': <name of the board/directory>,
# 'description': <description of the board/directory>,
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTreeWidget" name="boardTree">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</column>
</widget>
</item>
- <item>
- <widget class="QCheckBox" name="advancedCheckBox">
- <property name="text">
- <string>Advanced configuration</string>
- </property>
- </widget>
- </item>
</layout>
</item>
<item>
<item>
<widget class="QLabel" name="descriptionLabel">
<property name="text">
- <string>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim nisl, interdum ut venenatis in, suscipit in dolor. Integer a nisi sed libero ultrices commodo. Duis vitae nibh id arcu ullamcorper auctor non et metus. Cras ut justo ac dolor porttitor feugiat eget vitae velit. Fusce et rhoncus metus. Quisque vel mauris et augue elementum volutpat. Phasellus dolor dui, ultricies sit amet dictum ut, commodo et lacus. Proin eu ullamcorper purus. Aliquam in risus in lorem tempor condimentum ac quis erat. Mauris semper dui a urna facilisis vitae porttitor urna dictum. Nunc metus leo, iaculis non dignissim at, mollis at.</string>
+ <string><a href='http://duplo.develer.com'>duplo's blog</a>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus enim nisl, interdum ut venenatis in, suscipit in dolor. Integer a nisi sed libero ultrices commodo. Duis vitae nibh id arcu ullamcorper auctor non et metus. Cras ut justo ac dolor porttitor feugiat eget vitae velit. Fusce et rhoncus metus. Quisque vel mauris et augue elementum volutpat. Phasellus dolor dui, ultricies sit amet dictum ut, commodo et lacus. Proin eu ullamcorper purus. Aliquam in risus in lorem tempor condimentum ac quis erat. Mauris semper dui a urna facilisis vitae porttitor urna dictum. Nunc metus leo, iaculis non dignissim at, mollis at.</string>
</property>
<property name="wordWrap">
<bool>true</bool>