mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Replaced kick button with admin rank in list of members.
This commit is contained in:
parent
221ef74150
commit
d7bf9e285c
4 changed files with 42 additions and 23 deletions
|
@ -46,8 +46,7 @@ public:
|
|||
|
||||
void lazyInitialize(const style::PeerListItem &st) override;
|
||||
|
||||
private:
|
||||
void refreshActionLink();
|
||||
protected:
|
||||
QSize rightActionSize() const override;
|
||||
QMargins rightActionMargins() const override;
|
||||
void rightActionPaint(
|
||||
|
@ -58,6 +57,9 @@ private:
|
|||
bool selected,
|
||||
bool actionSelected) override;
|
||||
|
||||
private:
|
||||
void refreshActionLink();
|
||||
|
||||
QString _action;
|
||||
int _actionWidth = 0;
|
||||
|
||||
|
|
|
@ -1930,7 +1930,8 @@ auto ParticipantsBoxController::computeType(
|
|||
: (user && _additional.adminRights(user).has_value())
|
||||
? Rights::Admin
|
||||
: Rights::Normal;
|
||||
result.canRemove = _additional.canRemoveParticipant(participant);
|
||||
// result.canRemove = _additional.canRemoveParticipant(participant);
|
||||
result.adminRank = user ? _additional.adminRank(user) : QString();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,21 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#include "info/profile/info_profile_members_controllers.h"
|
||||
|
||||
#include <rpl/variable.h>
|
||||
#include "base/weak_ptr.h"
|
||||
#include "boxes/peers/edit_participants_box.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "apiwrap.h"
|
||||
#include "main/main_session.h"
|
||||
#include "mainwidget.h"
|
||||
#include "data/data_channel.h"
|
||||
#include "data/data_chat.h"
|
||||
#include "data/data_user.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "styles/style_info.h"
|
||||
#include "data/data_peer_values.h"
|
||||
|
||||
namespace Info {
|
||||
namespace Profile {
|
||||
|
@ -29,12 +19,18 @@ namespace Profile {
|
|||
MemberListRow::MemberListRow(
|
||||
not_null<UserData*> user,
|
||||
Type type)
|
||||
: PeerListRow(user)
|
||||
: PeerListRowWithLink(user)
|
||||
, _type(type) {
|
||||
PeerListRowWithLink::setActionLink(_type.adminRank);
|
||||
}
|
||||
|
||||
void MemberListRow::setType(Type type) {
|
||||
_type = type;
|
||||
PeerListRowWithLink::setActionLink(_type.adminRank);
|
||||
}
|
||||
|
||||
bool MemberListRow::rightActionDisabled() const {
|
||||
return !canRemove();
|
||||
}
|
||||
|
||||
QSize MemberListRow::rightActionSize() const {
|
||||
|
@ -43,7 +39,7 @@ QSize MemberListRow::rightActionSize() const {
|
|||
QPoint(),
|
||||
st::infoMembersRemoveIcon.size()).marginsAdded(
|
||||
st::infoMembersRemoveIconMargins).size()
|
||||
: QSize();
|
||||
: PeerListRowWithLink::rightActionSize();
|
||||
}
|
||||
|
||||
void MemberListRow::rightActionPaint(
|
||||
|
@ -59,9 +55,23 @@ void MemberListRow::rightActionPaint(
|
|||
(actionSelected
|
||||
? st::infoMembersRemoveIconOver
|
||||
: st::infoMembersRemoveIcon).paint(p, x, y, outerWidth);
|
||||
} else {
|
||||
PeerListRowWithLink::rightActionPaint(
|
||||
p,
|
||||
x,
|
||||
y,
|
||||
outerWidth,
|
||||
selected,
|
||||
actionSelected);
|
||||
}
|
||||
}
|
||||
|
||||
QMargins MemberListRow::rightActionMargins() const {
|
||||
return canRemove()
|
||||
? QMargins()
|
||||
: PeerListRowWithLink::rightActionMargins();
|
||||
}
|
||||
|
||||
int MemberListRow::nameIconWidth() const {
|
||||
return (_type.rights == Rights::Admin)
|
||||
? st::infoMembersAdminIcon.width()
|
||||
|
@ -80,7 +90,7 @@ void MemberListRow::paintNameIcon(
|
|||
int y,
|
||||
int outerWidth,
|
||||
bool selected) {
|
||||
auto icon = [&] {
|
||||
const auto icon = [&] {
|
||||
return (_type.rights == Rights::Admin)
|
||||
? (selected
|
||||
? &st::infoMembersAdminIconOver
|
||||
|
@ -94,7 +104,8 @@ void MemberListRow::paintNameIcon(
|
|||
|
||||
void MemberListRow::refreshStatus() {
|
||||
if (user()->isBot()) {
|
||||
auto seesAllMessages = (user()->botInfo->readsAllHistory || _type.rights != Rights::Normal);
|
||||
const auto seesAllMessages = (user()->botInfo->readsAllHistory
|
||||
|| _type.rights != Rights::Normal);
|
||||
setCustomStatus(seesAllMessages
|
||||
? tr::lng_status_bot_reads_all(tr::now)
|
||||
: tr::lng_status_bot_not_reads_all(tr::now));
|
||||
|
@ -103,6 +114,10 @@ void MemberListRow::refreshStatus() {
|
|||
}
|
||||
}
|
||||
|
||||
bool MemberListRow::canRemove() const {
|
||||
return _type.canRemove;
|
||||
}
|
||||
|
||||
std::unique_ptr<PeerListController> CreateMembersController(
|
||||
not_null<Window::SessionNavigation*> navigation,
|
||||
not_null<PeerData*> peer) {
|
||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include "boxes/peer_list_box.h"
|
||||
#include "boxes/peer_list_controllers.h"
|
||||
|
||||
namespace Window {
|
||||
class SessionNavigation;
|
||||
|
@ -16,7 +16,7 @@ class SessionNavigation;
|
|||
namespace Info {
|
||||
namespace Profile {
|
||||
|
||||
class MemberListRow final : public PeerListRow {
|
||||
class MemberListRow final : public PeerListRowWithLink {
|
||||
public:
|
||||
enum class Rights {
|
||||
Normal,
|
||||
|
@ -26,11 +26,14 @@ public:
|
|||
struct Type {
|
||||
Rights rights;
|
||||
bool canRemove = false;
|
||||
QString adminRank;
|
||||
};
|
||||
|
||||
MemberListRow(not_null<UserData*> user, Type type);
|
||||
|
||||
void setType(Type type);
|
||||
bool rightActionDisabled() const override;
|
||||
QMargins rightActionMargins() const override;
|
||||
QSize rightActionSize() const override;
|
||||
void rightActionPaint(
|
||||
Painter &p,
|
||||
|
@ -49,11 +52,9 @@ public:
|
|||
void refreshStatus() override;
|
||||
|
||||
not_null<UserData*> user() const;
|
||||
bool canRemove() const {
|
||||
return _type.canRemove;
|
||||
}
|
||||
|
||||
private:
|
||||
[[nodiscard]] bool canRemove() const;
|
||||
Type _type;
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue