mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Move Window::Theme::Colorizer to style::colorizer.
This commit is contained in:
@@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "main/main_domain.h" // Domain::activeSessionValue.
|
||||
#include "ui/chat/chat_theme.h"
|
||||
#include "ui/image/image.h"
|
||||
#include "ui/style/style_palette_colorizer.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "boxes/confirm_box.h"
|
||||
#include "boxes/background_box.h"
|
||||
@@ -159,7 +160,7 @@ enum class SetResult {
|
||||
SetResult setColorSchemeValue(
|
||||
QLatin1String name,
|
||||
QLatin1String value,
|
||||
const Colorizer &colorizer,
|
||||
const style::colorizer &colorizer,
|
||||
Instance *out) {
|
||||
auto result = style::palette::SetResult::Ok;
|
||||
auto size = value.size();
|
||||
@@ -171,7 +172,7 @@ SetResult setColorSchemeValue(
|
||||
auto b = readHexUchar(data[5], data[6], error);
|
||||
auto a = (size == 9) ? readHexUchar(data[7], data[8], error) : uchar(255);
|
||||
if (colorizer) {
|
||||
Colorize(name, r, g, b, colorizer);
|
||||
style::colorize(name, r, g, b, colorizer);
|
||||
}
|
||||
if (error) {
|
||||
LOG(("Theme Warning: Skipping value '%1: %2' (expected a color value in #rrggbb or #rrggbbaa or a previously defined key in the color scheme)").arg(name).arg(value));
|
||||
@@ -206,7 +207,7 @@ SetResult setColorSchemeValue(
|
||||
|
||||
bool loadColorScheme(
|
||||
const QByteArray &content,
|
||||
const Colorizer &colorizer,
|
||||
const style::colorizer &colorizer,
|
||||
Instance *out) {
|
||||
auto unsupported = QMap<QLatin1String, QLatin1String>();
|
||||
return ReadPaletteValues(content, [&](QLatin1String name, QLatin1String value) {
|
||||
@@ -268,7 +269,7 @@ bool loadBackground(zlib::FileToRead &file, QByteArray *outBackground, bool *out
|
||||
|
||||
bool LoadTheme(
|
||||
const QByteArray &content,
|
||||
const Colorizer &colorizer,
|
||||
const style::colorizer &colorizer,
|
||||
const std::optional<QByteArray> &editedPalette,
|
||||
Cached *cache = nullptr,
|
||||
Instance *out = nullptr) {
|
||||
@@ -282,7 +283,7 @@ bool LoadTheme(
|
||||
}
|
||||
zlib::FileToRead file(content);
|
||||
|
||||
const auto emptyColorizer = Colorizer();
|
||||
const auto emptyColorizer = style::colorizer();
|
||||
const auto &paletteColorizer = editedPalette ? emptyColorizer : colorizer;
|
||||
|
||||
unz_global_info globalInfo = { 0 };
|
||||
@@ -331,7 +332,7 @@ bool LoadTheme(
|
||||
return false;
|
||||
}
|
||||
if (colorizer) {
|
||||
Colorize(background, colorizer);
|
||||
style::colorize(background, colorizer);
|
||||
}
|
||||
if (cache) {
|
||||
auto buffer = QBuffer(&cache->background);
|
||||
@@ -353,7 +354,7 @@ bool LoadTheme(
|
||||
}
|
||||
}
|
||||
if (out) {
|
||||
out->palette.finalize();
|
||||
out->palette.finalize(paletteColorizer);
|
||||
}
|
||||
if (cache) {
|
||||
if (out) {
|
||||
@@ -1270,7 +1271,7 @@ void ApplyDefaultWithPath(const QString &themePath) {
|
||||
|
||||
bool ApplyEditedPalette(const QByteArray &content) {
|
||||
auto out = Instance();
|
||||
if (!loadColorScheme(content, Colorizer(), &out)) {
|
||||
if (!loadColorScheme(content, style::colorizer(), &out)) {
|
||||
return false;
|
||||
}
|
||||
style::main_palette::apply(out.palette);
|
||||
@@ -1420,7 +1421,7 @@ bool LoadFromFile(
|
||||
not_null<Instance*> out,
|
||||
Cached *outCache,
|
||||
QByteArray *outContent,
|
||||
const Colorizer &colorizer) {
|
||||
const style::colorizer &colorizer) {
|
||||
const auto content = readThemeContent(path);
|
||||
if (outContent) {
|
||||
*outContent = content;
|
||||
@@ -1432,7 +1433,12 @@ bool LoadFromContent(
|
||||
const QByteArray &content,
|
||||
not_null<Instance*> out,
|
||||
Cached *outCache) {
|
||||
return LoadTheme(content, Colorizer(), std::nullopt, outCache, out);
|
||||
return LoadTheme(
|
||||
content,
|
||||
style::colorizer(),
|
||||
std::nullopt,
|
||||
outCache,
|
||||
out);
|
||||
}
|
||||
|
||||
QString EditingPalettePath() {
|
||||
|
Reference in New Issue
Block a user