mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 13:17:08 +02:00
Added support of muted chats filters to chats filters strip.
This commit is contained in:
parent
edf6c42e9d
commit
9c1701c62a
3 changed files with 15 additions and 8 deletions
|
@ -70,19 +70,19 @@ void ChatsFiltersTabs::fitWidthToSections() {
|
|||
}
|
||||
}
|
||||
|
||||
void ChatsFiltersTabs::setUnreadCount(int index, int unreadCount) {
|
||||
void ChatsFiltersTabs::setUnreadCount(int index, int unreadCount, bool mute) {
|
||||
const auto it = _unreadCounts.find(index);
|
||||
if (it == _unreadCounts.end()) {
|
||||
if (unreadCount) {
|
||||
_unreadCounts.emplace(index, Unread{
|
||||
.cache = cacheUnreadCount(unreadCount),
|
||||
.cache = cacheUnreadCount(unreadCount, mute),
|
||||
.count = unreadCount,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (unreadCount) {
|
||||
it->second.count = unreadCount;
|
||||
it->second.cache = cacheUnreadCount(unreadCount);
|
||||
it->second.cache = cacheUnreadCount(unreadCount, mute);
|
||||
} else {
|
||||
_unreadCounts.erase(it);
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ void ChatsFiltersTabs::setLockedFrom(int index) {
|
|||
});
|
||||
}
|
||||
|
||||
QImage ChatsFiltersTabs::cacheUnreadCount(int count) const {
|
||||
QImage ChatsFiltersTabs::cacheUnreadCount(int count, bool muted) const {
|
||||
const auto widthIndex = (count < 10) ? 0 : (count < 100) ? 1 : 2;
|
||||
auto image = QImage(
|
||||
QSize(_cachedBadgeWidths[widthIndex], _cachedBadgeHeight)
|
||||
|
@ -145,7 +145,13 @@ QImage ChatsFiltersTabs::cacheUnreadCount(int count) const {
|
|||
: QString::number(count);
|
||||
{
|
||||
auto p = QPainter(&image);
|
||||
Ui::PaintUnreadBadge(p, string, 0, 0, _unreadSt, 0);
|
||||
if (muted) {
|
||||
auto copy = _unreadSt;
|
||||
copy.muted = muted;
|
||||
Ui::PaintUnreadBadge(p, string, 0, 0, copy, 0);
|
||||
} else {
|
||||
Ui::PaintUnreadBadge(p, string, 0, 0, _unreadSt, 0);
|
||||
}
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
|
||||
[[nodiscard]] int centerOfSection(int section) const;
|
||||
void fitWidthToSections();
|
||||
void setUnreadCount(int index, int unreadCount);
|
||||
void setUnreadCount(int index, int unreadCount, bool muted);
|
||||
void setLockedFrom(int index);
|
||||
|
||||
[[nodiscard]] rpl::producer<int> contextMenuRequested() const;
|
||||
|
@ -62,7 +62,7 @@ protected:
|
|||
std::vector<ShiftedSection> _sections;
|
||||
|
||||
private:
|
||||
[[nodiscard]] QImage cacheUnreadCount(int count) const;
|
||||
[[nodiscard]] QImage cacheUnreadCount(int count, bool muted) const;
|
||||
[[nodiscard]] int calculateLockedFromX() const;
|
||||
|
||||
using Index = int;
|
||||
|
|
|
@ -330,7 +330,8 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
|||
const auto muted = (state.chatsMuted + state.marksMuted);
|
||||
const auto count = (state.chats + state.marks)
|
||||
- (includeMuted ? 0 : muted);
|
||||
slider->setUnreadCount(i, count);
|
||||
const auto isMuted = includeMuted && (count == muted);
|
||||
slider->setUnreadCount(i, count, isMuted);
|
||||
slider->fitWidthToSections();
|
||||
}, state->unreadLifetime);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue