From: duplo Date: Mon, 19 Apr 2010 15:50:12 +0000 (+0000) Subject: Add icons to the Board page. X-Git-Tag: 2.5.0~445 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=05a69da42b847bac920791a54264bac179ae65ae;p=bertos.git Add icons to the Board page. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3463 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/wizard/BBoardPage.py b/wizard/BBoardPage.py index 2bf90ff3..4553da77 100644 --- a/wizard/BBoardPage.py +++ b/wizard/BBoardPage.py @@ -33,6 +33,8 @@ # Author: Lorenzo Berni # +import os + from PyQt4.QtCore import * from PyQt4.QtGui import * @@ -101,6 +103,7 @@ class BBoardPage(BWizardPage): #### def _fillPresetTree(self): + self.pageContent.boardTree.clear() self.project.loadProjectPresets() preset_tree = self.project.info("PRESET_TREE") for obj in preset_tree['children']: @@ -109,6 +112,16 @@ class BBoardPage(BWizardPage): 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 diff --git a/wizard/BProject.py b/wizard/BProject.py index 81f2de6c..36623e3a 100644 --- a/wizard/BProject.py +++ b/wizard/BProject.py @@ -131,6 +131,7 @@ class BProject(object): _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: diff --git a/wizard/bertos.qrc b/wizard/bertos.qrc index c1aba5c1..34f8ccc5 100644 --- a/wizard/bertos.qrc +++ b/wizard/bertos.qrc @@ -10,5 +10,7 @@ images/folderopen.png images/appicon.png images/logo.png + images/default_dir_icon.png + images/default_project_icon.png diff --git a/wizard/const.py b/wizard/const.py index 1bd69e8f..b937ddae 100644 --- a/wizard/const.py +++ b/wizard/const.py @@ -43,6 +43,11 @@ del _tmp 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': , # 'description': , diff --git a/wizard/images/default_dir_icon.png b/wizard/images/default_dir_icon.png new file mode 100755 index 00000000..56c63edc Binary files /dev/null and b/wizard/images/default_dir_icon.png differ diff --git a/wizard/images/default_project_icon.png b/wizard/images/default_project_icon.png new file mode 100755 index 00000000..c6781c6b Binary files /dev/null and b/wizard/images/default_project_icon.png differ diff --git a/wizard/ui/board_select.ui b/wizard/ui/board_select.ui index f610d358..694db514 100644 --- a/wizard/ui/board_select.ui +++ b/wizard/ui/board_select.ui @@ -18,6 +18,12 @@ + + + 0 + 0 + + false @@ -31,13 +37,6 @@ - - - - Advanced configuration - - - @@ -45,7 +44,7 @@ - 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. + <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. true