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

View file

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

View file

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