[Improvement] Better chat statuses
This commit is contained in:
		
							parent
							
								
									03cb40cf15
								
							
						
					
					
						commit
						a254d406e7
					
				
					 4 changed files with 120 additions and 9 deletions
				
			
		|  | @ -147,6 +147,14 @@ | |||
| 	"ktg_channel_id_copied": "Channel ID copied to clipboard.", | ||||
| 	"ktg_phone_copied": "Phone copied to clipboard.", | ||||
| 	"ktg_mention_copied": "Username 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_settings_forward": "Forward", | ||||
| 	"ktg_settings_forward_retain_selection": "Retain selection after forward", | ||||
|  |  | |||
|  | @ -21,6 +21,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | |||
| #include "ui/filter_icon_panel.h" | ||||
| #include "data/data_chat_filters.h" | ||||
| #include "data/data_peer.h" | ||||
| #include "data/data_user.h" | ||||
| #include "data/data_chat.h" | ||||
| #include "data/data_channel.h" | ||||
| #include "data/data_session.h" | ||||
| #include "core/application.h" | ||||
| #include "core/core_settings.h" | ||||
|  | @ -236,6 +239,8 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) { | |||
| 	const auto nameLeft = st.namePosition.x(); | ||||
| 	p.setFont(st::windowFilterSmallItem.nameStyle.font); | ||||
| 	const auto nameTop = st.namePosition.y(); | ||||
| 	const auto chatNameTop = st.chatNamePosition.y(); | ||||
| 	const auto chatDescTop = st.chatDescPosition.y(); | ||||
| 	for (const auto &[flag, button] : _removeFlag) { | ||||
| 		PaintFilterChatsTypeIcon( | ||||
| 			p, | ||||
|  | @ -253,6 +258,9 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) { | |||
| 			FilterChatsTypeName(flag)); | ||||
| 		top += st.height; | ||||
| 	} | ||||
| 
 | ||||
| 	QStringList statuses; | ||||
| 
 | ||||
| 	for (auto &[history, userpic, button] : _removePeer) { | ||||
| 		const auto savedMessages = history->peer->isSelf(); | ||||
| 		const auto repliesMessages = history->peer->isRepliesChat(); | ||||
|  | @ -288,13 +296,90 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) { | |||
| 				top + iconTop, | ||||
| 				width(), | ||||
| 				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); | ||||
| 			history->peer->nameText().drawLeftElided( | ||||
| 				p, | ||||
| 				nameLeft, | ||||
| 				top + nameTop, | ||||
| 				button->x() - nameLeft, | ||||
| 				width()); | ||||
| 			if (statuses.empty()) { | ||||
| 				p.setFont(st::windowFilterSmallItem.nameStyle.font); | ||||
| 				history->peer->nameText().drawLeftElided( | ||||
| 					p, | ||||
| 					nameLeft, | ||||
| 					top + nameTop, | ||||
| 					button->x() - nameLeft, | ||||
| 					width()); | ||||
| 			} else { | ||||
| 				auto nameStr = Ui::Text::String{ | ||||
| 					st::windowFilterChatNameStyle, | ||||
| 					history->peer->nameText().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(); | ||||
| 			} | ||||
| 		} | ||||
| 		top += st.height; | ||||
| 	} | ||||
|  |  | |||
|  | @ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL | |||
| #include "lang/lang_keys.h" | ||||
| #include "storage/file_download.h" | ||||
| #include "data/data_peer_values.h" | ||||
| #include "data/data_channel.h" | ||||
| #include "data/data_chat.h" | ||||
| #include "data/data_user.h" | ||||
| #include "data/data_session.h" | ||||
|  | @ -498,14 +499,22 @@ void PeerListRow::refreshStatus() { | |||
| 		if (!chat->amIn()) { | ||||
| 			setStatusText(tr::lng_chat_status_unaccessible(tr::now)); | ||||
| 		} 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 { | ||||
| 			setStatusText(tr::lng_group_status(tr::now)); | ||||
| 		} | ||||
| 	} 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()) { | ||||
| 		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)); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -303,6 +303,8 @@ windowFilterSmallItem: PeerListItem(defaultPeerListItem) { | |||
| 	height: 44px; | ||||
| 	photoPosition: point(15px, 5px); | ||||
| 	namePosition: point(62px, 14px); | ||||
| 	chatNamePosition: point(62px, 5px); | ||||
| 	chatDescPosition: point(62px, 23px); | ||||
| 	photoSize: 34px; | ||||
| 	checkbox: RoundImageCheckbox(defaultPeerListCheckbox) { | ||||
| 		imageRadius: 17px; | ||||
|  | @ -352,6 +354,13 @@ windowArchiveToast: Toast(defaultToast) { | |||
| 	maxWidth: boxWideWidth; | ||||
| } | ||||
| 
 | ||||
| windowFilterChatNameStyle: TextStyle(defaultTextStyle) { | ||||
| 	font: font(11px semibold); | ||||
| } | ||||
| windowFilterChatDescStyle: TextStyle(defaultTextStyle) { | ||||
| 	font: font(11px); | ||||
| } | ||||
| 
 | ||||
| // Mac specific | ||||
| 
 | ||||
| macAccessoryWidth: 450.; | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue