2017-09-26 17:57:01 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-09-26 17:57:01 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-09-26 17:57:01 +00:00
|
|
|
*/
|
|
|
|
#include "info/profile/info_profile_members_controllers.h"
|
|
|
|
|
2019-01-10 06:26:08 +00:00
|
|
|
#include "boxes/peers/edit_participants_box.h"
|
2022-05-24 06:56:12 +00:00
|
|
|
#include "info/profile/info_profile_values.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_chat.h"
|
|
|
|
#include "data/data_user.h"
|
2022-05-24 06:56:12 +00:00
|
|
|
#include "ui/unread_badge.h"
|
2022-03-29 16:43:33 +00:00
|
|
|
#include "lang/lang_keys.h"
|
2017-11-07 17:53:00 +00:00
|
|
|
#include "styles/style_info.h"
|
2022-05-24 06:56:12 +00:00
|
|
|
#include "styles/style_boxes.h"
|
|
|
|
#include "styles/style_dialogs.h"
|
2017-09-26 17:57:01 +00:00
|
|
|
|
|
|
|
namespace Info {
|
|
|
|
namespace Profile {
|
|
|
|
|
2017-11-07 17:53:00 +00:00
|
|
|
MemberListRow::MemberListRow(
|
|
|
|
not_null<UserData*> user,
|
|
|
|
Type type)
|
2022-03-29 16:43:33 +00:00
|
|
|
: PeerListRowWithLink(user)
|
2017-11-07 17:53:00 +00:00
|
|
|
, _type(type) {
|
2022-05-24 06:56:12 +00:00
|
|
|
setType(type);
|
2017-11-07 17:53:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MemberListRow::setType(Type type) {
|
|
|
|
_type = type;
|
2022-05-24 06:56:12 +00:00
|
|
|
PeerListRowWithLink::setActionLink(!_type.adminRank.isEmpty()
|
|
|
|
? _type.adminRank
|
|
|
|
: (_type.rights == Rights::Creator)
|
|
|
|
? tr::lng_owner_badge(tr::now)
|
|
|
|
: (_type.rights == Rights::Admin)
|
|
|
|
? tr::lng_admin_badge(tr::now)
|
|
|
|
: QString());
|
2022-03-29 16:43:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool MemberListRow::rightActionDisabled() const {
|
2022-05-24 06:56:12 +00:00
|
|
|
return true;
|
2017-11-07 17:53:00 +00:00
|
|
|
}
|
|
|
|
|
2022-03-29 16:43:33 +00:00
|
|
|
QMargins MemberListRow::rightActionMargins() const {
|
2022-05-24 06:56:12 +00:00
|
|
|
const auto skip = st::contactsCheckPosition.x();
|
|
|
|
return QMargins(
|
|
|
|
skip,
|
|
|
|
st::defaultPeerListItem.namePosition.y(),
|
|
|
|
st::defaultPeerListItem.photoPosition.x() + skip,
|
|
|
|
0);
|
2022-03-29 16:43:33 +00:00
|
|
|
}
|
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
not_null<UserData*> MemberListRow::user() const {
|
|
|
|
return peer()->asUser();
|
|
|
|
}
|
|
|
|
|
2020-04-30 15:31:44 +00:00
|
|
|
void MemberListRow::refreshStatus() {
|
|
|
|
if (user()->isBot()) {
|
2022-03-29 16:43:33 +00:00
|
|
|
const auto seesAllMessages = (user()->botInfo->readsAllHistory
|
|
|
|
|| _type.rights != Rights::Normal);
|
2020-04-30 15:31:44 +00:00
|
|
|
setCustomStatus(seesAllMessages
|
|
|
|
? tr::lng_status_bot_reads_all(tr::now)
|
|
|
|
: tr::lng_status_bot_not_reads_all(tr::now));
|
|
|
|
} else {
|
|
|
|
PeerListRow::refreshStatus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-26 17:57:01 +00:00
|
|
|
std::unique_ptr<PeerListController> CreateMembersController(
|
2019-06-06 10:21:40 +00:00
|
|
|
not_null<Window::SessionNavigation*> navigation,
|
2017-09-26 17:57:01 +00:00
|
|
|
not_null<PeerData*> peer) {
|
2019-01-13 08:03:34 +00:00
|
|
|
return std::make_unique<ParticipantsBoxController>(
|
|
|
|
navigation,
|
|
|
|
peer,
|
|
|
|
ParticipantsBoxController::Role::Profile);
|
2017-09-26 17:57:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Profile
|
|
|
|
} // namespace Info
|