diff --git a/Telegram/SourceFiles/settings/settings_common.cpp b/Telegram/SourceFiles/settings/settings_common.cpp index 7ec5a5b21..bdbbb1477 100644 --- a/Telegram/SourceFiles/settings/settings_common.cpp +++ b/Telegram/SourceFiles/settings/settings_common.cpp @@ -83,6 +83,11 @@ Icon::Icon(IconDescriptor descriptor) : _icon(descriptor.icon) { ? st::settingsIconRadius : (std::min(_icon->width(), _icon->height()) / 2); _background.emplace(radius, *background); + } else if (const auto brush = descriptor.backgroundBrush) { + const auto radius = (descriptor.type == IconType::Rounded) + ? st::settingsIconRadius + : (std::min(_icon->width(), _icon->height()) / 2); + _backgroundBrush.emplace(radius, std::move(*brush)); } } @@ -93,6 +98,14 @@ void Icon::paint(QPainter &p, QPoint position) const { void Icon::paint(QPainter &p, int x, int y) const { if (_background) { _background->paint(p, { { x, y }, _icon->size() }); + } else if (_backgroundBrush) { + PainterHighQualityEnabler hq(p); + p.setPen(Qt::NoPen); + p.setBrush(_backgroundBrush->second); + p.drawRoundedRect( + QRect(QPoint(x, y), _icon->size()), + _backgroundBrush->first, + _backgroundBrush->first); } if (OptionMonoSettingsIcons.value()) { _icon->paint(p, { x, y }, 2 * x + _icon->width(), st::menuIconFg->c); diff --git a/Telegram/SourceFiles/settings/settings_common.h b/Telegram/SourceFiles/settings/settings_common.h index 3e340858c..cf50deaa4 100644 --- a/Telegram/SourceFiles/settings/settings_common.h +++ b/Telegram/SourceFiles/settings/settings_common.h @@ -137,6 +137,7 @@ struct IconDescriptor { int color = 0; // settingsIconBg{color}, 9 for settingsIconBgArchive. IconType type = IconType::Rounded; const style::color *background = nullptr; + std::optional backgroundBrush; // Can be useful for gragdients. explicit operator bool() const { return (icon != nullptr); @@ -157,6 +158,7 @@ public: private: not_null _icon; std::optional _background; + std::optional> _backgroundBrush; };