def showMenu(self, point): """ Displays the menu for this filter widget. """ menu = QMenu(self) acts = {} acts['edit'] = menu.addAction('Edit quick filter...') trigger = menu.exec_(self.mapToGlobal(point)) if trigger == acts['edit']: text, accepted = XTextEdit.getText(self.window(), 'Edit Format', 'Format:', self.filterFormat(), wrapped=False) if accepted: self.setFilterFormat(text)
def showMenu(self, point): """ Displays the menu for this filter widget. """ menu = QMenu(self) acts = {} acts['edit'] = menu.addAction('Edit quick filter...') trigger = menu.exec_(self.mapToGlobal(point)) if trigger == acts['edit']: text, accepted = XTextEdit.getText(self.window(), 'Edit Format', 'Format:', self.filterFormat(), wrapped=False) if accepted: self.setFilterFormat(text)
def __init__(self, scaffold, parent=None): super(XScaffoldPropertiesPage, self).__init__(parent) # setup the scaffolding options self._scaffold = scaffold self.setTitle('Properties') self.setSubTitle('Setup scaffold properties') if scaffold.uifile(): projexui.loadUi(__file__, self, scaffold.uifile()) else: layout = QtGui.QFormLayout() for prop in scaffold.properties(): # define the text text = prop.label if prop.required: text += '*' text += ':' # create a checkbox if prop.type == 'bool': widget = QtGui.QCheckBox(self) widget.setProperty('propertyName', wrapVariant(prop.name)) widget.setText(text.strip(':')) layout.addRow(None, widget) # create a float elif prop.type == 'int': lbl = QtGui.QLabel(text, self) widget = QtGui.QSpinBox(self) widget.setProperty('propertyName', wrapVariant(prop.name)) layout.addRow(lbl, widget) # create a double elif prop.type == 'float': lbl = QtGui.QLabel(text, self) widget = QtGui.QDoubleSpinBox(self) widget.setProperty('propertyName', wrapVariant(prop.name)) layout.addRow(lbl, widget) # create a text edit elif prop.type == 'text': lbl = QtGui.QLabel(text, self) widget = XTextEdit(self) widget.setProperty('propertyName', wrapVariant(prop.name)) layout.addRow(lbl, widget) # create a filepath elif prop.type == 'file': lbl = QtGui.QLabel(text, self) widget = XFilepathEdit(self) # create an icon elif prop.type == 'icon': widget = XIconButton(self) layout.addRow(lbl, widget) # create a line edit else: lbl = QtGui.QLabel(text, self) if prop.choices: widget = XComboBox(self) widget.setProperty('dataType', 'string') widget.addItems([''] + prop.choices) else: widget = XLineEdit(self) if prop.regex: regexp = QtCore.QRegExp(prop.regex) validator = QtGui.QRegExpValidator(regexp, widget) widget.setValidator(validator) widget.setProperty('propertyName', wrapVariant(prop.name)) layout.addRow(lbl, widget) self.setLayout(layout) for prop, widget in self.propertyWidgetMap().items(): if prop.default is not None: try: widget.setHint(prop.default) except AttributeError: projexui.setWidgetValue(widget, prop.default)
def __init__(self, scaffold, parent=None): super(XScaffoldPropertiesPage, self).__init__(parent) # setup the scaffolding options self._scaffold = scaffold self.setTitle('Properties') self.setSubTitle('Setup scaffold properties') if scaffold.uifile(): projexui.loadUi(__file__, self, scaffold.uifile()) else: layout = QtGui.QFormLayout() for prop in scaffold.properties(): # define the text text = prop.label if prop.required: text += '*' text += ':' # create a checkbox if prop.type == 'bool': widget = QtGui.QCheckBox(self) widget.setProperty('propertyName', wrapVariant(prop.name)) widget.setText(text.strip(':')) layout.addRow(None, widget) # create a float elif prop.type == 'int': lbl = QtGui.QLabel(text, self) widget = QtGui.QSpinBox(self) widget.setProperty('propertyName', wrapVariant(prop.name)) layout.addRow(lbl, widget) # create a double elif prop.type == 'float': lbl = QtGui.QLabel(text, self) widget = QtGui.QDoubleSpinBox(self) widget.setProperty('propertyName', wrapVariant(prop.name)) layout.addRow(lbl, widget) # create a text edit elif prop.type == 'text': lbl = QtGui.QLabel(text, self) widget = XTextEdit(self) widget.setProperty('propertyName', wrapVariant(prop.name)) layout.addRow(lbl, widget) # create a filepath elif prop.type == 'file': lbl = QtGui.QLabel(text, self) widget = XFilepathEdit(self) # create an icon elif prop.type == 'icon': widget = XIconButton(self) layout.addRow(lbl, widget) # create a line edit else: lbl = QtGui.QLabel(text, self) if prop.choices: widget = XComboBox(self) widget.setProperty('dataType', 'string') widget.addItems([''] + prop.choices) else: widget = XLineEdit(self) if prop.regex: regexp = QtCore.QRegExp(prop.regex) validator = QtGui.QRegExpValidator(regexp, widget) widget.setValidator(validator) widget.setProperty('propertyName', wrapVariant(prop.name)) layout.addRow(lbl, widget) self.setLayout(layout) for prop, widget in self.propertyWidgetMap().items(): if prop.default is not None: try: widget.setHint(prop.default) except AttributeError: projexui.setWidgetValue(widget, prop.default)