Allow different style for child PopupMenu.

This commit is contained in:
John Preston 2022-07-27 13:48:32 +03:00
parent 4ff70e7dff
commit 9b0f4df007
3 changed files with 7 additions and 4 deletions

View file

@ -24,7 +24,7 @@ MenuCallback CreateAddActionCallback(
a.icon); a.icon);
// Dummy menu. // Dummy menu.
action->setMenu(Ui::CreateChild<QMenu>(menu->menu().get())); action->setMenu(Ui::CreateChild<QMenu>(menu->menu().get()));
a.fillSubmenu(menu->ensureSubmenu(action)); a.fillSubmenu(menu->ensureSubmenu(action, menu->st()));
return action; return action;
} else if (a.isSeparator) { } else if (a.isSeparator) {
return menu->addSeparator(); return menu->addSeparator();

View file

@ -259,7 +259,9 @@ void PopupMenu::init() {
setAttribute(Qt::WA_TranslucentBackground, true); setAttribute(Qt::WA_TranslucentBackground, true);
} }
not_null<PopupMenu*> PopupMenu::ensureSubmenu(not_null<QAction*> action) { not_null<PopupMenu*> PopupMenu::ensureSubmenu(
not_null<QAction*> action,
const style::PopupMenu &st) {
const auto &list = actions(); const auto &list = actions();
const auto i = ranges::find(list, action); const auto i = ranges::find(list, action);
Assert(i != end(list)); Assert(i != end(list));
@ -270,7 +272,7 @@ not_null<PopupMenu*> PopupMenu::ensureSubmenu(not_null<QAction*> action) {
} }
const auto result = _submenus.emplace( const auto result = _submenus.emplace(
action, action,
base::make_unique_q<PopupMenu>(parentWidget(), st()) base::make_unique_q<PopupMenu>(parentWidget(), st)
).first->second.get(); ).first->second.get();
result->deleteOnHide(false); result->deleteOnHide(false);
return result; return result;

View file

@ -49,7 +49,8 @@ public:
[[nodiscard]] const std::vector<not_null<QAction*>> &actions() const; [[nodiscard]] const std::vector<not_null<QAction*>> &actions() const;
[[nodiscard]] not_null<PopupMenu*> ensureSubmenu( [[nodiscard]] not_null<PopupMenu*> ensureSubmenu(
not_null<QAction*> action); not_null<QAction*> action,
const style::PopupMenu &st);
void removeSubmenu(not_null<QAction*> action); void removeSubmenu(not_null<QAction*> action);
void checkSubmenuShow(); void checkSubmenuShow();
bool empty() const; bool empty() const;