Skip to content

Commit

Permalink
feat: [Customize menu] Customize menu merging
Browse files Browse the repository at this point in the history
Merge menus with the same name

Log: [Customize menu] Customize menu merging
Task: https://pms.uniontech.com/task-view-363005.html
  • Loading branch information
pppanghu77 committed Sep 20, 2024
1 parent c7875fc commit 3d29dbc
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,24 @@ bool ExtendMenuScene::create(QMenu *parent)
//自动释放
action->setParent(parent);

auto actions = d->childActions(action);
d->extendChildActions.append(actions);

bool isExist = false;
for (auto existAction : d->extendActions) {
//合并名字相同的菜单且都有子菜单的一级菜单
if (action->text() == existAction->text()
&& existAction->menu()
&& action->menu()) {
isExist = true;
for (QAction *subaction : action->menu()->actions()) {
existAction->menu()->addAction(subaction);
}
}
}
if (isExist)
continue;

//记录分隔线
if (actionData.separator() != DCustomActionDefines::kNone)
d->cacheActionsSeparator.insert(action, actionData.separator());
Expand All @@ -290,9 +308,6 @@ bool ExtendMenuScene::create(QMenu *parent)
action->setProperty(kActionPosInMenu, pos);
}

auto actions = d->childActions(action);
d->extendChildActions.append(actions);

d->extendActions.append(action);
}

Expand Down

0 comments on commit 3d29dbc

Please sign in to comment.