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 000986c
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,23 @@ 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()) {
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 +307,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 000986c

Please sign in to comment.