mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Moved out UnreadState to td_ui.
This commit is contained in:
parent
a405794a03
commit
7f85494b1d
6 changed files with 146 additions and 121 deletions
136
Telegram/SourceFiles/dialogs/dialogs_common.h
Normal file
136
Telegram/SourceFiles/dialogs/dialogs_common.h
Normal file
|
@ -0,0 +1,136 @@
|
|||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace Ui {
|
||||
class RippleAnimation;
|
||||
} // namespace Ui
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
class Row;
|
||||
|
||||
enum class SortMode {
|
||||
Date = 0x00,
|
||||
Name = 0x01,
|
||||
Add = 0x02,
|
||||
};
|
||||
|
||||
struct PositionChange {
|
||||
int from = -1;
|
||||
int to = -1;
|
||||
int height = 0;
|
||||
};
|
||||
|
||||
struct UnreadState {
|
||||
int messages = 0;
|
||||
int messagesMuted = 0;
|
||||
int chats = 0;
|
||||
int chatsMuted = 0;
|
||||
int chatsTopic = 0;
|
||||
int chatsTopicMuted = 0;
|
||||
int marks = 0;
|
||||
int marksMuted = 0;
|
||||
int reactions = 0;
|
||||
int reactionsMuted = 0;
|
||||
int forums = 0;
|
||||
int forumsMuted = 0;
|
||||
int mentions = 0;
|
||||
bool known = false;
|
||||
|
||||
UnreadState &operator+=(const UnreadState &other) {
|
||||
messages += other.messages;
|
||||
messagesMuted += other.messagesMuted;
|
||||
chats += other.chats;
|
||||
chatsMuted += other.chatsMuted;
|
||||
chatsTopic += other.chatsTopic;
|
||||
chatsTopicMuted += other.chatsTopicMuted;
|
||||
marks += other.marks;
|
||||
marksMuted += other.marksMuted;
|
||||
reactions += other.reactions;
|
||||
reactionsMuted += other.reactionsMuted;
|
||||
forums += other.forums;
|
||||
forumsMuted += other.forumsMuted;
|
||||
mentions += other.mentions;
|
||||
return *this;
|
||||
}
|
||||
UnreadState &operator-=(const UnreadState &other) {
|
||||
messages -= other.messages;
|
||||
messagesMuted -= other.messagesMuted;
|
||||
chats -= other.chats;
|
||||
chatsMuted -= other.chatsMuted;
|
||||
chatsTopic -= other.chatsTopic;
|
||||
chatsTopicMuted -= other.chatsTopicMuted;
|
||||
marks -= other.marks;
|
||||
marksMuted -= other.marksMuted;
|
||||
reactions -= other.reactions;
|
||||
reactionsMuted -= other.reactionsMuted;
|
||||
forums -= other.forums;
|
||||
forumsMuted -= other.forumsMuted;
|
||||
mentions -= other.mentions;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
inline UnreadState operator+(const UnreadState &a, const UnreadState &b) {
|
||||
auto result = a;
|
||||
result += b;
|
||||
return result;
|
||||
}
|
||||
|
||||
inline UnreadState operator-(const UnreadState &a, const UnreadState &b) {
|
||||
auto result = a;
|
||||
result -= b;
|
||||
return result;
|
||||
}
|
||||
|
||||
struct BadgesState {
|
||||
int unreadCounter = 0;
|
||||
bool unread : 1 = false;
|
||||
bool unreadMuted : 1 = false;
|
||||
bool mention : 1 = false;
|
||||
bool mentionMuted : 1 = false;
|
||||
bool reaction : 1 = false;
|
||||
bool reactionMuted : 1 = false;
|
||||
|
||||
friend inline constexpr auto operator<=>(
|
||||
BadgesState,
|
||||
BadgesState) = default;
|
||||
|
||||
[[nodiscard]] bool empty() const {
|
||||
return !unread && !mention && !reaction;
|
||||
}
|
||||
};
|
||||
|
||||
enum class CountInBadge : uchar {
|
||||
Default,
|
||||
Chats,
|
||||
Messages,
|
||||
};
|
||||
|
||||
enum class IncludeInBadge : uchar {
|
||||
Default,
|
||||
Unmuted,
|
||||
All,
|
||||
UnmutedOrAll,
|
||||
};
|
||||
|
||||
struct RowsByLetter {
|
||||
not_null<Row*> main;
|
||||
base::flat_map<QChar, not_null<Row*>> letters;
|
||||
};
|
||||
|
||||
struct RightButton final {
|
||||
QImage bg;
|
||||
QImage selectedBg;
|
||||
QImage activeBg;
|
||||
Ui::Text::String text;
|
||||
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||
};
|
||||
|
||||
} // namespace Dialogs
|
|
@ -10,10 +10,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "base/flat_map.h"
|
||||
#include "base/weak_ptr.h"
|
||||
#include "base/flags.h"
|
||||
#include "dialogs/dialogs_key.h"
|
||||
#include "dialogs/dialogs_common.h"
|
||||
#include "ui/unread_badge.h"
|
||||
|
||||
class HistoryItem;
|
||||
class History;
|
||||
class UserData;
|
||||
|
||||
namespace Main {
|
||||
|
@ -26,10 +27,10 @@ class Forum;
|
|||
class Folder;
|
||||
class ForumTopic;
|
||||
class SavedSublist;
|
||||
class Thread;
|
||||
} // namespace Data
|
||||
|
||||
namespace Ui {
|
||||
class RippleAnimation;
|
||||
struct PeerUserpicView;
|
||||
} // namespace Ui
|
||||
|
||||
|
@ -40,128 +41,11 @@ struct PaintContext;
|
|||
|
||||
namespace Dialogs {
|
||||
|
||||
struct UnreadState;
|
||||
class Row;
|
||||
class IndexedList;
|
||||
class MainList;
|
||||
|
||||
struct RightButton final {
|
||||
QImage bg;
|
||||
QImage selectedBg;
|
||||
QImage activeBg;
|
||||
Ui::Text::String text;
|
||||
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||
};
|
||||
|
||||
struct RowsByLetter {
|
||||
not_null<Row*> main;
|
||||
base::flat_map<QChar, not_null<Row*>> letters;
|
||||
};
|
||||
|
||||
enum class SortMode {
|
||||
Date = 0x00,
|
||||
Name = 0x01,
|
||||
Add = 0x02,
|
||||
};
|
||||
|
||||
struct PositionChange {
|
||||
int from = -1;
|
||||
int to = -1;
|
||||
int height = 0;
|
||||
};
|
||||
|
||||
struct UnreadState {
|
||||
int messages = 0;
|
||||
int messagesMuted = 0;
|
||||
int chats = 0;
|
||||
int chatsMuted = 0;
|
||||
int chatsTopic = 0;
|
||||
int chatsTopicMuted = 0;
|
||||
int marks = 0;
|
||||
int marksMuted = 0;
|
||||
int reactions = 0;
|
||||
int reactionsMuted = 0;
|
||||
int forums = 0;
|
||||
int forumsMuted = 0;
|
||||
int mentions = 0;
|
||||
bool known = false;
|
||||
|
||||
UnreadState &operator+=(const UnreadState &other) {
|
||||
messages += other.messages;
|
||||
messagesMuted += other.messagesMuted;
|
||||
chats += other.chats;
|
||||
chatsMuted += other.chatsMuted;
|
||||
chatsTopic += other.chatsTopic;
|
||||
chatsTopicMuted += other.chatsTopicMuted;
|
||||
marks += other.marks;
|
||||
marksMuted += other.marksMuted;
|
||||
reactions += other.reactions;
|
||||
reactionsMuted += other.reactionsMuted;
|
||||
forums += other.forums;
|
||||
forumsMuted += other.forumsMuted;
|
||||
mentions += other.mentions;
|
||||
return *this;
|
||||
}
|
||||
UnreadState &operator-=(const UnreadState &other) {
|
||||
messages -= other.messages;
|
||||
messagesMuted -= other.messagesMuted;
|
||||
chats -= other.chats;
|
||||
chatsMuted -= other.chatsMuted;
|
||||
chatsTopic -= other.chatsTopic;
|
||||
chatsTopicMuted -= other.chatsTopicMuted;
|
||||
marks -= other.marks;
|
||||
marksMuted -= other.marksMuted;
|
||||
reactions -= other.reactions;
|
||||
reactionsMuted -= other.reactionsMuted;
|
||||
forums -= other.forums;
|
||||
forumsMuted -= other.forumsMuted;
|
||||
mentions -= other.mentions;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
inline UnreadState operator+(const UnreadState &a, const UnreadState &b) {
|
||||
auto result = a;
|
||||
result += b;
|
||||
return result;
|
||||
}
|
||||
|
||||
inline UnreadState operator-(const UnreadState &a, const UnreadState &b) {
|
||||
auto result = a;
|
||||
result -= b;
|
||||
return result;
|
||||
}
|
||||
|
||||
struct BadgesState {
|
||||
int unreadCounter = 0;
|
||||
bool unread : 1 = false;
|
||||
bool unreadMuted : 1 = false;
|
||||
bool mention : 1 = false;
|
||||
bool mentionMuted : 1 = false;
|
||||
bool reaction : 1 = false;
|
||||
bool reactionMuted : 1 = false;
|
||||
|
||||
friend inline constexpr auto operator<=>(
|
||||
BadgesState,
|
||||
BadgesState) = default;
|
||||
|
||||
[[nodiscard]] bool empty() const {
|
||||
return !unread && !mention && !reaction;
|
||||
}
|
||||
};
|
||||
|
||||
enum class CountInBadge : uchar {
|
||||
Default,
|
||||
Chats,
|
||||
Messages,
|
||||
};
|
||||
|
||||
enum class IncludeInBadge : uchar {
|
||||
Default,
|
||||
Unmuted,
|
||||
All,
|
||||
UnmutedOrAll,
|
||||
};
|
||||
|
||||
[[nodiscard]] BadgesState BadgesForUnread(
|
||||
const UnreadState &state,
|
||||
CountInBadge count = CountInBadge::Default,
|
||||
|
|
|
@ -7,13 +7,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dialogs/dialogs_entry.h"
|
||||
#include "dialogs/dialogs_list.h"
|
||||
|
||||
class History;
|
||||
|
||||
namespace Dialogs {
|
||||
|
||||
struct RowsByLetter;
|
||||
class Row;
|
||||
|
||||
class IndexedList {
|
||||
public:
|
||||
IndexedList(SortMode sortMode, FilterId filterId = 0);
|
||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dialogs/dialogs_common.h"
|
||||
#include "dialogs/dialogs_indexed_list.h"
|
||||
#include "dialogs/dialogs_pinned_list.h"
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "data/data_photo_media.h"
|
||||
#include "data/data_file_origin.h"
|
||||
#include "data/data_session.h"
|
||||
#include "dialogs/dialogs_entry.h"
|
||||
#include "dialogs/ui/dialogs_layout.h"
|
||||
#include "ui/painter.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
|
|
|
@ -95,6 +95,7 @@ PRIVATE
|
|||
data/data_statistics_chart.h
|
||||
data/data_subscriptions.h
|
||||
|
||||
dialogs/dialogs_common.h
|
||||
dialogs/dialogs_three_state_icon.h
|
||||
dialogs/ui/chat_search_empty.cpp
|
||||
dialogs/ui/chat_search_empty.h
|
||||
|
|
Loading…
Add table
Reference in a new issue