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"
|
|
|
|
|
2017-10-22 12:07:57 +00:00
|
|
|
#include <rpl/variable.h>
|
2017-11-30 17:33:27 +00:00
|
|
|
#include "base/weak_ptr.h"
|
2019-01-10 06:26:08 +00:00
|
|
|
#include "boxes/peers/edit_participants_box.h"
|
2017-10-22 17:06:57 +00:00
|
|
|
#include "ui/widgets/popup_menu.h"
|
2017-09-26 17:57:01 +00:00
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "apiwrap.h"
|
|
|
|
#include "auth_session.h"
|
2017-10-22 17:06:57 +00:00
|
|
|
#include "mainwidget.h"
|
2017-09-26 17:57:01 +00:00
|
|
|
#include "observer_peer.h"
|
2019-01-10 06:26:08 +00:00
|
|
|
#include "data/data_channel.h"
|
2019-01-04 11:09:48 +00:00
|
|
|
#include "data/data_chat.h"
|
|
|
|
#include "data/data_user.h"
|
2017-10-22 17:06:57 +00:00
|
|
|
#include "boxes/confirm_box.h"
|
2017-10-03 13:05:58 +00:00
|
|
|
#include "window/window_controller.h"
|
2017-11-07 17:53:00 +00:00
|
|
|
#include "styles/style_info.h"
|
2017-12-17 08:13:26 +00:00
|
|
|
#include "data/data_peer_values.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)
|
|
|
|
: PeerListRow(user)
|
|
|
|
, _type(type) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void MemberListRow::setType(Type type) {
|
|
|
|
_type = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize MemberListRow::actionSize() const {
|
|
|
|
return canRemove()
|
|
|
|
? QRect(
|
|
|
|
QPoint(),
|
|
|
|
st::infoMembersRemoveIcon.size()).marginsAdded(
|
|
|
|
st::infoMembersRemoveIconMargins).size()
|
|
|
|
: QSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MemberListRow::paintAction(
|
|
|
|
Painter &p,
|
2019-02-19 06:57:53 +00:00
|
|
|
crl::time ms,
|
2017-11-07 17:53:00 +00:00
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
bool selected,
|
|
|
|
bool actionSelected) {
|
|
|
|
if (_type.canRemove && selected) {
|
|
|
|
x += st::infoMembersRemoveIconMargins.left();
|
|
|
|
y += st::infoMembersRemoveIconMargins.top();
|
|
|
|
(actionSelected
|
|
|
|
? st::infoMembersRemoveIconOver
|
|
|
|
: st::infoMembersRemoveIcon).paint(p, x, y, outerWidth);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int MemberListRow::nameIconWidth() const {
|
|
|
|
return (_type.rights == Rights::Admin)
|
|
|
|
? st::infoMembersAdminIcon.width()
|
|
|
|
: (_type.rights == Rights::Creator)
|
|
|
|
? st::infoMembersCreatorIcon.width()
|
|
|
|
: 0;
|
|
|
|
}
|
|
|
|
|
2019-01-04 11:09:48 +00:00
|
|
|
not_null<UserData*> MemberListRow::user() const {
|
|
|
|
return peer()->asUser();
|
|
|
|
}
|
|
|
|
|
2017-11-07 17:53:00 +00:00
|
|
|
void MemberListRow::paintNameIcon(
|
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
2017-11-08 16:45:30 +00:00
|
|
|
int outerWidth,
|
|
|
|
bool selected) {
|
2017-11-07 17:53:00 +00:00
|
|
|
auto icon = [&] {
|
|
|
|
return (_type.rights == Rights::Admin)
|
2017-11-08 16:45:30 +00:00
|
|
|
? (selected
|
|
|
|
? &st::infoMembersAdminIconOver
|
|
|
|
: &st::infoMembersAdminIcon)
|
|
|
|
: (selected
|
|
|
|
? &st::infoMembersCreatorIconOver
|
|
|
|
: &st::infoMembersCreatorIcon);
|
2017-11-07 17:53:00 +00:00
|
|
|
}();
|
|
|
|
icon->paint(p, x, y, outerWidth);
|
|
|
|
}
|
|
|
|
|
2017-09-26 17:57:01 +00:00
|
|
|
std::unique_ptr<PeerListController> CreateMembersController(
|
2017-12-04 07:33:33 +00:00
|
|
|
not_null<Window::Navigation*> 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
|