diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index 0f744d8ebc..c1fdab0171 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -1773,6 +1773,18 @@ void InnerWidget::contextMenuEvent(QContextMenuEvent *e) { } else { const auto addAction = Window::PeerMenuCallback([&]( Window::PeerMenuCallback::Args &&a) { + if (a.fillSubmenu) { + const auto action = _menu->addAction( + a.text, + std::move(a.handler), + a.icon); + // Dummy menu. + action->setMenu(Ui::CreateChild(_menu->menu().get())); + a.fillSubmenu(_menu->ensureSubmenu(action)); + return action; + } else if (a.isSeparator) { + return _menu->addSeparator(); + } return _menu->addAction(a.text, std::move(a.handler), a.icon); }); Window::FillDialogsEntryMenu( diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 50769b9080..4cc81207e9 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -283,7 +283,7 @@ bool TopBarWidget::createMenu(not_null button) { if (!_activeChat.key || _menu) { return false; } - _menu.create(this, st::popupMenuWithIcons); + _menu.create(this, st::popupMenuExpandedSeparator); _menu->setDestroyedCallback([ weak = Ui::MakeWeak(this), weakButton = Ui::MakeWeak(button), @@ -307,6 +307,18 @@ void TopBarWidget::showPeerMenu() { } const auto addAction = Window::PeerMenuCallback([&]( Window::PeerMenuCallback::Args a) { + if (a.fillSubmenu) { + const auto action = _menu->addAction( + a.text, + std::move(a.handler), + a.icon); + // Dummy menu. + action->setMenu(Ui::CreateChild(_menu->menu().get())); + a.fillSubmenu(_menu->ensureSubmenu(action)); + return action; + } else if (a.isSeparator) { + return _menu->addSeparator(); + } return _menu->addAction(a.text, std::move(a.handler), a.icon); }); Window::FillDialogsEntryMenu(_controller, _activeChat, addAction); diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h index ef7f896812..a4032358e3 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.h +++ b/Telegram/SourceFiles/window/window_peer_menu.h @@ -41,9 +41,11 @@ extern const char kOptionViewProfileInChatsListContextMenu[]; struct PeerMenuCallback { public: struct Args { - const QString &text; + QString text; Fn handler; const style::icon *icon; + Fn)> fillSubmenu; + bool isSeparator = false; }; using Callback = Fn; @@ -58,7 +60,7 @@ public: const QString &text, Fn handler, const style::icon *icon) const { - return callback({ text, std::move(handler), icon }); + return callback({ text, std::move(handler), icon, nullptr }); } private: Callback callback;