2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 22:16:14 +00:00

Returned render color theme in main menu when background is filled.

This commit is contained in:
23rd
2019-05-31 20:53:00 +03:00
parent 9871184953
commit b45705f39d
3 changed files with 36 additions and 3 deletions

View File

@@ -49,6 +49,20 @@ inline bool AreTestingTheme() {
return !GlobalApplying.paletteForRevert.isEmpty();
};
bool CalculateIsMonoColorImage(const QImage &image) {
if (!image.isNull()) {
const auto bits = reinterpret_cast<const uint32*>(image.constBits());
const auto first = bits[0];
for (auto i = 0; i < image.width() * image.height(); i++) {
if (first != bits[i]) {
return false;
}
}
return true;
}
return false;
}
QByteArray readThemeContent(const QString &path) {
QFile file(path);
if (!file.exists()) {
@@ -580,6 +594,7 @@ void ChatBackground::preparePixmaps(QImage image) {
}
_pixmapForTiled = App::pixmapFromImageInPlace(std::move(imageForTiled));
}
_isMonoColorImage = CalculateIsMonoColorImage(image);
_pixmap = App::pixmapFromImageInPlace(std::move(image));
if (!isSmallForTiled) {
_pixmapForTiled = _pixmap;
@@ -671,6 +686,10 @@ bool ChatBackground::tileNight() const {
return _tileNightValue;
}
bool ChatBackground::isMonoColorImage() const {
return _isMonoColorImage;
}
void ChatBackground::ensureStarted() {
if (_pixmap.isNull() && !_paper.backgroundColor()) {
// We should start first, otherwise the default call