from PyQt4.QtGui import *
import PyQt4.uic as uic
-class BStartPage(QWidget):
+class BStartPage(QDialog):
def __init__(self):
QDialog.__init__(self)
#
from BWizardPage import *
+import BToolchainSearch
import bertos_utils
class BToolchainPage(BWizardPage):
def __init__(self):
BWizardPage.__init__(self, "toolchain_select.ui")
self.setTitle(self.tr("Select toolchain"))
- self._setupUi()
self._populateToolchainList()
- self._populateDirList()
self._connectSignals()
- def _setupUi(self):
- path = self._settingsRetrieve("path_search").toBool()
- if not path is None:
- self.pageContent.pathBox.setChecked(path)
- else:
- self.pageContent.pathBox.setChecked(False)
- customPath = self._settingsRetrieve("custom_dir").toBool()
- if not customPath is None:
- self.pageContent.customDirBox.setChecked(customPath)
- else:
- self.pageContent.customDirBox.setChecked(False)
- self._updateUi()
-
def _updateUi(self):
if self.pageContent.customDirBox.isChecked():
self._enableCustomDir()
item = QListWidgetItem(element.toString())
item.setData(Qt.UserRole, element)
self.pageContent.toolchainList.addItem(item)
-
- def _populateDirList(self):
- search_dir_list = self._settingsRetrieve("search_dir_list").toList()
- for element in search_dir_list:
- item = QListWidgetItem(element.toString())
- item.setData(Qt.UserRole, element)
- self.pageContent.customDirList.addItem(item)
-
- def _disableCustomDir(self):
- self.pageContent.customDirList.setEnabled(False)
- self.pageContent.addDirButton.setEnabled(False)
- self.pageContent.removeDirButton.setEnabled(False)
-
- def _enableCustomDir(self):
- self.pageContent.customDirList.setEnabled(True)
- self.pageContent.addDirButton.setEnabled(True)
- self.pageContent.removeDirButton.setEnabled(True)
-
+
def _clearList(self):
self.pageContent.toolchainList.clear()
def _selectionChanged(self):
self.emit(SIGNAL("completeChanged()"))
+ def _search(self):
+ pass
+
+
def _connectSignals(self):
- self.connect(self.pageContent.pathBox, SIGNAL("clicked()"), self._updateUi)
- self.connect(self.pageContent.customDirBox, SIGNAL("clicked()"), self._updateUi)
- self.connect(self.pageContent.searchButton, SIGNAL("clicked()"), self.toSearchSubpage)
- self.connect(self.pageContent.cancelButton, SIGNAL("clicked()"), self.toSelectionSubpage)
- self.connect(self.pageContent.doSearchButton, SIGNAL("clicked()"), self.doSearch)
- self.connect(self.pageContent.addDirButton, SIGNAL("clicked()"), self.addDir)
- self.connect(self.pageContent.removeDirButton, SIGNAL("clicked()"), self.removeDir)
self.connect(self.pageContent.toolchainList, SIGNAL("itemSelectionChanged()"), self._selectionChanged)
self.connect(self.pageContent.addButton, SIGNAL("clicked()"), self.addToolchain)
self.connect(self.pageContent.removeButton, SIGNAL("clicked()"), self.removeToolchain)
-
- def toSearchSubpage(self):
- self.pageContent.pageSelector.setCurrentIndex(1)
-
- def toSelectionSubpage(self):
- self.pageContent.pageSelector.setCurrentIndex(0)
-
- def doSearch(self):
- path = []
- if self.pageContent.pathBox.isChecked():
- path += bertos_utils.getSystemPath()
- if self.pageContent.customDirBox.isChecked():
- for element in range(self.pageContent.customDirList.count()):
- path += [unicode(self.pageContent.customDirList.item(element).data(Qt.UserRole).toString())]
- toolchains = bertos_utils.findToolchains(path)
- toolchains_stored = self._settingsRetrieve("toolchains").toList()
- toolchains += [unicode(toolchain.toString()) for toolchain in toolchains_stored]
- toolchains = set(toolchains)
- toolchains = list(toolchains)
- self._clearList()
- for toolchain in toolchains:
- item = QListWidgetItem(toolchain)
- item.setData(Qt.UserRole, QVariant(toolchain))
- self.pageContent.toolchainList.addItem(item)
- self._settingsStore("toolchains", toolchains)
- self.toSelectionSubpage()
+ self.connect(self.pageContent.searchButton, SIGNAL("clicked()"), self.searchToolchain)
def addToolchain(self):
sel_toolchain = QFileDialog.getOpenFileName(self, self.tr("Choose the toolchain"), "")
toolchains.remove(unicode(item))
self._settingsStore("toolchains", toolchains)
- def addDir(self):
- directory = QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly)
- if not directory.isEmpty():
- item = QListWidgetItem(directory)
- item.setData(Qt.UserRole, QVariant(directory))
- self.pageContent.customDirList.addItem(item)
- search_dir_list = self._settingsRetrieve("search_dir_list").toList()
- search_dir_list = set([d.toString() for d in search_dir_list] + [directory])
- self._settingsStore("search_dir_list", list(search_dir_list))
-
- def removeDir(self):
- if self.pageContent.customDirList.currentRow() != -1:
- item = self.pageContent.customDirList.takeItem(self.pageContent.customDirList.currentRow())
- search_dir_list = self._settingsRetrieve("search_dir_list").toList()
- search_dir_list = set([d.toString() for d in search_dir_list])
- search_dir_list.remove(item.data(Qt.UserRole).toString())
- self._settingsStore("search_dir_list", list(search_dir_list))
+ def searchToolchain(self):
+ search = BToolchainSearch.BToolchainSearch()
+ self.connect(search, SIGNAL("accepted()"), self._search)
+ search.exec_()
def isComplete(self):
if self.pageContent.toolchainList.currentRow() != -1:
--- /dev/null
+#!/usr/bin/env python
+# encoding: utf-8
+#
+# Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# $Id:$
+#
+# Author: Lorenzo Berni <duplo@develer.com>
+#
+
+from PyQt4.QtCore import *
+from PyQt4.QtGui import *
+import PyQt4.uic as uic
+
+class BToolchainSearch(QDialog):
+
+ def __init__(self):
+ QDialog.__init__(self)
+ self._setupUi()
+ self._connectSignals()
+ self.setWindowTitle(self.tr("Toolchain search page"))
+
+ def _setupUi(self):
+ self.content = uic.loadUi("toolchain_search.ui", None)
+ layout = QVBoxLayout()
+ layout.addWidget(self.content)
+ self.setLayout(layout)
+ self._populateDirList()
+ self._setPathSearch()
+ self._setSearchButton()
+
+ def _connectSignals(self):
+ self.connect(self.content.pathBox, SIGNAL("stateChanged(int)"), self._stateChanged)
+ self.connect(self.content.addButton, SIGNAL("clicked()"), self._addDir)
+ self.connect(self.content.removeButton, SIGNAL("clicked()"), self._removeDir)
+ self.connect(self.content.cancelButton, SIGNAL("clicked()"), self.reject)
+ self.connect(self.content.searchButton, SIGNAL("clicked()"), self.accept)
+
+ def _setSearchButton(self):
+ self.content.searchButton.setDefault(True)
+ self.content.searchButton.setEnabled(self.content.pathBox.isChecked() or self.content.customDirList.count() != 0)
+
+ def _populateDirList(self):
+ search_dir_list = QApplication.instance().settings.value(QString("search_dir_list")).toList()
+ for element in search_dir_list:
+ item = QListWidgetItem(unicode(element.toString()))
+ self.content.customDirList.addItem(item)
+
+ def _setPathSearch(self):
+ pathSearch = QApplication.instance().settings.value(QString("path_search")).toBool()
+ self.content.pathBox.setChecked(pathSearch)
+
+ def _stateChanged(self, state):
+ QApplication.instance().settings.setValue(QString("path_search"), QVariant(state != 0))
+ self._setSearchButton()
+
+ def _addDir(self):
+ directory = QFileDialog.getExistingDirectory(self, self.tr("Open Directory"), "", QFileDialog.ShowDirsOnly)
+ if not directory.isEmpty():
+ item = QListWidgetItem(directory)
+ self.content.customDirList.addItem(item)
+ search_dir_list = QApplication.instance().settings.value(QString("search_dir_list")).toList()
+ search_dir_list = set([d.toString() for d in search_dir_list] + [directory])
+ QApplication.instance().settings.setValue(QString("search_dir_list"), QVariant(list(search_dir_list)))
+ self._setSearchButton()
+
+ def _removeDir(self):
+ if self.content.customDirList.currentRow() != -1:
+ item = self.content.customDirList.takeItem(self.content.customDirList.currentRow())
+ search_dir_list = QApplication.instance().settings.value(QString("search_dir_list")).toList()
+ search_dir_list = set([d.toString() for d in search_dir_list])
+ search_dir_list.remove(item.text())
+ QApplication.instance().settings.setValue(QString("search_dir_list"), QVariant(list(search_dir_list)))
+ self._setSearchButton()
+
\ No newline at end of file
--- /dev/null
+<ui version="4.0" >
+ <class>Form</class>
+ <widget class="QWidget" name="Form" >
+ <property name="geometry" >
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>350</width>
+ <height>290</height>
+ </rect>
+ </property>
+ <property name="windowTitle" >
+ <string>Form</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2" >
+ <item>
+ <widget class="QCheckBox" name="pathBox" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text" >
+ <string>Search in PATH</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox" >
+ <property name="title" >
+ <string>Custom directories</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QListWidget" name="customDirList" />
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QToolButton" name="addButton" >
+ <property name="minimumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="bertos.qrc" >
+ <normaloff>:/images/listadd.png</normaloff>:/images/listadd.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="removeButton" >
+ <property name="minimumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="bertos.qrc" >
+ <normaloff>:/images/listremove.png</normaloff>:/images/listremove.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2" >
+ <item>
+ <spacer name="horizontalSpacer_2" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton" >
+ <property name="text" >
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="searchButton" >
+ <property name="text" >
+ <string>Search</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources>
+ <include location="bertos.qrc" />
+ </resources>
+ <connections/>
+</ui>
<rect>
<x>0</x>
<y>0</y>
- <width>428</width>
- <height>369</height>
+ <width>321</width>
+ <height>298</height>
</rect>
</property>
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
<property name="windowTitle" >
<string>Form</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_5" >
+ <layout class="QVBoxLayout" name="verticalLayout" >
+ <item>
+ <widget class="QListWidget" name="toolchainList" />
+ </item>
<item>
- <widget class="QStackedWidget" name="pageSelector" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="currentIndex" >
- <number>0</number>
- </property>
- <widget class="QWidget" name="page" >
- <layout class="QVBoxLayout" name="verticalLayout_6" >
- <item>
- <widget class="QListWidget" name="toolchainList" />
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout" >
- <item>
- <widget class="QToolButton" name="addButton" >
- <property name="minimumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="maximumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset resource="bertos.qrc" >
- <normaloff>:/images/listadd.png</normaloff>:/images/listadd.png</iconset>
- </property>
- <property name="iconSize" >
- <size>
- <width>16</width>
- <height>16</height>
- </size>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="removeButton" >
- <property name="minimumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="maximumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset resource="bertos.qrc" >
- <normaloff>:/images/listremove.png</normaloff>:/images/listremove.png</iconset>
- </property>
- <property name="iconSize" >
- <size>
- <width>16</width>
- <height>16</height>
- </size>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="checkButton" >
- <property name="minimumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="maximumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset resource="bertos.qrc" >
- <normaloff>:/images/ok.png</normaloff>:/images/ok.png</iconset>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QToolButton" name="searchButton" >
- <property name="minimumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="maximumSize" >
- <size>
- <width>16777215</width>
- <height>26</height>
- </size>
- </property>
- <property name="text" >
- <string>Search</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- <widget class="QWidget" name="page_2" >
- <layout class="QVBoxLayout" name="verticalLayout_2" >
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_5" >
- <item>
- <layout class="QVBoxLayout" name="verticalLayout" >
- <item>
- <widget class="QCheckBox" name="pathBox" >
- <property name="sizePolicy" >
- <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text" >
- <string>Search in PATH</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QCheckBox" name="customDirBox" >
- <property name="text" >
- <string>Search in custom directories</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_4" >
- <item>
- <spacer name="horizontalSpacer_4" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QToolButton" name="cancelButton" >
- <property name="minimumSize" >
- <size>
- <width>0</width>
- <height>26</height>
- </size>
- </property>
- <property name="maximumSize" >
- <size>
- <width>16777215</width>
- <height>26</height>
- </size>
- </property>
- <property name="text" >
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="doSearchButton" >
- <property name="minimumSize" >
- <size>
- <width>0</width>
- <height>26</height>
- </size>
- </property>
- <property name="maximumSize" >
- <size>
- <width>16777215</width>
- <height>26</height>
- </size>
- </property>
- <property name="text" >
- <string>Search</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3" >
- <item>
- <spacer name="horizontalSpacer_3" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QGroupBox" name="groupBox" >
- <property name="title" >
- <string/>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout_4" >
- <item>
- <layout class="QVBoxLayout" name="verticalLayout_3" >
- <item>
- <widget class="QListWidget" name="customDirList" />
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2" >
- <item>
- <widget class="QToolButton" name="addDirButton" >
- <property name="minimumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="maximumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset resource="bertos.qrc" >
- <normaloff>:/images/listadd.png</normaloff>:/images/listadd.png</iconset>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="removeDirButton" >
- <property name="minimumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="maximumSize" >
- <size>
- <width>26</width>
- <height>26</height>
- </size>
- </property>
- <property name="text" >
- <string/>
- </property>
- <property name="icon" >
- <iconset resource="bertos.qrc" >
- <normaloff>:/images/listremove.png</normaloff>:/images/listremove.png</iconset>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_2" >
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0" >
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </item>
- </layout>
- </item>
- </layout>
- </widget>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout" >
+ <item>
+ <widget class="QToolButton" name="addButton" >
+ <property name="minimumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="bertos.qrc" >
+ <normaloff>:/images/listadd.png</normaloff>:/images/listadd.png</iconset>
+ </property>
+ <property name="iconSize" >
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="removeButton" >
+ <property name="minimumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="bertos.qrc" >
+ <normaloff>:/images/listremove.png</normaloff>:/images/listremove.png</iconset>
+ </property>
+ <property name="iconSize" >
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="checkButton" >
+ <property name="minimumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string/>
+ </property>
+ <property name="icon" >
+ <iconset resource="bertos.qrc" >
+ <normaloff>:/images/ok.png</normaloff>:/images/ok.png</iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer" >
+ <property name="orientation" >
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0" >
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="searchButton" >
+ <property name="minimumSize" >
+ <size>
+ <width>26</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="maximumSize" >
+ <size>
+ <width>16777215</width>
+ <height>26</height>
+ </size>
+ </property>
+ <property name="text" >
+ <string>Search</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>