mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Handle click on userpic in edit admin/banned box.
In admins/banned/restricted lists on row click the edit box is shown. Now click on the userpic in this box allows to get to user profile.
This commit is contained in:
parent
58a592ba47
commit
b79ddb7a1c
5 changed files with 18 additions and 11 deletions
|
@ -662,7 +662,10 @@ rightsDividerHeight: 11px;
|
||||||
rightsHeaderMargin: margins(23px, 20px, 23px, 8px);
|
rightsHeaderMargin: margins(23px, 20px, 23px, 8px);
|
||||||
rightsToggleMargin: margins(23px, 8px, 23px, 8px);
|
rightsToggleMargin: margins(23px, 8px, 23px, 8px);
|
||||||
rightsAboutMargin: margins(23px, 8px, 23px, 8px);
|
rightsAboutMargin: margins(23px, 8px, 23px, 8px);
|
||||||
rightsPhotoSize: 60px;
|
rightsPhotoButton: PeerAvatarButton {
|
||||||
|
size: 60px;
|
||||||
|
photoSize: 60px;
|
||||||
|
}
|
||||||
rightsPhotoMargin: margins(20px, 0px, 15px, 18px);
|
rightsPhotoMargin: margins(20px, 0px, 15px, 18px);
|
||||||
rightsNameStyle: TextStyle(semiboldTextStyle) {
|
rightsNameStyle: TextStyle(semiboldTextStyle) {
|
||||||
font: font(15px semibold);
|
font: font(15px semibold);
|
||||||
|
|
|
@ -26,6 +26,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_profile.h"
|
#include "styles/style_profile.h"
|
||||||
|
#include "ui/special_buttons.h"
|
||||||
#include "boxes/calendar_box.h"
|
#include "boxes/calendar_box.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -118,6 +119,7 @@ private:
|
||||||
|
|
||||||
gsl::not_null<ChannelData*> _channel;
|
gsl::not_null<ChannelData*> _channel;
|
||||||
gsl::not_null<UserData*> _user;
|
gsl::not_null<UserData*> _user;
|
||||||
|
object_ptr<Ui::PeerAvatarButton> _userPhoto;
|
||||||
Text _userName;
|
Text _userName;
|
||||||
bool _hasAdminRights = false;
|
bool _hasAdminRights = false;
|
||||||
struct Control {
|
struct Control {
|
||||||
|
@ -131,8 +133,10 @@ private:
|
||||||
EditParticipantBox::Inner::Inner(QWidget *parent, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights) : TWidget(parent)
|
EditParticipantBox::Inner::Inner(QWidget *parent, gsl::not_null<ChannelData*> channel, gsl::not_null<UserData*> user, bool hasAdminRights) : TWidget(parent)
|
||||||
, _channel(channel)
|
, _channel(channel)
|
||||||
, _user(user)
|
, _user(user)
|
||||||
|
, _userPhoto(this, _user, st::rightsPhotoButton)
|
||||||
, _hasAdminRights(hasAdminRights) {
|
, _hasAdminRights(hasAdminRights) {
|
||||||
_userName.setText(st::rightsNameStyle, App::peerName(_user), _textNameOptions);
|
_userName.setText(st::rightsNameStyle, App::peerName(_user), _textNameOptions);
|
||||||
|
_userPhoto->setClickedCallback([this] { Ui::showPeerProfile(_user); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditParticipantBox::Inner::removeControl(QPointer<TWidget> widget) {
|
void EditParticipantBox::Inner::removeControl(QPointer<TWidget> widget) {
|
||||||
|
@ -151,7 +155,8 @@ void EditParticipantBox::Inner::doAddControl(object_ptr<TWidget> widget, QMargin
|
||||||
}
|
}
|
||||||
|
|
||||||
int EditParticipantBox::Inner::resizeGetHeight(int newWidth) {
|
int EditParticipantBox::Inner::resizeGetHeight(int newWidth) {
|
||||||
auto newHeight = st::rightsPhotoMargin.top() + st::rightsPhotoSize + st::rightsPhotoMargin.bottom();
|
_userPhoto->moveToLeft(st::rightsPhotoMargin.left(), st::rightsPhotoMargin.top());
|
||||||
|
auto newHeight = st::rightsPhotoMargin.top() + st::rightsPhotoButton.size + st::rightsPhotoMargin.bottom();
|
||||||
for (auto &&row : _rows) {
|
for (auto &&row : _rows) {
|
||||||
auto rowWidth = newWidth - row.margin.left() - row.margin.right();
|
auto rowWidth = newWidth - row.margin.left() - row.margin.right();
|
||||||
newHeight += row.margin.top();
|
newHeight += row.margin.top();
|
||||||
|
@ -167,10 +172,8 @@ void EditParticipantBox::Inner::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
p.fillRect(e->rect(), st::boxBg);
|
p.fillRect(e->rect(), st::boxBg);
|
||||||
|
|
||||||
_user->paintUserpicLeft(p, st::rightsPhotoMargin.left(), st::rightsPhotoMargin.top(), width(), st::rightsPhotoSize);
|
|
||||||
|
|
||||||
p.setPen(st::contactsNameFg);
|
p.setPen(st::contactsNameFg);
|
||||||
auto namex = st::rightsPhotoMargin.left() + st::rightsPhotoSize + st::rightsPhotoMargin.right();
|
auto namex = st::rightsPhotoMargin.left() + st::rightsPhotoButton.size + st::rightsPhotoMargin.right();
|
||||||
auto namew = width() - namex - st::rightsPhotoMargin.right();
|
auto namew = width() - namex - st::rightsPhotoMargin.right();
|
||||||
_userName.drawLeftElided(p, namex, st::rightsPhotoMargin.top() + st::rightsNameTop, namew, width());
|
_userName.drawLeftElided(p, namex, st::rightsPhotoMargin.top() + st::rightsNameTop, namew, width());
|
||||||
auto statusText = [this] {
|
auto statusText = [this] {
|
||||||
|
|
|
@ -146,7 +146,7 @@ private:
|
||||||
|
|
||||||
class PeerAvatarButton : public AbstractButton {
|
class PeerAvatarButton : public AbstractButton {
|
||||||
public:
|
public:
|
||||||
PeerAvatarButton(QWidget *parent, PeerData *peer, const style::PeerAvatarButton &st);
|
PeerAvatarButton(QWidget *parent,PeerData *peer, const style::PeerAvatarButton &st);
|
||||||
|
|
||||||
void setPeer(PeerData *peer) {
|
void setPeer(PeerData *peer) {
|
||||||
_peer = peer;
|
_peer = peer;
|
||||||
|
@ -157,7 +157,7 @@ protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PeerData *_peer;
|
PeerData *_peer = nullptr;
|
||||||
const style::PeerAvatarButton &_st;
|
const style::PeerAvatarButton &_st;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -492,6 +492,11 @@ ImportantTooltip {
|
||||||
duration: int;
|
duration: int;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PeerAvatarButton {
|
||||||
|
size: pixels;
|
||||||
|
photoSize: pixels;
|
||||||
|
}
|
||||||
|
|
||||||
defaultLabelSimple: LabelSimple {
|
defaultLabelSimple: LabelSimple {
|
||||||
font: normalFont;
|
font: normalFont;
|
||||||
maxWidth: 0px;
|
maxWidth: 0px;
|
||||||
|
|
|
@ -283,10 +283,6 @@ topBarMenuToggle: IconButton(topBarSearch) {
|
||||||
}
|
}
|
||||||
topBarActionSkip: 10px;
|
topBarActionSkip: 10px;
|
||||||
|
|
||||||
PeerAvatarButton {
|
|
||||||
size: pixels;
|
|
||||||
photoSize: pixels;
|
|
||||||
}
|
|
||||||
topBarInfoButton: PeerAvatarButton {
|
topBarInfoButton: PeerAvatarButton {
|
||||||
size: topBarHeight;
|
size: topBarHeight;
|
||||||
photoSize: 42px;
|
photoSize: 42px;
|
||||||
|
|
Loading…
Add table
Reference in a new issue