mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-05 19:33:35 +00:00
Added applying of wallpaper pattern from theme settings.
This commit is contained in:
@@ -63,6 +63,19 @@ constexpr auto kGiftThemesLimit = 24;
|
||||
|
||||
bool IsTestingColors/* = false*/;
|
||||
|
||||
[[nodiscard]] Window::SessionController *ChatThemeWindow(
|
||||
not_null<Main::Session*> session) {
|
||||
const auto &windows = session->windows();
|
||||
if (windows.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
const auto primary = ranges::find_if(windows, [](
|
||||
not_null<Window::SessionController*> window) {
|
||||
return window->isPrimary();
|
||||
});
|
||||
return (primary != end(windows)) ? *primary : windows.front();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
CloudTheme CloudTheme::Parse(
|
||||
@@ -308,14 +321,23 @@ void CloudThemes::reloadCurrent() {
|
||||
|
||||
void CloudThemes::applyUpdate(const MTPTheme &theme) {
|
||||
theme.match([&](const MTPDtheme &data) {
|
||||
const auto cloud = CloudTheme::Parse(_session, data);
|
||||
const auto cloud = CloudTheme::Parse(_session, data, true);
|
||||
const auto &object = Window::Theme::Background()->themeObject();
|
||||
if ((cloud.id != object.cloud.id)
|
||||
|| (cloud.documentId == object.cloud.documentId)
|
||||
|| !cloud.documentId) {
|
||||
if (cloud.id != object.cloud.id) {
|
||||
return;
|
||||
} else if (cloud.documentId
|
||||
&& (cloud.documentId != object.cloud.documentId)) {
|
||||
applyFromDocument(cloud);
|
||||
return;
|
||||
} else if (cloud.settings.empty()) {
|
||||
return;
|
||||
}
|
||||
applyFromDocument(cloud);
|
||||
auto updated = object;
|
||||
updated.cloud = cloud;
|
||||
Window::Theme::Background()->setThemeObject(updated);
|
||||
if (const auto controller = ChatThemeWindow(_session)) {
|
||||
Window::Theme::CheckChatThemeWallPaper(controller);
|
||||
}
|
||||
});
|
||||
scheduleReload();
|
||||
}
|
||||
@@ -819,17 +841,10 @@ void CloudThemes::checkAppliedChatTheme() {
|
||||
if (!fresh) {
|
||||
return;
|
||||
}
|
||||
const auto &windows = _session->windows();
|
||||
if (windows.empty()) {
|
||||
const auto controller = ChatThemeWindow(_session);
|
||||
if (!controller) {
|
||||
return;
|
||||
}
|
||||
const auto primary = ranges::find_if(windows, [](
|
||||
not_null<Window::SessionController*> window) {
|
||||
return window->isPrimary();
|
||||
});
|
||||
const auto controller = (primary != end(windows))
|
||||
? *primary
|
||||
: windows.front();
|
||||
if (!SameThemeSettings(cloud.settings, fresh->settings)) {
|
||||
ApplyChatTheme(
|
||||
controller,
|
||||
|
||||
@@ -1069,7 +1069,7 @@ void writeTheme(const Window::Theme::Saved &saved) {
|
||||
const auto &cache = saved.cache;
|
||||
const auto tag = QString(kThemeNewPathRelativeTag);
|
||||
auto chatTheme = QByteArray();
|
||||
if (!object.cloud.emoticon.isEmpty() && !object.cloud.settings.empty()) {
|
||||
if (!object.cloud.settings.empty()) {
|
||||
auto stream = QDataStream(&chatTheme, QIODevice::WriteOnly);
|
||||
stream.setVersion(QDataStream::Qt_5_1);
|
||||
stream
|
||||
|
||||
@@ -516,7 +516,7 @@ Fn<void()> SavePreparedTheme(
|
||||
done();
|
||||
|
||||
const auto cloud = result.match([&](const MTPDtheme &data) {
|
||||
const auto result = Data::CloudTheme::Parse(session, data);
|
||||
const auto result = Data::CloudTheme::Parse(session, data, true);
|
||||
session->data().cloudThemes().savedFromEditor(result);
|
||||
return result;
|
||||
});
|
||||
|
||||
@@ -359,7 +359,7 @@ void CheckChatThemeWallPaper(not_null<SessionController*> controller) {
|
||||
}
|
||||
const auto background = Background();
|
||||
auto cloud = background->themeObject().cloud;
|
||||
if (cloud.emoticon.isEmpty() || cloud.settings.empty()) {
|
||||
if (cloud.settings.empty()) {
|
||||
return;
|
||||
}
|
||||
auto used = ChatThemeVariant(cloud, IsNightMode());
|
||||
|
||||
Reference in New Issue
Block a user