Skip to content

Commit

Permalink
EMSUSD-1657 bring changes back from other light linking repo
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrebai-adsk committed Jan 7, 2025
1 parent 42a472a commit 50874cd
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down Expand Up @@ -193,5 +193,3 @@ def onListSelectionChanged(self):
def onIncludeAllToggle(self, _: Qt.CheckState):
incAll = self._include.cbIncludeAll.isChecked()
self._collData.setIncludeAll(incAll)


Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@


class FilteredStringListView(QListView):
selectionChanged = Signal()

itemSelectionChanged = Signal()

class Delegate(QStyledItemDelegate):
def __init__(self, model: QStringListModel, parent=None):
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
'''
Expand Down

0 comments on commit 50874cd

Please sign in to comment.