Slightly refactored touchbar.

This commit is contained in:
23rd 2019-06-11 13:44:29 +03:00 committed by John Preston
parent 77a216cbca
commit 484ecffb66

View file

@ -106,9 +106,7 @@ inline bool IsUserOnline(PeerData *peer) {
} }
inline int UnreadCount(PeerData *peer) { inline int UnreadCount(PeerData *peer) {
return (peer return (peer && peer->owner().history(peer->id)->unreadCountForBadge());
&& AuthSession::Exists()
&& Auth().data().history(peer->id)->unreadCountForBadge());
} }
NSString *FormatTime(int time) { NSString *FormatTime(int time) {
@ -130,7 +128,7 @@ NSString *FormatTime(int time) {
} }
bool PaintUnreadBadge(Painter &p, PeerData *peer) { bool PaintUnreadBadge(Painter &p, PeerData *peer) {
const auto history = Auth().data().history(peer->id); const auto history = peer->owner().history(peer->id);
const auto count = history->unreadCountForBadge(); const auto count = history->unreadCountForBadge();
if (!count) { if (!count) {
return false; return false;
@ -346,8 +344,8 @@ void SendKeyEvent(int command) {
// Don't draw self userpic if we pin Saved Messages. // Don't draw self userpic if we pin Saved Messages.
if (self.number <= kSavedMessagesId || IsSelfPeer(_peer)) { if (self.number <= kSavedMessagesId || IsSelfPeer(_peer)) {
const auto s = kIdealIconSize * cIntRetinaFactor(); const auto s = kIdealIconSize * cIntRetinaFactor();
auto *pixmap = new QPixmap(s, s); _userpic = QPixmap(s, s);
Painter paint(pixmap); Painter paint(&_userpic);
paint.fillRect(QRectF(0, 0, s, s), QColor(0, 0, 0, 255)); paint.fillRect(QRectF(0, 0, s, s), QColor(0, 0, 0, 255));
if (self.number == kArchiveId) { if (self.number == kArchiveId) {
@ -357,8 +355,7 @@ void SendKeyEvent(int command) {
} else { } else {
Ui::EmptyUserpic::PaintSavedMessages(paint, 0, 0, s, s); Ui::EmptyUserpic::PaintSavedMessages(paint, 0, 0, s, s);
} }
pixmap->setDevicePixelRatio(cRetinaFactor()); _userpic.setDevicePixelRatio(cRetinaFactor());
_userpic = *pixmap;
[self updateImage:_userpic]; [self updateImage:_userpic];
return; return;
} }