diff --git a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/expressionRulesMenu.py b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/expressionRulesMenu.py index d4d6fdf34..896551099 100644 --- a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/expressionRulesMenu.py +++ b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/expressionRulesMenu.py @@ -4,8 +4,7 @@ from PySide6.QtWidgets import QMenu, QWidget # type: ignore from PySide6.QtGui import QActionGroup, QAction # type: ignore except ImportError: - from PySide2.QtWidgets import QMenu, QWidget # type: ignore - from PySide2.QtGui import QActionGroup # type: ignore + from PySide2.QtWidgets import QMenu, QWidget, QActionGroup, QAction # type: ignore from pxr import Usd diff --git a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/includeExcludeWidget.py b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/includeExcludeWidget.py index dd2dbe7a4..5aa8f3a13 100644 --- a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/includeExcludeWidget.py +++ b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/includeExcludeWidget.py @@ -113,8 +113,8 @@ def __init__( self._resizableExclude.minContentSize = Theme.instance().uiScaled(44) mainLayout.addWidget(self._resizableExclude) - self._include.list.selectionChanged.connect(self.onListSelectionChanged) - self._exclude.list.selectionChanged.connect(self.onListSelectionChanged) + self._include.list.itemSelectionChanged.connect(self.onListSelectionChanged) + self._exclude.list.itemSelectionChanged.connect(self.onListSelectionChanged) self._filterWidget.textChanged.connect(self._include.list._model.setFilter) self._filterWidget.textChanged.connect(self._exclude.list._model.setFilter) @@ -133,21 +133,21 @@ def onAddToIncludePrimClicked(self): if not stage: return items = Host.instance().pick(stage, dialogTitle=ADD_INCLUDE_OBJECTS_TITLE) - self._collData.getIncludeData().addStrings(items) + self._collData.getIncludeData().addStrings(map(lambda x: str(x.GetPath()), items)) def onAddToExcludePrimClicked(self): stage = self._collData.getStage() if not stage: return items = Host.instance().pick(stage, dialogTitle=ADD_EXCLUDE_OBJECTS_TITLE) - self._collData.getExcludeData().addStrings(items) + self._collData.getExcludeData().addStrings(map(lambda x: str(x.GetPath()), items)) def onRemoveSelectionFromInclude(self): self._collData.getIncludeData().removeStrings(self._include.list.selectedItems()) self.onListSelectionChanged() def onRemoveSelectionFromExclude(self): - self._collData.getExcludeData().removeStrings(self._include.list.selectedItems()) + self._collData.getExcludeData().removeStrings(self._exclude.list.selectedItems()) self.onListSelectionChanged() def _findAction(self, label): @@ -193,5 +193,3 @@ def onListSelectionChanged(self): def onIncludeAllToggle(self, _: Qt.CheckState): incAll = self._include.cbIncludeAll.isChecked() self._collData.setIncludeAll(incAll) - - diff --git a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/widget.py b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/widget.py index 912c5a876..40eafceba 100644 --- a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/widget.py +++ b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/widget.py @@ -44,7 +44,6 @@ def __init__( mainLayout.setContentsMargins(0, 0, 0, 0) self._includeExcludeWidget = IncludeExcludeWidget(self._collData, self) - self._tabWidget = None # only create tab when usd version is greater then 23.11 @@ -70,6 +69,11 @@ def __init__( self.setLayout(mainLayout) + def setCollection(self, prim: Usd.Prim = None, collection: Usd.CollectionAPI = None): + self._collection = collection + self._prim = prim + self._collData = UsdCollectionData(prim, collection) + if Usd.GetVersion() >= (0, 23, 11): def onTabChanged(self, index): diff --git a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/filteredStringListView.py b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/filteredStringListView.py index edea5fe95..8f6fffa24 100644 --- a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/filteredStringListView.py +++ b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/filteredStringListView.py @@ -44,7 +44,8 @@ class FilteredStringListView(QListView): - selectionChanged = Signal() + + itemSelectionChanged = Signal() class Delegate(QStyledItemDelegate): def __init__(self, model: QStringListModel, parent=None): @@ -96,9 +97,7 @@ def __init__(self, data: StringListData, headerTitle: str = "", parent=None): DragAndDropEventFilter(self, data) - self.selectionModel().selectionChanged.connect( - lambda: self.selectionChanged.emit() - ) + self.selectionModel().selectionChanged.connect(self.itemSelectionChanged) def paintEvent(self, event: QPaintEvent): painter = QPainter(self) diff --git a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/theme.py b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/theme.py index 380ef8499..e56de9cd4 100644 --- a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/theme.py +++ b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/theme.py @@ -1,10 +1,12 @@ try: + from PySide6 import QtSvg from PySide6.QtCore import QRect, Qt # type: ignore - from PySide6.QtGui import QPalette, QPainter, QColor, QPen, QIcon # type: ignore + from PySide6.QtGui import QImage, QPixmap, QPalette, QPainter, QColor, QPen, QIcon # type: ignore from PySide6.QtWidgets import QWidget # type: ignore except: + from PySide2 import QtSvg # type: ignore from PySide2.QtCore import QRect, Qt # type: ignore - from PySide2.QtGui import QPalette, QPainter, QColor, QPen, QIcon # type: ignore + from PySide2.QtGui import QImage, QPixmap, QPalette, QPainter, QColor, QPen, QIcon # type: ignore from PySide2.QtWidgets import QWidget # type: ignore from enum import Flag, auto @@ -50,8 +52,8 @@ def __init__(self): super(Theme.Palette, self) self.colorResizeBorderActive: QColor = QColor(0x5285a6) - pal = QPalette() + pal = QPalette() self.colorPlaceHolderText = pal.color(QPalette.ColorRole.WindowText) self.colorPlaceHolderText.setAlphaF(0.7) @@ -79,13 +81,25 @@ def themedIcon(self, name: str, theme: str) -> QIcon: if os.path.exists(iconFolder): icons = fnmatch.filter(os.listdir(iconFolder), f"{name}.svg") for icon in icons: - result.addPixmap(os.path.join(iconFolder, icon)) + svg_renderer = QtSvg.QSvgRenderer(os.path.join(iconFolder, icon)) + image = QImage(64, 64, QImage.Format_ARGB32) + image.fill(0x00000000) + svg_renderer.render(QPainter(image)) + pixmap = QPixmap.fromImage(image) + + result.addPixmap(pixmap) # take the first SVG and run! return result icons = fnmatch.filter(os.listdir(iconFolder), f"{name}*.png") for icon in icons: - result.addPixmap(os.path.join(iconFolder, icon)) + svg_renderer = QtSvg.QSvgRenderer(os.path.join(iconFolder, icon)) + image = QImage(64, 64, QImage.Format_ARGB32) + image.fill(0x00000000) + svg_renderer.render(QPainter(image)) + pixmap = QPixmap.fromImage(image) + + result.addPixmap(pixmap) return result diff --git a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/data/collectionData.py b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/data/collectionData.py index 61a477bb6..f94aacd7c 100644 --- a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/data/collectionData.py +++ b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/data/collectionData.py @@ -46,7 +46,7 @@ def getExcludeData(self) -> StringListData: Returns the excluded items string list. ''' return None - + def removeAllIncludeExclude(self): ''' Remove all included and excluded items. diff --git a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/usdData/usdCollectionData.py b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/usdData/usdCollectionData.py index 387912529..7af5ea7bb 100644 --- a/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/usdData/usdCollectionData.py +++ b/lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/usdData/usdCollectionData.py @@ -37,8 +37,9 @@ def _trackCollectionNotifications(self): converted to the class's dataChanged signal (and to each CollectionStringListData dataChanged signal) ''' - self._noticeKey = Tf.Notice.Register( - Usd.Notice.ObjectsChanged, self._onObjectsChanged, self._prim.GetStage()) + if self._prim: + self._noticeKey = Tf.Notice.Register( + Usd.Notice.ObjectsChanged, self._onObjectsChanged, self._prim.GetStage()) def _untrackCollectionNotifications(self): '''