2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Allow removing cloud wallpapers.

This commit is contained in:
John Preston
2019-02-09 16:36:07 +03:00
parent f9d56eb4c1
commit b6e37b7730
7 changed files with 210 additions and 39 deletions

View File

@@ -409,7 +409,9 @@ void ChatBackground::checkUploadWallPaper() {
if (const auto id = base::take(_wallPaperRequestId)) {
_session->api().request(id).cancel();
}
if (!Data::IsCustomWallPaper(_paper) || _original.isNull()) {
if (!Data::IsCustomWallPaper(_paper)
|| _original.isNull()
|| testingPalette()) {
return;
}
@@ -439,8 +441,9 @@ void ChatBackground::checkUploadWallPaper() {
data.vdocument);
});
if (const auto paper = Data::WallPaper::Create(result)) {
_paper = *paper;
setPaper(*paper);
writeNewBackgroundSettings();
notify(BackgroundUpdate(BackgroundUpdate::Type::New, tile()));
}
}).send();
});
@@ -596,12 +599,6 @@ bool ChatBackground::adjustPaletteRequired() {
return Data::IsDefaultWallPaper(_paper)
|| Data::details::IsTestingDefaultWallPaper(_paper);
};
const auto testingPalette = [&] {
const auto path = AreTestingTheme()
? GlobalApplying.pathAbsolute
: _themeAbsolutePath;
return IsPaletteTestingPath(path);
};
if (testingPalette()) {
return false;
@@ -611,6 +608,13 @@ bool ChatBackground::adjustPaletteRequired() {
return !usingDefaultBackground();
}
bool ChatBackground::testingPalette() const {
const auto path = AreTestingTheme()
? GlobalApplying.pathAbsolute
: _themeAbsolutePath;
return IsPaletteTestingPath(path);
}
void ChatBackground::adjustPaletteUsingBackground(const QImage &image) {
adjustPaletteUsingColor(CountAverageColor(image));
}