feat: group OpenFX plugins under dedicated "OpenFX" category with sub-groups

All OpenFX plugins were previously hardcoded to return kCategoryUnknown,
  causing them to pile up under "Uncategorized" in the node creation menu.

  This commit introduces a two-level grouping system for OFX plugins:

  1. Add new kCategoryOpenFX top-level category
     - Node::CategoryID enum extended with kCategoryOpenFX
     - PluginNode::Category() now returns {kCategoryOpenFX}
     - Node::GetCategoryName() returns "OpenFX"

  2. Add secondary sub-grouping support
     - Node base class gains virtual SubCategory() method
     - PluginNode implements SubCategory() backed by sub_category_ member
     - sub_category_ is set in the constructor from the plugin's OFX context:
         Filter     → "Filter"
         Generator  → "Generator"
         Transition → "Transition"
         others     → "General"

  3. Update NodeFactory::CreateMenu()
     - When a node belongs to kCategoryOpenFX and provides a non-empty
       SubCategory(), creates a second-level submenu under "OpenFX"
     - Nodes without a sub-category are placed directly in the top menu

  Expected menu layout:
    OpenFX
      ├── Filter
      │     ├── ColorCorrect
      │     └── ...
      ├── Generator
      ├── Transition
      └── General

  All 4 test suites pass.
This commit is contained in:
2026-05-14 21:05:29 +08:00
parent b2de04962d
commit e012f16083
5 changed files with 54 additions and 9 deletions
+23 -8
View File
@@ -128,25 +128,40 @@ Menu *NodeFactory::CreateMenu(QWidget *parent, bool create_none_item,
// Make sure nodes are up-to-date with the current translation
n->Retranslate();
Menu *destination = nullptr;
QString category_name = Node::GetCategoryName(
n->Category().isEmpty() ? Node::kCategoryUnknown :
n->Category().first());
// See if a menu with this category name already exists
// Find or create top-level category menu
Menu *top_menu = nullptr;
QList<QAction *> menu_actions = menu->actions();
foreach (QAction *action, menu_actions) {
if (action->menu() && action->menu()->title() == category_name) {
destination = static_cast<Menu *>(action->menu());
top_menu = static_cast<Menu *>(action->menu());
break;
}
}
if (!top_menu) {
top_menu = new Menu(category_name, menu);
menu->InsertAlphabetically(top_menu);
}
// Create menu here if it doesn't exist
if (!destination) {
destination = new Menu(category_name, menu);
menu->InsertAlphabetically(destination);
// Determine final destination (support secondary grouping)
Menu *destination = top_menu;
QString sub = n->SubCategory();
if (!sub.isEmpty() &&
n->Category().contains(Node::kCategoryOpenFX)) {
QList<QAction *> sub_actions = top_menu->actions();
foreach (QAction *action, sub_actions) {
if (action->menu() && action->menu()->title() == sub) {
destination = static_cast<Menu *>(action->menu());
break;
}
}
if (destination == top_menu) {
destination = new Menu(sub, top_menu);
top_menu->InsertAlphabetically(destination);
}
}
// Add entry to menu