mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Fix reading background before style init.
This commit is contained in:
parent
55ec4ebf86
commit
4add6234b6
2 changed files with 29 additions and 18 deletions
|
@ -536,12 +536,17 @@ void ChatBackground::setThemeData(QImage &&themeImage, bool themeTile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatBackground::initialRead() {
|
void ChatBackground::initialRead() {
|
||||||
if (!Data::details::IsUninitializedWallPaper(_paper)) {
|
if (started()) {
|
||||||
return;
|
return;
|
||||||
}
|
} else if (!Local::readBackground()) {
|
||||||
if (!Local::readBackground()) {
|
|
||||||
set(Data::ThemeWallPaper());
|
set(Data::ThemeWallPaper());
|
||||||
}
|
}
|
||||||
|
if (_localStoredTileDayValue) {
|
||||||
|
_tileDayValue = *_localStoredTileDayValue;
|
||||||
|
}
|
||||||
|
if (_localStoredTileNightValue) {
|
||||||
|
_tileNightValue = *_localStoredTileNightValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatBackground::start() {
|
void ChatBackground::start() {
|
||||||
|
@ -855,16 +860,9 @@ bool ChatBackground::isMonoColorImage() const {
|
||||||
return _isMonoColorImage;
|
return _isMonoColorImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatBackground::ensureInitialRead() {
|
|
||||||
if (_pixmap.isNull() && !_paper.backgroundColor()) {
|
|
||||||
// We should start first, otherwise the default call
|
|
||||||
// to initialRead() will reset this value to _themeTile.
|
|
||||||
initialRead();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChatBackground::setTile(bool tile) {
|
void ChatBackground::setTile(bool tile) {
|
||||||
ensureInitialRead();
|
Expects(started());
|
||||||
|
|
||||||
const auto old = this->tile();
|
const auto old = this->tile();
|
||||||
if (nightMode()) {
|
if (nightMode()) {
|
||||||
setTileNightValue(tile);
|
setTileNightValue(tile);
|
||||||
|
@ -881,13 +879,19 @@ void ChatBackground::setTile(bool tile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatBackground::setTileDayValue(bool tile) {
|
void ChatBackground::setTileDayValue(bool tile) {
|
||||||
ensureInitialRead();
|
if (started()) {
|
||||||
_tileDayValue = tile;
|
_tileDayValue = tile;
|
||||||
|
} else {
|
||||||
|
_localStoredTileDayValue = tile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatBackground::setTileNightValue(bool tile) {
|
void ChatBackground::setTileNightValue(bool tile) {
|
||||||
ensureInitialRead();
|
if (started()) {
|
||||||
_tileNightValue = tile;
|
_tileNightValue = tile;
|
||||||
|
} else {
|
||||||
|
_localStoredTileNightValue = tile;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatBackground::setThemeObject(const Object &object) {
|
void ChatBackground::setThemeObject(const Object &object) {
|
||||||
|
@ -920,8 +924,13 @@ void ChatBackground::reset() {
|
||||||
writeNewBackgroundSettings();
|
writeNewBackgroundSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ChatBackground::started() const {
|
||||||
|
return !Data::details::IsUninitializedWallPaper(_paper);
|
||||||
|
}
|
||||||
|
|
||||||
void ChatBackground::saveForRevert() {
|
void ChatBackground::saveForRevert() {
|
||||||
ensureInitialRead();
|
Expects(started());
|
||||||
|
|
||||||
if (!Data::details::IsTestingThemeWallPaper(_paper)
|
if (!Data::details::IsTestingThemeWallPaper(_paper)
|
||||||
&& !Data::details::IsTestingDefaultWallPaper(_paper)) {
|
&& !Data::details::IsTestingDefaultWallPaper(_paper)) {
|
||||||
_paperForRevert = _paper;
|
_paperForRevert = _paper;
|
||||||
|
|
|
@ -178,8 +178,8 @@ private:
|
||||||
QColor original;
|
QColor original;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] bool started() const;
|
||||||
void initialRead();
|
void initialRead();
|
||||||
void ensureInitialRead();
|
|
||||||
void saveForRevert();
|
void saveForRevert();
|
||||||
void setPreparedImage(QImage original, QImage prepared);
|
void setPreparedImage(QImage original, QImage prepared);
|
||||||
void preparePixmaps(QImage image);
|
void preparePixmaps(QImage image);
|
||||||
|
@ -226,6 +226,8 @@ private:
|
||||||
bool _nightMode = false;
|
bool _nightMode = false;
|
||||||
bool _tileDayValue = false;
|
bool _tileDayValue = false;
|
||||||
bool _tileNightValue = true;
|
bool _tileNightValue = true;
|
||||||
|
std::optional<bool> _localStoredTileDayValue;
|
||||||
|
std::optional<bool> _localStoredTileNightValue;
|
||||||
|
|
||||||
bool _isMonoColorImage = false;
|
bool _isMonoColorImage = false;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue