diff --git a/Changes.md b/Changes.md index 9293b4b46b0..9fc7ee888c0 100644 --- a/Changes.md +++ b/Changes.md @@ -8,6 +8,7 @@ Improvements - DelightOptions : Added new options for modern 3Delight, as of version `2.9.39`. - ShaderQuery and ShaderTweaks : Added a filter for shader parameter names in the shader browser (#5293). +- MatchPatternPathFilterWidget : Added the name of the property being filtered to the placeholder text. Fixes ----- diff --git a/python/GafferUI/MatchPatternPathFilterWidget.py b/python/GafferUI/MatchPatternPathFilterWidget.py index fca21b358b4..6342d26f5bb 100644 --- a/python/GafferUI/MatchPatternPathFilterWidget.py +++ b/python/GafferUI/MatchPatternPathFilterWidget.py @@ -48,6 +48,7 @@ def __init__( self, pathFilter, **kw ) : self.__row = GafferUI.ListContainer( GafferUI.ListContainer.Orientation.Horizontal, spacing=2, borderWidth=0 ) GafferUI.PathFilterWidget.__init__( self, self.__row, pathFilter, **kw ) + pathFilter.changedSignal().connect( Gaffer.WeakMethod( self.__updatePlaceholderText ), scoped = False ) with self.__row : @@ -61,11 +62,11 @@ def __init__( self, pathFilter, **kw ) : ) self.__patternWidget = GafferUI.TextWidget() - self.__patternWidget._qtWidget().setPlaceholderText( "Filter..." ) self.__patternWidget.editingFinishedSignal().connect( Gaffer.WeakMethod( self.__patternEditingFinished ), scoped = False ) self.__patternWidget.textChangedSignal().connect( Gaffer.WeakMethod( self.__patternTextChanged ), scoped = False ) + self.__updatePlaceholderText( pathFilter ) self._updateFromPathFilter() def _updateFromPathFilter( self ) : @@ -134,14 +135,7 @@ def __updateFilterMatchPatterns( self ) : def __propertyMenuDefinition( self ) : - propertiesAndLabels = ( - ( "name", "Name" ), - ( "fileSystem:owner", "Owner" ), - ) - - with IECore.IgnoredExceptions( KeyError ) : - propertyFilters = self.pathFilter().userData()["UI"]["propertyFilters"] - propertiesAndLabels = [ ( k, v.value ) for k, v in propertyFilters.items() ] + propertiesAndLabels = [ ( k, v.value ) for k, v in self.__propertyFilters().items() ] menuDefinition = IECore.MenuDefinition() for property, label in propertiesAndLabels : @@ -160,4 +154,22 @@ def __setPropertyName( self, property, checked ) : with Gaffer.Signals.BlockedConnection( self._pathFilterChangedConnection() ) : self.pathFilter().setPropertyName( property ) + def __updatePlaceholderText( self, pathFilter ) : + + propertyNameData = self.__propertyFilters().get( pathFilter.getPropertyName(), None ) + + self.__patternWidget._qtWidget().setPlaceholderText( + "Filter{}".format( ( " by " + propertyNameData.value + "..." ) if propertyNameData is not None else "..." ) + ) + + def __propertyFilters( self ) : + + result = { "name": IECore.StringData( "Name" ), "filesystem:owner": IECore.StringData( "Owner" ) } + + with IECore.IgnoredExceptions( KeyError ) : + result = self.pathFilter().userData()["UI"]["propertyFilters"] + + return result + + GafferUI.PathFilterWidget.registerType( Gaffer.MatchPatternPathFilter, MatchPatternPathFilterWidget )