mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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(
|
_updates.events(
|
||||||
) | rpl::start_with_next([=](const BackgroundUpdate &update) {
|
) | rpl::start_with_next([=](const BackgroundUpdate &update) {
|
||||||
if (const auto path = _themeObject.pathAbsolute
|
refreshThemeWatcher();
|
||||||
; !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;
|
|
||||||
}
|
|
||||||
if (update.paletteChanged()) {
|
if (update.paletteChanged()) {
|
||||||
style::NotifyPaletteChanged();
|
style::NotifyPaletteChanged();
|
||||||
}
|
}
|
||||||
|
@ -603,6 +588,25 @@ void ChatBackground::start() {
|
||||||
Core::App().settings().setSystemDarkMode(Platform::IsDarkMode());
|
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() {
|
void ChatBackground::checkUploadWallPaper() {
|
||||||
if (!_session) {
|
if (!_session) {
|
||||||
_wallPaperUploadLifetime = rpl::lifetime();
|
_wallPaperUploadLifetime = rpl::lifetime();
|
||||||
|
@ -826,6 +830,7 @@ std::optional<Data::CloudTheme> ChatBackground::editingTheme() const {
|
||||||
|
|
||||||
void ChatBackground::setEditingTheme(const Data::CloudTheme &editing) {
|
void ChatBackground::setEditingTheme(const Data::CloudTheme &editing) {
|
||||||
_editingTheme = editing;
|
_editingTheme = editing;
|
||||||
|
refreshThemeWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatBackground::clearEditingTheme(ClearEditing clear) {
|
void ChatBackground::clearEditingTheme(ClearEditing clear) {
|
||||||
|
@ -841,6 +846,7 @@ void ChatBackground::clearEditingTheme(ClearEditing clear) {
|
||||||
reapplyWithNightMode(std::nullopt, _nightMode);
|
reapplyWithNightMode(std::nullopt, _nightMode);
|
||||||
KeepApplied();
|
KeepApplied();
|
||||||
}
|
}
|
||||||
|
refreshThemeWatcher();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatBackground::adjustPaletteUsingBackground(const QImage &image) {
|
void ChatBackground::adjustPaletteUsingBackground(const QImage &image) {
|
||||||
|
|
|
@ -243,6 +243,7 @@ private:
|
||||||
[[nodiscard]] bool isNonDefaultBackground();
|
[[nodiscard]] bool isNonDefaultBackground();
|
||||||
void checkUploadWallPaper();
|
void checkUploadWallPaper();
|
||||||
[[nodiscard]] QImage postprocessBackgroundImage(QImage image);
|
[[nodiscard]] QImage postprocessBackgroundImage(QImage image);
|
||||||
|
void refreshThemeWatcher();
|
||||||
|
|
||||||
friend bool IsNightMode();
|
friend bool IsNightMode();
|
||||||
friend void SetNightModeValue(bool nightMode);
|
friend void SetNightModeValue(bool nightMode);
|
||||||
|
|
Loading…
Add table
Reference in a new issue