Use circle userpics in reactions from forums.

This commit is contained in:
John Preston 2024-10-03 11:16:22 +04:00
parent b60c7e97ab
commit 7d67b3d00a
3 changed files with 19 additions and 9 deletions

View file

@ -394,7 +394,8 @@ void PeerData::paintUserpic(
Ui::PeerUserpicView &view,
int x,
int y,
int size) const {
int size,
bool forceCircle) const {
const auto cloud = userpicCloudImage(view);
const auto ratio = style::DevicePixelRatio();
Ui::ValidateUserpicCache(
@ -402,7 +403,7 @@ void PeerData::paintUserpic(
cloud,
cloud ? nullptr : ensureEmptyUserpic().get(),
size * ratio,
isForum());
!forceCircle && isForum());
p.drawImage(QRect(x, y, size, size), view.cached);
}

View file

@ -317,15 +317,23 @@ public:
Ui::PeerUserpicView &view,
int x,
int y,
int size) const;
int size,
bool forceCircle = false) const;
void paintUserpicLeft(
Painter &p,
Ui::PeerUserpicView &view,
int x,
int y,
int w,
int size) const {
paintUserpic(p, view, rtl() ? (w - x - size) : x, y, size);
int size,
bool forceCircle = false) const {
paintUserpic(
p,
view,
rtl() ? (w - x - size) : x,
y,
size,
forceCircle);
}
void loadUserpic();
[[nodiscard]] bool hasUserpic() const;

View file

@ -38,13 +38,14 @@ void GenerateUserpicsInRow(
const auto single = st.size;
const auto shift = st.shift;
const auto width = single + (limit - 1) * (single - shift);
if (result.width() != width * style::DevicePixelRatio()) {
const auto ratio = style::DevicePixelRatio();
if (result.width() != width * ratio) {
result = QImage(
QSize(width, single) * style::DevicePixelRatio(),
QSize(width, single) * ratio,
QImage::Format_ARGB32_Premultiplied);
}
result.fill(Qt::transparent);
result.setDevicePixelRatio(style::DevicePixelRatio());
result.setDevicePixelRatio(ratio);
auto q = Painter(&result);
auto hq = PainterHighQualityEnabler(q);
@ -54,7 +55,7 @@ void GenerateUserpicsInRow(
for (auto i = count; i != 0;) {
auto &entry = list[--i];
q.setCompositionMode(QPainter::CompositionMode_SourceOver);
entry.peer->paintUserpic(q, entry.view, x, 0, single);
entry.peer->paintUserpic(q, entry.view, x, 0, single, true);
entry.uniqueKey = entry.peer->userpicUniqueKey(entry.view);
q.setCompositionMode(QPainter::CompositionMode_Source);
q.setBrush(Qt::NoBrush);