[Improvement] Better chat statuses
This commit is contained in:
parent
f66b40cd42
commit
328cec5487
4 changed files with 120 additions and 9 deletions
|
|
@ -108,6 +108,14 @@
|
||||||
"ktg_supergroup_id_copied": "Supergroup ID copied to clipboard.",
|
"ktg_supergroup_id_copied": "Supergroup ID copied to clipboard.",
|
||||||
"ktg_channel_id_copied": "Channel ID copied to clipboard.",
|
"ktg_channel_id_copied": "Channel ID copied to clipboard.",
|
||||||
"ktg_phone_copied": "Phone copied to clipboard.",
|
"ktg_phone_copied": "Phone copied to clipboard.",
|
||||||
|
"ktg_status_mutual_contact": "mutual contact",
|
||||||
|
"ktg_status_contact": "contact",
|
||||||
|
"ktg_status_non_contact": "non-contact",
|
||||||
|
"ktg_supergroup_status": "supergroup",
|
||||||
|
"ktg_group_status_not_in": "not a member",
|
||||||
|
"ktg_channel_status_not_in": "not subscribed",
|
||||||
|
"ktg_group_status_owner": "is owner",
|
||||||
|
"ktg_group_status_admin": "is admin",
|
||||||
"ktg_forward_go_to_chat": "Go to chat",
|
"ktg_forward_go_to_chat": "Go to chat",
|
||||||
"ktg_settings_forward": "Forward",
|
"ktg_settings_forward": "Forward",
|
||||||
"ktg_settings_forward_retain_selection": "Retain selection after forward",
|
"ktg_settings_forward_retain_selection": "Retain selection after forward",
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,12 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "boxes/filters/edit_filter_chats_preview.h"
|
#include "boxes/filters/edit_filter_chats_preview.h"
|
||||||
|
|
||||||
|
#include "kotato/kotato_lang.h"
|
||||||
#include "boxes/filters/edit_filter_chats_list.h"
|
#include "boxes/filters/edit_filter_chats_list.h"
|
||||||
#include "data/data_peer.h"
|
#include "data/data_peer.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_chat.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
#include "history/history.h"
|
#include "history/history.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/text/text_options.h"
|
#include "ui/text/text_options.h"
|
||||||
|
|
@ -104,6 +108,8 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
|
||||||
const auto nameLeft = st.namePosition.x();
|
const auto nameLeft = st.namePosition.x();
|
||||||
p.setFont(st::windowFilterSmallItem.nameStyle.font);
|
p.setFont(st::windowFilterSmallItem.nameStyle.font);
|
||||||
const auto nameTop = st.namePosition.y();
|
const auto nameTop = st.namePosition.y();
|
||||||
|
const auto chatNameTop = st.chatNamePosition.y();
|
||||||
|
const auto chatDescTop = st.chatDescPosition.y();
|
||||||
for (const auto &[flag, button] : _removeFlag) {
|
for (const auto &[flag, button] : _removeFlag) {
|
||||||
PaintFilterChatsTypeIcon(
|
PaintFilterChatsTypeIcon(
|
||||||
p,
|
p,
|
||||||
|
|
@ -121,6 +127,9 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
|
||||||
FilterChatsTypeName(flag));
|
FilterChatsTypeName(flag));
|
||||||
top += st.height;
|
top += st.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList statuses;
|
||||||
|
|
||||||
for (auto &[history, userpic, name, button] : _removePeer) {
|
for (auto &[history, userpic, name, button] : _removePeer) {
|
||||||
const auto savedMessages = history->peer->isSelf();
|
const auto savedMessages = history->peer->isSelf();
|
||||||
const auto repliesMessages = history->peer->isRepliesChat();
|
const auto repliesMessages = history->peer->isRepliesChat();
|
||||||
|
|
@ -156,19 +165,96 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
|
||||||
top + iconTop,
|
top + iconTop,
|
||||||
width(),
|
width(),
|
||||||
st.photoSize);
|
st.photoSize);
|
||||||
|
|
||||||
|
if (history->peer->isUser()) {
|
||||||
|
const auto user = history->peer->asUser();
|
||||||
|
const auto flags = user->flags();
|
||||||
|
|
||||||
|
if (user->isInaccessible()) {
|
||||||
|
statuses << ktr("ktg_user_status_unaccessible");
|
||||||
|
} else {
|
||||||
|
if (user->isSupport()) {
|
||||||
|
statuses << tr::lng_status_support(tr::now);
|
||||||
|
}
|
||||||
|
if (user->isBot()) {
|
||||||
|
statuses << tr::lng_status_bot(tr::now);
|
||||||
|
} else if (flags & UserDataFlag::MutualContact) {
|
||||||
|
statuses << ktr("ktg_status_mutual_contact");
|
||||||
|
} else if (flags & UserDataFlag::Contact) {
|
||||||
|
statuses << ktr("ktg_status_contact");
|
||||||
|
} else {
|
||||||
|
statuses << ktr("ktg_status_non_contact");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (history->peer->isChat()) {
|
||||||
|
statuses << tr::lng_group_status(tr::now);
|
||||||
|
|
||||||
|
const auto chat = history->peer->asChat();
|
||||||
|
if (!chat->amIn()) {
|
||||||
|
statuses << ktr("ktg_group_status_not_in");
|
||||||
|
} else if (chat->amCreator()) {
|
||||||
|
statuses << ktr("ktg_group_status_owner");
|
||||||
|
} else if (chat->hasAdminRights()) {
|
||||||
|
statuses << ktr("ktg_group_status_admin");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (history->peer->isChannel()) {
|
||||||
|
if (history->peer->isMegagroup()) {
|
||||||
|
statuses << ktr("ktg_supergroup_status");
|
||||||
|
} else {
|
||||||
|
statuses << tr::lng_channel_status(tr::now);
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto channel = history->peer->asChannel();
|
||||||
|
if (!channel->amIn()) {
|
||||||
|
statuses << (channel->isMegagroup()
|
||||||
|
? ktr("ktg_group_status_not_in")
|
||||||
|
: ktr("ktg_channel_status_not_in"));
|
||||||
|
} else if (channel->amCreator()) {
|
||||||
|
statuses << ktr("ktg_group_status_owner");
|
||||||
|
} else if (channel->hasAdminRights()) {
|
||||||
|
statuses << ktr("ktg_group_status_admin");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
p.setPen(st::contactsNameFg);
|
p.setPen(st::contactsNameFg);
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
name.setText(
|
name.setText(
|
||||||
st::msgNameStyle,
|
st::msgNameStyle,
|
||||||
history->peer->name(),
|
history->peer->name(),
|
||||||
Ui::NameTextOptions());
|
Ui::NameTextOptions());
|
||||||
|
}
|
||||||
|
if (statuses.empty()) {
|
||||||
|
p.setFont(st::windowFilterSmallItem.nameStyle.font);
|
||||||
|
name.drawLeftElided(
|
||||||
|
p,
|
||||||
|
nameLeft,
|
||||||
|
top + nameTop,
|
||||||
|
button->x() - nameLeft,
|
||||||
|
width());
|
||||||
|
} else {
|
||||||
|
auto nameStr = Ui::Text::String{
|
||||||
|
st::windowFilterChatNameStyle,
|
||||||
|
name.toString(),
|
||||||
|
Ui::NameTextOptions() };
|
||||||
|
|
||||||
|
nameStr.drawLeftElided(
|
||||||
|
p,
|
||||||
|
nameLeft,
|
||||||
|
top + chatNameTop,
|
||||||
|
button->x() - nameLeft,
|
||||||
|
width());
|
||||||
|
|
||||||
|
p.setPen(st::windowSubTextFg);
|
||||||
|
p.setFont(st::windowFilterChatDescStyle.font);
|
||||||
|
p.drawTextLeft(
|
||||||
|
nameLeft,
|
||||||
|
top + chatDescTop,
|
||||||
|
width(),
|
||||||
|
statuses.join(", "));
|
||||||
|
|
||||||
|
statuses.clear();
|
||||||
}
|
}
|
||||||
name.drawLeftElided(
|
|
||||||
p,
|
|
||||||
nameLeft,
|
|
||||||
top + nameTop,
|
|
||||||
button->x() - nameLeft,
|
|
||||||
width());
|
|
||||||
}
|
}
|
||||||
top += st.height;
|
top += st.height;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "storage/file_download.h"
|
#include "storage/file_download.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
#include "data/data_chat.h"
|
#include "data/data_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
|
@ -604,14 +605,22 @@ void PeerListRow::refreshStatus() {
|
||||||
if (!chat->amIn()) {
|
if (!chat->amIn()) {
|
||||||
setStatusText(tr::lng_chat_status_unaccessible(tr::now));
|
setStatusText(tr::lng_chat_status_unaccessible(tr::now));
|
||||||
} else if (chat->count > 0) {
|
} else if (chat->count > 0) {
|
||||||
setStatusText(tr::lng_chat_status_members(tr::now, lt_count_decimal, chat->count));
|
setStatusText(tr::lng_group_status(tr::now) + ", " + tr::lng_chat_status_members(tr::now, lt_count_decimal, chat->count));
|
||||||
} else {
|
} else {
|
||||||
setStatusText(tr::lng_group_status(tr::now));
|
setStatusText(tr::lng_group_status(tr::now));
|
||||||
}
|
}
|
||||||
} else if (peer()->isMegagroup()) {
|
} else if (peer()->isMegagroup()) {
|
||||||
setStatusText(tr::lng_group_status(tr::now));
|
if (peer()->asChannel()->membersCountKnown()) {
|
||||||
|
setStatusText(ktr("ktg_supergroup_status") + ", " + tr::lng_chat_status_members(tr::now, lt_count_decimal, peer()->asChannel()->membersCount()));
|
||||||
|
} else {
|
||||||
|
setStatusText(ktr("ktg_supergroup_status"));
|
||||||
|
}
|
||||||
} else if (peer()->isChannel()) {
|
} else if (peer()->isChannel()) {
|
||||||
setStatusText(tr::lng_channel_status(tr::now));
|
if (peer()->asChannel()->membersCountKnown()) {
|
||||||
|
setStatusText(tr::lng_channel_status(tr::now) + ", " + tr::lng_chat_status_subscribers(tr::now, lt_count_decimal, peer()->asChannel()->membersCount()));
|
||||||
|
} else {
|
||||||
|
setStatusText(tr::lng_channel_status(tr::now));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -275,6 +275,8 @@ windowFilterSmallItem: PeerListItem(defaultPeerListItem) {
|
||||||
height: 44px;
|
height: 44px;
|
||||||
photoPosition: point(13px, 5px);
|
photoPosition: point(13px, 5px);
|
||||||
namePosition: point(59px, 14px);
|
namePosition: point(59px, 14px);
|
||||||
|
chatNamePosition: point(62px, 5px);
|
||||||
|
chatDescPosition: point(62px, 23px);
|
||||||
photoSize: 34px;
|
photoSize: 34px;
|
||||||
checkbox: RoundImageCheckbox(defaultPeerListCheckbox) {
|
checkbox: RoundImageCheckbox(defaultPeerListCheckbox) {
|
||||||
imageRadius: 17px;
|
imageRadius: 17px;
|
||||||
|
|
@ -320,6 +322,12 @@ windowFilterChatsSectionSubtitle: FlatLabel(defaultFlatLabel) {
|
||||||
textFg: searchedBarFg;
|
textFg: searchedBarFg;
|
||||||
}
|
}
|
||||||
windowFilterChatsSectionSubtitlePadding: margins(22px, 5px, 22px, 5px);
|
windowFilterChatsSectionSubtitlePadding: margins(22px, 5px, 22px, 5px);
|
||||||
|
windowFilterChatNameStyle: TextStyle(defaultTextStyle) {
|
||||||
|
font: font(11px semibold);
|
||||||
|
}
|
||||||
|
windowFilterChatDescStyle: TextStyle(defaultTextStyle) {
|
||||||
|
font: font(11px);
|
||||||
|
}
|
||||||
|
|
||||||
windowArchiveToast: Toast(defaultToast) {
|
windowArchiveToast: Toast(defaultToast) {
|
||||||
minWidth: boxWideWidth;
|
minWidth: boxWideWidth;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue