2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Custom scroll bar in WebKit / Chromium.

This commit is contained in:
John Preston
2022-04-12 19:48:32 +04:00
parent 9510d38929
commit d4cb56a73d
10 changed files with 52 additions and 20 deletions

View File

@@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "api/api_cloud_password.h"
#include "window/themes/window_theme.h"
#include "webview/webview_interface.h"
#include <QJsonDocument>
#include <QJsonObject>

View File

@@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "core/core_cloud_password.h"
#include "window/themes/window_theme.h"
#include "webview/webview_interface.h"
#include "styles/style_payments.h" // paymentsThumbnailSize.
#include <QtCore/QJsonDocument>
@@ -242,7 +243,7 @@ void Form::requestForm() {
MTP_flags(MTPpayments_GetPaymentForm::Flag::f_theme_params),
_peer->input,
MTP_int(_msgId),
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams()))
MTP_dataJSON(MTP_bytes(Window::Theme::WebViewParams().json))
)).done([=](const MTPpayments_PaymentForm &result) {
hideProgress();
result.match([&](const auto &data) {

View File

@@ -783,15 +783,20 @@ void Panel::showWebviewError(
showCriticalError(rich);
}
void Panel::updateThemeParams(const QByteArray &json) {
void Panel::updateThemeParams(const Webview::ThemeParams &params) {
if (!_webview || !_webview->window.widget()) {
return;
}
_webview->window.updateTheme(
params.scrollBg,
params.scrollBgOver,
params.scrollBarBg,
params.scrollBarBgOver);
_webview->window.eval(R"(
if (window.TelegramGameProxy) {
window.TelegramGameProxy.receiveEvent(
"theme_changed",
{ "theme_params": )" + json + R"( });
{ "theme_params": )" + params.json + R"( });
}
)");
}

View File

@@ -18,6 +18,7 @@ class Checkbox;
namespace Webview {
struct Available;
struct ThemeParams;
} // namespace Webview
namespace Payments::Ui {
@@ -76,7 +77,7 @@ public:
const QString &url,
bool allowBack,
rpl::producer<QString> bottomText);
void updateThemeParams(const QByteArray &json);
void updateThemeParams(const Webview::ThemeParams &params);
[[nodiscard]] rpl::producer<> backRequests() const;