pyblish / pyblish-qml

Pyblish QML frontend for Maya 2013+, Houdini 11+, Nuke 8+ and more
GNU Lesser General Public License v3.0
114 stars 44 forks source link

Action icon "a" showing before evaluation #341

Closed anjosa closed 4 years ago

anjosa commented 4 years ago

Hi all,

Having an issue with categories added to an action where the icon "A" is showed before evaluation. As such: https://imgur.com/a/8WpxgCJ

Using Python 2.7.9, latest version of Pyblish QML and PYQt5.

I have attached a simple example to replicate the problem:

"""
Collect all of the subdivision generator objects and checks if are enabled.
If False enables it and passes the validation.
"""

import pyblish.api as api

objs_sds = ["Object_1", "Object_2"]

class CollectSDSObjects(api.ContextPlugin):
    """
    Collect all of the subdivision generator objects.
    """

    order = api.CollectorOrder
    label = "Collect SDS Objects"

    def process(self, context):

        instance = context.create_instance("SDS Objects", family="assets")
        instance.data["objsSDS"] = objs_sds

        self.log.info("Collected {} SDS object(s).".format(len(objs_sds)))
        self.log.info([obj for obj in objs_sds])

class EnableSDSAction(api.Action):
    """
    Action to let user enable SDS Objects.
    """

    label = "Enable SDS Objects"
    on = "processed"
    icon = "wrench"

    def process(self, context, plugin):

        self.log.info("Enabled {} SDS object.".format(len(objs_sds)))

class ValidateSDSObjects(api.InstancePlugin):
    """
    Checks if the SDS objects is enabled. If False enables it with actions.
    """

    order = api.ValidatorOrder
    families = ["assets"]
    label = "Enable SDS Objects"

    actions = [
        api.Category("Workflow"),
        EnableSDSAction
    ]

    def process(self, instance):

        assert False, "Failed"

api.register_plugin(CollectSDSObjects)
api.register_plugin(ValidateSDSObjects)

Thank you very much! :)

Andre

BigRoy commented 4 years ago

Thanks for creating this issue, I can confirm this happens (on Python 3 too). It only happens when a api.Category is added.

Taking a look now.

BigRoy commented 4 years ago

It's the actionsIconVisible that defines whether the icon should be visible or not. Which will instantly be enabled here as the Category results in a special action that is set to "on=all" because that's the default for the Action class.

As such, the actionsIconVisible checks should discard any Category here and here. I'd say there must be at least one non-category related action available for the icon to be visible, for example with a change like this: any(action.__type__ == "action" for action in actions)

@mottosso does that sound like the way this should act?

mottosso commented 4 years ago

@mottosso does that sound like the way this should act?

I suppose, can't really wrap my head around it atm.

anjosa commented 4 years ago

@BigRoy @mottosso Hi both,

Tested the changes and can confirm it works! :+1:

Thank you very much! Will update and close it once PR is done :)