mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 23:57:16 +02:00
Don't watch theme file while using theme editor.
This commit is contained in:
parent
f7bc84fdd6
commit
ce39eb2da9
2 changed files with 23 additions and 16 deletions
|
@ -569,22 +569,7 @@ void ChatBackground::start() {
|
|||
|
||||
_updates.events(
|
||||
) | rpl::start_with_next([=](const BackgroundUpdate &update) {
|
||||
if (const auto path = _themeObject.pathAbsolute
|
||||
; !path.isEmpty() && QFileInfo(path).isNativePath()) {
|
||||
if (!_themeWatcher || !_themeWatcher->files().contains(path)) {
|
||||
_themeWatcher = std::make_unique<QFileSystemWatcher>(
|
||||
QStringList(path));
|
||||
QObject::connect(
|
||||
_themeWatcher.get(),
|
||||
&QFileSystemWatcher::fileChanged,
|
||||
[](const QString &path) {
|
||||
Apply(path);
|
||||
KeepApplied();
|
||||
});
|
||||
}
|
||||
} else {
|
||||
_themeWatcher = nullptr;
|
||||
}
|
||||
refreshThemeWatcher();
|
||||
if (update.paletteChanged()) {
|
||||
style::NotifyPaletteChanged();
|
||||
}
|
||||
|
@ -603,6 +588,25 @@ void ChatBackground::start() {
|
|||
Core::App().settings().setSystemDarkMode(Platform::IsDarkMode());
|
||||
}
|
||||
|
||||
void ChatBackground::refreshThemeWatcher() {
|
||||
const auto path = _themeObject.pathAbsolute;
|
||||
if (path.isEmpty()
|
||||
|| !QFileInfo(path).isNativePath()
|
||||
|| editingTheme()) {
|
||||
_themeWatcher = nullptr;
|
||||
} else if (!_themeWatcher || !_themeWatcher->files().contains(path)) {
|
||||
_themeWatcher = std::make_unique<QFileSystemWatcher>(
|
||||
QStringList(path));
|
||||
QObject::connect(
|
||||
_themeWatcher.get(),
|
||||
&QFileSystemWatcher::fileChanged,
|
||||
[](const QString &path) {
|
||||
Apply(path);
|
||||
KeepApplied();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ChatBackground::checkUploadWallPaper() {
|
||||
if (!_session) {
|
||||
_wallPaperUploadLifetime = rpl::lifetime();
|
||||
|
@ -826,6 +830,7 @@ std::optional<Data::CloudTheme> ChatBackground::editingTheme() const {
|
|||
|
||||
void ChatBackground::setEditingTheme(const Data::CloudTheme &editing) {
|
||||
_editingTheme = editing;
|
||||
refreshThemeWatcher();
|
||||
}
|
||||
|
||||
void ChatBackground::clearEditingTheme(ClearEditing clear) {
|
||||
|
@ -841,6 +846,7 @@ void ChatBackground::clearEditingTheme(ClearEditing clear) {
|
|||
reapplyWithNightMode(std::nullopt, _nightMode);
|
||||
KeepApplied();
|
||||
}
|
||||
refreshThemeWatcher();
|
||||
}
|
||||
|
||||
void ChatBackground::adjustPaletteUsingBackground(const QImage &image) {
|
||||
|
|
|
@ -243,6 +243,7 @@ private:
|
|||
[[nodiscard]] bool isNonDefaultBackground();
|
||||
void checkUploadWallPaper();
|
||||
[[nodiscard]] QImage postprocessBackgroundImage(QImage image);
|
||||
void refreshThemeWatcher();
|
||||
|
||||
friend bool IsNightMode();
|
||||
friend void SetNightModeValue(bool nightMode);
|
||||
|
|
Loading…
Add table
Reference in a new issue