def Symbols(self): """ Load symbols settings from config file """ # Loading symbols conf basegroup = "Symbol.settings" c = ConfDB() c.beginGroup(basegroup) childGroups = c.childGroups() c.endGroup() loaded_symbols = [] for id in childGroups: cgroup = basegroup + '/' + id name = str(c.get(cgroup + "/name", 'default')) type = str(c.get(cgroup + "/type", 'DecorativeNode')) object = DecorativeNode for (object_class, type_name) in SYMBOL_TYPES.iteritems(): if type_name == type: object = object_class break normal_svg_file = str( c.get(cgroup + "/normal_svg_file", ':/icons/default.svg')) selected_svg_file = str( c.get(cgroup + "/selected_svg_file", ':/icons/default.svg')) SYMBOLS.append({ 'name': name, 'object': object, 'normal_svg_file': normal_svg_file, 'select_svg_file': selected_svg_file, 'translated': False })
def Symbols(self): """ Load symbols settings from config file """ # Loading symbols conf basegroup = "Symbol.settings" c = ConfDB() c.beginGroup(basegroup) childGroups = c.childGroups() c.endGroup() loaded_symbols = [] for id in childGroups: cgroup = basegroup + '/' + id name = str(c.get(cgroup + "/name", 'default')) type = str(c.get(cgroup + "/type", 'DecorativeNode')) object = DecorativeNode for (object_class, type_name) in SYMBOL_TYPES.iteritems(): if type_name == type: object = object_class break normal_svg_file = str(c.get(cgroup + "/normal_svg_file", ':/icons/default.svg')) selected_svg_file = str(c.get(cgroup + "/selected_svg_file", ':/icons/default.svg')) SYMBOLS.append( {'name': name, 'object': object, 'normal_svg_file': normal_svg_file, 'select_svg_file': selected_svg_file, 'translated': False})
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setupUi(self) # connections to slots self.connect(self.pushButtonAdd, QtCore.SIGNAL('clicked()'), self.slotAdd) self.connect(self.pushButtonRemove, QtCore.SIGNAL('clicked()'), self.slotRemove) self.connect(self.pushButtonApply, QtCore.SIGNAL('clicked()'), self.slotApply) self.connect(self.pushButtonAddLibrary, QtCore.SIGNAL('clicked()'), self.slotAddLibrary) self.connect(self.pushButtonRemoveLibrary, QtCore.SIGNAL('clicked()'), self.slotRemoveLibrary) self.connect(self.toolButtonLibrary, QtCore.SIGNAL('clicked()'), self.slotCallLibraryBrowser) self.connect(self.treeWidgetNodes, QtCore.SIGNAL('itemSelectionChanged()'), self.slotNodeSelectionChanged) self.connect(self.treeWidgetSymbols, QtCore.SIGNAL('itemSelectionChanged()'), self.slotSymbolSelectionChanged) self.connect(self.treeWidgetNodes, QtCore.SIGNAL('itemActivated(QTreeWidgetItem *, int)'), self.slotNodeSelected) self.connect(self.treeWidgetSymbols, QtCore.SIGNAL('itemActivated(QTreeWidgetItem *, int)'), self.slotLibrarySelected) # populate node type list for type in SYMBOL_TYPES.values(): self.comboBoxNodeType.addItem(translate("nodesDock", type)) # load current nodes self.treeWidgetNodes.clear() for symbol in SYMBOLS: if not symbol['translated']: item = QtGui.QTreeWidgetItem(self.treeWidgetNodes) item.setText(0, symbol['name']) item.setIcon(0, QtGui.QIcon(symbol['normal_svg_file'])) item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(translate("nodesDock", SYMBOL_TYPES[symbol['object']]))) # load built-in symbols self.treeWidgetSymbols.clear() internal_symbols = QtGui.QTreeWidgetItem() internal_symbols.setText(0, 'Built-in symbols') internal_symbols.setIcon(0, QtGui.QIcon(':/icons/package.svg')) internal_symbols.setFlags(QtCore.Qt.ItemIsEnabled) self.treeWidgetSymbols.addTopLevelItem(internal_symbols) self.treeWidgetSymbols.expandItem(internal_symbols) symbol_resources = QtCore.QResource(":/symbols") for symbol in symbol_resources.children(): symbol = str(symbol) if symbol.endswith('.normal.svg'): name = symbol[:-11] item = QtGui.QTreeWidgetItem(internal_symbols) item.setText(0, name) item.setIcon(0, QtGui.QIcon(':/symbols/' + symbol)) item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(':/symbols/' + symbol)) # load libraries for (library_name, conf) in globals.GApp.libraries.iteritems(): self.addLibrarySymbols(library_name, conf.path) self.pushButtonAdd.setEnabled(False) self.pushButtonRemove.setEnabled(False)
def slotApply(self): """ Apply settings for a node """ current = self.treeWidgetNodes.currentItem() if current and self.lineEditNodeName.text(): name = unicode(self.lineEditNodeName.text()) type = unicode(self.comboBoxNodeType.currentText()) for symbol in SYMBOLS: if symbol['name'] == unicode(current.text(0)): symbol['name'] = name for (object, type_name) in SYMBOL_TYPES.iteritems(): if translate("nodesDock", type_name) == type: symbol['object'] = object break break current.setText(0, name) current.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(type))