Skip to content

Commit

Permalink
Use circle userpics in reactions from forums.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Oct 3, 2024
1 parent b60c7e9 commit 7d67b3d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Telegram/SourceFiles/data/data_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,16 @@ 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(
view,
cloud,
cloud ? nullptr : ensureEmptyUserpic().get(),
size * ratio,
isForum());
!forceCircle && isForum());
p.drawImage(QRect(x, y, size, size), view.cached);
}

Expand Down
14 changes: 11 additions & 3 deletions Telegram/SourceFiles/data/data_peer.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,23 @@ class PeerData {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 7d67b3d

Please sign in to comment.