verified check display for users added

This commit is contained in:
John Preston 2015-10-29 11:52:39 -04:00
parent 1d4057f137
commit 59abcc2986
7 changed files with 45 additions and 18 deletions

View File

@ -372,6 +372,7 @@ namespace App {
data->setName(lang(lng_deleted), QString(), QString(), QString());
data->setPhoto(MTP_userProfilePhotoEmpty());
data->access = UserNoAccess;
data->flags = 0;
data->setBotInfoVersion(-1);
wasContact = (data->contact > 0);
status = &emptyStatus;
@ -382,7 +383,7 @@ namespace App {
PeerId peer(peerFromUser(d.vid.v));
data = App::user(peer);
int32 flags = d.vflags.v;
data->flags = d.vflags.v;
if (d.is_self()) {
data->input = MTP_inputPeerSelf();
data->inputUser = MTP_inputUserSelf();

View File

@ -337,7 +337,7 @@ void ContactsInner::paintDialog(Painter &p, PeerData *peer, ContactData *data, b
int32 namex = st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left();
int32 iconw = (_chat || _creating != CreatingGroupNone) ? (st::contactsCheckPosition.x() * 2 + st::contactsCheckIcon.pxWidth()) : 0;
int32 namew = width() - namex - st::contactsPadding.right() - iconw;
if (peer->isChannel() && peer->asChannel()->isVerified()) {
if (peer->isVerified()) {
namew -= st::verifiedCheck.pxWidth() + st::verifiedCheckPos.x();
p.drawSpriteLeft(namex + qMin(data->name.maxWidth(), namew) + st::verifiedCheckPos.x(), st::contactsPadding.top() + st::contactsNameTop + st::verifiedCheckPos.y(), width(), st::verifiedCheck);
}
@ -1640,7 +1640,7 @@ void MembersInner::paintDialog(Painter &p, PeerData *peer, MemberData *data, boo
int32 namex = st::contactsPadding.left() + st::contactsPhotoSize + st::contactsPadding.left();
int32 namew = width() - namex - st::contactsPadding.right() - (data->canKick ? (_kickWidth + st::contactsCheckPosition.x() * 2) : 0);
if (peer->isChannel() && peer->asChannel()->isVerified()) {
if (peer->isVerified()) {
namew -= st::verifiedCheck.pxWidth() + st::verifiedCheckPos.x();
p.drawSpriteLeft(namex + qMin(data->name.maxWidth(), namew) + st::verifiedCheckPos.x(), st::contactsPadding.top() + st::contactsNameTop + st::verifiedCheckPos.y(), width(), st::verifiedCheck);
}

View File

@ -245,12 +245,12 @@ void DialogsInner::peopleResultPaint(PeerData *peer, Painter &p, int32 w, bool a
} else if (peer->isChannel()) {
p.drawPixmap(QPoint(rectForName.left() + st::dlgChannelImgPos.x(), rectForName.top() + st::dlgChannelImgPos.y()), App::sprite(), (act ? st::dlgActiveChannelImg : st::dlgChannelImg));
rectForName.setLeft(rectForName.left() + st::dlgImgSkip);
if (peer->asChannel()->isVerified()) {
rectForName.setWidth(rectForName.width() - st::verifiedCheck.pxWidth() - st::verifiedCheckPos.x());
p.drawSprite(rectForName.topLeft() + QPoint(qMin(peer->dialogName().maxWidth(), rectForName.width()), 0) + st::verifiedCheckPos, (act ? st::verifiedCheckInv : st::verifiedCheck));
}
}
if (peer->isVerified()) {
rectForName.setWidth(rectForName.width() - st::verifiedCheck.pxWidth() - st::verifiedCheckPos.x());
p.drawSprite(rectForName.topLeft() + QPoint(qMin(peer->dialogName().maxWidth(), rectForName.width()), 0) + st::verifiedCheckPos, (act ? st::verifiedCheckInv : st::verifiedCheck));
}
QRect tr(nameleft, st::dlgPaddingVer + st::dlgFont->height + st::dlgSep, namewidth, st::dlgFont->height);
p.setFont(st::dlgHistFont->f);
QString username = peer->userName();

View File

@ -2935,8 +2935,16 @@ namespace Local {
if (peer->isUser()) {
UserData *user = peer->asUser();
// first + last + phone + username + access + onlineTill + contact + botInfoVersion
result += _stringSize(user->firstName) + _stringSize(user->lastName) + _stringSize(user->phone) + _stringSize(user->username) + sizeof(quint64) + sizeof(qint32) + sizeof(qint32) + sizeof(qint32);
// first + last + phone + username + access
result += _stringSize(user->firstName) + _stringSize(user->lastName) + _stringSize(user->phone) + _stringSize(user->username) + sizeof(quint64);
// flags
if (AppVersion >= 9009) {
result += sizeof(qint32);
}
// onlineTill + contact + botInfoVersion
result += sizeof(qint32) + sizeof(qint32) + sizeof(qint32);
} else if (peer->isChat()) {
ChatData *chat = peer->asChat();
@ -2945,8 +2953,8 @@ namespace Local {
} else if (peer->isChannel()) {
ChannelData *channel = peer->asChannel();
// name + access + date + version + adminned + forbidden + left + invitationUrl
result += _stringSize(channel->name) + sizeof(quint64) + sizeof(qint32) + sizeof(qint32) + sizeof(qint32) + sizeof(qint32) + sizeof(qint32) + _stringSize(channel->invitationUrl);
// name + access + date + version + forbidden + flags + invitationUrl
result += _stringSize(channel->name) + sizeof(quint64) + sizeof(qint32) + sizeof(qint32) + sizeof(qint32) + sizeof(qint32) + _stringSize(channel->invitationUrl);
}
return result;
}
@ -2957,7 +2965,11 @@ namespace Local {
if (peer->isUser()) {
UserData *user = peer->asUser();
stream << user->firstName << user->lastName << user->phone << user->username << quint64(user->access) << qint32(user->onlineTill) << qint32(user->contact) << qint32(user->botInfo ? user->botInfo->version : -1);
stream << user->firstName << user->lastName << user->phone << user->username << quint64(user->access);
if (AppVersion >= 9009) {
stream << qint32(user->flags);
}
stream << qint32(user->onlineTill) << qint32(user->contact) << qint32(user->botInfo ? user->botInfo->version : -1);
} else if (peer->isChat()) {
ChatData *chat = peer->asChat();
@ -2985,8 +2997,12 @@ namespace Local {
QString first, last, phone, username;
quint64 access;
qint32 onlineTill, contact, botInfoVersion;
from.stream >> first >> last >> phone >> username >> access >> onlineTill >> contact >> botInfoVersion;
qint32 flags = 0, onlineTill, contact, botInfoVersion;
from.stream >> first >> last >> phone >> username >> access;
if (from.version >= 9009) {
from.stream >> flags;
}
from.stream >> onlineTill >> contact >> botInfoVersion;
bool showPhone = !isServiceUser(user->id) && (peerToUser(user->id) != MTP::authedId()) && (contact <= 0);
QString pname = (showPhone && !phone.isEmpty()) ? App::formatPhone(phone) : QString();
@ -2994,6 +3010,7 @@ namespace Local {
user->setName(first, last, pname, username);
user->access = access;
user->flags = flags;
user->onlineTill = onlineTill;
user->contact = contact;
user->setBotInfoVersion(botInfoVersion);

View File

@ -686,7 +686,7 @@ void ProfileInner::paintEvent(QPaintEvent *e) {
int32 namew = _width - st::profilePhotoSize - st::profileNameLeft;
p.setPen(st::black->p);
if (_peerChannel && _peerChannel->isVerified()) {
if (_peer->isVerified()) {
namew -= st::verifiedCheckProfile.pxWidth() + st::verifiedCheckProfilePos.x();
int32 cx = _left + st::profilePhotoSize + st::profileNameLeft + qMin(_nameText.maxWidth(), namew);
p.drawSprite(QPoint(cx, top + st::profileNameTop) + st::verifiedCheckProfilePos, st::verifiedCheckProfile);

View File

@ -210,6 +210,7 @@ public:
bool isSelf() const {
return (input.type() == mtpc_inputPeerSelf);
}
bool isVerified() const;
UserData *asUser();
const UserData *asUser() const;
ChatData *asChat();
@ -329,7 +330,7 @@ struct PhotoData;
class UserData : public PeerData {
public:
UserData(const PeerId &id) : PeerData(id), access(0), onlineTill(0), contact(-1), blocked(UserBlockUnknown), photosCount(-1), botInfo(0) {
UserData(const PeerId &id) : PeerData(id), access(0), flags(0), onlineTill(0), contact(-1), blocked(UserBlockUnknown), photosCount(-1), botInfo(0) {
setName(QString(), QString(), QString(), QString());
}
void setPhoto(const MTPUserProfilePhoto &photo);
@ -344,6 +345,11 @@ public:
uint64 access;
int32 flags;
bool isVerified() const {
return flags & MTPDuser::flag_verified;
}
MTPInputUser inputUser;
QString firstName;
@ -584,6 +590,9 @@ inline const QString &PeerData::shortName() const {
inline const QString &PeerData::userName() const {
return isUser() ? asUser()->username : (isChannel() ? asChannel()->username : emptyUsername());
}
inline bool PeerData::isVerified() const {
return isUser() ? asUser()->isVerified() : (isChannel() ? asChannel()->isVerified() : false);
}
inline int32 newMessageFlags(PeerData *p) {
return p->isSelf() ? 0 : (((p->isChat() || (p->isUser() && !p->asUser()->botInfo)) ? MTPDmessage::flag_unread : 0) | MTPDmessage::flag_out);

View File

@ -636,7 +636,7 @@ void Window::sendServiceHistoryRequest() {
UserData *user = App::userLoaded(ServiceUserId);
if (!user) {
int32 userFlags = MTPDuser::flag_first_name | MTPDuser::flag_phone | MTPDuser::flag_status;
int32 userFlags = MTPDuser::flag_first_name | MTPDuser::flag_phone | MTPDuser::flag_status | MTPDuser::flag_verified;
user = App::feedUsers(MTP_vector<MTPUser>(1, MTP_user(MTP_int(userFlags), MTP_int(ServiceUserId), MTPlong(), MTP_string("Telegram"), MTPstring(), MTPstring(), MTP_string("42777"), MTP_userProfilePhotoEmpty(), MTP_userStatusRecently(), MTPint())));
}
_serviceHistoryRequest = MTP::send(MTPmessages_GetHistory(user->input, MTP_int(0), MTP_int(0), MTP_int(1), MTP_int(0), MTP_int(0)), main->rpcDone(&MainWidget::serviceHistoryDone), main->rpcFail(&MainWidget::serviceHistoryFail));