def widgetFactory(self): item, _, current, t = self.getCurrent() t = getItemType(item) if t == StyleTypes.COLOR: w = QtGui.QToolButton(self) w.setStyleSheet('background-color:%s'%current) w.clicked.connect(self.editColor) return w elif t == StyleTypes.BOOL: w = QtGui.QCheckBox(self) w.setChecked(getBool(current)) w.stateChanged.connect(self.acceptCheckboxUpdate) return w elif t == StyleTypes.FONT: w = QtGui.QPushButton(current, self) w.clicked.connect(self.editFont) return w elif t in [StyleTypes.LINESTYLE, StyleTypes.HALIGN, StyleTypes.VALIGN]: w = QtGui.QComboBox(self) opts = {StyleTypes.LINESTYLE:Style.linestyles.keys(), StyleTypes.HALIGN:Style.halignopts.keys(), StyleTypes.VALIGN:Style.valignopts.keys()}[t] w.addItems(opts) if current: w.setCurrentIndex(opts.index(current)) w.currentIndexChanged.connect(self.acceptComboUpdate) return w elif t in [StyleTypes.FLOAT, StyleTypes.ARROW, StyleTypes.XYCOOD]: default = {StyleTypes.FLOAT:'0.0', StyleTypes.ARROW:'[[0,0]]', StyleTypes.XYCOOD:'[0.0, 0.0]'}[t] current = current if current else default w = QtGui.QLineEdit(current, self) w.editingFinished.connect(self.acceptLineEditUpdate) return w elif t == StyleTypes.ICON: names = Controller.get().getIconNames() names = names + [NO_ICON] frame = QtGui.QWidget(self) w = QtGui.QComboBox(frame) w.addItems(names) if current: w.setCurrentIndex(names.index(current)) w.currentIndexChanged.connect(self.acceptComboUpdate) b = QtGui.QPushButton('Add Icon', frame) b.clicked.connect(self.onAddIcon) layout = QtGui.QVBoxLayout(frame) layout.addWidget(w) layout.addWidget(b) frame.combo = w frame.currentText = w.currentText return frame else: raise RuntimeError("Unsupported style item")
def getCurrent(self): item = str(self.ui.cmbDetails.currentText()) t = getItemType(item) full_role = self.stylable.full_role if self.stylable.role else self.stylable.stereotype role = {self.Level.Global:'', self.Level.Stereotype:self.stylable.stereotype, self.Level.Role:full_role}[self.getLevel()] current = self.stylesheet.findItem(role, item) return item, role, current, t