mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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;
|
void lazyInitialize(const style::PeerListItem &st) override;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
void refreshActionLink();
|
|
||||||
QSize rightActionSize() const override;
|
QSize rightActionSize() const override;
|
||||||
QMargins rightActionMargins() const override;
|
QMargins rightActionMargins() const override;
|
||||||
void rightActionPaint(
|
void rightActionPaint(
|
||||||
|
@ -58,6 +57,9 @@ private:
|
||||||
bool selected,
|
bool selected,
|
||||||
bool actionSelected) override;
|
bool actionSelected) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void refreshActionLink();
|
||||||
|
|
||||||
QString _action;
|
QString _action;
|
||||||
int _actionWidth = 0;
|
int _actionWidth = 0;
|
||||||
|
|
||||||
|
|
|
@ -1930,7 +1930,8 @@ auto ParticipantsBoxController::computeType(
|
||||||
: (user && _additional.adminRights(user).has_value())
|
: (user && _additional.adminRights(user).has_value())
|
||||||
? Rights::Admin
|
? Rights::Admin
|
||||||
: Rights::Normal;
|
: Rights::Normal;
|
||||||
result.canRemove = _additional.canRemoveParticipant(participant);
|
// result.canRemove = _additional.canRemoveParticipant(participant);
|
||||||
|
result.adminRank = user ? _additional.adminRank(user) : QString();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,21 +7,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "info/profile/info_profile_members_controllers.h"
|
#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 "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_chat.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "window/window_session_controller.h"
|
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
#include "data/data_peer_values.h"
|
|
||||||
|
|
||||||
namespace Info {
|
namespace Info {
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
|
@ -29,12 +19,18 @@ namespace Profile {
|
||||||
MemberListRow::MemberListRow(
|
MemberListRow::MemberListRow(
|
||||||
not_null<UserData*> user,
|
not_null<UserData*> user,
|
||||||
Type type)
|
Type type)
|
||||||
: PeerListRow(user)
|
: PeerListRowWithLink(user)
|
||||||
, _type(type) {
|
, _type(type) {
|
||||||
|
PeerListRowWithLink::setActionLink(_type.adminRank);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemberListRow::setType(Type type) {
|
void MemberListRow::setType(Type type) {
|
||||||
_type = type;
|
_type = type;
|
||||||
|
PeerListRowWithLink::setActionLink(_type.adminRank);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MemberListRow::rightActionDisabled() const {
|
||||||
|
return !canRemove();
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize MemberListRow::rightActionSize() const {
|
QSize MemberListRow::rightActionSize() const {
|
||||||
|
@ -43,7 +39,7 @@ QSize MemberListRow::rightActionSize() const {
|
||||||
QPoint(),
|
QPoint(),
|
||||||
st::infoMembersRemoveIcon.size()).marginsAdded(
|
st::infoMembersRemoveIcon.size()).marginsAdded(
|
||||||
st::infoMembersRemoveIconMargins).size()
|
st::infoMembersRemoveIconMargins).size()
|
||||||
: QSize();
|
: PeerListRowWithLink::rightActionSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemberListRow::rightActionPaint(
|
void MemberListRow::rightActionPaint(
|
||||||
|
@ -59,9 +55,23 @@ void MemberListRow::rightActionPaint(
|
||||||
(actionSelected
|
(actionSelected
|
||||||
? st::infoMembersRemoveIconOver
|
? st::infoMembersRemoveIconOver
|
||||||
: st::infoMembersRemoveIcon).paint(p, x, y, outerWidth);
|
: 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 {
|
int MemberListRow::nameIconWidth() const {
|
||||||
return (_type.rights == Rights::Admin)
|
return (_type.rights == Rights::Admin)
|
||||||
? st::infoMembersAdminIcon.width()
|
? st::infoMembersAdminIcon.width()
|
||||||
|
@ -80,7 +90,7 @@ void MemberListRow::paintNameIcon(
|
||||||
int y,
|
int y,
|
||||||
int outerWidth,
|
int outerWidth,
|
||||||
bool selected) {
|
bool selected) {
|
||||||
auto icon = [&] {
|
const auto icon = [&] {
|
||||||
return (_type.rights == Rights::Admin)
|
return (_type.rights == Rights::Admin)
|
||||||
? (selected
|
? (selected
|
||||||
? &st::infoMembersAdminIconOver
|
? &st::infoMembersAdminIconOver
|
||||||
|
@ -94,7 +104,8 @@ void MemberListRow::paintNameIcon(
|
||||||
|
|
||||||
void MemberListRow::refreshStatus() {
|
void MemberListRow::refreshStatus() {
|
||||||
if (user()->isBot()) {
|
if (user()->isBot()) {
|
||||||
auto seesAllMessages = (user()->botInfo->readsAllHistory || _type.rights != Rights::Normal);
|
const auto seesAllMessages = (user()->botInfo->readsAllHistory
|
||||||
|
|| _type.rights != Rights::Normal);
|
||||||
setCustomStatus(seesAllMessages
|
setCustomStatus(seesAllMessages
|
||||||
? tr::lng_status_bot_reads_all(tr::now)
|
? tr::lng_status_bot_reads_all(tr::now)
|
||||||
: tr::lng_status_bot_not_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(
|
std::unique_ptr<PeerListController> CreateMembersController(
|
||||||
not_null<Window::SessionNavigation*> navigation,
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
not_null<PeerData*> peer) {
|
not_null<PeerData*> peer) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "boxes/peer_list_box.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class SessionNavigation;
|
class SessionNavigation;
|
||||||
|
@ -16,7 +16,7 @@ class SessionNavigation;
|
||||||
namespace Info {
|
namespace Info {
|
||||||
namespace Profile {
|
namespace Profile {
|
||||||
|
|
||||||
class MemberListRow final : public PeerListRow {
|
class MemberListRow final : public PeerListRowWithLink {
|
||||||
public:
|
public:
|
||||||
enum class Rights {
|
enum class Rights {
|
||||||
Normal,
|
Normal,
|
||||||
|
@ -26,11 +26,14 @@ public:
|
||||||
struct Type {
|
struct Type {
|
||||||
Rights rights;
|
Rights rights;
|
||||||
bool canRemove = false;
|
bool canRemove = false;
|
||||||
|
QString adminRank;
|
||||||
};
|
};
|
||||||
|
|
||||||
MemberListRow(not_null<UserData*> user, Type type);
|
MemberListRow(not_null<UserData*> user, Type type);
|
||||||
|
|
||||||
void setType(Type type);
|
void setType(Type type);
|
||||||
|
bool rightActionDisabled() const override;
|
||||||
|
QMargins rightActionMargins() const override;
|
||||||
QSize rightActionSize() const override;
|
QSize rightActionSize() const override;
|
||||||
void rightActionPaint(
|
void rightActionPaint(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
|
@ -49,11 +52,9 @@ public:
|
||||||
void refreshStatus() override;
|
void refreshStatus() override;
|
||||||
|
|
||||||
not_null<UserData*> user() const;
|
not_null<UserData*> user() const;
|
||||||
bool canRemove() const {
|
|
||||||
return _type.canRemove;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
[[nodiscard]] bool canRemove() const;
|
||||||
Type _type;
|
Type _type;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue