mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add FileSizeLimitBox and pass "ref" to premium payment.
This commit is contained in:
parent
62f42eabb0
commit
d1907083ed
20 changed files with 211 additions and 350 deletions
|
@ -223,6 +223,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_caption_limit_reached#one" = "You've reached the media caption limit. Please make the caption shorter by {count} character.";
|
"lng_caption_limit_reached#one" = "You've reached the media caption limit. Please make the caption shorter by {count} character.";
|
||||||
"lng_caption_limit_reached#other" = "You've reached the media caption limit. Please make the caption shorter by {count} characters.";
|
"lng_caption_limit_reached#other" = "You've reached the media caption limit. Please make the caption shorter by {count} characters.";
|
||||||
|
|
||||||
|
"lng_file_size_limit_title" = "File Too Large";
|
||||||
|
"lng_file_size_limit" = "{total} Gb";
|
||||||
|
"lng_file_size_limit1" = "The document can't be sent, because it is larger than {size}.";
|
||||||
|
"lng_file_size_limit2" = "You can double this limit to {size} per document by subscribing to **Telegram Premium**.";
|
||||||
|
|
||||||
"lng_limits_increase" = "Increase Limit";
|
"lng_limits_increase" = "Increase Limit";
|
||||||
|
|
||||||
"lng_sticker_premium_about" = "Unlock this sticker and more by subscribing to\nTelegram Premium.";
|
"lng_sticker_premium_about" = "Unlock this sticker and more by subscribing to\nTelegram Premium.";
|
||||||
|
|
|
@ -453,7 +453,7 @@ void ApiWrap::sendMessageFail(
|
||||||
: tr::lng_error_noforwards_group(tr::now)
|
: tr::lng_error_noforwards_group(tr::now)
|
||||||
}, .duration = kJoinErrorDuration });
|
}, .duration = kJoinErrorDuration });
|
||||||
} else if (error.type() == qstr("PREMIUM_ACCOUNT_REQUIRED")) {
|
} else if (error.type() == qstr("PREMIUM_ACCOUNT_REQUIRED")) {
|
||||||
Settings::ShowPremium(&session());
|
Settings::ShowPremium(&session(), "premium_stickers");
|
||||||
}
|
}
|
||||||
if (const auto item = _session->data().message(itemId)) {
|
if (const auto item = _session->data().message(itemId)) {
|
||||||
Assert(randomId != 0);
|
Assert(randomId != 0);
|
||||||
|
|
|
@ -207,48 +207,6 @@ void ShowAddParticipantsError(
|
||||||
Ui::show(Ui::MakeInformBox(text), Ui::LayerOption::KeepOther);
|
Ui::show(Ui::MakeInformBox(text), Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RevokePublicLinkBox::Inner : public TWidget {
|
|
||||||
public:
|
|
||||||
Inner(
|
|
||||||
QWidget *parent,
|
|
||||||
not_null<Main::Session*> session,
|
|
||||||
Fn<void()> revokeCallback);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void mouseMoveEvent(QMouseEvent *e) override;
|
|
||||||
void mousePressEvent(QMouseEvent *e) override;
|
|
||||||
void mouseReleaseEvent(QMouseEvent *e) override;
|
|
||||||
void paintEvent(QPaintEvent *e) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct ChatRow {
|
|
||||||
ChatRow(not_null<PeerData*> peer) : peer(peer) {
|
|
||||||
}
|
|
||||||
|
|
||||||
not_null<PeerData*> peer;
|
|
||||||
mutable std::shared_ptr<Data::CloudImageView> userpic;
|
|
||||||
Ui::Text::String name, status;
|
|
||||||
};
|
|
||||||
void paintChat(Painter &p, const ChatRow &row, bool selected) const;
|
|
||||||
void updateSelected();
|
|
||||||
|
|
||||||
const not_null<Main::Session*> _session;
|
|
||||||
MTP::Sender _api;
|
|
||||||
|
|
||||||
PeerData *_selected = nullptr;
|
|
||||||
PeerData *_pressed = nullptr;
|
|
||||||
|
|
||||||
std::vector<ChatRow> _rows;
|
|
||||||
|
|
||||||
int _rowsTop = 0;
|
|
||||||
int _rowHeight = 0;
|
|
||||||
int _revokeWidth = 0;
|
|
||||||
|
|
||||||
Fn<void()> _revokeCallback;
|
|
||||||
mtpRequestId _revokeRequestId = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
AddContactBox::AddContactBox(
|
AddContactBox::AddContactBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
not_null<Main::Session*> session)
|
not_null<Main::Session*> session)
|
||||||
|
@ -1243,9 +1201,7 @@ void SetupChannelBox::privacyChanged(Privacy value) {
|
||||||
check();
|
check();
|
||||||
});
|
});
|
||||||
Ui::show(
|
Ui::show(
|
||||||
Box<RevokePublicLinkBox>(
|
Box(PublicLinksLimitBox, _navigation, callback),
|
||||||
&_channel->session(),
|
|
||||||
callback),
|
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1337,9 +1293,7 @@ void SetupChannelBox::showRevokePublicLinkBoxForEdit() {
|
||||||
};
|
};
|
||||||
closeBox();
|
closeBox();
|
||||||
Ui::show(
|
Ui::show(
|
||||||
Box<RevokePublicLinkBox>(
|
Box(PublicLinksLimitBox, navigation, callback),
|
||||||
&channel->session(),
|
|
||||||
callback),
|
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1505,252 +1459,3 @@ void EditNameBox::saveSelfFail(const QString &error) {
|
||||||
_first->setFocus();
|
_first->setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RevokePublicLinkBox::Inner::Inner(
|
|
||||||
QWidget *parent,
|
|
||||||
not_null<Main::Session*> session,
|
|
||||||
Fn<void()> revokeCallback)
|
|
||||||
: TWidget(parent)
|
|
||||||
, _session(session)
|
|
||||||
, _api(&_session->mtp())
|
|
||||||
, _rowHeight(st::contactsPadding.top()
|
|
||||||
+ st::contactsPhotoSize
|
|
||||||
+ st::contactsPadding.bottom())
|
|
||||||
, _revokeWidth(st::normalFont->width(
|
|
||||||
tr::lng_channels_too_much_public_revoke(tr::now)))
|
|
||||||
, _revokeCallback(std::move(revokeCallback)) {
|
|
||||||
setMouseTracking(true);
|
|
||||||
|
|
||||||
resize(width(), 5 * _rowHeight);
|
|
||||||
|
|
||||||
_api.request(MTPchannels_GetAdminedPublicChannels(
|
|
||||||
MTP_flags(0)
|
|
||||||
)).done([=](const MTPmessages_Chats &result) {
|
|
||||||
const auto &chats = result.match([](const auto &data) {
|
|
||||||
return data.vchats().v;
|
|
||||||
});
|
|
||||||
for (const auto &chat : chats) {
|
|
||||||
if (const auto peer = _session->data().processChat(chat)) {
|
|
||||||
if (!peer->isChannel() || peer->userName().isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto row = ChatRow(peer);
|
|
||||||
row.peer = peer;
|
|
||||||
row.name.setText(
|
|
||||||
st::contactsNameStyle,
|
|
||||||
peer->name,
|
|
||||||
Ui::NameTextOptions());
|
|
||||||
row.status.setMarkedText(
|
|
||||||
st::defaultTextStyle,
|
|
||||||
_session->createInternalLink(
|
|
||||||
Ui::Text::Link(peer->userName())));
|
|
||||||
_rows.push_back(std::move(row));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resize(width(), _rows.size() * _rowHeight);
|
|
||||||
update();
|
|
||||||
}).send();
|
|
||||||
}
|
|
||||||
|
|
||||||
RevokePublicLinkBox::RevokePublicLinkBox(
|
|
||||||
QWidget*,
|
|
||||||
not_null<Main::Session*> session,
|
|
||||||
Fn<void()> revokeCallback)
|
|
||||||
: _session(session)
|
|
||||||
, _aboutRevoke(
|
|
||||||
this,
|
|
||||||
tr::lng_channels_too_much_public_about(tr::now),
|
|
||||||
st::aboutRevokePublicLabel)
|
|
||||||
, _revokeCallback(std::move(revokeCallback)) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void RevokePublicLinkBox::prepare() {
|
|
||||||
_innerTop = st::boxPadding.top()
|
|
||||||
+ _aboutRevoke->height()
|
|
||||||
+ st::boxPadding.top();
|
|
||||||
_inner = setInnerWidget(object_ptr<Inner>(this, _session, [=] {
|
|
||||||
const auto callback = _revokeCallback;
|
|
||||||
closeBox();
|
|
||||||
if (callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}), st::boxScroll, _innerTop);
|
|
||||||
|
|
||||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
|
||||||
|
|
||||||
_session->downloaderTaskFinished(
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
update();
|
|
||||||
}, lifetime());
|
|
||||||
|
|
||||||
_inner->resizeToWidth(st::boxWideWidth);
|
|
||||||
setDimensions(st::boxWideWidth, _innerTop + _inner->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RevokePublicLinkBox::Inner::mouseMoveEvent(QMouseEvent *e) {
|
|
||||||
updateSelected();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RevokePublicLinkBox::Inner::updateSelected() {
|
|
||||||
const auto point = mapFromGlobal(QCursor::pos());
|
|
||||||
PeerData *selected = nullptr;
|
|
||||||
auto top = _rowsTop;
|
|
||||||
for (const auto &row : _rows) {
|
|
||||||
const auto revokeLink = style::rtlrect(
|
|
||||||
width()
|
|
||||||
- st::contactsPadding.right()
|
|
||||||
- st::contactsCheckPosition.x()
|
|
||||||
- _revokeWidth,
|
|
||||||
top
|
|
||||||
+ st::contactsPadding.top()
|
|
||||||
+ (st::contactsPhotoSize - st::normalFont->height) / 2,
|
|
||||||
_revokeWidth,
|
|
||||||
st::normalFont->height,
|
|
||||||
width());
|
|
||||||
if (revokeLink.contains(point)) {
|
|
||||||
selected = row.peer;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
top += _rowHeight;
|
|
||||||
}
|
|
||||||
if (selected != _selected) {
|
|
||||||
_selected = selected;
|
|
||||||
setCursor((_selected || _pressed)
|
|
||||||
? style::cur_pointer
|
|
||||||
: style::cur_default);
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RevokePublicLinkBox::Inner::mousePressEvent(QMouseEvent *e) {
|
|
||||||
if (_pressed != _selected) {
|
|
||||||
_pressed = _selected;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
|
|
||||||
const auto pressed = base::take(_pressed);
|
|
||||||
setCursor((_selected || _pressed)
|
|
||||||
? style::cur_pointer
|
|
||||||
: style::cur_default);
|
|
||||||
if (pressed && pressed == _selected) {
|
|
||||||
const auto textMethod = pressed->isMegagroup()
|
|
||||||
? tr::lng_channels_too_much_public_revoke_confirm_group
|
|
||||||
: tr::lng_channels_too_much_public_revoke_confirm_channel;
|
|
||||||
const auto text = textMethod(
|
|
||||||
tr::now,
|
|
||||||
lt_link,
|
|
||||||
_session->createInternalLink(pressed->userName()),
|
|
||||||
lt_group,
|
|
||||||
pressed->name);
|
|
||||||
const auto confirmText = tr::lng_channels_too_much_public_revoke(
|
|
||||||
tr::now);
|
|
||||||
auto callback = crl::guard(this, [=](Fn<void()> &&close) {
|
|
||||||
if (_revokeRequestId) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_revokeRequestId = _api.request(MTPchannels_UpdateUsername(
|
|
||||||
pressed->asChannel()->inputChannel,
|
|
||||||
MTP_string()
|
|
||||||
)).done([=, close = std::move(close)] {
|
|
||||||
close();
|
|
||||||
if (const auto callback = _revokeCallback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}).send();
|
|
||||||
});
|
|
||||||
Ui::show(
|
|
||||||
Ui::MakeConfirmBox({
|
|
||||||
.text = text,
|
|
||||||
.confirmed = std::move(callback),
|
|
||||||
.confirmText = confirmText,
|
|
||||||
}),
|
|
||||||
Ui::LayerOption::KeepOther);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RevokePublicLinkBox::Inner::paintEvent(QPaintEvent *e) {
|
|
||||||
Painter p(this);
|
|
||||||
p.translate(0, _rowsTop);
|
|
||||||
for (const auto &row : _rows) {
|
|
||||||
paintChat(p, row, (row.peer == _selected));
|
|
||||||
p.translate(0, _rowHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RevokePublicLinkBox::resizeEvent(QResizeEvent *e) {
|
|
||||||
BoxContent::resizeEvent(e);
|
|
||||||
|
|
||||||
_aboutRevoke->moveToLeft(st::boxPadding.left(), st::boxPadding.top());
|
|
||||||
}
|
|
||||||
|
|
||||||
void RevokePublicLinkBox::Inner::paintChat(
|
|
||||||
Painter &p,
|
|
||||||
const ChatRow &row,
|
|
||||||
bool selected) const {
|
|
||||||
const auto peer = row.peer;
|
|
||||||
peer->paintUserpicLeft(
|
|
||||||
p,
|
|
||||||
row.userpic,
|
|
||||||
st::contactsPadding.left(),
|
|
||||||
st::contactsPadding.top(),
|
|
||||||
width(),
|
|
||||||
st::contactsPhotoSize);
|
|
||||||
|
|
||||||
p.setPen(st::contactsNameFg);
|
|
||||||
|
|
||||||
const auto namex = st::contactsPadding.left()
|
|
||||||
+ st::contactsPhotoSize
|
|
||||||
+ st::contactsPadding.left();
|
|
||||||
auto namew = width()
|
|
||||||
- namex
|
|
||||||
- st::contactsPadding.right()
|
|
||||||
- (_revokeWidth + st::contactsCheckPosition.x() * 2);
|
|
||||||
|
|
||||||
const auto badgeStyle = Ui::PeerBadgeStyle{
|
|
||||||
&st::dialogsVerifiedIcon,
|
|
||||||
nullptr, // premium
|
|
||||||
&st::attentionButtonFg
|
|
||||||
};
|
|
||||||
namew -= Ui::DrawPeerBadgeGetWidth(
|
|
||||||
peer,
|
|
||||||
p,
|
|
||||||
QRect(
|
|
||||||
namex,
|
|
||||||
st::contactsPadding.top() + st::contactsNameTop,
|
|
||||||
row.name.maxWidth(),
|
|
||||||
st::contactsNameStyle.font->height),
|
|
||||||
namew,
|
|
||||||
width(),
|
|
||||||
badgeStyle);
|
|
||||||
row.name.drawLeftElided(
|
|
||||||
p,
|
|
||||||
namex,
|
|
||||||
st::contactsPadding.top() + st::contactsNameTop,
|
|
||||||
namew,
|
|
||||||
width());
|
|
||||||
|
|
||||||
p.setFont(selected ? st::linkOverFont : st::linkFont);
|
|
||||||
p.setPen(selected
|
|
||||||
? st::defaultLinkButton.overColor
|
|
||||||
: st::defaultLinkButton.color);
|
|
||||||
p.drawTextRight(
|
|
||||||
st::contactsPadding.right() + st::contactsCheckPosition.x(),
|
|
||||||
st::contactsPadding.top()
|
|
||||||
+ (st::contactsPhotoSize - st::normalFont->height) / 2,
|
|
||||||
width(),
|
|
||||||
tr::lng_channels_too_much_public_revoke(tr::now),
|
|
||||||
_revokeWidth);
|
|
||||||
|
|
||||||
p.setPen(st::contactsStatusFg);
|
|
||||||
p.setTextPalette(st::revokePublicLinkStatusPalette);
|
|
||||||
row.status.drawLeftElided(
|
|
||||||
p,
|
|
||||||
namex,
|
|
||||||
st::contactsPadding.top() + st::contactsStatusTop,
|
|
||||||
namew,
|
|
||||||
width());
|
|
||||||
p.restoreTextPalette();
|
|
||||||
}
|
|
||||||
|
|
|
@ -249,28 +249,3 @@ private:
|
||||||
QString _sentName;
|
QString _sentName;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RevokePublicLinkBox final : public Ui::BoxContent {
|
|
||||||
public:
|
|
||||||
RevokePublicLinkBox(
|
|
||||||
QWidget*,
|
|
||||||
not_null<Main::Session*> session,
|
|
||||||
Fn<void()> revokeCallback);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void prepare() override;
|
|
||||||
|
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const not_null<Main::Session*> _session;
|
|
||||||
|
|
||||||
object_ptr<Ui::FlatLabel> _aboutRevoke;
|
|
||||||
|
|
||||||
class Inner;
|
|
||||||
QPointer<Inner> _inner;
|
|
||||||
|
|
||||||
int _innerTop = 0;
|
|
||||||
Fn<void()> _revokeCallback;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
|
@ -579,7 +579,7 @@ void Controller::askUsernameRevoke() {
|
||||||
checkUsernameAvailability();
|
checkUsernameAvailability();
|
||||||
});
|
});
|
||||||
_show->showBox(
|
_show->showBox(
|
||||||
Box(PublicLinksLimitBox, _navigation),
|
Box(PublicLinksLimitBox, _navigation, revokeCallback),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -394,6 +394,7 @@ void SimpleLimitBox(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
rpl::producer<QString> title,
|
rpl::producer<QString> title,
|
||||||
rpl::producer<TextWithEntities> text,
|
rpl::producer<TextWithEntities> text,
|
||||||
|
const QString &refAddition,
|
||||||
const InfographicDescriptor &descriptor,
|
const InfographicDescriptor &descriptor,
|
||||||
bool premium,
|
bool premium,
|
||||||
bool fixed = false) {
|
bool fixed = false) {
|
||||||
|
@ -433,7 +434,7 @@ void SimpleLimitBox(
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
box->addButton(tr::lng_limits_increase(), [=] {
|
box->addButton(tr::lng_limits_increase(), [=] {
|
||||||
Settings::ShowPremium(session);
|
Settings::ShowPremium(session, LimitsPremiumRef(refAddition));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,6 +451,7 @@ void SimpleLimitBox(
|
||||||
void SimplePinsLimitBox(
|
void SimplePinsLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
|
const QString &refAddition,
|
||||||
const QString &keyDefault,
|
const QString &keyDefault,
|
||||||
int limitDefault,
|
int limitDefault,
|
||||||
const QString &keyPremium,
|
const QString &keyPremium,
|
||||||
|
@ -480,6 +482,7 @@ void SimplePinsLimitBox(
|
||||||
session,
|
session,
|
||||||
tr::lng_filter_pin_limit_title(),
|
tr::lng_filter_pin_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
refAddition,
|
||||||
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconPins },
|
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconPins },
|
||||||
premium);
|
premium);
|
||||||
}
|
}
|
||||||
|
@ -514,6 +517,7 @@ void ChannelsLimitBox(
|
||||||
session,
|
session,
|
||||||
tr::lng_channels_limit_title(),
|
tr::lng_channels_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
"channels",
|
||||||
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconGroups },
|
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconGroups },
|
||||||
premium,
|
premium,
|
||||||
true);
|
true);
|
||||||
|
@ -564,7 +568,7 @@ void ChannelsLimitBox(
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
box->addButton(tr::lng_limits_increase(), [=] {
|
box->addButton(tr::lng_limits_increase(), [=] {
|
||||||
Settings::ShowPremium(session);
|
Settings::ShowPremium(session, LimitsPremiumRef("channels"));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
|
@ -572,7 +576,8 @@ void ChannelsLimitBox(
|
||||||
|
|
||||||
void PublicLinksLimitBox(
|
void PublicLinksLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Window::SessionNavigation*> navigation) {
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
Fn<void()> retry) {
|
||||||
const auto session = &navigation->session();
|
const auto session = &navigation->session();
|
||||||
const auto premium = session->premium();
|
const auto premium = session->premium();
|
||||||
|
|
||||||
|
@ -605,6 +610,7 @@ void PublicLinksLimitBox(
|
||||||
session,
|
session,
|
||||||
tr::lng_links_limit_title(),
|
tr::lng_links_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
"channels_public",
|
||||||
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconLinks },
|
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconLinks },
|
||||||
premium,
|
premium,
|
||||||
true);
|
true);
|
||||||
|
@ -616,7 +622,7 @@ void PublicLinksLimitBox(
|
||||||
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
||||||
const auto controller = box->lifetime().make_state<PublicsController>(
|
const auto controller = box->lifetime().make_state<PublicsController>(
|
||||||
navigation,
|
navigation,
|
||||||
crl::guard(box, [=] { box->closeBox(); }));
|
crl::guard(box, [=] { box->closeBox(); retry(); }));
|
||||||
|
|
||||||
const auto content = box->addRow(
|
const auto content = box->addRow(
|
||||||
object_ptr<PeerListContent>(box, controller),
|
object_ptr<PeerListContent>(box, controller),
|
||||||
|
@ -672,6 +678,7 @@ void FilterChatsLimitBox(
|
||||||
session,
|
session,
|
||||||
tr::lng_filter_chats_limit_title(),
|
tr::lng_filter_chats_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
"dialog_filters_chats",
|
||||||
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconChats },
|
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconChats },
|
||||||
premium);
|
premium);
|
||||||
}
|
}
|
||||||
|
@ -711,6 +718,7 @@ void FiltersLimitBox(
|
||||||
session,
|
session,
|
||||||
tr::lng_filters_limit_title(),
|
tr::lng_filters_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
"dialog_filters",
|
||||||
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconFolders },
|
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconFolders },
|
||||||
premium);
|
premium);
|
||||||
}
|
}
|
||||||
|
@ -721,6 +729,7 @@ void FilterPinsLimitBox(
|
||||||
SimplePinsLimitBox(
|
SimplePinsLimitBox(
|
||||||
box,
|
box,
|
||||||
session,
|
session,
|
||||||
|
"dialog_filters_pinned",
|
||||||
"dialog_filters_chats_limit_default",
|
"dialog_filters_chats_limit_default",
|
||||||
100,
|
100,
|
||||||
"dialog_filters_chats_limit_premium",
|
"dialog_filters_chats_limit_premium",
|
||||||
|
@ -733,9 +742,10 @@ void FolderPinsLimitBox(
|
||||||
SimplePinsLimitBox(
|
SimplePinsLimitBox(
|
||||||
box,
|
box,
|
||||||
session,
|
session,
|
||||||
"dialog_filters_chats_limit_default",
|
"dialogs_folder_pinned",
|
||||||
|
"dialogs_folder_pinned_limit_default",
|
||||||
100,
|
100,
|
||||||
"dialog_filters_chats_limit_premium",
|
"dialogs_folder_pinned_limit_premium",
|
||||||
200);
|
200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,6 +755,7 @@ void PinsLimitBox(
|
||||||
SimplePinsLimitBox(
|
SimplePinsLimitBox(
|
||||||
box,
|
box,
|
||||||
session,
|
session,
|
||||||
|
"dialog_pinned",
|
||||||
"dialogs_pinned_limit_default",
|
"dialogs_pinned_limit_default",
|
||||||
5,
|
5,
|
||||||
"dialogs_pinned_limit_premium",
|
"dialogs_pinned_limit_premium",
|
||||||
|
@ -783,6 +794,7 @@ void CaptionLimitBox(
|
||||||
session,
|
session,
|
||||||
tr::lng_caption_limit_title(),
|
tr::lng_caption_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
|
"caption_length",
|
||||||
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconChats },
|
{ defaultLimit, defaultLimit, premiumLimit, &st::premiumIconChats },
|
||||||
premium);
|
premium);
|
||||||
}
|
}
|
||||||
|
@ -806,6 +818,55 @@ void CaptionLimitReachedBox(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileSizeLimitBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session) {
|
||||||
|
const auto premium = session->premium();
|
||||||
|
|
||||||
|
const auto defaultLimit = Limit(
|
||||||
|
session,
|
||||||
|
"upload_max_fileparts_default",
|
||||||
|
4000);
|
||||||
|
const auto premiumLimit = Limit(
|
||||||
|
session,
|
||||||
|
"upload_max_fileparts_premium",
|
||||||
|
8000);
|
||||||
|
|
||||||
|
const auto defaultGb = (defaultLimit + 999) / 2000;
|
||||||
|
const auto premiumGb = (premiumLimit + 999) / 2000;
|
||||||
|
const auto gb = [](int count) {
|
||||||
|
return tr::lng_file_size_limit(
|
||||||
|
tr::now,
|
||||||
|
lt_total,
|
||||||
|
QString::number(count));
|
||||||
|
};
|
||||||
|
|
||||||
|
auto text = rpl::combine(
|
||||||
|
tr::lng_file_size_limit1(
|
||||||
|
lt_size,
|
||||||
|
rpl::single(Ui::Text::Bold(gb(defaultGb))),
|
||||||
|
Ui::Text::RichLangValue),
|
||||||
|
tr::lng_file_size_limit2(
|
||||||
|
lt_size,
|
||||||
|
rpl::single(Ui::Text::Bold(gb(premiumGb))),
|
||||||
|
Ui::Text::RichLangValue)
|
||||||
|
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
||||||
|
return a.append(QChar(' ')).append(std::move(b));
|
||||||
|
});
|
||||||
|
|
||||||
|
SimpleLimitBox(
|
||||||
|
box,
|
||||||
|
session,
|
||||||
|
tr::lng_file_size_limit_title(),
|
||||||
|
std::move(text),
|
||||||
|
"upload_max_fileparts",
|
||||||
|
{ defaultGb, defaultGb, premiumGb, &st::premiumIconFiles },
|
||||||
|
premium);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString LimitsPremiumRef(const QString &addition) {
|
||||||
|
return "double_limits__" + addition;
|
||||||
|
}
|
||||||
|
|
||||||
int AppConfigLimit(
|
int AppConfigLimit(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
|
|
|
@ -22,7 +22,8 @@ void ChannelsLimitBox(
|
||||||
not_null<Main::Session*> session);
|
not_null<Main::Session*> session);
|
||||||
void PublicLinksLimitBox(
|
void PublicLinksLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Window::SessionNavigation*> navigation);
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
Fn<void()> retry);
|
||||||
void FilterChatsLimitBox(
|
void FilterChatsLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session);
|
not_null<Main::Session*> session);
|
||||||
|
@ -45,6 +46,11 @@ void CaptionLimitReachedBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
int remove);
|
int remove);
|
||||||
|
void FileSizeLimitBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session);
|
||||||
|
|
||||||
|
[[nodiscard]] QString LimitsPremiumRef(const QString &addition);
|
||||||
|
|
||||||
[[nodiscard]] int AppConfigLimit(
|
[[nodiscard]] int AppConfigLimit(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
|
|
|
@ -448,7 +448,7 @@ void ReactionsSettingsBox(
|
||||||
|
|
||||||
button->setClickedCallback([=, emoji = r.emoji] {
|
button->setClickedCallback([=, emoji = r.emoji] {
|
||||||
if (premium && !controller->session().premium()) {
|
if (premium && !controller->session().premium()) {
|
||||||
Settings::ShowPremium(&controller->session());
|
Settings::ShowPremium(controller, "unique_reactions");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
checkButton(button);
|
checkButton(button);
|
||||||
|
|
|
@ -203,7 +203,7 @@ void StickerBox(
|
||||||
const auto width = size - buttonPadding.left() - buttonPadding.right();
|
const auto width = size - buttonPadding.left() - buttonPadding.right();
|
||||||
auto button = CreateUnlockButton(box, width);
|
auto button = CreateUnlockButton(box, width);
|
||||||
button->setClickedCallback([=] {
|
button->setClickedCallback([=] {
|
||||||
controller->showSettings(Settings::PremiumId());
|
Settings::ShowPremium(controller, "premium_stickers");
|
||||||
});
|
});
|
||||||
box->addButton(std::move(button));
|
box->addButton(std::move(button));
|
||||||
}
|
}
|
||||||
|
|
|
@ -748,8 +748,10 @@ bool ResolvePremiumOffer(
|
||||||
const auto params = url_parse_params(
|
const auto params = url_parse_params(
|
||||||
match->captured(1).mid(1),
|
match->captured(1).mid(1),
|
||||||
qthelp::UrlParamNameTransform::ToLower);
|
qthelp::UrlParamNameTransform::ToLower);
|
||||||
const auto ref = params.value(qsl("ref"));
|
const auto refAddition = params.value(qsl("ref"));
|
||||||
controller->showSettings(::Settings::PremiumId());
|
const auto ref = "deeplink"
|
||||||
|
+ (refAddition.isEmpty() ? QString() : '_' + refAddition);
|
||||||
|
::Settings::ShowPremium(controller, ref);
|
||||||
controller->window().activate();
|
controller->window().activate();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,8 @@ using SetFlag = StickersSetFlag;
|
||||||
|
|
||||||
void MaybeShowPremiumToast(
|
void MaybeShowPremiumToast(
|
||||||
Window::SessionController *controller,
|
Window::SessionController *controller,
|
||||||
TextWithEntities text) {
|
TextWithEntities text,
|
||||||
|
const QString &ref) {
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +100,7 @@ void MaybeShowPremiumToast(
|
||||||
const auto widget = QPointer<Ui::RpWidget>(
|
const auto widget = QPointer<Ui::RpWidget>(
|
||||||
controller->window().widget()->bodyWidget());
|
controller->window().widget()->bodyWidget());
|
||||||
const auto filter = [=](const auto ...) {
|
const auto filter = [=](const auto ...) {
|
||||||
controller->showSettings(Settings::PremiumId());
|
Settings::ShowPremium(controller, ref);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
Ui::ShowMultilineToast({
|
Ui::ShowMultilineToast({
|
||||||
|
@ -322,7 +323,10 @@ void Stickers::addSavedGif(
|
||||||
400);
|
400);
|
||||||
if (_savedGifs.size() > limit) {
|
if (_savedGifs.size() > limit) {
|
||||||
_savedGifs.pop_back();
|
_savedGifs.pop_back();
|
||||||
MaybeShowPremiumToast(controller, SavedGifsToast(session));
|
MaybeShowPremiumToast(
|
||||||
|
controller,
|
||||||
|
SavedGifsToast(session),
|
||||||
|
LimitsPremiumRef("saved_gifs"));
|
||||||
}
|
}
|
||||||
session->local().writeSavedGifs();
|
session->local().writeSavedGifs();
|
||||||
|
|
||||||
|
@ -534,7 +538,10 @@ void Stickers::checkFavedLimit(
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
MaybeShowPremiumToast(controller, FaveStickersToast(session));
|
MaybeShowPremiumToast(
|
||||||
|
controller,
|
||||||
|
FaveStickersToast(session),
|
||||||
|
LimitsPremiumRef("stickers_faved"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stickers::pushFavedToFront(
|
void Stickers::pushFavedToFront(
|
||||||
|
|
|
@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/send_files_box.h"
|
#include "boxes/send_files_box.h"
|
||||||
#include "boxes/share_box.h"
|
#include "boxes/share_box.h"
|
||||||
#include "boxes/edit_caption_box.h"
|
#include "boxes/edit_caption_box.h"
|
||||||
|
#include "boxes/premium_limits_box.h"
|
||||||
#include "boxes/peers/edit_peer_permissions_box.h" // ShowAboutGigagroup.
|
#include "boxes/peers/edit_peer_permissions_box.h" // ShowAboutGigagroup.
|
||||||
#include "boxes/peers/edit_peer_requests_box.h"
|
#include "boxes/peers/edit_peer_requests_box.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
|
@ -4969,12 +4970,15 @@ bool HistoryWidget::showSendingFilesError(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_name,
|
lt_name,
|
||||||
list.errorData);
|
list.errorData);
|
||||||
case Error::PremiumRequired: return u"premium.."_q;
|
case Error::PremiumRequired: return u"(premium)"_q;
|
||||||
}
|
}
|
||||||
return tr::lng_forward_send_files_cant(tr::now);
|
return tr::lng_forward_send_files_cant(tr::now);
|
||||||
}();
|
}();
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (text == u"(premium)"_q) {
|
||||||
|
controller()->show(Box(FileSizeLimitBox, &session()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::ShowMultilineToast({
|
Ui::ShowMultilineToast({
|
||||||
|
|
|
@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/delete_messages_box.h"
|
#include "boxes/delete_messages_box.h"
|
||||||
#include "boxes/edit_caption_box.h"
|
#include "boxes/edit_caption_box.h"
|
||||||
#include "boxes/send_files_box.h"
|
#include "boxes/send_files_box.h"
|
||||||
|
#include "boxes/premium_limits_box.h"
|
||||||
#include "window/window_adaptive.h"
|
#include "window/window_adaptive.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
|
@ -940,12 +941,15 @@ bool RepliesWidget::showSendingFilesError(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_name,
|
lt_name,
|
||||||
list.errorData);
|
list.errorData);
|
||||||
case Error::PremiumRequired: return u"premium.."_q;
|
case Error::PremiumRequired: return u"(premium)"_q;
|
||||||
}
|
}
|
||||||
return tr::lng_forward_send_files_cant(tr::now);
|
return tr::lng_forward_send_files_cant(tr::now);
|
||||||
}();
|
}();
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (text == u"(premium)"_q) {
|
||||||
|
controller()->show(Box(FileSizeLimitBox, &session()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::ShowMultilineToast({
|
Ui::ShowMultilineToast({
|
||||||
|
|
|
@ -36,6 +36,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/delete_messages_box.h"
|
#include "boxes/delete_messages_box.h"
|
||||||
#include "boxes/edit_caption_box.h"
|
#include "boxes/edit_caption_box.h"
|
||||||
#include "boxes/send_files_box.h"
|
#include "boxes/send_files_box.h"
|
||||||
|
#include "boxes/premium_limits_box.h"
|
||||||
#include "window/window_adaptive.h"
|
#include "window/window_adaptive.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "window/window_peer_menu.h"
|
#include "window/window_peer_menu.h"
|
||||||
|
@ -560,12 +561,15 @@ bool ScheduledWidget::showSendingFilesError(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_name,
|
lt_name,
|
||||||
list.errorData);
|
list.errorData);
|
||||||
case Error::PremiumRequired: return u"premium.."_q;
|
case Error::PremiumRequired: return u"(premium)"_q;
|
||||||
}
|
}
|
||||||
return tr::lng_forward_send_files_cant(tr::now);
|
return tr::lng_forward_send_files_cant(tr::now);
|
||||||
}();
|
}();
|
||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (text == u"(premium)"_q) {
|
||||||
|
controller()->show(Box(FileSizeLimitBox, &session()));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::ShowMultilineToast({
|
Ui::ShowMultilineToast({
|
||||||
|
|
|
@ -251,7 +251,12 @@ void SetupSections(
|
||||||
std::move(label),
|
std::move(label),
|
||||||
st::settingsButton,
|
st::settingsButton,
|
||||||
std::move(descriptor)
|
std::move(descriptor)
|
||||||
)->addClickHandler([=] { showOther(type); });
|
)->addClickHandler([=] {
|
||||||
|
if (type == PremiumId()) {
|
||||||
|
controller->setPremiumRef("settings");
|
||||||
|
}
|
||||||
|
showOther(type);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
if (controller->session().supportMode()) {
|
if (controller->session().supportMode()) {
|
||||||
SetupSupport(controller, container);
|
SetupSupport(controller, container);
|
||||||
|
|
|
@ -30,6 +30,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_account.h"
|
#include "main/main_account.h"
|
||||||
#include "main/main_app_config.h"
|
#include "main/main_app_config.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
|
#include "base/unixtime.h"
|
||||||
|
#include "apiwrap.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
@ -138,6 +140,58 @@ struct Entry {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SendAppLog(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const QString &type,
|
||||||
|
const MTPJSONValue &data) {
|
||||||
|
const auto now = double(base::unixtime::now())
|
||||||
|
+ (QTime::currentTime().msec() / 1000.);
|
||||||
|
session->api().request(MTPhelp_SaveAppLog(
|
||||||
|
MTP_vector<MTPInputAppEvent>(1, MTP_inputAppEvent(
|
||||||
|
MTP_double(now),
|
||||||
|
MTP_string(type),
|
||||||
|
MTP_long(0),
|
||||||
|
data
|
||||||
|
))
|
||||||
|
)).send();
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] QString ResolveRef(const QString &ref) {
|
||||||
|
return ref.isEmpty() ? "settings" : ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendScreenShow(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
const std::vector<QString> &order,
|
||||||
|
const QString &ref) {
|
||||||
|
auto list = QVector<MTPJSONValue>();
|
||||||
|
list.reserve(order.size());
|
||||||
|
for (const auto &element : order) {
|
||||||
|
list.push_back(MTP_jsonString(MTP_string(element)));
|
||||||
|
}
|
||||||
|
auto values = QVector<MTPJSONObjectValue>{
|
||||||
|
MTP_jsonObjectValue(
|
||||||
|
MTP_string("premium_promo_order"),
|
||||||
|
MTP_jsonArray(MTP_vector<MTPJSONValue>(std::move(list)))),
|
||||||
|
MTP_jsonObjectValue(
|
||||||
|
MTP_string("source"),
|
||||||
|
MTP_jsonString(MTP_string(ResolveRef(ref)))),
|
||||||
|
};
|
||||||
|
const auto data = MTP_jsonObject(
|
||||||
|
MTP_vector<MTPJSONObjectValue>(std::move(values)));
|
||||||
|
SendAppLog(
|
||||||
|
&controller->session(),
|
||||||
|
"premium.promo_screen_show",
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendScreenAccept(not_null<Window::SessionController*> controller) {
|
||||||
|
SendAppLog(
|
||||||
|
&controller->session(),
|
||||||
|
"premium.promo_screen_accept",
|
||||||
|
MTP_jsonNull());
|
||||||
|
}
|
||||||
|
|
||||||
class TopBar final : public Ui::RpWidget {
|
class TopBar final : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
TopBar(not_null<QWidget*> parent);
|
TopBar(not_null<QWidget*> parent);
|
||||||
|
@ -282,6 +336,7 @@ private:
|
||||||
void setupContent();
|
void setupContent();
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
const QString _ref;
|
||||||
|
|
||||||
base::unique_qptr<Ui::FadeWrap<Ui::IconButton>> _back;
|
base::unique_qptr<Ui::FadeWrap<Ui::IconButton>> _back;
|
||||||
base::unique_qptr<Ui::IconButton> _close;
|
base::unique_qptr<Ui::IconButton> _close;
|
||||||
|
@ -296,7 +351,8 @@ Premium::Premium(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller)
|
not_null<Window::SessionController*> controller)
|
||||||
: Section(parent)
|
: Section(parent)
|
||||||
, _controller(controller) {
|
, _controller(controller)
|
||||||
|
, _ref(ResolveRef(controller->premiumRef())) {
|
||||||
setupContent();
|
setupContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,6 +456,8 @@ void Premium::setupContent() {
|
||||||
processEntry(entry);
|
processEntry(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SendScreenShow(_controller, mtpOrder, _ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
content->resizeToWidth(content->height());
|
content->resizeToWidth(content->height());
|
||||||
|
@ -530,7 +588,8 @@ QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
|
||||||
Ui::Premium::ButtonGradientStops());
|
Ui::Premium::ButtonGradientStops());
|
||||||
|
|
||||||
result->setClickedCallback([=] {
|
result->setClickedCallback([=] {
|
||||||
StartPremiumPayment(_controller, "settings");
|
SendScreenAccept(_controller);
|
||||||
|
StartPremiumPayment(_controller, _ref);
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto &st = st::premiumPreviewBox.button;
|
const auto &st = st::premiumPreviewBox.button;
|
||||||
|
@ -561,22 +620,29 @@ Type PremiumId() {
|
||||||
return Premium::Id();
|
return Premium::Id();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowPremium(not_null<Main::Session*> session) {
|
void ShowPremium(not_null<Main::Session*> session, const QString &ref) {
|
||||||
const auto active = Core::App().activeWindow();
|
const auto active = Core::App().activeWindow();
|
||||||
const auto controller = (active && active->isPrimary())
|
const auto controller = (active && active->isPrimary())
|
||||||
? active->sessionController()
|
? active->sessionController()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (controller && session == &controller->session()) {
|
if (controller && session == &controller->session()) {
|
||||||
controller->showSettings(Settings::PremiumId());
|
ShowPremium(controller, ref);
|
||||||
} else {
|
} else {
|
||||||
for (const auto &controller : session->windows()) {
|
for (const auto &controller : session->windows()) {
|
||||||
if (controller->window().isPrimary()) {
|
if (controller->window().isPrimary()) {
|
||||||
controller->showSettings(Settings::PremiumId());
|
ShowPremium(controller, ref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShowPremium(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
const QString &ref) {
|
||||||
|
controller->setPremiumRef(ref);
|
||||||
|
controller->showSettings(Settings::PremiumId());
|
||||||
|
}
|
||||||
|
|
||||||
void StartPremiumPayment(
|
void StartPremiumPayment(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
const QString &ref) {
|
const QString &ref) {
|
||||||
|
|
|
@ -21,7 +21,11 @@ namespace Settings {
|
||||||
|
|
||||||
[[nodiscard]] Type PremiumId();
|
[[nodiscard]] Type PremiumId();
|
||||||
|
|
||||||
void ShowPremium(not_null<::Main::Session*> session);
|
void ShowPremium(not_null<::Main::Session*> session, const QString &ref);
|
||||||
|
void ShowPremium(
|
||||||
|
not_null<Window::SessionController*> controller,
|
||||||
|
const QString &ref);
|
||||||
|
|
||||||
void StartPremiumPayment(
|
void StartPremiumPayment(
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
const QString &ref);
|
const QString &ref);
|
||||||
|
|
|
@ -355,7 +355,7 @@ bool ShowReactPremiumError(
|
||||||
if (i == end(list) || !i->premium) {
|
if (i == end(list) || !i->premium) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Settings::ShowPremium(&controller->session());
|
Settings::ShowPremium(controller, "unique_reactions");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1862,6 +1862,14 @@ HistoryView::PaintContext SessionController::preparePaintContext(
|
||||||
args.clip);
|
args.clip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SessionController::setPremiumRef(const QString &ref) {
|
||||||
|
_premiumRef = ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SessionController::premiumRef() const {
|
||||||
|
return _premiumRef;
|
||||||
|
}
|
||||||
|
|
||||||
SessionController::~SessionController() {
|
SessionController::~SessionController() {
|
||||||
resetFakeUnreadWhileOpened();
|
resetFakeUnreadWhileOpened();
|
||||||
}
|
}
|
||||||
|
|
|
@ -503,6 +503,9 @@ public:
|
||||||
return *_cachedReactionIconFactory;
|
return *_cachedReactionIconFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setPremiumRef(const QString &ref);
|
||||||
|
[[nodiscard]] QString premiumRef() const;
|
||||||
|
|
||||||
rpl::lifetime &lifetime() {
|
rpl::lifetime &lifetime() {
|
||||||
return _lifetime;
|
return _lifetime;
|
||||||
}
|
}
|
||||||
|
@ -590,6 +593,8 @@ private:
|
||||||
using ReactionIconFactory = HistoryView::Reactions::CachedIconFactory;
|
using ReactionIconFactory = HistoryView::Reactions::CachedIconFactory;
|
||||||
std::unique_ptr<ReactionIconFactory> _cachedReactionIconFactory;
|
std::unique_ptr<ReactionIconFactory> _cachedReactionIconFactory;
|
||||||
|
|
||||||
|
QString _premiumRef;
|
||||||
|
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue