mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
Add option to blur chat background.
This commit is contained in:
@@ -227,12 +227,14 @@ WallPaper WallPaper::withUrlParams(
|
||||
}
|
||||
}
|
||||
if (const auto color = ColorFromString(params.value("bg_color"))) {
|
||||
result._settings |= Flag::f_background_color;
|
||||
result._backgroundColor = color;
|
||||
}
|
||||
if (const auto string = params.value("intensity"); !string.isEmpty()) {
|
||||
auto ok = false;
|
||||
const auto intensity = string.toInt(&ok);
|
||||
if (ok && base::in_range(intensity, 0, 101)) {
|
||||
result._settings |= Flag::f_intensity;
|
||||
result._intensity = intensity;
|
||||
}
|
||||
}
|
||||
@@ -240,6 +242,52 @@ WallPaper WallPaper::withUrlParams(
|
||||
return result;
|
||||
}
|
||||
|
||||
WallPaper WallPaper::withBlurred(bool blurred) const {
|
||||
using Flag = MTPDwallPaperSettings::Flag;
|
||||
|
||||
auto result = *this;
|
||||
if (blurred) {
|
||||
result._settings |= Flag::f_blur;
|
||||
} else {
|
||||
result._settings &= ~Flag::f_blur;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
WallPaper WallPaper::withPatternIntensity(int intensity) const {
|
||||
using Flag = MTPDwallPaperSettings::Flag;
|
||||
|
||||
auto result = *this;
|
||||
result._settings |= Flag::f_intensity;
|
||||
result._intensity = intensity;
|
||||
return result;
|
||||
}
|
||||
|
||||
WallPaper WallPaper::withBackgroundColor(QColor color) const {
|
||||
using Flag = MTPDwallPaperSettings::Flag;
|
||||
|
||||
auto result = *this;
|
||||
result._settings |= Flag::f_background_color;
|
||||
result._backgroundColor = color;
|
||||
if (ColorFromString(_slug)) {
|
||||
result._slug = StringFromColor(color);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
WallPaper WallPaper::withParamsFrom(const WallPaper &other) const {
|
||||
auto result = *this;
|
||||
result._settings = other._settings;
|
||||
if (other._backgroundColor || !ColorFromString(_slug)) {
|
||||
result._backgroundColor = other._backgroundColor;
|
||||
if (ColorFromString(_slug)) {
|
||||
result._slug = StringFromColor(*result._backgroundColor);
|
||||
}
|
||||
}
|
||||
result._intensity = other._intensity;
|
||||
return result;
|
||||
}
|
||||
|
||||
std::optional<WallPaper> WallPaper::Create(const MTPWallPaper &data) {
|
||||
return data.match([](const MTPDwallPaper &data) {
|
||||
return Create(data);
|
||||
|
Reference in New Issue
Block a user