From df17f20a475272d9c8a9cd3391dbd8f062988355 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 3 Jun 2022 20:07:33 +0400 Subject: [PATCH] Support attach bot menu / reload / settings. --- Telegram/Resources/langs/lang.strings | 6 +- .../dialogs/dialogs_inner_widget.cpp | 4 +- .../view/history_view_top_bar_widget.cpp | 4 +- .../view/history_view_top_bar_widget.h | 1 - .../SourceFiles/info/info_wrap_widget.cpp | 4 +- .../inline_bots/bot_attach_web_view.cpp | 64 ++++++++++++++++++- .../inline_bots/bot_attach_web_view.h | 1 + .../SourceFiles/menu/add_action_callback.cpp | 27 -------- .../SourceFiles/menu/add_action_callback.h | 39 ----------- .../menu/add_action_callback_factory.cpp | 46 ------------- .../menu/add_action_callback_factory.h | 23 ------- .../SourceFiles/settings/settings_common.cpp | 3 +- .../SourceFiles/settings/settings_common.h | 7 +- .../settings/settings_information.cpp | 5 +- .../ui/chat/attach/attach_bot_webview.cpp | 36 ++++++++++- .../ui/chat/attach/attach_bot_webview.h | 16 +++++ Telegram/SourceFiles/ui/menu_icons.style | 27 +------- .../SourceFiles/window/window_peer_menu.h | 4 +- Telegram/cmake/td_ui.cmake | 4 -- Telegram/lib_ui | 2 +- Telegram/lib_webview | 2 +- 21 files changed, 140 insertions(+), 185 deletions(-) delete mode 100644 Telegram/SourceFiles/menu/add_action_callback.cpp delete mode 100644 Telegram/SourceFiles/menu/add_action_callback.h delete mode 100644 Telegram/SourceFiles/menu/add_action_callback_factory.cpp delete mode 100644 Telegram/SourceFiles/menu/add_action_callback_factory.h diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 2681f3ad1c..ca75530bf0 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1918,8 +1918,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_bot_sure_add_text_channel" = "Are you sure you want to add this bot as an admin in the channel {group}?"; "lng_bot_sure_add" = "Add as admin"; "lng_bot_no_webview" = "Unfortunately, you can't open such menu with current system configuration."; -"lng_bot_remove_from_menu" = "Remove from menu"; +"lng_bot_remove_from_menu" = "Remove From Menu"; +"lng_bot_remove_from_menu_sure" = "Remove {bot} from the attachment menu?"; "lng_bot_remove_from_menu_done" = "Bot removed from the menu."; +"lng_bot_settings" = "Settings"; +"lng_bot_open" = "Open Bot"; +"lng_bot_reload_page" = "Reload Page"; "lng_bot_add_to_menu" = "{bot} asks your permission to be added as an option to your attachments menu so you can access it from any chat."; "lng_bot_add_to_menu_done" = "Bot added to the menu."; "lng_bot_menu_not_supported" = "This bot isn't supported in the attach menu."; diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index cb021a7d06..1d529c0a6a 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -38,7 +38,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "mainwindow.h" #include "mainwidget.h" -#include "menu/add_action_callback_factory.h" #include "storage/storage_account.h" #include "apiwrap.h" #include "main/main_session.h" @@ -48,6 +47,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "window/window_session_controller.h" #include "window/window_peer_menu.h" #include "ui/widgets/multi_select.h" +#include "ui/widgets/menu/menu_add_action_callback_factory.h" #include "ui/empty_userpic.h" #include "ui/unread_badge.h" #include "boxes/filters/edit_filter_box.h" @@ -1828,7 +1828,7 @@ void InnerWidget::contextMenuEvent(QContextMenuEvent *e) { fillArchiveSearchMenu(_menu.get()); } } else { - const auto addAction = Menu::CreateAddActionCallback(_menu); + const auto addAction = Ui::Menu::CreateAddActionCallback(_menu); Window::FillDialogsEntryMenu( _controller, Dialogs::EntryState{ 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 0174044960..6f1fa60277 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mainwidget.h" #include "mainwindow.h" #include "main/main_session.h" -#include "menu/add_action_callback_factory.h" #include "mtproto/mtproto_config.h" #include "lang/lang_keys.h" #include "core/shortcuts.h" @@ -27,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "core/core_settings.h" #include "ui/widgets/buttons.h" #include "ui/widgets/popup_menu.h" +#include "ui/widgets/menu/menu_add_action_callback_factory.h" #include "ui/effects/radial_animation.h" #include "ui/toasts/common_toasts.h" #include "ui/boxes/report_box.h" // Ui::ReportReason @@ -306,7 +306,7 @@ void TopBarWidget::showPeerMenu() { if (!created) { return; } - const auto addAction = Menu::CreateAddActionCallback(_menu); + const auto addAction = Ui::Menu::CreateAddActionCallback(_menu); Window::FillDialogsEntryMenu(_controller, _activeChat, addAction); if (_menu->empty()) { _menu = nullptr; diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h index 1e825b9707..79434c71ac 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.h @@ -108,7 +108,6 @@ private: void call(); void groupCall(); - void startGroupCall(not_null megagroup, bool confirmed); void showPeerMenu(); void showGroupCallMenu(not_null peer); void toggleInfoSection(); diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index 1e82be2cab..e569e4443e 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/buttons.h" #include "ui/widgets/shadow.h" #include "ui/widgets/popup_menu.h" +#include "ui/widgets/menu/menu_add_action_callback_factory.h" #include "ui/wrap/fade_wrap.h" #include "ui/search_field_controller.h" #include "core/application.h" @@ -34,7 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/peer_list_box.h" #include "ui/boxes/confirm_box.h" #include "main/main_session.h" -#include "menu/add_action_callback_factory.h" #include "mtproto/mtproto_config.h" #include "data/data_download_manager.h" #include "data/data_session.h" @@ -532,7 +532,7 @@ void WrapWidget::showTopBarMenu(bool check) { } }); - const auto addAction = Menu::CreateAddActionCallback(_topBarMenu); + const auto addAction = Ui::Menu::CreateAddActionCallback(_topBarMenu); if (key().isDownloads()) { addAction( tr::lng_context_delete_all_files(tr::now), diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 8409f72db5..8d1374b280 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -107,6 +107,7 @@ struct ParsedBot { .name = qs(data.vshort_name()), .types = ResolvePeerTypes(data.vpeer_types().v), .inactive = data.is_inactive(), + .hasSettings = data.is_has_settings(), } : std::optional(); }); if (result && result->icon) { @@ -818,6 +819,61 @@ void AttachWebView::show( return value.text; }); ActiveWebViews().emplace(this); + + using Button = Ui::BotWebView::MenuButton; + const auto attached = ranges::find( + _attachBots, + not_null{ _bot }, + &AttachWebViewBot::user); + const auto name = (attached != end(_attachBots)) + ? attached->name + : _bot->name; + const auto hasSettings = (attached != end(_attachBots)) + && !attached->inactive + && attached->hasSettings; + const auto hasOpenBot = (_bot != _peer); + const auto hasRemoveFromMenu = (attached != end(_attachBots)) + && !attached->inactive; + const auto buttons = (hasSettings ? Button::Settings : Button::None) + | (hasOpenBot ? Button::OpenBot : Button::None) + | (hasRemoveFromMenu ? Button::RemoveFromMenu : Button::None); + const auto bot = _bot; + + const auto handleMenuButton = crl::guard(this, [=](Button button) { + switch (button) { + case Button::OpenBot: + close(); + if (bot->session().windows().empty()) { + Core::App().domain().activate(&bot->session().account()); + } + if (!bot->session().windows().empty()) { + const auto window = bot->session().windows().front(); + window->showPeerHistory(bot); + window->window().activate(); + } + break; + case Button::RemoveFromMenu: + if (const auto strong = panel->get()) { + const auto done = crl::guard(this, [=] { + removeFromMenu(bot); + close(); + if (const auto active = Core::App().activeWindow()) { + active->activate(); + } + }); + strong->showBox(Ui::MakeConfirmBox({ + tr::lng_bot_remove_from_menu_sure( + tr::now, + lt_bot, + Ui::Text::Bold(name), + Ui::Text::WithEntities), + done, + })); + } + break; + } + }); + _panel = Ui::BotWebView::Show({ .url = url, .userDataPath = _session->domain().local().webviewDataPath(), @@ -827,6 +883,8 @@ void AttachWebView::show( .handleInvoice = handleInvoice, .sendData = sendData, .close = close, + .menuButtons = buttons, + .handleMenuButton = handleMenuButton, .themeParams = [] { return Window::Theme::WebViewParams(); }, }); *panel = _panel.get(); @@ -881,7 +939,11 @@ void AttachWebView::confirmAddToMenu( return; } _confirmAddBox = active->show(Ui::MakeConfirmBox({ - tr::lng_bot_add_to_menu(tr::now, lt_bot, bot.name), + tr::lng_bot_add_to_menu( + tr::now, + lt_bot, + Ui::Text::Bold(bot.name), + Ui::Text::WithEntities), done, })); } diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h index 90fd9beb8b..6f9a0f36cf 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h @@ -56,6 +56,7 @@ struct AttachWebViewBot { QString name; PeerTypes types = 0; bool inactive = false; + bool hasSettings = false; }; class AttachWebView final : public base::has_weak_ptr { diff --git a/Telegram/SourceFiles/menu/add_action_callback.cpp b/Telegram/SourceFiles/menu/add_action_callback.cpp deleted file mode 100644 index 1f36c84f11..0000000000 --- a/Telegram/SourceFiles/menu/add_action_callback.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "menu/add_action_callback.h" - -namespace Menu { - -MenuCallback::MenuCallback(MenuCallback::Callback callback) -: _callback(std::move(callback)) { -} - -QAction *MenuCallback::operator()(Args &&args) const { - return _callback(std::move(args)); -} - -QAction *MenuCallback::operator()( - const QString &text, - Fn handler, - const style::icon *icon) const { - return _callback({ text, std::move(handler), icon, nullptr }); -} - -} // namespace Menu diff --git a/Telegram/SourceFiles/menu/add_action_callback.h b/Telegram/SourceFiles/menu/add_action_callback.h deleted file mode 100644 index 1185c001ba..0000000000 --- a/Telegram/SourceFiles/menu/add_action_callback.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -namespace Ui { -class PopupMenu; -} // namespace Ui - -namespace Menu { - -struct MenuCallback final { -public: - struct Args { - QString text; - Fn handler; - const style::icon *icon; - Fn)> fillSubmenu; - bool isSeparator = false; - bool isAttention = false; - }; - using Callback = Fn; - - explicit MenuCallback(Callback callback); - - QAction *operator()(Args &&args) const; - QAction *operator()( - const QString &text, - Fn handler, - const style::icon *icon) const; -private: - Callback _callback; -}; - -} // namespace Menu diff --git a/Telegram/SourceFiles/menu/add_action_callback_factory.cpp b/Telegram/SourceFiles/menu/add_action_callback_factory.cpp deleted file mode 100644 index abd953a2fe..0000000000 --- a/Telegram/SourceFiles/menu/add_action_callback_factory.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "menu/add_action_callback_factory.h" - -#include "menu/add_action_callback.h" -#include "ui/widgets/menu/menu_action.h" -#include "ui/widgets/popup_menu.h" -#include "styles/style_menu_icons.h" - -namespace Menu { - -MenuCallback CreateAddActionCallback( - const base::unique_qptr &menu) { - return MenuCallback([&](MenuCallback::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(); - } else if (a.isAttention) { - return menu->addAction(base::make_unique_q( - menu, - st::menuWithIconsAttention, - Ui::Menu::CreateAction( - menu->menu().get(), - a.text, - std::move(a.handler)), - a.icon, - a.icon)); - } - return menu->addAction(a.text, std::move(a.handler), a.icon); - }); -} - -} // namespace Menu diff --git a/Telegram/SourceFiles/menu/add_action_callback_factory.h b/Telegram/SourceFiles/menu/add_action_callback_factory.h deleted file mode 100644 index dae8c338cf..0000000000 --- a/Telegram/SourceFiles/menu/add_action_callback_factory.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -#include "base/unique_qptr.h" - -namespace Ui { -class PopupMenu; -} // namespace Ui - -namespace Menu { - -struct MenuCallback; - -[[nodiscard]] MenuCallback CreateAddActionCallback( - const base::unique_qptr &menu); - -} // namespace Menu diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index 42a7283640..ab540f48da 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/widgets/box_content_divider.h" #include "ui/widgets/buttons.h" +#include "ui/widgets/menu/menu_add_action_callback.h" #include "boxes/abstract_box.h" #include "boxes/sessions_box.h" #include "window/themes/window_theme_editor_box.h" @@ -306,7 +307,7 @@ void FillMenu( not_null controller, Type type, Fn showOther, - Menu::MenuCallback addAction) { + Ui::Menu::MenuCallback addAction) { const auto window = &controller->window(); if (type == Chat::Id()) { addAction( diff --git a/Telegram/SourceFiles/settings/settings_common.h b/Telegram/SourceFiles/settings/settings_common.h index a9d09f7b76..cf5b6fda2e 100644 --- a/Telegram/SourceFiles/settings/settings_common.h +++ b/Telegram/SourceFiles/settings/settings_common.h @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "menu/add_action_callback.h" #include "ui/rp_widget.h" #include "ui/round_rect.h" #include "base/object_ptr.h" @@ -28,6 +27,10 @@ class SettingsButton; class AbstractButton; } // namespace Ui +namespace Ui::Menu { +struct MenuCallback; +} // namespace Ui::Menu + namespace Window { class SessionController; } // namespace Window @@ -218,6 +221,6 @@ void FillMenu( not_null controller, Type type, Fn showOther, - Menu::MenuCallback addAction); + Ui::Menu::MenuCallback addAction); } // namespace Settings diff --git a/Telegram/SourceFiles/settings/settings_information.cpp b/Telegram/SourceFiles/settings/settings_information.cpp index 625b41fcf5..71830aa702 100644 --- a/Telegram/SourceFiles/settings/settings_information.cpp +++ b/Telegram/SourceFiles/settings/settings_information.cpp @@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/input_fields.h" #include "ui/widgets/popup_menu.h" #include "ui/widgets/box_content_divider.h" +#include "ui/widgets/menu/menu_add_action_callback_factory.h" #include "ui/boxes/confirm_box.h" #include "ui/text/text_utilities.h" #include "ui/special_buttons.h" @@ -38,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "main/main_account.h" #include "main/main_session.h" #include "main/main_domain.h" -#include "menu/add_action_callback_factory.h" #include "mtproto/mtproto_dc_options.h" #include "window/window_session_controller.h" #include "window/window_controller.h" @@ -568,7 +568,8 @@ void SetupAccountsWrap( } else if (which != Qt::RightButton) { return; } - const auto addAction = Menu::CreateAddActionCallback(state->menu); + const auto addAction = Ui::Menu::CreateAddActionCallback( + state->menu); if (!state->menu && IsAltShift(raw->clickModifiers()) && !locked) { state->menu = base::make_unique_q( raw, diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index 3f93800c66..d7bf74ff46 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/separate_panel.h" #include "ui/widgets/buttons.h" #include "ui/widgets/labels.h" +#include "ui/widgets/menu/menu_add_action_callback.h" #include "ui/wrap/fade_wrap.h" #include "lang/lang_keys.h" #include "webview/webview_embed.h" @@ -22,8 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/debug_log.h" #include "styles/style_payments.h" #include "styles/style_layers.h" - -#include "base/timer_rpl.h" +#include "styles/style_menu_icons.h" #include #include @@ -334,12 +334,16 @@ Panel::Panel( Fn handleInvoice, Fn sendData, Fn close, + MenuButtons menuButtons, + Fn handleMenuButton, Fn themeParams) : _userDataPath(userDataPath) , _handleLocalUri(std::move(handleLocalUri)) , _handleInvoice(std::move(handleInvoice)) , _sendData(std::move(sendData)) , _close(std::move(close)) +, _menuButtons(menuButtons) +, _handleMenuButton(std::move(handleMenuButton)) , _widget(std::make_unique()) { _widget->setInnerSize(st::paymentsPanelSize); _widget->setWindowFlag(Qt::WindowStaysOnTopHint, false); @@ -531,6 +535,32 @@ bool Panel::showWebview( label->show(); _webviewBottom->resize(_webviewBottom->width(), height); } + _widget->setMenuAllowed([=](const Ui::Menu::MenuCallback &callback) { + if (_menuButtons & MenuButton::Settings) { + callback(tr::lng_bot_settings(tr::now), [=] { + postEvent("settings_button_pressed"); + }, &st::menuIconSettings); + } + if (_menuButtons & MenuButton::OpenBot) { + callback(tr::lng_bot_open(tr::now), [=] { + _handleMenuButton(MenuButton::OpenBot); + }, &st::menuIconLeave); + } + callback(tr::lng_bot_reload_page(tr::now), [=] { + _webview->window.reload(); + }, &st::menuIconRestore); + if (_menuButtons & MenuButton::RemoveFromMenu) { + const auto handler = [=] { + _handleMenuButton(MenuButton::RemoveFromMenu); + }; + callback({ + .text = tr::lng_bot_remove_from_menu(tr::now), + .handler = handler, + .icon = &st::menuIconDeleteAttention, + .isAttention = true, + }); + } + }); return true; } @@ -947,6 +977,8 @@ std::unique_ptr Show(Args &&args) { std::move(args.handleInvoice), std::move(args.sendData), std::move(args.close), + args.menuButtons, + std::move(args.handleMenuButton), std::move(args.themeParams)); if (!result->showWebview(args.url, params, std::move(args.bottom))) { const auto available = Webview::Availability(); diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h index 660ce3d86e..8726b6f3cb 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h @@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "base/object_ptr.h" #include "base/weak_ptr.h" +#include "base/flags.h" namespace Ui { class BoxContent; @@ -30,6 +31,15 @@ struct MainButtonArgs { QString text; }; +enum class MenuButton { + None = 0x00, + Settings = 0x01, + OpenBot = 0x02, + RemoveFromMenu = 0x04, +}; +inline constexpr bool is_flag_type(MenuButton) { return true; } +using MenuButtons = base::flags; + class Panel final : public base::has_weak_ptr { public: Panel( @@ -39,6 +49,8 @@ public: Fn handleInvoice, Fn sendData, Fn close, + MenuButtons menuButtons, + Fn handleMenuButton, Fn themeParams); ~Panel(); @@ -92,6 +104,8 @@ private: Fn _handleInvoice; Fn _sendData; Fn _close; + MenuButtons _menuButtons = {}; + Fn _handleMenuButton; std::unique_ptr _widget; std::unique_ptr _webview; std::unique_ptr _webviewBottom; @@ -117,6 +131,8 @@ struct Args { Fn handleInvoice; Fn sendData; Fn close; + MenuButtons menuButtons; + Fn handleMenuButton; Fn themeParams; }; [[nodiscard]] std::unique_ptr Show(Args &&args); diff --git a/Telegram/SourceFiles/ui/menu_icons.style b/Telegram/SourceFiles/ui/menu_icons.style index 8d8c08ecea..08e360f827 100644 --- a/Telegram/SourceFiles/ui/menu_icons.style +++ b/Telegram/SourceFiles/ui/menu_icons.style @@ -8,32 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL using "ui/colors.palette"; using "ui/widgets/widgets.style"; -menuIconColor: windowBoldFg; -menuIconAttentionColor: attentionButtonFg; - -menuIconSubmenuArrow: icon {{ "menu/submenu_arrow", menuIconColor }}; - -menuWithIcons: Menu(defaultMenu) { - itemIconPosition: point(15px, 5px); - itemPadding: margins(54px, 8px, 17px, 8px); - - arrow: menuIconSubmenuArrow; -} -menuWithIconsAttention: Menu(menuWithIcons) { - itemFg: attentionButtonFg; - itemFgOver: attentionButtonFgOver; -} -popupMenuWithIcons: PopupMenu(defaultPopupMenu) { - scrollPadding: margins(0px, 5px, 0px, 5px); - menu: menuWithIcons; -} -dropdownMenuWithIcons: DropdownMenu(defaultDropdownMenu) { - wrap: InnerDropdown(defaultInnerDropdown) { - scrollPadding: margins(0px, 5px, 0px, 5px); - } - menu: menuWithIcons; -} - menuIconReactions: icon {{ "menu/read_reactions", menuIconColor }}; menuIconReply: icon {{ "menu/reply", menuIconColor }}; menuIconViewReplies: icon {{ "menu/view_replies", menuIconColor }}; @@ -112,6 +86,7 @@ menuIconSoundAdd: icon {{ "menu/sound_add", menuIconColor }}; menuIconFile: icon {{ "menu/file", menuIconColor }}; menuIconPhoto: icon {{ "menu/image", menuIconColor }}; menuIconAddToFolder: icon {{ "menu/add_to_folder", menuIconColor }}; +menuIconLeave: icon {{ "menu/leave", menuIconColor }}; menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }}; menuIconTTLAnyTextPosition: point(11px, 22px); diff --git a/Telegram/SourceFiles/window/window_peer_menu.h b/Telegram/SourceFiles/window/window_peer_menu.h index f84f377a4f..62afac6ef0 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.h +++ b/Telegram/SourceFiles/window/window_peer_menu.h @@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_common.h" #include "menu/menu_send.h" #include "data/data_poll.h" -#include "menu/add_action_callback.h" +#include "ui/widgets/menu/menu_add_action_callback.h" class History; @@ -39,7 +39,7 @@ class SessionNavigation; extern const char kOptionViewProfileInChatsListContextMenu[]; -using PeerMenuCallback = Menu::MenuCallback; +using PeerMenuCallback = Ui::Menu::MenuCallback; void FillDialogsEntryMenu( not_null controller, diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake index 365cdeb169..584630f3cb 100644 --- a/Telegram/cmake/td_ui.cmake +++ b/Telegram/cmake/td_ui.cmake @@ -105,10 +105,6 @@ PRIVATE media/player/media_player_dropdown.cpp media/player/media_player_dropdown.h - menu/add_action_callback.cpp - menu/add_action_callback.h - menu/add_action_callback_factory.cpp - menu/add_action_callback_factory.h menu/menu_check_item.cpp menu/menu_check_item.h menu/menu_ttl.cpp diff --git a/Telegram/lib_ui b/Telegram/lib_ui index b802516ca7..6ae122f1b2 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit b802516ca73c9b20103b5e98d940490dfcc7fea8 +Subproject commit 6ae122f1b27332a27316892dada6050e2f225ad8 diff --git a/Telegram/lib_webview b/Telegram/lib_webview index cd22386a67..439b21ce26 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit cd22386a67d80db31aec007f636228697e488d76 +Subproject commit 439b21ce26acbdce808bc4777f3abc3adf430857