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

Fix to remove all empty categories in action menu #300

Closed davidlatwe closed 6 years ago

davidlatwe commented 6 years ago

Problem

Plugins which using multiple Category or Separator to organize Action may produce an action menu that left some Category or Separator uncleaned in GUI.

qml_menu_before

As you can see, in those two action menus, there are an empty Category C and a Separator with no actions to separate.

Fix

qml_menu_after

I like to use Category, and with this PR, redundant Category and Separator would be taken care of.

🍺 🍺

Reproducible Code ```python import pyblish.api class CollectInstances(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder def process(self, context): context.create_instance(name="Dummy") class ActionToAll(pyblish.api.Action): on = "all" label = "Action to All" class ActionOnFailed(pyblish.api.Action): on = "failed" label = "Action On Failed" class ValidateFailed(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrder label = "Many Categories" actions = [ pyblish.api.Category("A"), ActionToAll, pyblish.api.Category("B"), ActionOnFailed, pyblish.api.Category("C"), ActionOnFailed, ] def process(self, instance): assert True is False class ValidatePass(pyblish.api.InstancePlugin): order = pyblish.api.ValidatorOrder label = "With Separator" actions = [ pyblish.api.Category("A"), ActionToAll, pyblish.api.Separator, ActionOnFailed, ] def process(self, instance): assert True pyblish.api.register_plugin(CollectInstances) pyblish.api.register_plugin(ValidateFailed) pyblish.api.register_plugin(ValidatePass) ```
mottosso commented 6 years ago

Nice one. :) Welcome to merge. 👍

davidlatwe commented 6 years ago

Merge !