Skip to content

Commit ff4b056

Browse files
committed
PR feedback
1 parent 37b0cff commit ff4b056

File tree

2 files changed

+18
-23
lines changed

2 files changed

+18
-23
lines changed

lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/collection/includeExcludeWidget.py

+4-16
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ def __init__(
8787

8888
headerLayout.addWidget(self._filterWidget)
8989
headerLayout.addWidget(separator)
90-
91-
# Will need a separator for future designs
92-
# headerLayout.addWidget(separator)
9390
headerLayout.addWidget(menuButton)
9491
includeExcludeLayout.addWidget(headerWidget)
9592

@@ -209,6 +206,7 @@ def onRemoveSelectionFromInclude(self):
209206
self._updatingUI = False
210207
self.updateUI()
211208
self.onListSelectionChanged()
209+
self._include.list.update_placeholder()
212210

213211
def onRemoveSelectionFromExclude(self):
214212
self._updatingUI = True
@@ -217,6 +215,7 @@ def onRemoveSelectionFromExclude(self):
217215
self._updatingUI = False
218216
self.updateUI()
219217
self.onListSelectionChanged()
218+
self._exclude.list.update_placeholder()
220219

221220
def onListSelectionChanged(self):
222221
includesSelected = self._include.list.hasSelectedItems
@@ -229,7 +228,7 @@ def onListSelectionChanged(self):
229228
try:
230229
self._deleteBtn.pressed.disconnect(self.onRemoveSelectionFromInclude)
231230
self._deleteBtn.pressed.disconnect(self.onRemoveSelectionFromExclude)
232-
except:
231+
except Exception:
233232
pass
234233

235234
if includesSelected and excludeSelected:
@@ -301,17 +300,6 @@ def addItemToCollection(self, items):
301300

302301
self.control.update()
303302

304-
"""
305-
def removeItemToCollection(self, item):
306-
if self.control._collection is not None:
307-
if self.widget.headerTitle == "Include":
308-
self.control._collection.GetIncludesRel().RemoveTarget(item)
309-
elif self.widget.headerTitle == "Exclude":
310-
self.control._collection.GetExcludesRel().RemoveTarget(item)
311-
312-
self.control.update()
313-
"""
314-
315303
def _validatePath(self, collection, path):
316304

317305
if not Sdf.Path.IsValidPathString(path):
@@ -321,7 +309,7 @@ def _validatePath(self, collection, path):
321309
prim = stage.GetPrimAtPath(Sdf.Path(path))
322310

323311
if not prim or not prim.IsValid():
324-
raise ValueError("Value must be a float or an int")(
312+
raise ValueError(
325313
"Error: The dragged object is not in the same stage as the collection. Ensure that objects belong to the same stage before adding them"
326314
)
327315

lib/mayaUsd/resources/ae/usd-shared-components/src/python/usdSharedComponents/common/filteredStringListView.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
QStyleOptionViewItem,
1919
QStyledItemDelegate,
2020
QListView,
21+
QLabel
2122
)
2223
except:
2324
from PySide2.QtCore import ( # type: ignore
@@ -31,7 +32,7 @@
3132
Signal,
3233
)
3334
from PySide2.QtGui import QPainter, QPaintEvent, QPen, QColor # type: ignore
34-
from PySide2.QtWidgets import QStyleOptionViewItem, QStyledItemDelegate, QListView # type: ignore
35+
from PySide2.QtWidgets import QStyleOptionViewItem, QStyledItemDelegate, QListView, QLabel # type: ignore
3536

3637

3738
kNoObjectFoundLabel = "No objects found"
@@ -81,6 +82,11 @@ def __init__(self, items: Sequence[str] = [], headerTitle: str = "", parent=None
8182
lambda: self.selectionChanged.emit()
8283
)
8384

85+
self.placeholder_label = QLabel("Drag objects here or click “+” to add", self)
86+
self.placeholder_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
87+
self.placeholder_label.setStyleSheet("color: gray; font-size: 18px;")
88+
self.placeholder_label.hide()
89+
8490
def drawFrame(self, painter: QPainter):
8591
pass
8692

@@ -118,13 +124,14 @@ def hasSelectedItems(self) -> bool:
118124
def update_placeholder(self):
119125
"""Show or hide placeholder based on the model's content."""
120126
model = self.model()
121-
# if model and model.rowCount() == 0:
122-
# self.placeholder_label.show()
123-
# else:
124-
# self.placeholder_label.hide()
127+
if model and model.rowCount() == 0:
128+
self.placeholder_label.show()
129+
self.placeholder_label.setGeometry(self.viewport().geometry())
130+
else:
131+
self.placeholder_label.hide()
125132

126133
def resizeEvent(self, event):
127134
"""Ensure placeholder is centered on resize."""
128135
super().resizeEvent(event)
129-
# if self.placeholder_label.isVisible():
130-
# self.placeholder_label.setGeometry(self.viewport().geometry())
136+
if self.placeholder_label.isVisible():
137+
self.placeholder_label.setGeometry(self.viewport().geometry())

0 commit comments

Comments
 (0)