Display unread/mention mark in small left column.

Fixes #4939.
This commit is contained in:
John Preston 2018-07-12 22:25:10 +03:00
parent 0b7bb806b7
commit 4c9ef606f3
2 changed files with 45 additions and 26 deletions

View file

@ -432,20 +432,6 @@ void RowPainter::paint(
} }
return cloudDraft ? ParseDateTime(cloudDraft->date) : QDateTime(); return cloudDraft ? ParseDateTime(cloudDraft->date) : QDateTime();
}(); }();
const auto from = history
? (history->peer->migrateTo()
? history->peer->migrateTo()
: history->peer.get())
: nullptr;
const auto flags = (active ? Flag::Active : Flag(0))
| (selected ? Flag::Selected : Flag(0))
| (onlyBackground ? Flag::OnlyBackground : Flag(0))
| (peer && peer->isSelf() ? Flag::SavedMessages : Flag(0));
const auto paintItemCallback = [&](int nameleft, int namewidth) {
auto availableWidth = namewidth;
auto texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip;
auto hadOneBadge = false;
const auto displayMentionBadge = history const auto displayMentionBadge = history
? history->hasUnreadMentions() ? history->hasUnreadMentions()
: false; : false;
@ -467,6 +453,20 @@ void RowPainter::paint(
&& !displayMentionBadge && !displayMentionBadge
&& !displayUnreadMark && !displayUnreadMark
&& entry->isPinnedDialog(); && entry->isPinnedDialog();
const auto from = history
? (history->peer->migrateTo()
? history->peer->migrateTo()
: history->peer.get())
: nullptr;
const auto flags = (active ? Flag::Active : Flag(0))
| (selected ? Flag::Selected : Flag(0))
| (onlyBackground ? Flag::OnlyBackground : Flag(0))
| (peer && peer->isSelf() ? Flag::SavedMessages : Flag(0));
const auto paintItemCallback = [&](int nameleft, int namewidth) {
auto availableWidth = namewidth;
auto texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip;
auto hadOneBadge = false;
if (displayUnreadCounter || displayUnreadMark) { if (displayUnreadCounter || displayUnreadMark) {
auto counter = (unreadCount > 0) auto counter = (unreadCount > 0)
? QString::number(unreadCount) ? QString::number(unreadCount)
@ -533,10 +533,15 @@ void RowPainter::paint(
} }
}; };
const auto paintCounterCallback = [&] { const auto paintCounterCallback = [&] {
if (unreadCount) { auto hadOneBadge = false;
auto counter = QString::number(unreadCount); auto skipBeforeMention = 0;
if (counter.size() > 4) { if (displayUnreadCounter || displayUnreadMark) {
counter = qsl("..") + counter.mid(counter.size() - 3); auto counter = (unreadCount > 0)
? QString::number(unreadCount)
: QString();
const auto allowDigits = displayMentionBadge ? 1 : 3;
if (counter.size() > allowDigits + 1) {
counter = qsl("..") + counter.mid(counter.size() - allowDigits);
} }
auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize; auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize;
auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight; auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight;
@ -546,6 +551,20 @@ void RowPainter::paint(
st.active = active; st.active = active;
st.muted = unreadMuted; st.muted = unreadMuted;
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth); paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
skipBeforeMention += unreadWidth + st.padding;
}
if (displayMentionBadge) {
auto counter = qsl("@");
auto unreadRight = st::dialogsPadding.x() + st::dialogsPhotoSize - skipBeforeMention;
auto unreadTop = st::dialogsPadding.y() + st::dialogsPhotoSize - st::dialogsUnreadHeight;
auto unreadWidth = 0;
UnreadBadgeStyle st;
st.active = active;
st.muted = false;
st.padding = 0;
st.textTop = 0;
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
} }
}; };
paintRow( paintRow(

View file

@ -646,7 +646,7 @@ int32 MainWindow::screenNameChecksum(const QString &name) const {
} }
void MainWindow::psRefreshTaskbarIcon() { void MainWindow::psRefreshTaskbarIcon() {
auto refresher = std::make_unique<QWidget>(this); const auto refresher = std::make_unique<QWidget>(this);
refresher->setWindowFlags(static_cast<Qt::WindowFlags>(Qt::Tool) | Qt::FramelessWindowHint); refresher->setWindowFlags(static_cast<Qt::WindowFlags>(Qt::Tool) | Qt::FramelessWindowHint);
refresher->setGeometry(x() + 1, y() + 1, 1, 1); refresher->setGeometry(x() + 1, y() + 1, 1, 1);
auto palette = refresher->palette(); auto palette = refresher->palette();