Improved background buttons in box for share QR box on different scales.

This commit is contained in:
23rd 2025-03-22 20:24:51 +03:00
parent 5adab2739b
commit 1f07e7978d

View file

@ -592,20 +592,25 @@ void FillPeerQrBox(
spacing + ((counter % kMaxInRow) * (size + spacing)), spacing + ((counter % kMaxInRow) * (size + spacing)),
0); 0);
widget->show(); widget->show();
const auto cornersMask = Images::CornersMask(
st::roundRadiusLarge * style::DevicePixelRatio());
const auto back = [&] { const auto back = [&] {
auto result = Images::Round( auto gradient = Images::GenerateGradient(
Images::GenerateGradient( Size(size - activewidth * 5) * style::DevicePixelRatio(),
Size(size - activewidth * 5), colors,
colors, 0,
0, 0);
0), gradient.setDevicePixelRatio(style::DevicePixelRatio());
ImageRoundRadius::Large); auto result = Images::Round(std::move(gradient), cornersMask);
const auto rect = Rect(
result.size() / style::DevicePixelRatio());
auto colored = result; auto colored = result;
colored.fill(Qt::transparent); colored.fill(Qt::transparent);
{ {
auto p = QPainter(&colored); auto p = QPainter(&colored);
auto hq = PainterHighQualityEnabler(p); auto hq = PainterHighQualityEnabler(p);
st::profileQrIcon.paintInCenter(p, result.rect()); st::profileQrIcon.paintInCenter(p, rect);
p.setCompositionMode(QPainter::CompositionMode_SourceIn); p.setCompositionMode(QPainter::CompositionMode_SourceIn);
p.drawImage(0, 0, result); p.drawImage(0, 0, result);
} }
@ -617,8 +622,8 @@ void FillPeerQrBox(
p.setPen(st::premiumButtonFg); p.setPen(st::premiumButtonFg);
p.setBrush(st::premiumButtonFg); p.setBrush(st::premiumButtonFg);
const auto size = st::profileQrIcon.width() * 1.5; const auto size = st::profileQrIcon.width() * 1.5;
const auto margins = Margins((result.width() - size) / 2); const auto margins = Margins((rect.width() - size) / 2);
const auto inner = result.rect() - margins; const auto inner = rect - margins;
p.drawRoundedRect( p.drawRoundedRect(
inner, inner,
st::roundRadiusLarge, st::roundRadiusLarge,