X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=wizard%2FBBoardPage.py;h=843562a7b72b139da864adea6c417f3767b77c5d;hb=2654dc2eff8a397ed1dd21d0f073bae553acbb61;hp=0877ea50194bc372c667974bc9df5d01ba37abce;hpb=afbcef7c7b408083dbcd77bc4697513dc10ea58d;p=bertos.git diff --git a/wizard/BBoardPage.py b/wizard/BBoardPage.py index 0877ea50..843562a7 100644 --- a/wizard/BBoardPage.py +++ b/wizard/BBoardPage.py @@ -41,12 +41,10 @@ from PyQt4.QtGui import * from BWizardPage import BWizardPage from BCpuPage import BCpuPage -from BOutputPage import BOutputPage -from BRoutePage import BRoutePage import const import qvariant_converter -from bertos_utils import presetList +from bertos_utils import presetList, _cmp class BBoardPage(BWizardPage): """ @@ -56,7 +54,7 @@ class BBoardPage(BWizardPage): def __init__(self): BWizardPage.__init__(self, const.UI_LOCATION + "/board_select.ui") - self.setTitle(self.tr("Select the board from the predefined ones")) + self.setTitle(self.tr("Select your development board")) ## Overloaded QWizardPage methods ## @@ -69,10 +67,19 @@ class BBoardPage(BWizardPage): preset_path = qvariant_converter.getStringDict(preset_path["info"]) preset_path = preset_path["path"] self.setProjectInfo("PROJECT_BOARD", preset_path) + self.setProjectInfo("PROJECT_FROM_PRESET", True) + self.setProjectInfo("PRESET_LOADED", False) return True else: return False + def nextId(self): + wizard = self.wizard() + if not self.projectInfo("PROJECT_FROM_PRESET"): + return wizard.pageIndex(BCpuPage) + else: + return QWizardPage.nextId(self) + #### ## Overloaded BWizardPage methods ## @@ -87,17 +94,17 @@ class BBoardPage(BWizardPage): """ Overload of the BWizardPage connectSignals method. """ - self.connect(self.pageContent.boardList, SIGNAL("itemSelectionChanged()"), self.updateUi) - self.connect(self.pageContent.boardList, SIGNAL("itemSelectionChanged()"), self, SIGNAL("completeChanged()")) + self.connect(self.pageContent.boardList, SIGNAL("currentItemChanged(QListWidgetItem*,QListWidgetItem*)"), self.updateUi) + self.connect(self.pageContent.boardList, SIGNAL("currentItemChanged(QListWidgetItem*,QListWidgetItem*)"), self, SIGNAL("completeChanged()")) + self.connect(self.pageContent.customButton, SIGNAL("clicked()"), self.customButtonClicked) - def reloadData(self): + def reloadData(self, previous_id=None): """ Overload of the BWizardPage reloadData method. """ + self.project.loadProjectPresets() preset_list = self.projectInfo("PRESET_TREE") preset_list = preset_list["children"] - def _cmp(x, y): - return cmp(x["info"].get('ord', 0), y["info"].get('ord', 0)) preset_list = sorted(preset_list.values(), _cmp) self.setItems(preset_list) @@ -110,11 +117,13 @@ 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 not os.path.exists(image): - image = ":/images/default_board_image.png" - self.pageContent.descriptionLabel.setText(description) - self.pageContent.imageLabel.setPixmap(QPixmap(image)) + 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) + self.wizard().next() #### @@ -125,7 +134,7 @@ class BBoardPage(BWizardPage): item_name = item_data["info"].get("name", item_data["info"]["filename"]) item_icon = os.path.join(item_data["info"]["path"], const.PREDEFINED_BOARD_ICON_FILE) if not os.path.exists(item_icon): - item_icon = ":/images/default_board_icon.png" + item_icon = const.PREDEFINED_BOARD_DEFAULT_ICON item = QListWidgetItem(QIcon(item_icon), item_name) item.setData(Qt.UserRole, qvariant_converter.convertDict(item_data)) self.pageContent.boardList.addItem(item) @@ -134,4 +143,4 @@ class BBoardPage(BWizardPage): @property def selected(self): - return self.pageContent.boardList.currentItem() \ No newline at end of file + return self.pageContent.boardList.currentItem()