def __init__(self, *args): QtWidgets.QLineEdit.__init__(self, *args) icon = studiolibrary.resource.icon("search.svg") self._iconButton = QtWidgets.QPushButton(self) self._iconButton.setObjectName("icon") self._iconButton.clicked.connect(self._iconClicked) self._iconButton.setIcon(icon) self._iconButton.setStyleSheet( "QPushButton{background-color: transparent;}") icon = studiolibrary.resource.icon("times.svg") self._clearButton = QtWidgets.QPushButton(self) self._clearButton.setObjectName("clear") self._clearButton.setCursor(QtCore.Qt.ArrowCursor) self._clearButton.setIcon(icon) self._clearButton.setToolTip("Clear all search text") self._clearButton.clicked.connect(self._clearClicked) self._clearButton.setStyleSheet( "QPushButton{background-color: transparent;}") self.textChanged.connect(self._textChanged) color = studioqt.Color.fromString("rgb(250,250,250,115)") self.setIconColor(color) self.update()
def reload(self): """ :rtype: None """ self.clear() if self._enableSelectContent: action = selectContentAction(item=self.item(), parent=self) self.addAction(action) self.addSeparator() selectionSets = self.selectionSets() if selectionSets: for selectionSet in selectionSets: dirname = os.path.basename(os.path.dirname( selectionSet.path())) basename = os.path.basename(selectionSet.path()) basename = basename.replace(selectionSet.EXTENSION, "") nicename = dirname + ": " + basename action = QtWidgets.QAction(nicename, self) callback = partial(selectionSet.load, namespaces=self.namespaces()) action.triggered.connect(callback) self.addAction(action) else: action = QtWidgets.QAction("No selection sets found!", self) action.setEnabled(False) self.addAction(action)
def __init__(self, *args, **kwargs): super(ButtonGroupFieldWidget, self).__init__(*args, **kwargs) self._value = "" self._buttons = {} items = self.data().get('items') widget = QtWidgets.QFrame() layout = QtWidgets.QHBoxLayout(widget) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) widget.setLayout(layout) i = 0 for item in items: i += 1 button = QtWidgets.QPushButton(item, self) button.setCheckable(True) callback = functools.partial(self.setValue, item) button.clicked.connect(callback) self._buttons[item] = button if i == 1: button.setProperty('first', True) if i == len(items): button.setProperty('last', True) widget.layout().addWidget(button) self.setWidget(widget)
def createWidget(self, menu): """ This method is called by the QWidgetAction base class. :type menu: QtWidgets.QMenu """ widget = QtWidgets.QFrame(self.parent()) widget.setObjectName("filterByAction") title = self._name # Using a checkbox so that the text aligns with the other actions label = QtWidgets.QCheckBox(widget) label.setText(title) label.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents) label.toggled.connect(self._triggered) label.setStyleSheet(""" #QCheckBox::indicator:checked { image: url(none.png) } QCheckBox::indicator:unchecked { image: url(none.png) } """) actionLayout = QtWidgets.QHBoxLayout(widget) actionLayout.setContentsMargins(0, 0, 0, 0) actionLayout.addWidget(label, stretch=1) widget.setLayout(actionLayout) return widget
def __init__(self, *args, **kwargs): """ Using a custom load widget to support nicer blending. """ super(PoseLoadWidget, self).__init__(*args, **kwargs) self.ui.blendFrame = QtWidgets.QFrame(self) layout = QtWidgets.QHBoxLayout(self) self.ui.blendFrame.setLayout(layout) self.ui.blendSlider = QtWidgets.QSlider(self) self.ui.blendSlider.setObjectName("blendSlider") self.ui.blendSlider.setMinimum(-30) self.ui.blendSlider.setMaximum(130) self.ui.blendSlider.setOrientation(QtCore.Qt.Horizontal) self.ui.blendSlider.sliderMoved.connect(self.sliderMoved) self.ui.blendSlider.sliderReleased.connect(self.sliderReleased) self.ui.blendEdit = QtWidgets.QLineEdit(self) self.ui.blendEdit.setObjectName("blendEdit") self.ui.blendEdit.setText("0") self.ui.blendEdit.editingFinished.connect(self._blendEditChanged) validator = QtGui.QIntValidator(-200, 200, self) self.ui.blendEdit.setValidator(validator) layout.addWidget(self.ui.blendSlider) layout.addWidget(self.ui.blendEdit) self.setCustomWidget(self.ui.blendFrame) self.item().sliderChanged.connect(self.setSliderValue)
def __init__(self, *args, **kwargs): super(FormWidget, self).__init__(*args, **kwargs) self._schema = [] self._widgets = [] self._validator = None layout = QtWidgets.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setLayout(layout) self._fieldsFrame = QtWidgets.QFrame(self) self._fieldsFrame.setObjectName("optionsFrame") layout = QtWidgets.QVBoxLayout(self._fieldsFrame) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self._fieldsFrame.setLayout(layout) self._titleWidget = QtWidgets.QPushButton(self) self._titleWidget.setCheckable(True) self._titleWidget.setObjectName("titleWidget") self._titleWidget.toggled.connect(self._titleClicked) self._titleWidget.hide() self.layout().addWidget(self._titleWidget) self.layout().addWidget(self._fieldsFrame)
def __init__(self, *args): QtWidgets.QToolButton.__init__(self, *args) self._imageSequence = ImageSequence("") self._imageSequence.frameChanged.connect(self._frameChanged) self._toolBar = QtWidgets.QToolBar(self) self._toolBar.setStyleSheet(STYLE) studioqt.fadeOut(self._toolBar, duration=0) spacer = QtWidgets.QWidget() spacer.setMaximumWidth(4) spacer.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred ) self._toolBar.addWidget(spacer) spacer = QtWidgets.QWidget() spacer.setMaximumWidth(4) spacer.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred ) self._firstSpacer = self._toolBar.addWidget(spacer) self.setSize(150, 150) self.setMouseTracking(True)
def createWidget(self, menu): """ This method is called by the QWidgetAction base class. :type menu: QtWidgets.QMenu """ widget = QtWidgets.QFrame(self.parent()) widget.setObjectName("filterByAction") facet = self._facet name = facet.get("name") or "" count = str(facet.get("count", 0)) title = name.replace(".", "").title() label = QtWidgets.QCheckBox(widget) label.setAttribute(QtCore.Qt.WA_TransparentForMouseEvents) label.setText(title) label.installEventFilter(self) label.toggled.connect(self._triggered) label.setChecked(self._checked) label2 = QtWidgets.QLabel(widget) label2.setObjectName("actionCounter") label2.setText(count) layout = QtWidgets.QHBoxLayout(widget) layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(label, stretch=1) layout.addWidget(label2) widget.setLayout(layout) return widget
def __init__(self, *args): QtWidgets.QFrame.__init__(self, *args) self.setObjectName("statusWidget") self.setFrameShape(QtWidgets.QFrame.NoFrame) self._blocking = False self._timer = QtCore.QTimer(self) self._label = QtWidgets.QLabel("", self) self._label.setCursor(QtCore.Qt.IBeamCursor) self._label.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) self._label.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self._button = QtWidgets.QPushButton(self) self._button.setMaximumSize(QtCore.QSize(17, 17)) self._button.setIconSize(QtCore.QSize(17, 17)) self._progressBar = ProgressBar(self) self._progressBar.hide() layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(1, 0, 0, 0) layout.addWidget(self._button) layout.addWidget(self._label) layout.addWidget(self._progressBar) self.setLayout(layout) self.setFixedHeight(19) self.setMinimumWidth(5) self._timer.timeout.connect(self.reset)
def __init__(self, path="", parent=None, startFrame=None, endFrame=None, step=1): """ :type path: str :type parent: QtWidgets.QWidget :type startFrame: int :type endFrame: int :type step: int """ parent = parent or mutils.gui.mayaWindow() QtWidgets.QDialog.__init__(self, parent) self._path = path self._step = step self._endFrame = None self._startFrame = None self._capturedPath = None if endFrame is None: endFrame = int(maya.cmds.currentTime(query=True)) if startFrame is None: startFrame = int(maya.cmds.currentTime(query=True)) self.setEndFrame(endFrame) self.setStartFrame(startFrame) self.setObjectName("CaptureWindow") self.setWindowTitle("Capture Window") self._captureButton = QtWidgets.QPushButton("Capture") self._captureButton.clicked.connect(self.capture) self._modelPanelWidget = mutils.gui.modelpanelwidget.ModelPanelWidget( self) vbox = QtWidgets.QVBoxLayout(self) vbox.setObjectName(self.objectName() + "Layout") vbox.addWidget(self._modelPanelWidget) vbox.addWidget(self._captureButton) self.setLayout(vbox) width = (self.DEFAULT_WIDTH * 1.5) height = (self.DEFAULT_HEIGHT * 1.5) + 50 self.setWidthHeight(width, height) self.centerWindow()
def __init__(self, parent=None, data=None, formWidget=None): super(FieldWidget, self).__init__(parent) self._data = data or {} self._widget = None self._default = None self._required = None self._collapsed = False self._errorLabel = None self._menuButton = None self._actionResult = None self._formWidget = None if formWidget: self.setFormWidget(formWidget) self.setObjectName("fieldWidget") direction = self._data.get("layout", self.DefaultLayout) if direction == "vertical": layout = QtWidgets.QVBoxLayout(self) else: layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self.setContentsMargins(0, 0, 0, 0) self._label = QtWidgets.QLabel(self) self._label.setObjectName('label') self._label.setSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred, ) layout.addWidget(self._label) self._layout2 = QtWidgets.QHBoxLayout(self) layout.addLayout(self._layout2) if direction == "vertical": self._label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) else: self._label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) widget = self.createWidget() if widget: self.setWidget(widget)
def createTitleWidget(self): """ Create a new instance of the title bar widget. :rtype: QtWidgets.QFrame """ class UI(object): """Proxy class for attaching ui widgets as properties.""" pass titleWidget = QtWidgets.QFrame(self) titleWidget.setObjectName("titleWidget") titleWidget.ui = UI() vlayout = QtWidgets.QVBoxLayout(self) vlayout.setSpacing(0) vlayout.setContentsMargins(0,0,0,0) hlayout = QtWidgets.QHBoxLayout(self) hlayout.setSpacing(0) hlayout.setContentsMargins(0,0,0,0) vlayout.addLayout(hlayout) titleButton = QtWidgets.QPushButton(self) titleButton.setText("Folders") titleButton.setObjectName("titleButton") titleWidget.ui.titleButton = titleButton hlayout.addWidget(titleButton) menuButton = QtWidgets.QPushButton(self) menuButton.setText("...") menuButton.setObjectName("menuButton") titleWidget.ui.menuButton = menuButton hlayout.addWidget(menuButton) self._lineEdit = studiolibrary.widgets.LineEdit(self) self._lineEdit.hide() self._lineEdit.setObjectName("filterEdit") self._lineEdit.setText(self.treeWidget().filterText()) self._lineEdit.textChanged.connect(self.searchChanged) titleWidget.ui.filterEdit = self._lineEdit vlayout.addWidget(self._lineEdit) titleWidget.setLayout(vlayout) return titleWidget
def __init__(self, label="", parent=None): """ :type parent: QtWidgets.QMenu """ QtWidgets.QWidgetAction.__init__(self, parent) self._widget = SliderWidgetAction(parent) self._label = QtWidgets.QLabel(label, self._widget) self._slider = QtWidgets.QSlider(QtCore.Qt.Horizontal, self._widget) self._slider.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.valueChanged = self._slider.valueChanged
def createWidget(self, menu): """ This method is called by the QWidgetAction base class. :type menu: QtWidgets.QMenu """ widget = QtWidgets.QFrame(menu) widget.setObjectName("colorPickerAction") actionLayout = QtWidgets.QHBoxLayout(widget) actionLayout.setContentsMargins(0, 0, 0, 0) actionLayout.addWidget(self.picker(), stretch=1) widget.setLayout(actionLayout) return widget
def createActions(self): """ Crate the actions to be shown in the menu. :rtype: None """ # Create the menu actions for setting the accent color action = SeparatorAction("Accent", self) self.addAction(action) themes = self._themes if not themes: themes = themePresets() for theme in themes: if theme.accentColor(): action = ThemeAction(theme, self) self.addAction(action) if self.ENABLE_CUSTOM_ACTION: action = QtWidgets.QAction("Custom", self) action.triggered.connect(self.theme().browseAccentColor) color = self.theme().accentColor().toString() icon = studiolibrary.resource.icon(ThemesMenu.THEME_ICON, color=color) action.setIcon(icon) self.addAction(action) # Create the menu actions for setting the background color action = SeparatorAction("Background", self) self.addAction(action) for theme in themes: if not theme.accentColor() and theme.backgroundColor(): action = ThemeAction(theme, self) self.addAction(action) if self.ENABLE_CUSTOM_ACTION: action = QtWidgets.QAction("Custom", self) action.triggered.connect(self._theme.browseBackgroundColor) color = self._theme.backgroundColor().toString() icon = studiolibrary.resource.icon(ThemesMenu.THEME_ICON, color=color) action.setIcon(icon) self.addAction(action) self.triggered.connect(self._triggered)
def addAction(self, path, text, tip, callback): """ Add an action to the tool bar. :type path: str :type text: str :type tip: str :type callback: func :rtype: QtWidgets.QAction """ icon = studioqt.Icon.fa( path, color="rgb(250,250,250,160)", color_active="rgb(250,250,250,250)", color_disabled="rgb(0,0,0,20)" ) action = QtWidgets.QAction(icon, text, self._toolBar) action.setToolTip(tip) # action.setStatusTip(tip) # action.setWhatsThis(tip) self._toolBar.insertAction(self._firstSpacer, action) action.triggered.connect(callback) return action
def createHideColumnMenu(self): """ Create the hide column menu. :rtype: QtWidgets.QMenu """ menu = QtWidgets.QMenu("Show/Hide Column", self) action = menu.addAction("Show All") action.triggered.connect(self.showAllColumns) action = menu.addAction("Hide All") action.triggered.connect(self.hideAllColumns) menu.addSeparator() for column in range(self.columnCount()): label = self.labelFromColumn(column) isHidden = self.isColumnHidden(column) action = menu.addAction(label) action.setCheckable(True) action.setChecked(not isHidden) callback = partial(self.setColumnHidden, column, not isHidden) action.triggered.connect(callback) return menu
def browseColor(self): """ Show the color dialog. :rtype: None """ color = self.currentColor() if color: color = studioqt.Color.fromString(color) d = QtWidgets.QColorDialog(self) d.setCurrentColor(color) standardColors = self.browserColors() if standardColors: index = -1 for standardColor in standardColors: index += 1 try: # Support for new qt5 signature standardColor = QtGui.QColor(standardColor) d.setStandardColor(index, standardColor) except: # Support for new qt4 signature standardColor = QtGui.QColor(standardColor).rgba() d.setStandardColor(index, standardColor) d.currentColorChanged.connect(self._colorChanged) if d.exec_(): self._colorChanged(d.selectedColor()) else: self._colorChanged(color)
def __init__(self, *args, **kwargs): super(EnumFieldWidget, self).__init__(*args, **kwargs) widget = QtWidgets.QComboBox(self) widget.currentIndexChanged.connect(self.emitValueChanged) self.setWidget(widget)
def contextEditMenu(self, menu, items=None): """ Called when creating the context menu for the item. :type menu: QtWidgets.QMenu :type items: list[FolderItem] or None """ super(FolderItem, self).contextEditMenu(menu, items=items) action = QtWidgets.QAction("Show in Preview", menu) action.triggered.connect(self._showPreviewFromMenu) menu.addAction(action) menu.addSeparator() action = studiolibrary.widgets.colorpicker.ColorPickerAction(menu) action.picker().setColors(self.DEFAULT_ICON_COLORS) action.picker().colorChanged.connect(self.setIconColor) action.picker().setCurrentColor(self.iconColor()) action.picker().menuButton().hide() menu.addAction(action) iconName = self.itemData().get("icon", "") action = studiolibrary.widgets.iconpicker.IconPickerAction(menu) action.picker().setIcons(self.DEFAULT_ICONS) action.picker().setCurrentIcon(iconName) action.picker().iconChanged.connect(self.setCustomIcon) action.picker().menuButton().hide() menu.addAction(action)
def showMenu(self): """Show the menu using the actions from the data.""" menu = QtWidgets.QMenu(self) actions = self.data().get("actions", []) for action in actions: name = action.get("name", "No name found") enabled = action.get("enabled", True) callback = action.get("callback") func = functools.partial(self._actionCallback, callback) action = menu.addAction(name) action.setEnabled(enabled) action.triggered.connect(func) point = QtGui.QCursor.pos() point.setX(point.x() + 3) point.setY(point.y() + 3) # Reset the action results self._actionResult = None menu.exec_(point) if self._actionResult is not None: self.setValue(self._actionResult)
def __init__(self, *args, **kwargs): super(BoolFieldWidget, self).__init__(*args, **kwargs) widget = QtWidgets.QCheckBox(self) widget.stateChanged.connect(self.emitValueChanged) self.setWidget(widget)
def __init__(self, libraryWindow=None): super(LibrariesMenu, self).__init__(libraryWindow) self.setTitle('Libraries') libraries = studiolibrary.readSettings() default = studiolibrary.defaultLibrary() for name in libraries: library = libraries[name] path = library.get('path', '') kwargs = library.get('kwargs', {}) enabled = True if libraryWindow: enabled = name != libraryWindow.name() text = name if name == default and name.lower() != "default": text = name + " (default)" action = QtWidgets.QAction(text, self) action.setEnabled(enabled) callback = partial(self.showLibrary, name, path, **kwargs) action.triggered.connect(callback) self.addAction(action)
def __init__(self, *args): super(SidebarWidget, self).__init__(*args) self._dataset = None self._lineEdit = None self._previousFilterText = "" layout = QtWidgets.QVBoxLayout(self) layout.setSpacing(0) layout.setContentsMargins(0,0,0,0) self.setLayout(layout) self._treeWidget = TreeWidget(self) self._treeWidget.itemDropped = self.itemDropped self._treeWidget.itemRenamed = self.itemRenamed self._treeWidget.itemSelectionChanged.connect(self._itemSelectionChanged) self._titleWidget = self.createTitleWidget() self._titleWidget.ui.menuButton.clicked.connect(self.showSettingsMenu) self._titleWidget.ui.titleButton.clicked.connect(self.clearSelection) self.layout().addWidget(self._titleWidget) self.layout().addWidget(self._treeWidget) self._treeWidget.installEventFilter(self)
def __init__(self, *args, **kwargs): super(RadioFieldWidget, self).__init__(*args, **kwargs) self._radioButtons = [] layout = QtWidgets.QVBoxLayout() layout.setContentsMargins(0, 0, 0, 0) self._radioFrame = QtWidgets.QFrame(self) self._radioFrame.setLayout(layout) self.setWidget(self._radioFrame) self.label().setStyleSheet("margin-top:2px;") self.widget().setStyleSheet("margin-top:2px;") self.label().setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTop)
def setWidget(self, widget): """ Set the widget used to set and get the field value. :type widget: QtWidgets.QWidget """ widgetLayout = QtWidgets.QHBoxLayout(self) widgetLayout.setContentsMargins(0, 0, 0, 0) widgetLayout.setSpacing(0) self._widget = widget self._widget.setParent(self) self._widget.setObjectName('widget') self._widget.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred, ) self._menuButton = QtWidgets.QPushButton("...") self._menuButton.setHidden(True) self._menuButton.setObjectName("menuButton") self._menuButton.clicked.connect(self._menuCallback) self._menuButton.setSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding, ) widgetLayout.addWidget(self._widget) widgetLayout.addWidget(self._menuButton) layout = QtWidgets.QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) self._errorLabel = QtWidgets.QLabel(self) self._errorLabel.setHidden(True) self._errorLabel.setObjectName("errorLabel") self._errorLabel.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred, ) layout.addLayout(widgetLayout) layout.addWidget(self._errorLabel) self._layout2.addLayout(layout)
def showBrowseImageDialog(self): """Show a file dialog for choosing an image from disc.""" fileDialog = QtWidgets.QFileDialog(self, caption="Open Image", filter="Image Files (*.png *.jpg)") fileDialog.fileSelected.connect(self.setThumbnailPath) fileDialog.exec_()
def createSettingsMenu(self): """ Create and return the settings menu for the widget. :rtype: QtWidgets.QMenu """ menu = QtWidgets.QMenu("Item View", self) menu.addSeparator() action = QtWidgets.QAction("Show labels", menu) action.setCheckable(True) action.setChecked(self.isItemTextVisible()) action.triggered[bool].connect(self.setItemTextVisible) menu.addAction(action) menu.addSeparator() copyTextMenu = self.treeWidget().createCopyTextMenu() menu.addMenu(copyTextMenu) menu.addSeparator() action = SliderAction("Size", menu) action.slider().setMinimum(10) action.slider().setMaximum(200) action.slider().setValue(self.zoomAmount()) action.slider().valueChanged.connect(self.setZoomAmount) menu.addAction(action) action = SliderAction("Border", menu) action.slider().setMinimum(0) action.slider().setMaximum(20) action.slider().setValue(self.padding()) action.slider().valueChanged.connect(self.setPadding) menu.addAction(action) # action = SliderAction("Spacing", menu) action.slider().setMinimum(self.DEFAULT_MIN_SPACING) action.slider().setMaximum(self.DEFAULT_MAX_SPACING) action.slider().setValue(self.spacing()) action.slider().valueChanged.connect(self.setSpacing) menu.addAction(action) return menu
def __init__(self, *args, **kwargs): super(IntFieldWidget, self).__init__(*args, **kwargs) validator = QtGui.QIntValidator(-50000000, 50000000, self) widget = QtWidgets.QLineEdit(self) widget.setValidator(validator) widget.textChanged.connect(self.emitValueChanged) self.setWidget(widget)
def __init__(self, *args, **kwargs): super(StringDoubleFieldWidget, self).__init__(*args, **kwargs) widget = QtWidgets.QFrame(self) layout = QtWidgets.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(4) widget.setLayout(layout) self._widget1 = QtWidgets.QLineEdit(self) self._widget1.textChanged.connect(self.emitValueChanged) widget.layout().addWidget(self._widget1) self._widget2 = QtWidgets.QLineEdit(self) self._widget2.textChanged.connect(self.emitValueChanged) widget.layout().addWidget(self._widget2) self.setWidget(widget)