mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Show all premium limits boxes.
This commit is contained in:
parent
63940ea557
commit
26c99cea7c
12 changed files with 301 additions and 24 deletions
|
@ -214,6 +214,14 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_saved_gif_limit_more#other" = "An older GIF was replaced with this one.\nYou can {link} to {count} GIFs.";
|
"lng_saved_gif_limit_more#other" = "An older GIF was replaced with this one.\nYou can {link} to {count} GIFs.";
|
||||||
"lng_saved_gif_limit_link" = "increase the limit";
|
"lng_saved_gif_limit_link" = "increase the limit";
|
||||||
|
|
||||||
|
"lng_caption_limit_title" = "Limit Reached";
|
||||||
|
"lng_caption_limit1#one" = "Sorry, you can't use more than **{count}** character in media captions.";
|
||||||
|
"lng_caption_limit1#other" = "Sorry, you can't use more than **{count}** characters in media captions.";
|
||||||
|
"lng_caption_limit2#one" = "Make the caption shorter or subscribe to **Telegram Premium** to double the limit to **{count}** character.";
|
||||||
|
"lng_caption_limit2#other" = "Make the caption shorter or subscribe to **Telegram Premium** to double the limit to **{count}** characters.";
|
||||||
|
"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_limits_increase" = "Increase Limit";
|
"lng_limits_increase" = "Increase Limit";
|
||||||
|
|
||||||
"lng_flood_error" = "Too many tries. Please try again later.";
|
"lng_flood_error" = "Too many tries. Please try again later.";
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_text_entities.h"
|
#include "api/api_text_entities.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
|
#include "boxes/premium_limits_box.h"
|
||||||
#include "chat_helpers/emoji_suggestions_widget.h"
|
#include "chat_helpers/emoji_suggestions_widget.h"
|
||||||
#include "chat_helpers/message_field.h"
|
#include "chat_helpers/message_field.h"
|
||||||
#include "chat_helpers/tabbed_panel.h"
|
#include "chat_helpers/tabbed_panel.h"
|
||||||
|
@ -33,6 +34,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
#include "storage/localimageloader.h" // SendMediaType
|
#include "storage/localimageloader.h" // SendMediaType
|
||||||
#include "storage/storage_media_prepare.h"
|
#include "storage/storage_media_prepare.h"
|
||||||
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/chat/attach/attach_item_single_file_preview.h"
|
#include "ui/chat/attach/attach_item_single_file_preview.h"
|
||||||
#include "ui/chat/attach/attach_item_single_media_preview.h"
|
#include "ui/chat/attach/attach_item_single_media_preview.h"
|
||||||
#include "ui/chat/attach/attach_single_file_preview.h"
|
#include "ui/chat/attach/attach_single_file_preview.h"
|
||||||
|
@ -240,8 +242,6 @@ void EditCaptionBox::rebuildPreview() {
|
||||||
void EditCaptionBox::setupField() {
|
void EditCaptionBox::setupField() {
|
||||||
const auto show = std::make_shared<Window::Show>(_controller);
|
const auto show = std::make_shared<Window::Show>(_controller);
|
||||||
const auto session = &_controller->session();
|
const auto session = &_controller->session();
|
||||||
_field->setMaxLength(
|
|
||||||
_controller->session().serverConfig().captionLengthMax);
|
|
||||||
_field->setSubmitSettings(
|
_field->setSubmitSettings(
|
||||||
Core::App().settings().sendSubmitWay());
|
Core::App().settings().sendSubmitWay());
|
||||||
_field->setInstantReplaces(Ui::InstantReplaces::Default());
|
_field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
|
@ -648,6 +648,22 @@ void EditCaptionBox::setInnerFocus() {
|
||||||
_field->setFocusFast();
|
_field->setFocusFast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditCaptionBox::validateLength(const QString &text) const {
|
||||||
|
const auto session = &_controller->session();
|
||||||
|
const auto limit = CurrentPremiumLimit(
|
||||||
|
session,
|
||||||
|
"caption_length_limit_default",
|
||||||
|
1024,
|
||||||
|
"caption_length_limit_premium",
|
||||||
|
2048);
|
||||||
|
const auto remove = int(text.size()) - limit;
|
||||||
|
if (remove <= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
_controller->show(Box(CaptionLimitReachedBox, session, remove));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void EditCaptionBox::save() {
|
void EditCaptionBox::save() {
|
||||||
if (_saveRequestId) {
|
if (_saveRequestId) {
|
||||||
return;
|
return;
|
||||||
|
@ -662,6 +678,9 @@ void EditCaptionBox::save() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto textWithTags = _field->getTextWithAppliedMarkdown();
|
const auto textWithTags = _field->getTextWithAppliedMarkdown();
|
||||||
|
if (!validateLength(textWithTags.text)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto sending = TextWithEntities{
|
const auto sending = TextWithEntities{
|
||||||
textWithTags.text,
|
textWithTags.text,
|
||||||
TextUtilities::ConvertTextTagsToEntities(textWithTags.tags)
|
TextUtilities::ConvertTextTagsToEntities(textWithTags.tags)
|
||||||
|
|
|
@ -62,6 +62,7 @@ private:
|
||||||
|
|
||||||
void setupDragArea();
|
void setupDragArea();
|
||||||
|
|
||||||
|
bool validateLength(const QString &text) const;
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
bool fileFromClipboard(not_null<const QMimeData*> data);
|
bool fileFromClipboard(not_null<const QMimeData*> data);
|
||||||
|
|
|
@ -626,6 +626,7 @@ void Controller::showEditPeerTypeBox(
|
||||||
= (_linkedChatSavedValue.value_or(nullptr) != nullptr);
|
= (_linkedChatSavedValue.value_or(nullptr) != nullptr);
|
||||||
_navigation->parentController()->show(
|
_navigation->parentController()->show(
|
||||||
Box<EditPeerTypeBox>(
|
Box<EditPeerTypeBox>(
|
||||||
|
_navigation,
|
||||||
_peer,
|
_peer,
|
||||||
_channelHasLocationOriginalValue,
|
_channelHasLocationOriginalValue,
|
||||||
boxCallback,
|
boxCallback,
|
||||||
|
|
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session.h"
|
#include "main/main_session.h"
|
||||||
#include "boxes/add_contact_box.h"
|
#include "boxes/add_contact_box.h"
|
||||||
#include "ui/boxes/confirm_box.h"
|
#include "ui/boxes/confirm_box.h"
|
||||||
|
#include "boxes/premium_limits_box.h"
|
||||||
#include "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
#include "boxes/peers/edit_participants_box.h"
|
#include "boxes/peers/edit_participants_box.h"
|
||||||
#include "boxes/peers/edit_peer_common.h"
|
#include "boxes/peers/edit_peer_common.h"
|
||||||
|
@ -48,6 +49,7 @@ namespace {
|
||||||
class Controller : public base::has_weak_ptr {
|
class Controller : public base::has_weak_ptr {
|
||||||
public:
|
public:
|
||||||
Controller(
|
Controller(
|
||||||
|
Window::SessionNavigation *navigation,
|
||||||
std::shared_ptr<Ui::BoxShow> show,
|
std::shared_ptr<Ui::BoxShow> show,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
|
@ -131,6 +133,7 @@ private:
|
||||||
const QString &text,
|
const QString &text,
|
||||||
rpl::producer<QString> about);
|
rpl::producer<QString> about);
|
||||||
|
|
||||||
|
Window::SessionNavigation *_navigation = nullptr;
|
||||||
std::shared_ptr<Ui::BoxShow> _show;
|
std::shared_ptr<Ui::BoxShow> _show;
|
||||||
|
|
||||||
not_null<PeerData*> _peer;
|
not_null<PeerData*> _peer;
|
||||||
|
@ -154,12 +157,14 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
Controller::Controller(
|
Controller::Controller(
|
||||||
|
Window::SessionNavigation *navigation,
|
||||||
std::shared_ptr<Ui::BoxShow> show,
|
std::shared_ptr<Ui::BoxShow> show,
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
bool useLocationPhrases,
|
bool useLocationPhrases,
|
||||||
std::optional<EditPeerTypeData> dataSavedValue)
|
std::optional<EditPeerTypeData> dataSavedValue)
|
||||||
: _show(show)
|
: _navigation(navigation)
|
||||||
|
, _show(show)
|
||||||
, _peer(peer)
|
, _peer(peer)
|
||||||
, _linkOnly(!dataSavedValue.has_value())
|
, _linkOnly(!dataSavedValue.has_value())
|
||||||
, _api(&_peer->session().mtp())
|
, _api(&_peer->session().mtp())
|
||||||
|
@ -249,7 +254,7 @@ void Controller::createContent() {
|
||||||
tr::lng_manage_peer_send_approve_members(),
|
tr::lng_manage_peer_send_approve_members(),
|
||||||
rpl::single(QString()),
|
rpl::single(QString()),
|
||||||
[=] {},
|
[=] {},
|
||||||
st::manageGroupTopButtonWithText,
|
st::peerPermissionsButton,
|
||||||
{})))->setDuration(0);
|
{})))->setDuration(0);
|
||||||
requestToJoinWrap->toggleOn(rpl::duplicate(joinToWrite));
|
requestToJoinWrap->toggleOn(rpl::duplicate(joinToWrite));
|
||||||
_controls.requestToJoin = requestToJoinWrap->entity();
|
_controls.requestToJoin = requestToJoinWrap->entity();
|
||||||
|
@ -574,9 +579,7 @@ void Controller::askUsernameRevoke() {
|
||||||
checkUsernameAvailability();
|
checkUsernameAvailability();
|
||||||
});
|
});
|
||||||
_show->showBox(
|
_show->showBox(
|
||||||
Box<RevokePublicLinkBox>(
|
Box(PublicLinksLimitBox, _navigation),
|
||||||
&_peer->session(),
|
|
||||||
std::move(revokeCallback)),
|
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -676,12 +679,14 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkBlock() {
|
||||||
|
|
||||||
EditPeerTypeBox::EditPeerTypeBox(
|
EditPeerTypeBox::EditPeerTypeBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
Window::SessionNavigation *navigation,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
bool useLocationPhrases,
|
bool useLocationPhrases,
|
||||||
std::optional<FnMut<void(EditPeerTypeData)>> savedCallback,
|
std::optional<FnMut<void(EditPeerTypeData)>> savedCallback,
|
||||||
std::optional<EditPeerTypeData> dataSaved,
|
std::optional<EditPeerTypeData> dataSaved,
|
||||||
std::optional<rpl::producer<QString>> usernameError)
|
std::optional<rpl::producer<QString>> usernameError)
|
||||||
: _peer(peer)
|
: _navigation(navigation)
|
||||||
|
, _peer(peer)
|
||||||
, _useLocationPhrases(useLocationPhrases)
|
, _useLocationPhrases(useLocationPhrases)
|
||||||
, _savedCallback(std::move(savedCallback))
|
, _savedCallback(std::move(savedCallback))
|
||||||
, _dataSavedValue(dataSaved)
|
, _dataSavedValue(dataSaved)
|
||||||
|
@ -691,7 +696,7 @@ EditPeerTypeBox::EditPeerTypeBox(
|
||||||
EditPeerTypeBox::EditPeerTypeBox(
|
EditPeerTypeBox::EditPeerTypeBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
not_null<PeerData*> peer)
|
not_null<PeerData*> peer)
|
||||||
: EditPeerTypeBox(nullptr, peer, {}, {}, {}) {
|
: EditPeerTypeBox(nullptr, nullptr, peer, {}, {}, {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditPeerTypeBox::setInnerFocus() {
|
void EditPeerTypeBox::setInnerFocus() {
|
||||||
|
@ -705,6 +710,7 @@ void EditPeerTypeBox::prepare() {
|
||||||
|
|
||||||
const auto controller = Ui::CreateChild<Controller>(
|
const auto controller = Ui::CreateChild<Controller>(
|
||||||
this,
|
this,
|
||||||
|
_navigation,
|
||||||
std::make_shared<Ui::BoxShow>(this),
|
std::make_shared<Ui::BoxShow>(this),
|
||||||
content.data(),
|
content.data(),
|
||||||
_peer,
|
_peer,
|
||||||
|
|
|
@ -18,6 +18,10 @@ class VerticalLayout;
|
||||||
class SettingsButton;
|
class SettingsButton;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
class SessionNavigation;
|
||||||
|
} // namespace Window
|
||||||
|
|
||||||
enum class Privacy {
|
enum class Privacy {
|
||||||
HasUsername,
|
HasUsername,
|
||||||
NoUsername,
|
NoUsername,
|
||||||
|
@ -42,6 +46,7 @@ class EditPeerTypeBox : public Ui::BoxContent {
|
||||||
public:
|
public:
|
||||||
EditPeerTypeBox(
|
EditPeerTypeBox(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
|
Window::SessionNavigation *navigation,
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
bool useLocationPhrases,
|
bool useLocationPhrases,
|
||||||
std::optional<FnMut<void(EditPeerTypeData)>> savedCallback,
|
std::optional<FnMut<void(EditPeerTypeData)>> savedCallback,
|
||||||
|
@ -58,7 +63,8 @@ protected:
|
||||||
void setInnerFocus() override;
|
void setInnerFocus() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
not_null<PeerData*> _peer;
|
Window::SessionNavigation *_navigation = nullptr;
|
||||||
|
const not_null<PeerData*> _peer;
|
||||||
bool _useLocationPhrases = false;
|
bool _useLocationPhrases = false;
|
||||||
std::optional<FnMut<void(EditPeerTypeData)>> _savedCallback;
|
std::optional<FnMut<void(EditPeerTypeData)>> _savedCallback;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
*/
|
*/
|
||||||
#include "boxes/premium_limits_box.h"
|
#include "boxes/premium_limits_box.h"
|
||||||
|
|
||||||
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/controls/peer_list_dummy.h"
|
#include "ui/controls/peer_list_dummy.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
|
@ -16,7 +17,10 @@ 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 "boxes/peer_list_controllers.h"
|
#include "boxes/peer_list_controllers.h"
|
||||||
|
#include "boxes/peers/prepare_short_info_box.h" // PrepareShortInfoBox
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
#include "data/data_channel.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
@ -47,6 +51,29 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PublicsController final : public PeerListController {
|
||||||
|
public:
|
||||||
|
PublicsController(
|
||||||
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
Fn<void()> closeBox);
|
||||||
|
~PublicsController();
|
||||||
|
|
||||||
|
Main::Session &session() const override;
|
||||||
|
void prepare() override;
|
||||||
|
void rowClicked(not_null<PeerListRow*> row) override;
|
||||||
|
void rowRightActionClicked(not_null<PeerListRow*> row) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void appendRow(not_null<PeerData*> peer);
|
||||||
|
[[nodiscard]] std::unique_ptr<PeerListRow> createRow(
|
||||||
|
not_null<PeerData*> peer) const;
|
||||||
|
|
||||||
|
const not_null<Window::SessionNavigation*> _navigation;
|
||||||
|
Fn<void()> _closeBox;
|
||||||
|
mtpRequestId _requestId = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class InactiveDelegate final : public PeerListContentDelegate {
|
class InactiveDelegate final : public PeerListContentDelegate {
|
||||||
public:
|
public:
|
||||||
void peerListSetTitle(rpl::producer<QString> title) override;
|
void peerListSetTitle(rpl::producer<QString> title) override;
|
||||||
|
@ -149,7 +176,6 @@ const base::flat_set<PeerListRowId> &InactiveDelegate::selected() const {
|
||||||
return _selectedIds;
|
return _selectedIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
InactiveController::InactiveController(not_null<Main::Session*> session)
|
InactiveController::InactiveController(not_null<Main::Session*> session)
|
||||||
: _session(session) {
|
: _session(session) {
|
||||||
}
|
}
|
||||||
|
@ -165,10 +191,6 @@ Main::Session &InactiveController::session() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InactiveController::prepare() {
|
void InactiveController::prepare() {
|
||||||
delegate()->peerListSetTitle(tr::lng_blocked_list_title());
|
|
||||||
setDescriptionText(tr::lng_contacts_loading(tr::now));
|
|
||||||
delegate()->peerListRefreshRows();
|
|
||||||
|
|
||||||
_requestId = _session->api().request(MTPchannels_GetInactiveChannels(
|
_requestId = _session->api().request(MTPchannels_GetInactiveChannels(
|
||||||
)).done([=](const MTPmessages_InactiveChats &result) {
|
)).done([=](const MTPmessages_InactiveChats &result) {
|
||||||
_requestId = 0;
|
_requestId = 0;
|
||||||
|
@ -241,6 +263,102 @@ std::unique_ptr<PeerListRow> InactiveController::createRow(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PublicsController::PublicsController(
|
||||||
|
not_null<Window::SessionNavigation*> navigation,
|
||||||
|
Fn<void()> closeBox)
|
||||||
|
: _navigation(navigation)
|
||||||
|
, _closeBox(std::move(closeBox)) {
|
||||||
|
}
|
||||||
|
|
||||||
|
PublicsController::~PublicsController() {
|
||||||
|
if (_requestId) {
|
||||||
|
_navigation->session().api().request(_requestId).cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Main::Session &PublicsController::session() const {
|
||||||
|
return _navigation->session();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PublicsController::prepare() {
|
||||||
|
_requestId = _navigation->session().api().request(
|
||||||
|
MTPchannels_GetAdminedPublicChannels(MTP_flags(0))
|
||||||
|
).done([=](const MTPmessages_Chats &result) {
|
||||||
|
_requestId = 0;
|
||||||
|
|
||||||
|
const auto &chats = result.match([](const auto &data) {
|
||||||
|
return data.vchats().v;
|
||||||
|
});
|
||||||
|
auto &owner = _navigation->session().data();
|
||||||
|
for (const auto &chat : chats) {
|
||||||
|
if (const auto peer = owner.processChat(chat)) {
|
||||||
|
if (!peer->isChannel() || peer->userName().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
appendRow(peer);
|
||||||
|
}
|
||||||
|
delegate()->peerListRefreshRows();
|
||||||
|
}
|
||||||
|
}).send();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PublicsController::rowClicked(not_null<PeerListRow*> row) {
|
||||||
|
_navigation->parentController()->show(
|
||||||
|
PrepareShortInfoBox(row->peer(), _navigation));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PublicsController::rowRightActionClicked(not_null<PeerListRow*> row) {
|
||||||
|
const auto peer = row->peer();
|
||||||
|
const auto textMethod = peer->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,
|
||||||
|
peer->session().createInternalLink(peer->userName()),
|
||||||
|
lt_group,
|
||||||
|
peer->name);
|
||||||
|
const auto confirmText = tr::lng_channels_too_much_public_revoke(
|
||||||
|
tr::now);
|
||||||
|
const auto closeBox = _closeBox;
|
||||||
|
const auto once = std::make_shared<bool>(false);
|
||||||
|
auto callback = crl::guard(_navigation, [=](Fn<void()> &&close) {
|
||||||
|
if (*once) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
*once = true;
|
||||||
|
peer->session().api().request(MTPchannels_UpdateUsername(
|
||||||
|
peer->asChannel()->inputChannel,
|
||||||
|
MTP_string()
|
||||||
|
)).done([=, close = std::move(close)] {
|
||||||
|
closeBox();
|
||||||
|
close();
|
||||||
|
}).send();
|
||||||
|
});
|
||||||
|
_navigation->parentController()->show(
|
||||||
|
Ui::MakeConfirmBox({
|
||||||
|
.text = text,
|
||||||
|
.confirmed = std::move(callback),
|
||||||
|
.confirmText = confirmText,
|
||||||
|
}),
|
||||||
|
Ui::LayerOption::KeepOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PublicsController::appendRow(not_null<PeerData*> participant) {
|
||||||
|
if (!delegate()->peerListFindRow(participant->id.value)) {
|
||||||
|
delegate()->peerListAppendRow(createRow(participant));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<PeerListRow> PublicsController::createRow(
|
||||||
|
not_null<PeerData*> peer) const {
|
||||||
|
auto result = std::make_unique<PeerListRowWithLink>(peer);
|
||||||
|
result->setActionLink(tr::lng_channels_too_much_public_revoke(tr::now));
|
||||||
|
result->setCustomStatus(
|
||||||
|
_navigation->session().createInternalLink(peer->userName()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] float64 Limit(
|
[[nodiscard]] float64 Limit(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const QString &key,
|
const QString &key,
|
||||||
|
@ -385,7 +503,7 @@ void ChannelsLimitBox(
|
||||||
delegate->setContent(content);
|
delegate->setContent(content);
|
||||||
controller->setDelegate(delegate);
|
controller->setDelegate(delegate);
|
||||||
|
|
||||||
const auto count = 50;
|
const auto count = 100;
|
||||||
const auto placeholder = box->addRow(
|
const auto placeholder = box->addRow(
|
||||||
object_ptr<PeerListDummy>(box, count, st::defaultPeerList),
|
object_ptr<PeerListDummy>(box, count, st::defaultPeerList),
|
||||||
{});
|
{});
|
||||||
|
@ -431,7 +549,8 @@ void ChannelsLimitBox(
|
||||||
|
|
||||||
void PublicLinksLimitBox(
|
void PublicLinksLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session) {
|
not_null<Window::SessionNavigation*> navigation) {
|
||||||
|
const auto session = &navigation->session();
|
||||||
const auto premium = session->user()->isPremium();
|
const auto premium = session->user()->isPremium();
|
||||||
|
|
||||||
auto text = rpl::combine(
|
auto text = rpl::combine(
|
||||||
|
@ -462,7 +581,30 @@ void PublicLinksLimitBox(
|
||||||
session,
|
session,
|
||||||
tr::lng_links_limit_title(),
|
tr::lng_links_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
premium);
|
premium,
|
||||||
|
true);
|
||||||
|
|
||||||
|
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
||||||
|
const auto controller = box->lifetime().make_state<PublicsController>(
|
||||||
|
navigation,
|
||||||
|
crl::guard(box, [=] { box->closeBox(); }));
|
||||||
|
|
||||||
|
const auto content = box->addRow(
|
||||||
|
object_ptr<PeerListContent>(box, controller),
|
||||||
|
{});
|
||||||
|
delegate->setContent(content);
|
||||||
|
controller->setDelegate(delegate);
|
||||||
|
|
||||||
|
const auto count = Limit(session, "channels_public_limit_default", 10);
|
||||||
|
const auto placeholder = box->addRow(
|
||||||
|
object_ptr<PeerListDummy>(box, count, st::defaultPeerList),
|
||||||
|
{});
|
||||||
|
|
||||||
|
using namespace rpl::mappers;
|
||||||
|
content->heightValue(
|
||||||
|
) | rpl::filter(_1 > 0) | rpl::start_with_next([=] {
|
||||||
|
delete placeholder;
|
||||||
|
}, placeholder->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FilterChatsLimitBox(
|
void FilterChatsLimitBox(
|
||||||
|
@ -575,6 +717,58 @@ void PinsLimitBox(
|
||||||
10);
|
10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CaptionLimitBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session) {
|
||||||
|
const auto premium = session->user()->isPremium();
|
||||||
|
|
||||||
|
auto text = rpl::combine(
|
||||||
|
tr::lng_caption_limit1(
|
||||||
|
lt_count,
|
||||||
|
rpl::single(Limit(
|
||||||
|
session,
|
||||||
|
(premium
|
||||||
|
? "caption_length_limit_premium"
|
||||||
|
: "caption_length_limit_default"),
|
||||||
|
premium ? 2048 : 1024)),
|
||||||
|
Ui::Text::RichLangValue),
|
||||||
|
tr::lng_caption_limit2(
|
||||||
|
lt_count,
|
||||||
|
rpl::single(
|
||||||
|
Limit(session, "caption_length_limit_premium", 2048)),
|
||||||
|
Ui::Text::RichLangValue)
|
||||||
|
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
||||||
|
return a.append(QChar(' ')).append(std::move(b));
|
||||||
|
});
|
||||||
|
|
||||||
|
SimpleLimitBox(
|
||||||
|
box,
|
||||||
|
session,
|
||||||
|
tr::lng_caption_limit_title(),
|
||||||
|
std::move(text),
|
||||||
|
premium);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CaptionLimitReachedBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
int remove) {
|
||||||
|
Ui::ConfirmBox(box, Ui::ConfirmBoxArgs{
|
||||||
|
.text = tr::lng_caption_limit_reached(tr::now, lt_count, remove),
|
||||||
|
.inform = true,
|
||||||
|
});
|
||||||
|
if (!session->user()->isPremium()) {
|
||||||
|
box->addLeftButton(tr::lng_limits_increase(), [=] {
|
||||||
|
box->getDelegate()->showBox(
|
||||||
|
Box(CaptionLimitBox, session),
|
||||||
|
Ui::LayerOption::KeepOther,
|
||||||
|
anim::type::normal);
|
||||||
|
box->closeBox();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int AppConfigLimit(
|
int AppConfigLimit(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const QString &key,
|
const QString &key,
|
||||||
|
|
|
@ -13,12 +13,16 @@ namespace Main {
|
||||||
class Session;
|
class Session;
|
||||||
} // namespace Main
|
} // namespace Main
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
class SessionNavigation;
|
||||||
|
} // namespace Window
|
||||||
|
|
||||||
void ChannelsLimitBox(
|
void ChannelsLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
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<Main::Session*> session);
|
not_null<Window::SessionNavigation*> navigation);
|
||||||
void FilterChatsLimitBox(
|
void FilterChatsLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session);
|
not_null<Main::Session*> session);
|
||||||
|
@ -34,6 +38,13 @@ void FolderPinsLimitBox(
|
||||||
void PinsLimitBox(
|
void PinsLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session);
|
not_null<Main::Session*> session);
|
||||||
|
void CaptionLimitBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session);
|
||||||
|
void CaptionLimitReachedBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
int remove);
|
||||||
|
|
||||||
[[nodiscard]] int AppConfigLimit(
|
[[nodiscard]] int AppConfigLimit(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
|
|
|
@ -25,6 +25,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "core/mime_type.h"
|
#include "core/mime_type.h"
|
||||||
#include "base/event_filter.h"
|
#include "base/event_filter.h"
|
||||||
|
#include "boxes/premium_limits_box.h"
|
||||||
|
#include "ui/boxes/confirm_box.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
#include "ui/effects/scroll_content_shadow.h"
|
#include "ui/effects/scroll_content_shadow.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
|
@ -60,6 +62,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
constexpr auto kMaxMessageLength = 4096;
|
||||||
|
|
||||||
using Ui::SendFilesWay;
|
using Ui::SendFilesWay;
|
||||||
|
|
||||||
inline bool CanAddUrls(const QList<QUrl> &urls) {
|
inline bool CanAddUrls(const QList<QUrl> &urls) {
|
||||||
|
@ -660,8 +664,7 @@ void SendFilesBox::updateSendWayControlsVisibility() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendFilesBox::setupCaption() {
|
void SendFilesBox::setupCaption() {
|
||||||
_caption->setMaxLength(
|
_caption->setMaxLength(kMaxMessageLength);
|
||||||
_controller->session().serverConfig().captionLengthMax);
|
|
||||||
_caption->setSubmitSettings(
|
_caption->setSubmitSettings(
|
||||||
Core::App().settings().sendSubmitWay());
|
Core::App().settings().sendSubmitWay());
|
||||||
connect(_caption, &Ui::InputField::resized, [=] {
|
connect(_caption, &Ui::InputField::resized, [=] {
|
||||||
|
@ -973,6 +976,25 @@ void SendFilesBox::saveSendWaySettings() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SendFilesBox::validateLength(const QString &text) const {
|
||||||
|
const auto session = &_controller->session();
|
||||||
|
const auto limit = CurrentPremiumLimit(
|
||||||
|
session,
|
||||||
|
"caption_length_limit_default",
|
||||||
|
1024,
|
||||||
|
"caption_length_limit_premium",
|
||||||
|
2048);
|
||||||
|
const auto remove = int(text.size()) - limit;
|
||||||
|
const auto way = _sendWay.current();
|
||||||
|
if (remove <= 0
|
||||||
|
|| !_list.canAddCaption(
|
||||||
|
way.groupFiles() && way.sendImagesAsPhotos())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
_controller->show(Box(CaptionLimitReachedBox, session, remove));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SendFilesBox::send(
|
void SendFilesBox::send(
|
||||||
Api::SendOptions options,
|
Api::SendOptions options,
|
||||||
bool ctrlShiftEnter) {
|
bool ctrlShiftEnter) {
|
||||||
|
@ -1001,6 +1023,9 @@ void SendFilesBox::send(
|
||||||
auto caption = (_caption && !_caption->isHidden())
|
auto caption = (_caption && !_caption->isHidden())
|
||||||
? _caption->getTextWithAppliedMarkdown()
|
? _caption->getTextWithAppliedMarkdown()
|
||||||
: TextWithTags();
|
: TextWithTags();
|
||||||
|
if (!validateLength(caption.text)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_confirmedCallback(
|
_confirmedCallback(
|
||||||
std::move(_list),
|
std::move(_list),
|
||||||
_sendWay.current(),
|
_sendWay.current(),
|
||||||
|
|
|
@ -120,6 +120,7 @@ private:
|
||||||
void initSendWay();
|
void initSendWay();
|
||||||
void initPreview();
|
void initPreview();
|
||||||
|
|
||||||
|
bool validateLength(const QString &text) const;
|
||||||
void refreshControls();
|
void refreshControls();
|
||||||
void setupSendWayControls();
|
void setupSendWayControls();
|
||||||
void setupCaption();
|
void setupCaption();
|
||||||
|
|
|
@ -392,7 +392,6 @@ void Form::processDetails(const MTPDpayments_paymentForm &data) {
|
||||||
.canSaveCredentials = data.is_can_save_credentials(),
|
.canSaveCredentials = data.is_can_save_credentials(),
|
||||||
.passwordMissing = data.is_password_missing(),
|
.passwordMissing = data.is_password_missing(),
|
||||||
};
|
};
|
||||||
//_invoice.isTest = data.is_test();
|
|
||||||
_invoice.cover.title = qs(data.vtitle());
|
_invoice.cover.title = qs(data.vtitle());
|
||||||
_invoice.cover.description = qs(data.vdescription());
|
_invoice.cover.description = qs(data.vdescription());
|
||||||
if (_invoice.cover.thumbnail.isNull() && !_thumbnailLoadProcess) {
|
if (_invoice.cover.thumbnail.isNull() && !_thumbnailLoadProcess) {
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "api/api_sending.h"
|
#include "api/api_sending.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
|
#include "data/data_user.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "core/mime_type.h"
|
#include "core/mime_type.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
|
@ -1042,6 +1043,11 @@ void FileLoadTask::process(Args &&args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileLoadTask::finish() {
|
void FileLoadTask::finish() {
|
||||||
|
const auto session = _session.get();
|
||||||
|
if (!session) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto premium = session->user()->isPremium();
|
||||||
if (!_result || !_result->filesize || _result->filesize < 0) {
|
if (!_result || !_result->filesize || _result->filesize < 0) {
|
||||||
Ui::show(
|
Ui::show(
|
||||||
Ui::MakeInformBox(
|
Ui::MakeInformBox(
|
||||||
|
@ -1054,13 +1060,13 @@ void FileLoadTask::finish() {
|
||||||
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),
|
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
removeFromAlbum();
|
removeFromAlbum();
|
||||||
} else if (_result->filesize > kFileSizeLimit) {
|
} else if (_result->filesize > kFileSizeLimit && !premium) {
|
||||||
Ui::show(
|
Ui::show(
|
||||||
Ui::MakeInformBox(
|
Ui::MakeInformBox(
|
||||||
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),
|
tr::lng_send_image_too_large(tr::now, lt_name, _filepath)),
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
removeFromAlbum();
|
removeFromAlbum();
|
||||||
} else if (const auto session = _session.get()) {
|
} else {
|
||||||
Api::SendConfirmedFile(session, _result);
|
Api::SendConfirmedFile(session, _result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue