mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Show new pins limit box.
This commit is contained in:
parent
d15b299e32
commit
23caae689b
3 changed files with 70 additions and 42 deletions
|
@ -252,11 +252,13 @@ 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,
|
||||||
bool premium) {
|
bool premium,
|
||||||
|
bool fixed = false) {
|
||||||
box->setWidth(st::boxWideWidth);
|
box->setWidth(st::boxWideWidth);
|
||||||
|
|
||||||
const auto top = box->setPinnedToTopContent(
|
const auto top = fixed
|
||||||
object_ptr<Ui::VerticalLayout>(box));
|
? box->setPinnedToTopContent(object_ptr<Ui::VerticalLayout>(box))
|
||||||
|
: box->verticalLayout();
|
||||||
top->add(
|
top->add(
|
||||||
object_ptr<Ui::CenterWrap<>>(
|
object_ptr<Ui::CenterWrap<>>(
|
||||||
box,
|
box,
|
||||||
|
@ -288,6 +290,42 @@ void SimpleLimitBox(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SimplePinsLimitBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const QString &keyDefault,
|
||||||
|
int limitDefault,
|
||||||
|
const QString &keyPremium,
|
||||||
|
int limitPremium) {
|
||||||
|
const auto premium = session->user()->isPremium();
|
||||||
|
|
||||||
|
auto text = rpl::combine(
|
||||||
|
tr::lng_filter_pin_limit1(
|
||||||
|
lt_count,
|
||||||
|
rpl::single(Limit(
|
||||||
|
session,
|
||||||
|
(premium ? keyPremium : keyDefault),
|
||||||
|
premium ? limitPremium : limitDefault)),
|
||||||
|
Ui::Text::RichLangValue),
|
||||||
|
(premium
|
||||||
|
? rpl::single(TextWithEntities())
|
||||||
|
: tr::lng_filter_pin_limit2(
|
||||||
|
lt_count,
|
||||||
|
rpl::single(Limit(session, keyPremium, limitPremium)),
|
||||||
|
Ui::Text::RichLangValue))
|
||||||
|
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
||||||
|
return b.text.isEmpty()
|
||||||
|
? a
|
||||||
|
: a.append(QChar(' ')).append(std::move(b));
|
||||||
|
});
|
||||||
|
SimpleLimitBox(
|
||||||
|
box,
|
||||||
|
session,
|
||||||
|
tr::lng_filter_pin_limit_title(),
|
||||||
|
std::move(text),
|
||||||
|
premium);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void ChannelsLimitBox(
|
void ChannelsLimitBox(
|
||||||
|
@ -320,7 +358,8 @@ void ChannelsLimitBox(
|
||||||
session,
|
session,
|
||||||
tr::lng_channels_limit_title(),
|
tr::lng_channels_limit_title(),
|
||||||
std::move(text),
|
std::move(text),
|
||||||
premium);
|
premium,
|
||||||
|
true);
|
||||||
|
|
||||||
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
const auto delegate = box->lifetime().make_state<InactiveDelegate>();
|
||||||
const auto controller = box->lifetime().make_state<InactiveController>(
|
const auto controller = box->lifetime().make_state<InactiveController>(
|
||||||
|
@ -489,36 +528,23 @@ void FiltersLimitBox(
|
||||||
void FilterPinsLimitBox(
|
void FilterPinsLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session) {
|
not_null<Main::Session*> session) {
|
||||||
const auto premium = session->user()->isPremium();
|
SimplePinsLimitBox(
|
||||||
|
|
||||||
auto text = rpl::combine(
|
|
||||||
tr::lng_filter_pin_limit1(
|
|
||||||
lt_count,
|
|
||||||
rpl::single(Limit(
|
|
||||||
session,
|
|
||||||
(premium
|
|
||||||
? "dialog_filters_pinned_limit_premium"
|
|
||||||
: "dialog_filters_pinned_limit_default"),
|
|
||||||
premium ? 200 : 100)),
|
|
||||||
Ui::Text::RichLangValue),
|
|
||||||
(premium
|
|
||||||
? rpl::single(TextWithEntities())
|
|
||||||
: tr::lng_filter_pin_limit2(
|
|
||||||
lt_count,
|
|
||||||
rpl::single(Limit(
|
|
||||||
session,
|
|
||||||
"dialog_filters_pinned_limit_premium",
|
|
||||||
200)),
|
|
||||||
Ui::Text::RichLangValue))
|
|
||||||
) | rpl::map([](TextWithEntities &&a, TextWithEntities &&b) {
|
|
||||||
return b.text.isEmpty()
|
|
||||||
? a
|
|
||||||
: a.append(QChar(' ')).append(std::move(b));
|
|
||||||
});
|
|
||||||
SimpleLimitBox(
|
|
||||||
box,
|
box,
|
||||||
session,
|
session,
|
||||||
tr::lng_filter_pin_limit_title(),
|
"dialog_filters_pinned_limit_default",
|
||||||
std::move(text),
|
100,
|
||||||
premium);
|
"dialog_filters_pinned_limit_premium",
|
||||||
|
200);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PinsLimitBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session) {
|
||||||
|
SimplePinsLimitBox(
|
||||||
|
box,
|
||||||
|
session,
|
||||||
|
"dialogs_pinned_limit_default",
|
||||||
|
5,
|
||||||
|
"dialogs_pinned_limit_premium",
|
||||||
|
10);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,3 +28,6 @@ void FiltersLimitBox(
|
||||||
void FilterPinsLimitBox(
|
void FilterPinsLimitBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<Main::Session*> session);
|
not_null<Main::Session*> session);
|
||||||
|
void PinsLimitBox(
|
||||||
|
not_null<Ui::GenericBox*> box,
|
||||||
|
not_null<Main::Session*> session);
|
||||||
|
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/choose_filter_box.h"
|
#include "boxes/choose_filter_box.h"
|
||||||
#include "boxes/create_poll_box.h"
|
#include "boxes/create_poll_box.h"
|
||||||
#include "boxes/pin_messages_box.h"
|
#include "boxes/pin_messages_box.h"
|
||||||
|
#include "boxes/premium_limits_box.h"
|
||||||
#include "boxes/report_messages_box.h"
|
#include "boxes/report_messages_box.h"
|
||||||
#include "boxes/peers/add_bot_to_chat_box.h"
|
#include "boxes/peers/add_bot_to_chat_box.h"
|
||||||
#include "boxes/peers/add_participants_box.h"
|
#include "boxes/peers/add_participants_box.h"
|
||||||
|
@ -247,15 +248,13 @@ bool PinnedLimitReached(
|
||||||
owner->setChatPinned(wasted, FilterId(), false);
|
owner->setChatPinned(wasted, FilterId(), false);
|
||||||
owner->setChatPinned(history, FilterId(), true);
|
owner->setChatPinned(history, FilterId(), true);
|
||||||
history->session().api().savePinnedOrder(folder);
|
history->session().api().savePinnedOrder(folder);
|
||||||
} else {
|
} else if (filterId) {
|
||||||
const auto errorText = filterId
|
|
||||||
? tr::lng_filters_error_pinned_max(tr::now)
|
|
||||||
: tr::lng_error_pinned_max(
|
|
||||||
tr::now,
|
|
||||||
lt_count,
|
|
||||||
owner->pinnedChatsLimit(folder));
|
|
||||||
controller->show(
|
controller->show(
|
||||||
Ui::MakeInformBox(errorText),
|
Box(FilterPinsLimitBox, &history->session()),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
|
} else {
|
||||||
|
controller->show(
|
||||||
|
Box(PinsLimitBox, &history->session()),
|
||||||
Ui::LayerOption::CloseOther);
|
Ui::LayerOption::CloseOther);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue