Show error on attempt to scan QR in bot app.

Fixes #26886.
This commit is contained in:
John Preston 2024-07-18 10:47:50 +02:00
parent 2f22a8f46b
commit 8a6a749296
3 changed files with 17 additions and 0 deletions

View file

@ -3160,6 +3160,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_bot_close_warning_sure" = "Close anyway";
"lng_bot_add_to_side_menu" = "{bot} asks your permission to be added as an option to your main menu so you can access it any time.";
"lng_bot_add_to_side_menu_done" = "Bot added to the main menu.";
"lng_bot_no_scan_qr" = "QR Codes for bots are not supported on Desktop. Please use one of Telegram's mobile apps.";
"lng_typing" = "typing";
"lng_user_typing" = "{user} is typing";

View file

@ -694,6 +694,8 @@ bool Panel::createWebview(const Webview::ThemeParams &params) {
openInvoice(arguments);
} else if (command == "web_app_open_popup") {
openPopup(arguments);
} else if (command == "web_app_open_scan_qr_popup") {
openScanQrPopup(arguments);
} else if (command == "web_app_request_write_access") {
requestWriteAccess();
} else if (command == "web_app_request_phone") {
@ -918,6 +920,19 @@ void Panel::openPopup(const QJsonObject &args) {
}
}
void Panel::openScanQrPopup(const QJsonObject &args) {
const auto widget = _webview->window.widget();
[[maybe_unused]] const auto ok = Webview::ShowBlockingPopup({
.parent = widget ? widget->window() : nullptr,
.text = tr::lng_bot_no_scan_qr(tr::now),
.buttons = { {
.id = "ok",
.text = tr::lng_box_ok(tr::now),
.type = Webview::PopupArgs::Button::Type::Ok,
}},
});
}
void Panel::requestWriteAccess() {
if (_inBlockingRequest) {
replyRequestWriteAccess(false);

View file

@ -132,6 +132,7 @@ private:
void openExternalLink(const QJsonObject &args);
void openInvoice(const QJsonObject &args);
void openPopup(const QJsonObject &args);
void openScanQrPopup(const QJsonObject &args);
void requestWriteAccess();
void replyRequestWriteAccess(bool allowed);
void requestPhone();