Don't change custom background in night mode.

This will at least make it a bit better in #3598.

The real solution with remembering custom backgrounds for both
night mode on and off doesn't fit with current theming way too well.
This commit is contained in:
John Preston 2017-06-30 15:03:51 +03:00
parent 51c0df79fe
commit 0798a0148a
2 changed files with 11 additions and 4 deletions

View File

@ -562,15 +562,18 @@ void ChatBackground::saveForRevert() {
} }
} }
void ChatBackground::setTestingTheme(Instance &&theme) { void ChatBackground::setTestingTheme(Instance &&theme, ChangeMode mode) {
style::main_palette::apply(theme.palette); style::main_palette::apply(theme.palette);
auto switchToThemeBackground = (mode == ChangeMode::SwitchToThemeBackground && !theme.background.isNull())
|| (_id == kThemeBackground)
|| (_id == kDefaultBackground && !Local::hasTheme());
if (AreTestingTheme() && IsPaletteTestingPath(instance->applying.path)) { if (AreTestingTheme() && IsPaletteTestingPath(instance->applying.path)) {
// Grab current background image if it is not already custom // Grab current background image if it is not already custom
if (_id != kCustomBackground) { if (_id != kCustomBackground) {
saveForRevert(); saveForRevert();
setImage(internal::kTestingEditorBackground, std::move(_pixmap).toImage()); setImage(internal::kTestingEditorBackground, std::move(_pixmap).toImage());
} }
} else if (!theme.background.isNull() || _id == kThemeBackground) { } else if (switchToThemeBackground) {
saveForRevert(); saveForRevert();
setImage(internal::kTestingThemeBackground, std::move(theme.background)); setImage(internal::kTestingThemeBackground, std::move(theme.background));
setTile(theme.tiled); setTile(theme.tiled);
@ -685,7 +688,7 @@ void SwitchNightTheme(bool enabled) {
if (instance->applying.paletteForRevert.isEmpty()) { if (instance->applying.paletteForRevert.isEmpty()) {
instance->applying.paletteForRevert = style::main_palette::save(); instance->applying.paletteForRevert = style::main_palette::save();
} }
Background()->setTestingTheme(std::move(preview->instance)); Background()->setTestingTheme(std::move(preview->instance), ChatBackground::ChangeMode::LeaveCurrentCustomBackground);
} else { } else {
Window::Theme::ApplyDefault(); Window::Theme::ApplyDefault();
} }

View File

@ -103,7 +103,11 @@ public:
void setTile(bool tile); void setTile(bool tile);
void reset(); void reset();
void setTestingTheme(Instance &&theme); enum class ChangeMode {
SwitchToThemeBackground,
LeaveCurrentCustomBackground,
};
void setTestingTheme(Instance &&theme, ChangeMode mode = ChangeMode::SwitchToThemeBackground);
void setTestingDefaultTheme(); void setTestingDefaultTheme();
void keepApplied(); void keepApplied();
void revert(); void revert();