Some colors split for the palette. Theme preview applying improved.

Also attempting to fix travis build.
This commit is contained in:
John Preston
2017-01-11 12:16:44 +04:00
parent 30c9bcb985
commit 2d185cf66e
13 changed files with 121 additions and 70 deletions
+17 -2
View File
@@ -421,7 +421,13 @@ void ChatBackground::setPreparedImage(QImage &&image) {
image = std_::move(image).convertToFormat(QImage::Format_ARGB32_Premultiplied);
image.setDevicePixelRatio(cRetinaFactor());
if (_id != kThemeBackground && _id != internal::kTestingThemeBackground) {
initColorsFromBackground(image);
auto colorsFromSomeTheme = Local::hasTheme();
if (instance && !instance->applying.paletteForRevert.isEmpty()) {
colorsFromSomeTheme = !instance->applying.path.isEmpty();
}
if (colorsFromSomeTheme || (_id != kDefaultBackground && _id != internal::kTestingDefaultBackground)) {
initColorsFromBackground(image);
}
}
auto width = image.width();
@@ -520,16 +526,22 @@ void ChatBackground::setTestingTheme(Instance &&theme) {
saveForRevert();
setImage(internal::kTestingThemeBackground, std_::move(theme.background));
setTile(theme.tiled);
} else {
// Apply current background image so that service bg colors are recounted.
setImage(_id, std_::move(_pixmap).toImage());
}
notify(BackgroundUpdate(BackgroundUpdate::Type::TestingTheme, _tile), true);
}
void ChatBackground::setTestingDefaultTheme() {
style::main_palette::reset();
if (_id != kDefaultBackground) {
if (_id == kThemeBackground) {
saveForRevert();
setImage(internal::kTestingDefaultBackground);
setTile(false);
} else {
// Apply current background image so that service bg colors are recounted.
setImage(_id, std_::move(_pixmap).toImage());
}
notify(BackgroundUpdate(BackgroundUpdate::Type::TestingTheme, _tile), true);
}
@@ -560,6 +572,9 @@ void ChatBackground::revert() {
if (_id == internal::kTestingThemeBackground || _id == internal::kTestingDefaultBackground) {
setTile(_tileForRevert);
setImage(_idForRevert, std_::move(_imageForRevert));
} else {
// Apply current background image so that service bg colors are recounted.
setImage(_id, std_::move(_pixmap).toImage());
}
notify(BackgroundUpdate(BackgroundUpdate::Type::RevertingTheme, _tile), true);
}