Merge tag 'v5.6.3' into dev

This commit is contained in:
AlexeyZavar
2024-10-16 13:41:32 +03:00
270 changed files with 9084 additions and 3098 deletions
+52 -16
View File
@@ -89,7 +89,8 @@ using TLStickerSet = MTPmessages_StickerSet;
[[nodiscard]] std::optional<QColor> ComputeImageColor(
const style::icon &lockIcon,
const QImage &frame) {
const QImage &frame,
RectPart part) {
if (frame.isNull()
|| frame.format() != QImage::Format_ARGB32_Premultiplied) {
return {};
@@ -98,13 +99,29 @@ using TLStickerSet = MTPmessages_StickerSet;
auto sg = int64();
auto sb = int64();
auto sa = int64();
const auto factor = frame.devicePixelRatio();
const auto factor = style::DevicePixelRatio();
const auto size = lockIcon.size() * factor;
const auto width = std::min(frame.width(), size.width());
const auto height = std::min(frame.height(), size.height());
const auto skipx = (frame.width() - width) / 2;
const auto radius = st::roundRadiusSmall;
const auto skipy = std::max(frame.height() - height - radius, 0);
const auto skipx = (part == RectPart::TopLeft
|| part == RectPart::Left
|| part == RectPart::BottomLeft)
? 0
: (part == RectPart::Top
|| part == RectPart::Center
|| part == RectPart::Bottom)
? (frame.width() - width) / 2
: std::max(frame.width() - width - radius, 0);
const auto skipy = (part == RectPart::TopLeft
|| part == RectPart::Top
|| part == RectPart::TopRight)
? 0
: (part == RectPart::Left
|| part == RectPart::Center
|| part == RectPart::Right)
? (frame.height() - height) / 2
: std::max(frame.height() - height - radius, 0);
const auto perline = frame.bytesPerLine();
const auto addperline = perline - (width * 4);
auto bits = static_cast<const uchar*>(frame.bits())
@@ -128,17 +145,20 @@ using TLStickerSet = MTPmessages_StickerSet;
[[nodiscard]] QColor ComputeLockColor(
const style::icon &lockIcon,
const QImage &frame) {
const QImage &frame,
RectPart part) {
return ComputeImageColor(
lockIcon,
frame
frame,
part
).value_or(st::windowSubTextFg->c);
}
void ValidatePremiumLockBg(
const style::icon &lockIcon,
QImage &image,
const QImage &frame) {
const QImage &frame,
RectPart part) {
if (!image.isNull()) {
return;
}
@@ -149,7 +169,7 @@ void ValidatePremiumLockBg(
QImage::Format_ARGB32_Premultiplied);
image.setDevicePixelRatio(factor);
auto p = QPainter(&image);
const auto color = ComputeLockColor(lockIcon, frame);
const auto color = ComputeLockColor(lockIcon, frame, part);
p.fillRect(
QRect(QPoint(), size),
anim::color(color, st::windowSubTextFg, kGrayLockOpacity));
@@ -202,8 +222,10 @@ void ValidatePremiumStarFg(const style::icon &lockIcon, QImage &image) {
StickerPremiumMark::StickerPremiumMark(
not_null<Main::Session*> session,
const style::icon &lockIcon)
: _lockIcon(lockIcon) {
const style::icon &lockIcon,
RectPart part)
: _lockIcon(lockIcon)
, _part(part) {
style::PaletteChanged(
) | rpl::start_with_next([=] {
_lockGray = QImage();
@@ -228,11 +250,15 @@ void StickerPremiumMark::paint(
const auto &bg = frame.isNull() ? _lockGray : backCache;
const auto factor = style::DevicePixelRatio();
const auto radius = st::roundRadiusSmall;
const auto point = position + QPoint(
(singleSize.width() - (bg.width() / factor) - radius),
singleSize.height() - (bg.height() / factor) - radius);
const auto shiftx = (_part == RectPart::Center)
? (singleSize.width() - (bg.width() / factor)) / 2
: (singleSize.width() - (bg.width() / factor) - radius);
const auto shifty = (_part == RectPart::Center)
? (singleSize.height() - (bg.height() / factor)) / 2
: (singleSize.height() - (bg.height() / factor) - radius);
const auto point = position + QPoint(shiftx, shifty);
p.drawImage(point, bg);
if (_premium) {
if (_premium && _part != RectPart::Center) {
validateStar();
p.drawImage(point, _star);
} else {
@@ -244,7 +270,7 @@ void StickerPremiumMark::validateLock(
const QImage &frame,
QImage &backCache) {
auto &image = frame.isNull() ? _lockGray : backCache;
ValidatePremiumLockBg(_lockIcon, image, frame);
ValidatePremiumLockBg(_lockIcon, image, frame, _part);
}
void StickerPremiumMark::validateStar() {
@@ -1447,9 +1473,13 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
const auto send = crl::guard(this, [=](Api::SendOptions options) {
chosen(index, document, options);
});
// In case we're adding items after FillSendMenu we have
// to pass nullptr for showForEffect and attach selector later.
// Otherwise added items widths won't be respected in menu geometry.
SendMenu::FillSendMenu(
_menu.get(),
_show,
nullptr, // showForEffect
details,
SendMenu::DefaultCallback(_show, send));
@@ -1483,6 +1513,12 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
.isAttention = true,
});
}
SendMenu::AttachSendMenuEffect(
_menu.get(),
_show,
details,
SendMenu::DefaultCallback(_show, send));
}
if (_menu->empty()) {
_menu = nullptr;