Support attach bot menu / reload / settings.

This commit is contained in:
John Preston 2022-06-03 20:07:33 +04:00
parent b023044cc8
commit df17f20a47
21 changed files with 140 additions and 185 deletions

View file

@ -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_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_sure_add" = "Add as admin";
"lng_bot_no_webview" = "Unfortunately, you can't open such menu with current system configuration."; "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_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" = "{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_add_to_menu_done" = "Bot added to the menu.";
"lng_bot_menu_not_supported" = "This bot isn't supported in the attach menu."; "lng_bot_menu_not_supported" = "This bot isn't supported in the attach menu.";

View file

@ -38,7 +38,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "menu/add_action_callback_factory.h"
#include "storage/storage_account.h" #include "storage/storage_account.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "main/main_session.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_session_controller.h"
#include "window/window_peer_menu.h" #include "window/window_peer_menu.h"
#include "ui/widgets/multi_select.h" #include "ui/widgets/multi_select.h"
#include "ui/widgets/menu/menu_add_action_callback_factory.h"
#include "ui/empty_userpic.h" #include "ui/empty_userpic.h"
#include "ui/unread_badge.h" #include "ui/unread_badge.h"
#include "boxes/filters/edit_filter_box.h" #include "boxes/filters/edit_filter_box.h"
@ -1828,7 +1828,7 @@ void InnerWidget::contextMenuEvent(QContextMenuEvent *e) {
fillArchiveSearchMenu(_menu.get()); fillArchiveSearchMenu(_menu.get());
} }
} else { } else {
const auto addAction = Menu::CreateAddActionCallback(_menu); const auto addAction = Ui::Menu::CreateAddActionCallback(_menu);
Window::FillDialogsEntryMenu( Window::FillDialogsEntryMenu(
_controller, _controller,
Dialogs::EntryState{ Dialogs::EntryState{

View file

@ -19,7 +19,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h" #include "mainwidget.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "menu/add_action_callback_factory.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "core/shortcuts.h" #include "core/shortcuts.h"
@ -27,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/core_settings.h" #include "core/core_settings.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/popup_menu.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/effects/radial_animation.h"
#include "ui/toasts/common_toasts.h" #include "ui/toasts/common_toasts.h"
#include "ui/boxes/report_box.h" // Ui::ReportReason #include "ui/boxes/report_box.h" // Ui::ReportReason
@ -306,7 +306,7 @@ void TopBarWidget::showPeerMenu() {
if (!created) { if (!created) {
return; return;
} }
const auto addAction = Menu::CreateAddActionCallback(_menu); const auto addAction = Ui::Menu::CreateAddActionCallback(_menu);
Window::FillDialogsEntryMenu(_controller, _activeChat, addAction); Window::FillDialogsEntryMenu(_controller, _activeChat, addAction);
if (_menu->empty()) { if (_menu->empty()) {
_menu = nullptr; _menu = nullptr;

View file

@ -108,7 +108,6 @@ private:
void call(); void call();
void groupCall(); void groupCall();
void startGroupCall(not_null<ChannelData*> megagroup, bool confirmed);
void showPeerMenu(); void showPeerMenu();
void showGroupCallMenu(not_null<PeerData*> peer); void showGroupCallMenu(not_null<PeerData*> peer);
void toggleInfoSection(); void toggleInfoSection();

View file

@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/shadow.h" #include "ui/widgets/shadow.h"
#include "ui/widgets/popup_menu.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/wrap/fade_wrap.h"
#include "ui/search_field_controller.h" #include "ui/search_field_controller.h"
#include "core/application.h" #include "core/application.h"
@ -34,7 +35,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "boxes/peer_list_box.h" #include "boxes/peer_list_box.h"
#include "ui/boxes/confirm_box.h" #include "ui/boxes/confirm_box.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "menu/add_action_callback_factory.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "data/data_download_manager.h" #include "data/data_download_manager.h"
#include "data/data_session.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()) { if (key().isDownloads()) {
addAction( addAction(
tr::lng_context_delete_all_files(tr::now), tr::lng_context_delete_all_files(tr::now),

View file

@ -107,6 +107,7 @@ struct ParsedBot {
.name = qs(data.vshort_name()), .name = qs(data.vshort_name()),
.types = ResolvePeerTypes(data.vpeer_types().v), .types = ResolvePeerTypes(data.vpeer_types().v),
.inactive = data.is_inactive(), .inactive = data.is_inactive(),
.hasSettings = data.is_has_settings(),
} : std::optional<AttachWebViewBot>(); } : std::optional<AttachWebViewBot>();
}); });
if (result && result->icon) { if (result && result->icon) {
@ -818,6 +819,61 @@ void AttachWebView::show(
return value.text; return value.text;
}); });
ActiveWebViews().emplace(this); 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({ _panel = Ui::BotWebView::Show({
.url = url, .url = url,
.userDataPath = _session->domain().local().webviewDataPath(), .userDataPath = _session->domain().local().webviewDataPath(),
@ -827,6 +883,8 @@ void AttachWebView::show(
.handleInvoice = handleInvoice, .handleInvoice = handleInvoice,
.sendData = sendData, .sendData = sendData,
.close = close, .close = close,
.menuButtons = buttons,
.handleMenuButton = handleMenuButton,
.themeParams = [] { return Window::Theme::WebViewParams(); }, .themeParams = [] { return Window::Theme::WebViewParams(); },
}); });
*panel = _panel.get(); *panel = _panel.get();
@ -881,7 +939,11 @@ void AttachWebView::confirmAddToMenu(
return; return;
} }
_confirmAddBox = active->show(Ui::MakeConfirmBox({ _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, done,
})); }));
} }

