/* 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/object_ptr.h" namespace Ui { class BoxContent; class RpWidget; class SeparatePanel; } // namespace Ui namespace Webview { struct Available; } // namespace Webview namespace Ui::BotWebView { class Panel final { public: Panel( const QString &userDataPath, rpl::producer title, Fn sendData, Fn close, Fn themeParams); ~Panel(); void requestActivate(); void toggleProgress(bool shown); bool showWebview( const QString &url, rpl::producer bottomText); void showBox(object_ptr box); void showToast(const TextWithEntities &text); void showCriticalError(const TextWithEntities &text); void showWebviewError( const QString &text, const Webview::Available &information); void updateThemeParams(const QByteArray &json); [[nodiscard]] rpl::lifetime &lifetime(); private: struct Progress; struct WebviewWithLifetime; bool createWebview(); void showWebviewProgress(); void hideWebviewProgress(); void setTitle(rpl::producer title); [[nodiscard]] bool progressWithBackground() const; [[nodiscard]] QRect progressRect() const; void setupProgressGeometry(); QString _userDataPath; Fn _sendData; Fn _close; std::unique_ptr _widget; std::unique_ptr _webview; std::unique_ptr _webviewBottom; std::unique_ptr _progress; bool _webviewProgress = false; bool _themeUpdateScheduled = false; }; struct Args { QString url; QString userDataPath; rpl::producer title; rpl::producer bottom; Fn sendData; Fn close; Fn themeParams; }; [[nodiscard]] std::unique_ptr Show(Args &&args); } // namespace Ui::BotWebView