From 9b0f4df00715f4dfaac81e17148ca37df26fb301 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 27 Jul 2022 13:48:32 +0300 Subject: [PATCH] Allow different style for child PopupMenu. --- ui/widgets/menu/menu_add_action_callback_factory.cpp | 2 +- ui/widgets/popup_menu.cpp | 6 ++++-- ui/widgets/popup_menu.h | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/widgets/menu/menu_add_action_callback_factory.cpp b/ui/widgets/menu/menu_add_action_callback_factory.cpp index 443fa45..2d1c73e 100644 --- a/ui/widgets/menu/menu_add_action_callback_factory.cpp +++ b/ui/widgets/menu/menu_add_action_callback_factory.cpp @@ -24,7 +24,7 @@ MenuCallback CreateAddActionCallback( a.icon); // Dummy menu. action->setMenu(Ui::CreateChild(menu->menu().get())); - a.fillSubmenu(menu->ensureSubmenu(action)); + a.fillSubmenu(menu->ensureSubmenu(action, menu->st())); return action; } else if (a.isSeparator) { return menu->addSeparator(); diff --git a/ui/widgets/popup_menu.cpp b/ui/widgets/popup_menu.cpp index c783372..75cd2c0 100644 --- a/ui/widgets/popup_menu.cpp +++ b/ui/widgets/popup_menu.cpp @@ -259,7 +259,9 @@ void PopupMenu::init() { setAttribute(Qt::WA_TranslucentBackground, true); } -not_null PopupMenu::ensureSubmenu(not_null action) { +not_null PopupMenu::ensureSubmenu( + not_null action, + const style::PopupMenu &st) { const auto &list = actions(); const auto i = ranges::find(list, action); Assert(i != end(list)); @@ -270,7 +272,7 @@ not_null PopupMenu::ensureSubmenu(not_null action) { } const auto result = _submenus.emplace( action, - base::make_unique_q(parentWidget(), st()) + base::make_unique_q(parentWidget(), st) ).first->second.get(); result->deleteOnHide(false); return result; diff --git a/ui/widgets/popup_menu.h b/ui/widgets/popup_menu.h index 1cfe9e7..2be0d27 100644 --- a/ui/widgets/popup_menu.h +++ b/ui/widgets/popup_menu.h @@ -49,7 +49,8 @@ public: [[nodiscard]] const std::vector> &actions() const; [[nodiscard]] not_null ensureSubmenu( - not_null action); + not_null action, + const style::PopupMenu &st); void removeSubmenu(not_null action); void checkSubmenuShow(); bool empty() const;