mirror of https://github.com/procxx/kepka.git
Allow to create channel invite link in boxes.
SetupChannelBox (public/private) and MaxInviteBox are suggesting to copy the channel invite link. Now they suggest to create it in case the channel didn't have the invite link already.
This commit is contained in:
parent
949104d879
commit
cabf35f2b3
|
@ -482,6 +482,11 @@ void SetupChannelBox::prepare() {
|
||||||
connect(&_checkTimer, SIGNAL(timeout()), this, SLOT(onCheck()));
|
connect(&_checkTimer, SIGNAL(timeout()), this, SLOT(onCheck()));
|
||||||
|
|
||||||
_privacyGroup->setChangedCallback([this](Privacy value) { privacyChanged(value); });
|
_privacyGroup->setChangedCallback([this](Privacy value) { privacyChanged(value); });
|
||||||
|
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::InviteLinkChanged, [this](const Notify::PeerUpdate &update) {
|
||||||
|
if (update.peer == _channel) {
|
||||||
|
rtlupdate(_invitationLink);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
updateMaxHeight();
|
updateMaxHeight();
|
||||||
}
|
}
|
||||||
|
@ -541,7 +546,8 @@ void SetupChannelBox::paintEvent(QPaintEvent *e) {
|
||||||
option.setWrapMode(QTextOption::WrapAnywhere);
|
option.setWrapMode(QTextOption::WrapAnywhere);
|
||||||
p.setFont(_linkOver ? st::boxTextFont->underline() : st::boxTextFont);
|
p.setFont(_linkOver ? st::boxTextFont->underline() : st::boxTextFont);
|
||||||
p.setPen(st::defaultLinkButton.color);
|
p.setPen(st::defaultLinkButton.color);
|
||||||
p.drawText(_invitationLink, _channel->inviteLink(), option);
|
auto inviteLinkText = _channel->inviteLink().isEmpty() ? lang(lng_group_invite_create) : _channel->inviteLink();
|
||||||
|
p.drawText(_invitationLink, inviteLinkText, option);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!_errorText.isEmpty()) {
|
if (!_errorText.isEmpty()) {
|
||||||
|
@ -573,8 +579,12 @@ void SetupChannelBox::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
|
||||||
void SetupChannelBox::mousePressEvent(QMouseEvent *e) {
|
void SetupChannelBox::mousePressEvent(QMouseEvent *e) {
|
||||||
if (_linkOver) {
|
if (_linkOver) {
|
||||||
QGuiApplication::clipboard()->setText(_channel->inviteLink());
|
if (_channel->inviteLink().isEmpty()) {
|
||||||
Ui::Toast::Show(lang(lng_create_channel_link_copied));
|
App::api()->exportInviteLink(_channel);
|
||||||
|
} else {
|
||||||
|
QGuiApplication::clipboard()->setText(_channel->inviteLink());
|
||||||
|
Ui::Toast::Show(lang(lng_create_channel_link_copied));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "auth_session.h"
|
#include "auth_session.h"
|
||||||
|
#include "observer_peer.h"
|
||||||
|
|
||||||
TextParseOptions _confirmBoxTextOptions = {
|
TextParseOptions _confirmBoxTextOptions = {
|
||||||
TextParseLinks | TextParseMultiline | TextParseRichText, // flags
|
TextParseLinks | TextParseMultiline | TextParseRichText, // flags
|
||||||
|
@ -216,9 +217,9 @@ InformBox::InformBox(QWidget*, const QString &text, base::lambda<void()> closedC
|
||||||
InformBox::InformBox(QWidget*, const QString &text, const QString &doneText, base::lambda<void()> closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std::move(closedCallback)) {
|
InformBox::InformBox(QWidget*, const QString &text, const QString &doneText, base::lambda<void()> closedCallback) : ConfirmBox(ConfirmBox::InformBoxTag(), text, doneText, std::move(closedCallback)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MaxInviteBox::MaxInviteBox(QWidget*, const QString &link)
|
MaxInviteBox::MaxInviteBox(QWidget*, gsl::not_null<ChannelData*> channel) : BoxContent()
|
||||||
: _text(st::boxLabelStyle, lng_participant_invite_sorry(lt_count, Global::ChatSizeMax()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
, _channel(channel)
|
||||||
, _link(link) {
|
, _text(st::boxLabelStyle, lng_participant_invite_sorry(lt_count, Global::ChatSizeMax()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxInviteBox::prepare() {
|
void MaxInviteBox::prepare() {
|
||||||
|
@ -229,6 +230,12 @@ void MaxInviteBox::prepare() {
|
||||||
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
|
_textWidth = st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right();
|
||||||
_textHeight = qMin(_text.countHeight(_textWidth), 16 * st::boxLabelStyle.lineHeight);
|
_textHeight = qMin(_text.countHeight(_textWidth), 16 * st::boxLabelStyle.lineHeight);
|
||||||
setDimensions(st::boxWidth, st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom());
|
setDimensions(st::boxWidth, st::boxPadding.top() + _textHeight + st::boxTextFont->height + st::boxTextFont->height * 2 + st::newGroupLinkPadding.bottom());
|
||||||
|
|
||||||
|
subscribe(Notify::PeerUpdated(), Notify::PeerUpdatedHandler(Notify::PeerUpdate::Flag::InviteLinkChanged, [this](const Notify::PeerUpdate &update) {
|
||||||
|
if (update.peer == _channel) {
|
||||||
|
rtlupdate(_invitationLink);
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxInviteBox::mouseMoveEvent(QMouseEvent *e) {
|
void MaxInviteBox::mouseMoveEvent(QMouseEvent *e) {
|
||||||
|
@ -238,8 +245,12 @@ void MaxInviteBox::mouseMoveEvent(QMouseEvent *e) {
|
||||||
void MaxInviteBox::mousePressEvent(QMouseEvent *e) {
|
void MaxInviteBox::mousePressEvent(QMouseEvent *e) {
|
||||||
mouseMoveEvent(e);
|
mouseMoveEvent(e);
|
||||||
if (_linkOver) {
|
if (_linkOver) {
|
||||||
Application::clipboard()->setText(_link);
|
if (_channel->inviteLink().isEmpty()) {
|
||||||
Ui::Toast::Show(lang(lng_create_channel_link_copied));
|
App::api()->exportInviteLink(_channel);
|
||||||
|
} else {
|
||||||
|
QGuiApplication::clipboard()->setText(_channel->inviteLink());
|
||||||
|
Ui::Toast::Show(lang(lng_create_channel_link_copied));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +282,8 @@ void MaxInviteBox::paintEvent(QPaintEvent *e) {
|
||||||
option.setWrapMode(QTextOption::WrapAnywhere);
|
option.setWrapMode(QTextOption::WrapAnywhere);
|
||||||
p.setFont(_linkOver ? st::defaultInputField.font->underline() : st::defaultInputField.font);
|
p.setFont(_linkOver ? st::defaultInputField.font->underline() : st::defaultInputField.font);
|
||||||
p.setPen(st::defaultLinkButton.color);
|
p.setPen(st::defaultLinkButton.color);
|
||||||
p.drawText(_invitationLink, _link, option);
|
auto inviteLinkText = _channel->inviteLink().isEmpty() ? lang(lng_group_invite_create) : _channel->inviteLink();
|
||||||
|
p.drawText(_invitationLink, inviteLinkText, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxInviteBox::resizeEvent(QResizeEvent *e) {
|
void MaxInviteBox::resizeEvent(QResizeEvent *e) {
|
||||||
|
|
|
@ -100,7 +100,7 @@ public:
|
||||||
|
|
||||||
class MaxInviteBox : public BoxContent {
|
class MaxInviteBox : public BoxContent {
|
||||||
public:
|
public:
|
||||||
MaxInviteBox(QWidget*, const QString &link);
|
MaxInviteBox(QWidget*, gsl::not_null<ChannelData*> channel);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -114,10 +114,11 @@ protected:
|
||||||
private:
|
private:
|
||||||
void updateSelected(const QPoint &cursorGlobalPosition);
|
void updateSelected(const QPoint &cursorGlobalPosition);
|
||||||
|
|
||||||
|
gsl::not_null<ChannelData*> _channel;
|
||||||
|
|
||||||
Text _text;
|
Text _text;
|
||||||
int32 _textWidth, _textHeight;
|
int32 _textWidth, _textHeight;
|
||||||
|
|
||||||
QString _link;
|
|
||||||
QRect _invitationLink;
|
QRect _invitationLink;
|
||||||
bool _linkOver = false;
|
bool _linkOver = false;
|
||||||
|
|
||||||
|
|
|
@ -1468,7 +1468,7 @@ void ContactsBox::Inner::changeCheckState(ContactData *data, PeerData *peer) {
|
||||||
} else if (selectedCount() < ((_channel && _channel->isMegagroup()) ? Global::MegagroupSizeMax() : Global::ChatSizeMax())) {
|
} else if (selectedCount() < ((_channel && _channel->isMegagroup()) ? Global::MegagroupSizeMax() : Global::ChatSizeMax())) {
|
||||||
changePeerCheckState(data, peer, true);
|
changePeerCheckState(data, peer, true);
|
||||||
} else if (_channel && !_channel->isMegagroup()) {
|
} else if (_channel && !_channel->isMegagroup()) {
|
||||||
Ui::show(Box<MaxInviteBox>(_channel->inviteLink()), KeepOtherLayers);
|
Ui::show(Box<MaxInviteBox>(_channel), KeepOtherLayers);
|
||||||
} else if (!_channel && selectedCount() >= Global::ChatSizeMax() && selectedCount() < Global::MegagroupSizeMax()) {
|
} else if (!_channel && selectedCount() >= Global::ChatSizeMax() && selectedCount() < Global::MegagroupSizeMax()) {
|
||||||
Ui::show(Box<InformBox>(lng_profile_add_more_after_upgrade(lt_count, Global::MegagroupSizeMax())), KeepOtherLayers);
|
Ui::show(Box<InformBox>(lng_profile_add_more_after_upgrade(lt_count, Global::MegagroupSizeMax())), KeepOtherLayers);
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ void ParticipantsBoxController::Start(gsl::not_null<ChannelData*> channel, Role
|
||||||
void ParticipantsBoxController::addNewItem() {
|
void ParticipantsBoxController::addNewItem() {
|
||||||
if (_role == Role::Members) {
|
if (_role == Role::Members) {
|
||||||
if (_channel->membersCount() >= Global::ChatSizeMax()) {
|
if (_channel->membersCount() >= Global::ChatSizeMax()) {
|
||||||
Ui::show(Box<MaxInviteBox>(_channel->inviteLink()), KeepOtherLayers);
|
Ui::show(Box<MaxInviteBox>(_channel), KeepOtherLayers);
|
||||||
} else {
|
} else {
|
||||||
auto already = MembersAlreadyIn();
|
auto already = MembersAlreadyIn();
|
||||||
for (auto i = 0, count = delegate()->peerListFullRowsCount(); i != count; ++i) {
|
for (auto i = 0, count = delegate()->peerListFullRowsCount(); i != count; ++i) {
|
||||||
|
|
Loading…
Reference in New Issue