2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Optimize theme edit data clearing.

This commit is contained in:
John Preston
2019-09-06 18:30:44 +03:00
parent 469c6770fb
commit 95ee17bd54
4 changed files with 27 additions and 14 deletions

View File

@@ -483,6 +483,10 @@ SendMediaReady PrepareWallPaper(const QImage &image) {
0);
}
void ClearEditingPalette() {
QFile(EditingPalettePath()).remove();
}
} // namespace
ChatBackground::AdjustableColor::AdjustableColor(style::color data)
@@ -739,13 +743,20 @@ std::optional<Data::CloudTheme> ChatBackground::editingTheme() const {
return _editingTheme;
}
void ChatBackground::setEditingTheme(
std::optional<Data::CloudTheme> editing) {
if (!_editingTheme && !editing) {
void ChatBackground::setEditingTheme(const Data::CloudTheme &editing) {
_editingTheme = editing;
}
void ChatBackground::clearEditingTheme(ClearEditing clear) {
if (!_editingTheme) {
return;
}
_editingTheme = editing;
if (!_editingTheme) {
_editingTheme = std::nullopt;
if (clear == ClearEditing::Temporary) {
return;
}
ClearEditingPalette();
if (clear == ClearEditing::RevertChanges) {
reapplyWithNightMode(std::nullopt, _nightMode);
KeepApplied();
}
@@ -1235,10 +1246,6 @@ QString EditingPalettePath() {
return cWorkingDir() + "tdata/editing-theme.tdesktop-palette";
}
void ClearEditingPalette() {
QFile(EditingPalettePath()).remove();
}
QColor CountAverageColor(const QImage &image) {
Expects(image.format() == QImage::Format_ARGB32_Premultiplied);