View file

@ -56,6 +56,7 @@ struct AttachWebViewBot {
QString name; QString name;
PeerTypes types = 0; PeerTypes types = 0;
bool inactive = false; bool inactive = false;
bool hasSettings = false;
}; };
class AttachWebView final : public base::has_weak_ptr { class AttachWebView final : public base::has_weak_ptr {

View file

@ -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<void()> handler,
const style::icon *icon) const {
return _callback({ text, std::move(handler), icon, nullptr });
}
} // namespace Menu

View file

@ -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<void()> handler;
const style::icon *icon;
Fn<void(not_null<Ui::PopupMenu*>)> fillSubmenu;
bool isSeparator = false;
bool isAttention = false;
};
using Callback = Fn<QAction*(Args&&)>;
explicit MenuCallback(Callback callback);
QAction *operator()(Args &&args) const;
QAction *operator()(
const QString &text,
Fn<void()> handler,
const style::icon *icon) const;
private:
Callback _callback;
};
} // namespace Menu

View file

@ -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<Ui::PopupMenu> &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<QMenu>(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<Ui::Menu::Action>(
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

View file

@ -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<Ui::PopupMenu> &menu);
} // namespace Menu

View file

@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/widgets/box_content_divider.h" #include "ui/widgets/box_content_divider.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/menu/menu_add_action_callback.h"
#include "boxes/abstract_box.h" #include "boxes/abstract_box.h"
#include "boxes/sessions_box.h" #include "boxes/sessions_box.h"
#include "window/themes/window_theme_editor_box.h" #include "window/themes/window_theme_editor_box.h"
@ -306,7 +307,7 @@ void FillMenu(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
Type type, Type type,
Fn<void(Type)> showOther, Fn<void(Type)> showOther,
Menu::MenuCallback addAction) { Ui::Menu::MenuCallback addAction) {
const auto window = &controller->window(); const auto window = &controller->window();
if (type == Chat::Id()) { if (type == Chat::Id()) {
addAction( addAction(

View file

@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#pragma once #pragma once
#include "menu/add_action_callback.h"
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
#include "ui/round_rect.h" #include "ui/round_rect.h"
#include "base/object_ptr.h" #include "base/object_ptr.h"
@ -28,6 +27,10 @@ class SettingsButton;
class AbstractButton; class AbstractButton;
} // namespace Ui } // namespace Ui
namespace Ui::Menu {
struct MenuCallback;
} // namespace Ui::Menu
namespace Window { namespace Window {
class SessionController; class SessionController;
} // namespace Window } // namespace Window
@ -218,6 +221,6 @@ void FillMenu(
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
Type type, Type type,
Fn<void(Type)> showOther, Fn<void(Type)> showOther,
Menu::MenuCallback addAction); Ui::Menu::MenuCallback addAction);
} // namespace Settings } // namespace Settings

View file

@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
#include "ui/widgets/box_content_divider.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/boxes/confirm_box.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/special_buttons.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_account.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_domain.h" #include "main/main_domain.h"
#include "menu/add_action_callback_factory.h"
#include "mtproto/mtproto_dc_options.h" #include "mtproto/mtproto_dc_options.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "window/window_controller.h" #include "window/window_controller.h"
@ -568,7 +568,8 @@ void SetupAccountsWrap(
} else if (which != Qt::RightButton) { } else if (which != Qt::RightButton) {
return; return;
} }
const auto addAction = Menu::CreateAddActionCallback(state->menu); const auto addAction = Ui::Menu::CreateAddActionCallback(
state->menu);
if (!state->menu && IsAltShift(raw->clickModifiers()) && !locked) { if (!state->menu && IsAltShift(raw->clickModifiers()) && !locked) {
state->menu = base::make_unique_q<Ui::PopupMenu>( state->menu = base::make_unique_q<Ui::PopupMenu>(
raw, raw,

View file

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/separate_panel.h" #include "ui/widgets/separate_panel.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "ui/widgets/menu/menu_add_action_callback.h"
#include "ui/wrap/fade_wrap.h" #include "ui/wrap/fade_wrap.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "webview/webview_embed.h" #include "webview/webview_embed.h"
@ -22,8 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/debug_log.h" #include "base/debug_log.h"
#include "styles/style_payments.h" #include "styles/style_payments.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_menu_icons.h"
#include "base/timer_rpl.h"
#include <QtCore/QJsonDocument> #include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject> #include <QtCore/QJsonObject>
@ -334,12 +334,16 @@ Panel::Panel(
Fn<void(QString)> handleInvoice, Fn<void(QString)> handleInvoice,
Fn<void(QByteArray)> sendData, Fn<void(QByteArray)> sendData,
Fn<void()> close, Fn<void()> close,
MenuButtons menuButtons,
Fn<void(MenuButton)> handleMenuButton,
Fn<Webview::ThemeParams()> themeParams) Fn<Webview::ThemeParams()> themeParams)
: _userDataPath(userDataPath) : _userDataPath(userDataPath)
, _handleLocalUri(std::move(handleLocalUri)) , _handleLocalUri(std::move(handleLocalUri))
, _handleInvoice(std::move(handleInvoice)) , _handleInvoice(std::move(handleInvoice))
, _sendData(std::move(sendData)) , _sendData(std::move(sendData))
, _close(std::move(close)) , _close(std::move(close))
, _menuButtons(menuButtons)
, _handleMenuButton(std::move(handleMenuButton))
, _widget(std::make_unique<SeparatePanel>()) { , _widget(std::make_unique<SeparatePanel>()) {
_widget->setInnerSize(st::paymentsPanelSize); _widget->setInnerSize(st::paymentsPanelSize);
_widget->setWindowFlag(Qt::WindowStaysOnTopHint, false); _widget->setWindowFlag(Qt::WindowStaysOnTopHint, false);
@ -531,6 +535,32 @@ bool Panel::showWebview(
label->show(); label->show();
_webviewBottom->resize(_webviewBottom->width(), height); _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; return true;
} }
@ -947,6 +977,8 @@ std::unique_ptr<Panel> Show(Args &&args) {
std::move(args.handleInvoice), std::move(args.handleInvoice),
std::move(args.sendData), std::move(args.sendData),
std::move(args.close), std::move(args.close),
args.menuButtons,
std::move(args.handleMenuButton),
std::move(args.themeParams)); std::move(args.themeParams));
if (!result->showWebview(args.url, params, std::move(args.bottom))) { if (!result->showWebview(args.url, params, std::move(args.bottom))) {
const auto available = Webview::Availability(); const auto available = Webview::Availability();

View file

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/object_ptr.h" #include "base/object_ptr.h"
#include "base/weak_ptr.h" #include "base/weak_ptr.h"
#include "base/flags.h"
namespace Ui { namespace Ui {
class BoxContent; class BoxContent;
@ -30,6 +31,15 @@ struct MainButtonArgs {
QString text; 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<MenuButton>;
class Panel final : public base::has_weak_ptr { class Panel final : public base::has_weak_ptr {
public: public:
Panel( Panel(
@ -39,6 +49,8 @@ public:
Fn<void(QString)> handleInvoice, Fn<void(QString)> handleInvoice,
Fn<void(QByteArray)> sendData, Fn<void(QByteArray)> sendData,
Fn<void()> close, Fn<void()> close,
MenuButtons menuButtons,
Fn<void(MenuButton)> handleMenuButton,
Fn<Webview::ThemeParams()> themeParams); Fn<Webview::ThemeParams()> themeParams);
~Panel(); ~Panel();
@ -92,6 +104,8 @@ private:
Fn<void(QString)> _handleInvoice; Fn<void(QString)> _handleInvoice;
Fn<void(QByteArray)> _sendData; Fn<void(QByteArray)> _sendData;
Fn<void()> _close; Fn<void()> _close;
MenuButtons _menuButtons = {};
Fn<void(MenuButton)> _handleMenuButton;
std::unique_ptr<SeparatePanel> _widget; std::unique_ptr<SeparatePanel> _widget;
std::unique_ptr<WebviewWithLifetime> _webview; std::unique_ptr<WebviewWithLifetime> _webview;
std::unique_ptr<RpWidget> _webviewBottom; std::unique_ptr<RpWidget> _webviewBottom;
@ -117,6 +131,8 @@ struct Args {
Fn<void(QString)> handleInvoice; Fn<void(QString)> handleInvoice;
Fn<void(QByteArray)> sendData; Fn<void(QByteArray)> sendData;
Fn<void()> close; Fn<void()> close;
MenuButtons menuButtons;
Fn<void(MenuButton)> handleMenuButton;
Fn<Webview::ThemeParams()> themeParams; Fn<Webview::ThemeParams()> themeParams;
}; };
[[nodiscard]] std::unique_ptr<Panel> Show(Args &&args); [[nodiscard]] std::unique_ptr<Panel> Show(Args &&args);

View file

@ -8,32 +8,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
using "ui/colors.palette"; using "ui/colors.palette";
using "ui/widgets/widgets.style"; 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 }}; menuIconReactions: icon {{ "menu/read_reactions", menuIconColor }};
menuIconReply: icon {{ "menu/reply", menuIconColor }}; menuIconReply: icon {{ "menu/reply", menuIconColor }};
menuIconViewReplies: icon {{ "menu/view_replies", menuIconColor }}; menuIconViewReplies: icon {{ "menu/view_replies", menuIconColor }};
@ -112,6 +86,7 @@ menuIconSoundAdd: icon {{ "menu/sound_add", menuIconColor }};
menuIconFile: icon {{ "menu/file", menuIconColor }}; menuIconFile: icon {{ "menu/file", menuIconColor }};
menuIconPhoto: icon {{ "menu/image", menuIconColor }}; menuIconPhoto: icon {{ "menu/image", menuIconColor }};
menuIconAddToFolder: icon {{ "menu/add_to_folder", menuIconColor }}; menuIconAddToFolder: icon {{ "menu/add_to_folder", menuIconColor }};
menuIconLeave: icon {{ "menu/leave", menuIconColor }};
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }}; menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
menuIconTTLAnyTextPosition: point(11px, 22px); menuIconTTLAnyTextPosition: point(11px, 22px);

View file

@ -10,7 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "api/api_common.h" #include "api/api_common.h"
#include "menu/menu_send.h" #include "menu/menu_send.h"
#include "data/data_poll.h" #include "data/data_poll.h"
#include "menu/add_action_callback.h" #include "ui/widgets/menu/menu_add_action_callback.h"
class History; class History;
@ -39,7 +39,7 @@ class SessionNavigation;
extern const char kOptionViewProfileInChatsListContextMenu[]; extern const char kOptionViewProfileInChatsListContextMenu[];
using PeerMenuCallback = Menu::MenuCallback; using PeerMenuCallback = Ui::Menu::MenuCallback;
void FillDialogsEntryMenu( void FillDialogsEntryMenu(
not_null<SessionController*> controller, not_null<SessionController*> controller,

View file

@ -105,10 +105,6 @@ PRIVATE
media/player/media_player_dropdown.cpp media/player/media_player_dropdown.cpp
media/player/media_player_dropdown.h 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.cpp
menu/menu_check_item.h menu/menu_check_item.h
menu/menu_ttl.cpp menu/menu_ttl.cpp

@ -1 +1 @@
Subproject commit b802516ca73c9b20103b5e98d940490dfcc7fea8 Subproject commit 6ae122f1b27332a27316892dada6050e2f225ad8

@ -1 +1 @@
Subproject commit cd22386a67d80db31aec007f636228697e488d76 Subproject commit 439b21ce26acbdce808bc4777f3abc3adf430857