mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Support theming for webview-s (payments, attach).
This commit is contained in:
@@ -38,6 +38,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "styles/style_chat.h"
|
||||
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QJsonDocument>
|
||||
#include <QtCore/QJsonObject>
|
||||
|
||||
namespace Window {
|
||||
namespace Theme {
|
||||
@@ -1489,5 +1491,31 @@ bool ReadPaletteValues(const QByteArray &content, Fn<bool(QLatin1String name, QL
|
||||
return true;
|
||||
}
|
||||
|
||||
[[nodiscard]] QByteArray WebViewParams() {
|
||||
const auto colors = std::vector<std::pair<QString, const style::color&>>{
|
||||
{ "bg_color", st::windowBg },
|
||||
{ "text_color", st::windowFg },
|
||||
{ "hint_color", st::windowSubTextFg },
|
||||
{ "link_color", st::windowActiveTextFg },
|
||||
{ "button_color", st::windowBgActive },
|
||||
{ "button_text_color", st::windowFgActive },
|
||||
};
|
||||
auto object = QJsonObject();
|
||||
for (const auto &[name, color] : colors) {
|
||||
auto r = 0;
|
||||
auto g = 0;
|
||||
auto b = 0;
|
||||
color->c.getRgb(&r, &g, &b);
|
||||
const auto hex = [](int component) {
|
||||
const auto digit = [](int c) {
|
||||
return QChar((c < 10) ? ('0' + c) : ('a' + c - 10));
|
||||
};
|
||||
return QString() + digit(component / 16) + digit(component % 16);
|
||||
};
|
||||
object.insert(name, '#' + hex(r) + hex(g) + hex(b));
|
||||
}
|
||||
return QJsonDocument(object).toJson(QJsonDocument::Compact);
|
||||
}
|
||||
|
||||
} // namespace Theme
|
||||
} // namespace Window
|
||||
|
Reference in New Issue
Block a user