2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Emoji status selector in MainMenu/Settings.

This commit is contained in:
John Preston
2022-08-11 20:22:21 +03:00
parent 64bd4f0926
commit bd089f20a8
18 changed files with 504 additions and 381 deletions

View File

@@ -653,27 +653,45 @@ void PeerListRow::invalidatePixmapsCache() {
}
}
int PeerListRow::nameIconWidth() const {
return special()
? 0
: _peer->isVerified()
? st::dialogsVerifiedIcon.width()
: (_peer->isPremium() && !_peer->isSelf())
? st::dialogsPremiumIcon.width()
: 0;
}
void PeerListRow::paintNameIcon(
int PeerListRow::paintNameIconGetWidth(
Painter &p,
int x,
int y,
Fn<void()> repaint,
crl::time now,
int nameLeft,
int nameTop,
int nameWidth,
int availableWidth,
int outerWidth,
bool selected) {
if (_peer->isVerified()) {
st::dialogsVerifiedIcon.paint(p, x, y, outerWidth);
} else if (_peer->isPremium() && !_peer->isSelf()) {
st::dialogsPremiumIcon.paint(p, x, y, outerWidth);
if (special()
|| _isSavedMessagesChat
|| _isRepliesMessagesChat
|| !_peer->isUser()) {
return 0;
}
return _bagde.drawGetWidth(
p,
QRect(
nameLeft,
nameTop,
availableWidth,
st::msgNameStyle.font->height),
nameWidth,
outerWidth,
{
.peer = _peer,
.verified = &(selected
? st::dialogsVerifiedIconOver
: st::dialogsVerifiedIcon),
.premium = &(selected
? st::dialogsPremiumIconOver
: st::dialogsPremiumIcon),
.scam = &(selected ? st::dialogsScamFgOver : st::dialogsScamFg),
.preview = st::windowBgOver->c,
.customEmojiRepaint = repaint,
.now = now,
.paused = false,
});
}
void PeerListRow::paintStatusText(
@@ -829,7 +847,7 @@ PeerListContent::PeerListContent(
using UpdateFlag = Data::PeerUpdate::Flag;
_controller->session().changes().peerUpdates(
UpdateFlag::Name | UpdateFlag::Photo
UpdateFlag::Name | UpdateFlag::Photo | UpdateFlag::EmojiStatus
) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
if (update.flags & UpdateFlag::Name) {
handleNameChanged(update.peer);
@@ -1564,15 +1582,16 @@ crl::time PeerListContent::paintRow(
- skipRight;
}
auto statusw = namew;
if (auto iconWidth = row->nameIconWidth()) {
namew -= iconWidth;
row->paintNameIcon(
p,
namex + qMin(name.maxWidth(), namew),
_st.item.namePosition.y(),
width(),
selected);
}
namew -= row->paintNameIconGetWidth(
p,
[=] { updateRow(row); },
now,
namex,
_st.item.namePosition.y(),
name.maxWidth(),
namew,
width(),
selected);
auto nameCheckedRatio = row->disabled() ? 0. : row->checkedRatio();
p.setPen(anim::pen(_st.item.nameFg, _st.item.nameFgChecked, nameCheckedRatio));
name.drawLeftElided(p, namex, _st.item.namePosition.y(), namew, width());

View File

@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/rp_widget.h"
#include "ui/empty_userpic.h"
#include "ui/unread_badge.h"
#include "boxes/abstract_box.h"
#include "mtproto/sender.h"
#include "data/data_cloud_file.h"
@@ -94,11 +95,14 @@ public:
void clearCustomStatus();
// Box interface.
virtual int nameIconWidth() const;
virtual void paintNameIcon(
virtual int paintNameIconGetWidth(
Painter &p,
int x,
int y,
Fn<void()> repaint,
crl::time now,
int nameLeft,
int nameTop,
int nameWidth,
int availableWidth,
int outerWidth,
bool selected);
@@ -258,6 +262,7 @@ private:
std::unique_ptr<Ui::RoundImageCheckbox> _checkbox;
Ui::Text::String _name;
Ui::Text::String _status;
Ui::PeerBadge _bagde;
StatusType _statusType = StatusType::Online;
crl::time _statusValidTill = 0;
base::flat_set<QChar> _nameFirstLetters;

View File

@@ -1932,18 +1932,6 @@ auto ParticipantsBoxController::computeType(
? Rights::Admin
: Rights::Normal;
result.adminRank = user ? _additional.adminRank(user) : QString();
using Badge = Info::Profile::Badge;
result.badge = !user
? Badge::None
: user->isScam()
? Badge::Scam
: user->isFake()
? Badge::Fake
: user->isVerified()
? Badge::Verified
: (user->isPremium() && participant->session().premiumBadgesShown())
? Badge::Premium
: Badge::None;
return result;
}
@@ -1952,7 +1940,8 @@ void ParticipantsBoxController::recomputeTypeFor(
if (_role != Role::Profile) {
return;
}
if (const auto row = delegate()->peerListFindRow(participant->id.value)) {
const auto row = delegate()->peerListFindRow(participant->id.value);
if (row) {
static_cast<Row*>(row)->setType(computeType(participant));
}
}