Detach ComposeControls from SessionController.

This commit is contained in:
John Preston 2023-05-02 13:33:19 +04:00
parent 665467b02d
commit 65afa2c402
178 changed files with 2080 additions and 1869 deletions

View File

@ -350,6 +350,8 @@ PRIVATE
calls/calls_video_bubble.h
calls/calls_video_incoming.cpp
calls/calls_video_incoming.h
chat_helpers/compose/compose_show.cpp
chat_helpers/compose/compose_show.h
chat_helpers/bot_command.cpp
chat_helpers/bot_command.h
chat_helpers/bot_keyboard.cpp
@ -934,6 +936,8 @@ PRIVATE
main/main_session_settings.h
main/session/send_as_peers.cpp
main/session/send_as_peers.h
main/session/session_show.cpp
main/session/session_show.h
media/system_media_controls_manager.h
media/system_media_controls_manager.cpp
media/audio/media_audio.cpp

View File

@ -41,7 +41,7 @@ void AttachedStickers::request(
return;
} else if (result.v.size() > 1) {
strongController->show(
Box<StickersBox>(strongController, result.v));
Box<StickersBox>(strongController->uiShow(), result.v));
return;
}
// Single attached sticker pack.
@ -54,16 +54,14 @@ void AttachedStickers::request(
.id = data->vid().v,
.accessHash = data->vaccess_hash().v }
: StickerSetIdentifier{ .shortName = qs(data->vshort_name()) };
strongController->show(
Box<StickerSetBox>(
strongController,
setId,
(data->is_emojis()
? Data::StickersType::Emoji
: data->is_masks()
? Data::StickersType::Masks
: Data::StickersType::Stickers)),
Ui::LayerOption::KeepOther);
strongController->show(Box<StickerSetBox>(
strongController->uiShow(),
setId,
(data->is_emojis()
? Data::StickersType::Emoji
: data->is_masks()
? Data::StickersType::Masks
: Data::StickersType::Stickers)));
}).fail([=] {
_requestId = 0;
if (const auto strongController = weak.get()) {

View File

@ -82,7 +82,7 @@ void SendBotCallbackData(
flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_password;
}
const auto weak = base::make_weak(controller);
const auto show = std::make_shared<Window::Show>(controller);
const auto show = controller->uiShow();
button->requestId = api->request(MTPmessages_GetBotCallbackAnswer(
MTP_flags(flags),
history->peer->input,
@ -119,7 +119,7 @@ void SendBotCallbackData(
if (withPassword) {
show->hideLayer();
}
Ui::Toast::Show(show->toastParent(), message);
show->showToast(message);
}
} else if (!link.isEmpty()) {
if (!isGame) {
@ -210,7 +210,7 @@ void SendBotCallbackDataWithPassword(
}
api->cloudPassword().reload();
const auto weak = base::make_weak(controller);
const auto show = std::make_shared<Window::Show>(controller);
const auto show = controller->uiShow();
SendBotCallbackData(controller, item, row, column, {}, {}, [=](
const QString &error) {
auto box = PrePasswordErrorBox(

View File

@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/boxes/confirm_box.h"
#include "ui/controls/filter_link_header.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/widgets/buttons.h"
#include "ui/filter_icons.h"
#include "window/window_session_controller.h"
@ -515,13 +514,9 @@ void ShowImportError(
} else if (error == u"CHATLISTS_TOO_MUCH"_q) {
window->show(Box(ShareableFiltersLimitBox, session));
} else {
const auto text = (error == u"INVITE_SLUG_EXPIRED"_q)
window->showToast((error == u"INVITE_SLUG_EXPIRED"_q)
? tr::lng_group_invite_bad_link(tr::now)
: error;
Ui::ShowMultilineToast({
.parentOverride = Window::Show(window).toastParent(),
.text = { text },
});
: error);
}
}
@ -545,10 +540,7 @@ void ShowImportToast(
: tr::lng_filters_updated_also;
text.append('\n').append(phrase(tr::now, lt_count, added));
}
Ui::ShowMultilineToast({
.parentOverride = Window::Show(strong).toastParent(),
.text = { std::move(text) },
});
strong->showToast(std::move(text));
}
void ProcessFilterInvite(
@ -565,10 +557,7 @@ void ProcessFilterInvite(
}
Core::App().hideMediaView();
if (peers.empty() && !filterId) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(strong).toastParent(),
.text = { tr::lng_group_invite_bad_link(tr::now) },
});
strong->showToast(tr::lng_group_invite_bad_link(tr::now));
return;
}
const auto fullyAdded = (peers.empty() && filterId);
@ -661,10 +650,7 @@ void ProcessFilterInvite(
const auto &list = strong->session().data().chatsFilters().list();
const auto it = ranges::find(list, filterId, &Data::ChatFilter::id);
if (it == end(list)) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(strong).toastParent(),
.text = { u"Filter not found :shrug:"_q },
});
strong->showToast(u"Filter not found :shrug:"_q);
return;
}
ProcessFilterInvite(

View File

@ -22,7 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_user.h"
#include "data/data_file_origin.h"
#include "ui/boxes/confirm_box.h"
#include "ui/toasts/common_toasts.h"
#include "ui/toast/toast.h"
#include "boxes/premium_limits_box.h"
#include "styles/style_boxes.h"
#include "styles/style_layers.h"
@ -85,20 +85,17 @@ void SubmitChatInvite(
}
strongController->hideLayer();
Ui::ShowMultilineToast({
.parentOverride = Window::Show(strongController).toastParent(),
.text = { [&] {
if (type == u"INVITE_REQUEST_SENT"_q) {
return isGroup
? tr::lng_group_request_sent(tr::now)
: tr::lng_group_request_sent_channel(tr::now);
} else if (type == u"USERS_TOO_MUCH"_q) {
return tr::lng_group_invite_no_room(tr::now);
} else {
return tr::lng_group_invite_bad_link(tr::now);
}
}() },
.duration = ApiWrap::kJoinErrorDuration });
strongController->showToast([&] {
if (type == u"INVITE_REQUEST_SENT"_q) {
return isGroup
? tr::lng_group_request_sent(tr::now)
: tr::lng_group_request_sent_channel(tr::now);
} else if (type == u"USERS_TOO_MUCH"_q) {
return tr::lng_group_invite_no_room(tr::now);
} else {
return tr::lng_group_invite_bad_link(tr::now);
}
}(), ApiWrap::kJoinErrorDuration);
}).send();
}

View File

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "ui/boxes/report_box.h"
#include "ui/toast/toast.h"
#include "ui/layers/show.h"
namespace Api {
@ -39,15 +39,14 @@ MTPreportReason ReasonToTL(const Ui::ReportReason &reason) {
} // namespace
void SendReport(
not_null<QWidget*> toastParent,
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer,
Ui::ReportReason reason,
const QString &comment,
std::variant<v::null_t, MessageIdsList, not_null<PhotoData*>> data) {
auto weak = Ui::MakeWeak(toastParent.get());
auto done = crl::guard(toastParent, [=] {
Ui::Toast::Show(toastParent, tr::lng_report_thanks(tr::now));
});
auto done = [=] {
show->showToast(tr::lng_report_thanks(tr::now));
};
v::match(data, [&](v::null_t) {
peer->session().api().request(MTPaccount_ReportPeer(
peer->input,

View File

@ -11,13 +11,14 @@ class PeerData;
class PhotoData;
namespace Ui {
class Show;
enum class ReportReason;
} // namespace Ui
namespace Api {
void SendReport(
not_null<QWidget*> toastParent,
std::shared_ptr<Ui::Show> show,
not_null<PeerData*> peer,
Ui::ReportReason reason,
const QString &comment,

View File

@ -48,27 +48,26 @@ void ToggleExistingMedia(
} // namespace
void ToggleFavedSticker(
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
Data::FileOrigin origin) {
ToggleFavedSticker(
controller,
std::move(show),
document,
std::move(origin),
!document->owner().stickers().isFaved(document));
}
void ToggleFavedSticker(
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
Data::FileOrigin origin,
bool faved) {
if (faved && !document->sticker()) {
return;
}
const auto weak = base::make_weak(controller);
auto done = [=] {
document->owner().stickers().setFaved(weak.get(), document, faved);
document->owner().stickers().setFaved(show, document, faved);
};
ToggleExistingMedia(
document,
@ -104,17 +103,16 @@ void ToggleRecentSticker(
}
void ToggleSavedGif(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
Data::FileOrigin origin,
bool saved) {
if (saved && !document->isGifv()) {
return;
}
const auto weak = base::make_weak(controller);
auto done = [=] {
if (saved) {
document->owner().stickers().addSavedGif(weak.get(), document);
document->owner().stickers().addSavedGif(show, document);
}
};
ToggleExistingMedia(

View File

@ -7,19 +7,19 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Window {
class SessionController;
} // namespace Window
namespace ChatHelpers {
class Show;
} // namespace ChatHelpers
namespace Api {
void ToggleFavedSticker(
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
Data::FileOrigin origin);
void ToggleFavedSticker(
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
Data::FileOrigin origin,
bool faved);
@ -30,7 +30,7 @@ void ToggleRecentSticker(
bool saved);
void ToggleSavedGif(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
Data::FileOrigin origin,
bool saved);

View File

@ -87,7 +87,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h"
#include "ui/emoji_config.h"
#include "ui/chat/attach/attach_prepare.h"
#include "ui/toasts/common_toasts.h"
#include "ui/toast/toast.h"
#include "support/support_helper.h"
#include "settings/settings_premium.h"
#include "storage/localimageloader.h"
@ -121,9 +121,16 @@ using UpdatedFileReferences = Data::UpdatedFileReferences;
return TimeId(msgId >> 32);
}
[[nodiscard]] std::shared_ptr<Window::Show> ShowForPeer(
[[nodiscard]] std::shared_ptr<ChatHelpers::Show> ShowForPeer(
not_null<PeerData*> peer) {
return std::make_shared<Window::Show>(Core::App().windowFor(peer));
if (const auto window = Core::App().windowFor(peer)) {
if (const auto controller = window->sessionController()) {
if (&controller->session() == &peer->session()) {
return controller->uiShow();
}
}
}
return nullptr;
}
void ShowChannelsLimitBox(not_null<PeerData*> peer) {
@ -484,13 +491,12 @@ void ApiWrap::sendMessageFail(
uint64 randomId,
FullMsgId itemId) {
const auto show = ShowForPeer(peer);
if (error == u"PEER_FLOOD"_q) {
if (show && error == u"PEER_FLOOD"_q) {
show->showBox(
Ui::MakeInformBox(
PeerFloodErrorText(&session(), PeerFloodType::Send)),
Ui::LayerOption::CloseOther);
} else if (error == u"USER_BANNED_IN_CHANNEL"_q) {
} else if (show && error == u"USER_BANNED_IN_CHANNEL"_q) {
const auto link = Ui::Text::Link(
tr::lng_cant_more_info(tr::now),
session().createInternalLinkFull(u"spambot"_q));
@ -519,21 +525,16 @@ void ApiWrap::sendMessageFail(
Assert(peer->isUser());
if (const auto item = scheduled.lookupItem(peer->id, itemId.msg)) {
scheduled.removeSending(item);
show->showBox(
Ui::MakeInformBox(tr::lng_cant_do_this()),
Ui::LayerOption::CloseOther);
}
} else if (error == u"CHAT_FORWARDS_RESTRICTED"_q) {
if (show->valid()) {
Ui::ShowMultilineToast({
.parentOverride = show->toastParent(),
.text = { peer->isBroadcast()
? tr::lng_error_noforwards_channel(tr::now)
: tr::lng_error_noforwards_group(tr::now)
},
.duration = kJoinErrorDuration
});
if (show) {
show->showBox(
Ui::MakeInformBox(tr::lng_cant_do_this()),
Ui::LayerOption::CloseOther);
}
}
} else if (show && error == u"CHAT_FORWARDS_RESTRICTED"_q) {
show->showToast(peer->isBroadcast()
? tr::lng_error_noforwards_channel(tr::now)
: tr::lng_error_noforwards_group(tr::now), kJoinErrorDuration);
} else if (error == u"PREMIUM_ACCOUNT_REQUIRED"_q) {
Settings::ShowPremium(&session(), "premium_stickers");
}
@ -1702,12 +1703,8 @@ void ApiWrap::joinChannel(not_null<ChannelData*> channel) {
}
return QString();
}();
if (!text.isEmpty() && show->valid()) {
Ui::ShowMultilineToast({
.parentOverride = show->toastParent(),
.text = { text },
.duration = kJoinErrorDuration,
});
if (!text.isEmpty()) {
show->showToast(text, kJoinErrorDuration);
}
}
_channelAmInRequests.remove(channel);
@ -2068,8 +2065,8 @@ void ApiWrap::applyAffectedMessages(
}
void ApiWrap::saveCurrentDraftToCloud() {
Core::App().materializeLocalDrafts();
for (const auto &controller : _session->windows()) {
controller->materializeLocalDrafts();
if (const auto thread = controller->activeChatCurrent().thread()) {
const auto topic = thread->asTopic();
if (topic && topic->creating()) {

View File

@ -112,7 +112,7 @@ void ChatCreateDone(
if (done) {
done(chat);
} else {
const auto show = std::make_shared<Window::Show>(navigation);
const auto show = navigation->uiShow();
navigation->showPeerHistory(chat);
ChatInviteForbidden(
show,
@ -141,7 +141,7 @@ void MustBePublicFailed(
const auto text = channel->isMegagroup()
? "Can't create a public group :("
: "Can't create a public channel :(";
Ui::Toast::Show(Window::Show(navigation).toastParent(), text);
navigation->showToast(text);
MustBePublicDestroy(channel);
}
@ -607,7 +607,7 @@ void GroupInfoBox::prepare() {
: QString());
(*menu)->addAction(
text,
[=, show = std::make_shared<Ui::BoxShow>(this)] {
[=, show = uiShow()] {
show->showBox(Box(TTLMenu::TTLBox, TTLMenu::Args{
.show = show,
.startTtl = _ttlPeriod,
@ -727,19 +727,14 @@ void GroupInfoBox::createGroup(
}
} else if (type == u"USERS_TOO_FEW"_q) {
controller->show(
Ui::MakeInformBox(tr::lng_cant_invite_privacy()),
Ui::LayerOption::KeepOther);
Ui::MakeInformBox(tr::lng_cant_invite_privacy()));
} else if (type == u"PEER_FLOOD"_q) {
controller->show(
Ui::MakeInformBox(
PeerFloodErrorText(
&_navigation->session(),
PeerFloodType::InviteGroup)),
Ui::LayerOption::KeepOther);
controller->show(Ui::MakeInformBox(
PeerFloodErrorText(
&_navigation->session(),
PeerFloodType::InviteGroup)));
} else if (type == u"USER_RESTRICTED"_q) {
controller->show(
Ui::MakeInformBox(tr::lng_cant_do_this()),
Ui::LayerOption::KeepOther);
controller->show(Ui::MakeInformBox(tr::lng_cant_do_this()));
}
}).send();
}
@ -1220,9 +1215,7 @@ void SetupChannelBox::mousePressEvent(QMouseEvent *e) {
return;
} else if (!_channel->inviteLink().isEmpty()) {
QGuiApplication::clipboard()->setText(_channel->inviteLink());
Ui::Toast::Show(
Ui::BoxShow(this).toastParent(),
tr::lng_create_channel_link_copied(tr::now));
showToast(tr::lng_create_channel_link_copied(tr::now));
} else if (_channel->isFullLoaded() && !_creatingInviteLink) {
_creatingInviteLink = true;
_channel->session().api().inviteLinks().create(_channel);
@ -1456,12 +1449,10 @@ void SetupChannelBox::showRevokePublicLinkBoxForEdit() {
const auto callback = [=] {
*revoked = true;
navigation->parentController()->show(
Box<SetupChannelBox>(navigation, channel, mustBePublic, done),
Ui::LayerOption::KeepOther);
Box<SetupChannelBox>(navigation, channel, mustBePublic, done));
};
const auto revoker = navigation->parentController()->show(
Box(PublicLinksLimitBox, navigation, callback),
Ui::LayerOption::KeepOther);
Box(PublicLinksLimitBox, navigation, callback));
const auto session = &navigation->session();
revoker->boxClosing(
) | rpl::start_with_next(crl::guard(session, [=] {

View File

@ -291,12 +291,10 @@ void BackgroundBox::chosen(const Data::WallPaper &paper) {
}
return;
}
_controller->show(
Box<BackgroundPreviewBox>(
_controller,
paper,
BackgroundPreviewArgs{ _forPeer }),
Ui::LayerOption::KeepOther);
_controller->show(Box<BackgroundPreviewBox>(
_controller,
paper,
BackgroundPreviewArgs{ _forPeer }));
}
void BackgroundBox::resetForPeer() {
@ -332,13 +330,11 @@ void BackgroundBox::removePaper(const Data::WallPaper &paper) {
paper.mtpSettings()
)).send();
};
_controller->show(
Ui::MakeConfirmBox({
.text = tr::lng_background_sure_delete(),
.confirmed = remove,
.confirmText = tr::lng_selected_delete(),
}),
Ui::LayerOption::KeepOther);
_controller->show(Ui::MakeConfirmBox({
.text = tr::lng_background_sure_delete(),
.confirmed = remove,
.confirmText = tr::lng_selected_delete(),
}));
}
BackgroundBox::Inner::Inner(

View File

@ -640,9 +640,7 @@ void BackgroundPreviewBox::applyForEveryone() {
void BackgroundPreviewBox::share() {
QGuiApplication::clipboard()->setText(
_paper.shareUrl(&_controller->session()));
Ui::Toast::Show(
Ui::BoxShow(this).toastParent(),
tr::lng_background_link_copied(tr::now));
showToast(tr::lng_background_link_copied(tr::now));
}
void BackgroundPreviewBox::paintEvent(QPaintEvent *e) {

View File

@ -280,15 +280,13 @@ void ChangePhone::EnterPhone::sendPhoneDone(
}
return 0;
}();
_controller->show(
Box<EnterCode>(
_controller,
phoneNumber,
phoneCodeHash,
codeByFragmentUrl,
codeLength,
callTimeout),
Ui::LayerOption::KeepOther);
_controller->show(Box<EnterCode>(
_controller,
phoneNumber,
phoneCodeHash,
codeByFragmentUrl,
codeLength,
callTimeout));
}
void ChangePhone::EnterPhone::sendPhoneFail(
@ -426,17 +424,13 @@ void ChangePhone::EnterCode::submit(const QString &code) {
MTP_string(_phone),
MTP_string(_hash),
MTP_string(code)
)).done([=, show = Window::Show(_controller)](const MTPUser &result) {
)).done([=, show = _controller->uiShow()](const MTPUser &result) {
_requestId = 0;
session->data().processUser(result);
if (show.valid()) {
if (weak) {
show.hideLayer();
}
Ui::Toast::Show(
show.toastParent(),
tr::lng_change_phone_success(tr::now));
if (weak) {
show->hideLayer();
}
show->showToast(tr::lng_change_phone_success(tr::now));
}).fail(crl::guard(this, [=](const MTP::Error &error) {
_requestId = 0;
sendCodeFail(error);

View File

@ -17,9 +17,9 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "ui/filter_icons.h"
#include "ui/text/text_utilities.h" // Ui::Text::Bold
#include "ui/toast/toast.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/popup_menu.h"
#include "window/window_controller.h"
#include "window/window_session_controller.h"
#include "styles/style_settings.h"
#include "styles/style_payments.h" // paymentsSectionButton
@ -74,7 +74,7 @@ void ChangeFilterById(
// We can safely show toast there.
const auto account = &history->session().account();
if (const auto controller = Core::App().windowFor(account)) {
auto text = (add
controller->showToast((add
? tr::lng_filters_toast_add
: tr::lng_filters_toast_remove)(
tr::now,
@ -82,10 +82,7 @@ void ChangeFilterById(
Ui::Text::Bold(chat),
lt_folder,
Ui::Text::Bold(name),
Ui::Text::WithEntities);
Ui::Toast::Show(
Window::Show(controller).toastParent(),
{ .text = std::move(text), .st = &st::defaultToast });
Ui::Text::WithEntities));
}
}).fail([=](const MTP::Error &error) {
// Revert filter on fail.

View File

@ -1265,7 +1265,7 @@ object_ptr<Ui::BoxContent> ProxiesBoxController::CreateOwningBox(
object_ptr<Ui::BoxContent> ProxiesBoxController::create() {
auto result = Box<ProxiesBox>(this, _settings);
_show = std::make_shared<Ui::BoxShow>(result.data());
_show = result->uiShow();
for (const auto &item : _list) {
updateView(item);
}
@ -1548,9 +1548,7 @@ void ProxiesBoxController::share(const ProxyData &proxy) {
+ ((proxy.type == Type::Mtproto && !proxy.password.isEmpty())
? "&secret=" + proxy.password : "");
QGuiApplication::clipboard()->setText(link);
Ui::Toast::Show(
_show->toastParent(),
tr::lng_username_copied(tr::now));
_show->showToast(tr::lng_username_copied(tr::now));
}
ProxiesBoxController::~ProxiesBoxController() {

View File

@ -775,7 +775,7 @@ void CreatePollBox::setInnerFocus() {
}
void CreatePollBox::submitFailed(const QString &error) {
Ui::Toast::Show(Ui::BoxShow(this).toastParent(), error);
showToast(error);
}
not_null<Ui::InputField*> CreatePollBox::setupQuestion(
@ -850,10 +850,7 @@ not_null<Ui::InputField*> CreatePollBox::setupSolution(
Core::App().settings().replaceEmojiValue());
solution->setMarkdownReplacesEnabled(rpl::single(true));
solution->setEditLinkCallback(
DefaultEditLinkCallback(
std::make_shared<Window::Show>(_controller),
session,
solution));
DefaultEditLinkCallback(_controller->uiShow(), solution));
solution->customTab(true);
const auto warning = CreateWarningLabel(
@ -988,12 +985,10 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|| (_chosen & PollData::Flag::Quiz));
multiple->events(
) | rpl::filter([=](not_null<QEvent*> e) {
return (e->type() == QEvent::MouseButtonPress) && quiz->checked();
}) | rpl::start_with_next([
toastParent = Ui::BoxShow(this).toastParent()] {
Ui::Toast::Show(
toastParent,
tr::lng_polls_create_one_answer(tr::now));
return (e->type() == QEvent::MouseButtonPress)
&& quiz->checked();
}) | rpl::start_with_next([show = uiShow()] {
show->showToast(tr::lng_polls_create_one_answer(tr::now));
}, multiple->lifetime());
}
@ -1070,10 +1065,9 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
*error &= ~Error::Solution;
}
};
const auto showError = [
toastParent = Ui::BoxShow(this).toastParent()](
const auto showError = [show = uiShow()](
tr::phrase<> text) {
Ui::Toast::Show(toastParent, text(tr::now));
show->showToast(text(tr::now));
};
const auto send = [=](Api::SendOptions sendOptions) {
collectError();
@ -1099,8 +1093,7 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
HistoryView::PrepareScheduleBox(
this,
SendMenu::Type::Scheduled,
send),
Ui::LayerOption::KeepOther);
send));
};
const auto sendWhenOnline = [=] {
send(Api::DefaultSendWhenOnlineOptions());

View File

@ -285,7 +285,7 @@ void DeleteMessagesBox::prepare() {
if (_wipeHistoryJustClear && _wipeHistoryPeer) {
const auto validator = TTLMenu::TTLValidator(
std::make_shared<Ui::BoxShow>(this),
uiShow(),
_wipeHistoryPeer);
if (validator.can()) {
_wipeHistoryPeer->updateFull();

View File

@ -129,7 +129,7 @@ void ChooseReplacement(
}
const auto showError = [=](tr::phrase<> t) {
if (const auto strong = weak.get()) {
strong->showToast({ t(tr::now) });
strong->showToast(t(tr::now));
}
};
@ -304,7 +304,7 @@ void EditCaptionBox::StartMediaReplace(
}
const auto type = ComputeAlbumType(item);
const auto showError = [=](tr::phrase<> t) {
controller->showToast({ t(tr::now) });
controller->showToast(t(tr::now));
};
const auto checkResult = [=](const Ui::PreparedList &list) {
if (list.files.size() != 1) {
@ -647,7 +647,7 @@ void EditCaptionBox::setupEmojiPanel() {
_controller,
object_ptr<Selector>(
nullptr,
_controller,
_controller->uiShow(),
Window::GifPauseReason::Layer,
Selector::Mode::EmojiOnly));
_emojiPanel->setDesiredHeightValues(
@ -728,9 +728,7 @@ bool EditCaptionBox::setPreparedList(Ui::PreparedList &&list) {
}
}
if (invalidForAlbum) {
Ui::Toast::Show(
Ui::BoxShow(this).toastParent(),
tr::lng_edit_media_album_error(tr::now));
showToast(tr::lng_edit_media_album_error(tr::now));
return false;
}
const auto wasSpoiler = hasSpoiler();

View File

@ -167,8 +167,7 @@ void EditPrivacyBox::editExceptions(
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
};
_window->show(
Box<PeerListBox>(std::move(controller), std::move(initBox)),
Ui::LayerOption::KeepOther);
Box<PeerListBox>(std::move(controller), std::move(initBox)));
}
std::vector<not_null<PeerData*>> &EditPrivacyBox::exceptions(Exception exception) {

View File

@ -386,10 +386,7 @@ void EditExceptions(
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
};
window->window().show(
Box<PeerListBox>(
std::move(controller),
std::move(initBox)),
Ui::LayerOption::KeepOther);
Box<PeerListBox>(std::move(controller), std::move(initBox)));
}
void CreateIconSelector(
@ -812,7 +809,7 @@ void EditFilterBox(
tr::lng_filters_link_about_many(),
tr::lng_filters_link_about()));
const auto show = std::make_shared<Ui::BoxShow>(box);
const auto show = box->uiShow();
const auto refreshPreviews = [=] {
include->updateData(
data->current().flags() & kTypes,

View File

@ -25,7 +25,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/controls/invite_link_buttons.h"
#include "ui/controls/invite_link_label.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h"
#include "ui/widgets/popup_menu.h"
@ -118,7 +117,7 @@ void ShowSaveError(
window->showToast(
{ tr::lng_filters_link_group_admin_error(tr::now) });
} else {
window->showToast({ error });
window->showToast(error);
}
}
@ -583,27 +582,22 @@ void LinkController::addLinkBlock(not_null<Ui::VerticalLayout*> container) {
const auto link = _data.url;
const auto weak = Ui::MakeWeak(container);
const auto copyLink = crl::guard(weak, [=] {
CopyInviteLink(delegate()->peerListToastParent(), link);
CopyInviteLink(delegate()->peerListUiShow(), link);
});
const auto shareLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(
ShareInviteLinkBox(&_window->session(), link),
Ui::LayerOption::KeepOther);
ShareInviteLinkBox(&_window->session(), link));
});
const auto getLinkQr = crl::guard(weak, [=] {
delegate()->peerListShowBox(
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()),
Ui::LayerOption::KeepOther);
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()));
});
const auto editLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(
Box(ChatFilterLinkBox, &_window->session(), _data),
Ui::LayerOption::KeepOther);
Box(ChatFilterLinkBox, &_window->session(), _data));
});
const auto deleteLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(
DeleteLinkBox(_window, _data),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(DeleteLinkBox(_window, _data));
});
const auto createMenu = [=] {
@ -702,10 +696,7 @@ void LinkController::rowClicked(not_null<PeerListRow*> row) {
const auto peer = row->peer();
if (const auto i = _denied.find(peer); i != end(_denied)) {
if (!i->second.isEmpty()) {
Ui::ShowMultilineToast({
.parentOverride = delegate()->peerListToastParent(),
.text = { i->second },
});
delegate()->peerListUiShow()->showToast(i->second);
}
} else {
const auto checked = row->checked();
@ -866,8 +857,7 @@ void LinksController::rebuild(const std::vector<InviteLinkData> &rows) {
void LinksController::rowClicked(not_null<PeerListRow*> row) {
const auto link = static_cast<LinkRow*>(row.get())->data();
delegate()->peerListShowBox(
ShowLinkBox(_window, _currentFilter(), link),
Ui::LayerOption::KeepOther);
ShowLinkBox(_window, _currentFilter(), link));
}
void LinksController::rowRightActionClicked(not_null<PeerListRow*> row) {
@ -898,27 +888,22 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
const auto data = real->data();
const auto link = data.url;
const auto copyLink = [=] {
CopyInviteLink(delegate()->peerListToastParent(), link);
CopyInviteLink(delegate()->peerListUiShow(), link);
};
const auto shareLink = [=] {
delegate()->peerListShowBox(
ShareInviteLinkBox(&_window->session(), link),
Ui::LayerOption::KeepOther);
ShareInviteLinkBox(&_window->session(), link));
};
const auto getLinkQr = [=] {
delegate()->peerListShowBox(
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()),
Ui::LayerOption::KeepOther);
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()));
};
const auto editLink = [=] {
delegate()->peerListShowBox(
Box(ChatFilterLinkBox, &_window->session(), data),
Ui::LayerOption::KeepOther);
Box(ChatFilterLinkBox, &_window->session(), data));
};
const auto deleteLink = [=] {
delegate()->peerListShowBox(
DeleteLinkBox(_window, data),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(DeleteLinkBox(_window, data));
};
auto result = base::make_unique_q<Ui::PopupMenu>(
parent,
@ -1008,10 +993,7 @@ bool GoodForExportFilterLink(
using Flag = Data::ChatFilter::Flag;
const auto listflags = Flag::Chatlist | Flag::HasMyLinks;
if (!filter.never().empty() || (filter.flags() & ~listflags)) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(window).toastParent(),
.text = { tr::lng_filters_link_cant(tr::now) },
});
window->showToast(tr::lng_filters_link_cant(tr::now));
return false;
}
return true;
@ -1151,7 +1133,7 @@ void SetupFilterLinks(
Fn<Data::ChatFilter()> currentFilter) {
auto &lifetime = container->lifetime();
const auto delegate = lifetime.make_state<PeerListContentDelegateShow>(
std::make_shared<Window::Show>(window));
window->uiShow());
const auto controller = lifetime.make_state<LinksController>(
window,
std::move(value),

View File

@ -1248,7 +1248,7 @@ void LanguageBox::setupTop(not_null<Ui::VerticalLayout*> container) {
st::settingsButtonNoIcon);
translateSkip->setClickedCallback([=] {
Ui::BoxShow(this).showBox(Ui::EditSkipTranslationLanguages());
uiShow()->showBox(Ui::EditSkipTranslationLanguages());
});
Settings::AddSkip(container);
Settings::AddDividerText(

View File

@ -91,9 +91,7 @@ void MaxInviteBox::mousePressEvent(QMouseEvent *e) {
if (_linkOver) {
if (!_channel->inviteLink().isEmpty()) {
QGuiApplication::clipboard()->setText(_channel->inviteLink());
Ui::Toast::Show(
Ui::BoxShow(this).toastParent(),
tr::lng_create_channel_link_copied(tr::now));
showToast(tr::lng_create_channel_link_copied(tr::now));
} else if (_channel->isFullLoaded() && !_creatingInviteLink) {
_creatingInviteLink = true;
_channel->session().api().inviteLinks().create(_channel);

View File

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "boxes/peer_list_box.h"
#include "main/session/session_show.h"
#include "main/main_session.h"
#include "mainwidget.h"
#include "ui/widgets/multi_select.h"
@ -74,7 +75,7 @@ PaintRoundImageCallback ForceRoundUserpicCallback(not_null<PeerData*> peer) {
}
PeerListContentDelegateShow::PeerListContentDelegateShow(
std::shared_ptr<Ui::Show> show)
std::shared_ptr<Main::SessionShow> show)
: _show(show) {
}
@ -88,15 +89,16 @@ void PeerListContentDelegateShow::peerListHideLayer() {
_show->hideLayer();
}
not_null<QWidget*> PeerListContentDelegateShow::peerListToastParent() {
return _show->toastParent();
auto PeerListContentDelegateShow::peerListUiShow()
-> std::shared_ptr<Main::SessionShow>{
return _show;
}
PeerListBox::PeerListBox(
QWidget*,
std::unique_ptr<PeerListController> controller,
Fn<void(not_null<PeerListBox*>)> init)
: _show(this)
: _show(Main::MakeSessionShow(uiShow(), &controller->session()))
, _controller(std::move(controller))
, _init(std::move(init)) {
Expects(_controller != nullptr);
@ -311,18 +313,20 @@ void PeerListBox::peerListSetSearchMode(PeerListSearchMode mode) {
void PeerListBox::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
_show.showBox(std::move(content), options);
_show->showBox(std::move(content), options);
}
void PeerListBox::peerListHideLayer() {
_show.hideLayer();
_show->hideLayer();
}
not_null<QWidget*> PeerListBox::peerListToastParent() {
return _show.toastParent();
std::shared_ptr<Main::SessionShow> PeerListBox::peerListUiShow() {
return _show;
}
PeerListController::PeerListController(std::unique_ptr<PeerListSearchController> searchController) : _searchController(std::move(searchController)) {
PeerListController::PeerListController(
std::unique_ptr<PeerListSearchController> searchController)
: _searchController(std::move(searchController)) {
if (_searchController) {
_searchController->setDelegate(this);
}

View File

@ -24,6 +24,7 @@ struct MultiSelect;
namespace Main {
class Session;
class SessionShow;
} // namespace Main
namespace Ui {
@ -329,7 +330,7 @@ public:
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) = 0;
virtual void peerListHideLayer() = 0;
virtual not_null<QWidget*> peerListToastParent() = 0;
virtual std::shared_ptr<Main::SessionShow> peerListUiShow() = 0;
template <typename PeerDataRange>
void peerListAddSelectedPeers(PeerDataRange &&range) {
@ -999,22 +1000,24 @@ public:
void peerListHideLayer() override {
Unexpected("...DelegateSimple::peerListHideLayer");
}
not_null<QWidget*> peerListToastParent() override {
Unexpected("...DelegateSimple::peerListToastParent");
std::shared_ptr<Main::SessionShow> peerListUiShow() override {
Unexpected("...DelegateSimple::peerListUiShow");
}
};
class PeerListContentDelegateShow : public PeerListContentDelegateSimple {
public:
PeerListContentDelegateShow(std::shared_ptr<Ui::Show> show);
explicit PeerListContentDelegateShow(
std::shared_ptr<Main::SessionShow> show);
void peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
not_null<QWidget*> peerListToastParent() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
private:
std::shared_ptr<Ui::Show> _show;
std::shared_ptr<Main::SessionShow> _show;
};
@ -1050,7 +1053,7 @@ public:
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
not_null<QWidget*> peerListToastParent() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
void setAddedTopScrollSkip(int skip);
@ -1092,7 +1095,7 @@ private:
object_ptr<Ui::SlideWrap<Ui::MultiSelect>> _select = { nullptr };
const Ui::BoxShow _show;
const std::shared_ptr<Main::SessionShow> _show;
std::unique_ptr<PeerListController> _controller;
Fn<void(PeerListBox*)> _init;
bool _scrollBottomFixed = false;

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/vertical_layout.h"
#include "ui/widgets/multi_select.h"
#include "ui/widgets/scroll_area.h"
#include "main/session/session_show.h"
#include "main/main_session.h"
#include "data/data_session.h"
#include "data/data_peer.h"
@ -301,7 +302,7 @@ PeerListsBox::Delegate::Delegate(
not_null<PeerListController*> controller)
: _box(box)
, _controller(controller)
, _show(_box) {
, _show(Main::MakeSessionShow(_box->uiShow(), &_controller->session())) {
}
void PeerListsBox::Delegate::peerListSetTitle(rpl::producer<QString> title) {
@ -374,15 +375,16 @@ void PeerListsBox::Delegate::peerListFinishSelectedRowsBunch() {
void PeerListsBox::Delegate::peerListShowBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) {
_show.showBox(std::move(content), options);
_show->showBox(std::move(content), options);
}
void PeerListsBox::Delegate::peerListHideLayer() {
_show.hideLayer();
_show->hideLayer();
}
not_null<QWidget*> PeerListsBox::Delegate::peerListToastParent() {
return _show.toastParent();
auto PeerListsBox::Delegate::peerListUiShow()
-> std::shared_ptr<Main::SessionShow> {
return _show;
}
bool PeerListsBox::Delegate::peerListIsRowChecked(

View File

@ -58,12 +58,12 @@ private:
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
not_null<QWidget*> peerListToastParent() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
private:
const not_null<PeerListsBox*> _box;
const not_null<PeerListController*> _controller;
const Ui::BoxShow _show;
const std::shared_ptr<Main::SessionShow> _show;
};
struct List {

View File

@ -182,8 +182,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null<PeerData*> chat) {
if (const auto megagroup = chat->asMegagroup()) {
if (!megagroup->canAddMembers()) {
_controller->show(
Ui::MakeInformBox(tr::lng_error_cant_add_member()),
Ui::LayerOption::KeepOther);
Ui::MakeInformBox(tr::lng_error_cant_add_member()));
return;
}
}
@ -243,18 +242,16 @@ void AddBotToGroupBoxController::addBotToGroup(not_null<PeerData*> chat) {
_token,
_existingRights.value_or(ChatAdminRights()) });
box->setSaveCallback(saveCallback);
controller->show(std::move(box), Ui::LayerOption::KeepOther);
controller->show(std::move(box));
} else {
auto callback = crl::guard(this, [=] {
AddBotToGroup(bot, chat, _token);
controller->hideLayer();
});
controller->show(
Ui::MakeConfirmBox({
tr::lng_bot_sure_invite(tr::now, lt_group, chat->name()),
std::move(callback),
}),
Ui::LayerOption::KeepOther);
controller->show(Ui::MakeConfirmBox({
tr::lng_bot_sure_invite(tr::now, lt_group, chat->name()),
std::move(callback),
}));
}
}

View File

@ -202,9 +202,7 @@ void InviteForbiddenController::send(
int(list.size()),
Ui::Text::RichLangValue);
close();
Ui::Toast::Show(
show->toastParent(),
{ .text = std::move(text), .st = &st::defaultToast });
show->showToast(std::move(text));
return true;
};
const auto sendForFull = [=] {
@ -368,7 +366,7 @@ bool AddParticipantsBoxController::needsInviteLinkButton() {
QPointer<Ui::BoxContent> AddParticipantsBoxController::showBox(
object_ptr<Ui::BoxContent> box) const {
const auto weak = Ui::MakeWeak(box.data());
delegate()->peerListShowBox(std::move(box), Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(std::move(box));
return weak;
}
@ -425,7 +423,7 @@ void AddParticipantsBoxController::inviteSelectedUsers(
if (users.empty()) {
return;
}
const auto show = std::make_shared<Ui::BoxShow>(box);
const auto show = box->uiShow();
const auto request = [=](bool checked) {
_peer->session().api().chatParticipants().add(
_peer,
@ -493,9 +491,8 @@ void AddParticipantsBoxController::Start(
});
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
};
Window::Show(navigation).showBox(
Box<PeerListBox>(std::move(controller), std::move(initBox)),
Ui::LayerOption::KeepOther);
parent->show(
Box<PeerListBox>(std::move(controller), std::move(initBox)));
}
void AddParticipantsBoxController::Start(
@ -538,9 +535,8 @@ void AddParticipantsBoxController::Start(
}, box->lifetime());
}
};
Window::Show(navigation).showBox(
Box<PeerListBox>(std::move(controller), std::move(initBox)),
Ui::LayerOption::KeepOther);
parent->show(
Box<PeerListBox>(std::move(controller), std::move(initBox)));
}
void AddParticipantsBoxController::Start(
@ -616,7 +612,7 @@ bool ChatInviteForbidden(
box->addButton(tr::lng_via_link_send(), [=] {
weak->send(
box->collectSelectedRows(),
std::make_shared<Ui::BoxShow>(box),
box->uiShow(),
crl::guard(box, [=] { box->closeBox(); }));
});
}
@ -626,8 +622,7 @@ bool ChatInviteForbidden(
}, box->lifetime());
};
show->showBox(
Box<PeerListBox>(std::move(controller), std::move(initBox)),
Ui::LayerOption::KeepOther);
Box<PeerListBox>(std::move(controller), std::move(initBox)));
return true;
}
@ -673,7 +668,7 @@ void AddSpecialBoxController::migrate(
QPointer<Ui::BoxContent> AddSpecialBoxController::showBox(
object_ptr<Ui::BoxContent> box) const {
const auto weak = Ui::MakeWeak(box.data());
delegate()->peerListShowBox(std::move(box), Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(std::move(box));
return weak;
}

View File

@ -505,5 +505,5 @@ void ShowChoosePeerBox(
bot,
query,
std::move(callback)),
std::move(initBox)), Ui::LayerOption::KeepOther);
std::move(initBox)));
}

View File

@ -69,8 +69,7 @@ void SendRequest(
}
if (box) {
if (!wasContact) {
Ui::Toast::Show(
Ui::BoxShow(box.data()).toastParent(),
box->showToast(
tr::lng_new_contact_add_done(tr::now, lt_user, first));
}
box->closeBox();

View File

@ -274,12 +274,9 @@ struct IconSelector {
};
const auto selector = body->add(
object_ptr<EmojiListWidget>(body, EmojiListDescriptor{
.session = &controller->session(),
.show = controller->uiShow(),
.mode = EmojiListWidget::Mode::TopicIcon,
.controller = controller,
.paused = Window::PausedIn(
controller,
Window::GifPauseReason::Layer),
.paused = Window::PausedIn(controller, PauseReason::Layer),
.customRecentList = recent(),
.customRecentFactory = std::move(factory),
.st = &st::reactPanelEmojiPan,

View File

@ -18,7 +18,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/text/text_utilities.h" // Ui::Text::ToUpper
#include "boxes/peer_list_box.h"
#include "ui/boxes/confirm_box.h"
#include "ui/toasts/common_toasts.h"
#include "boxes/add_contact_box.h"
#include "apiwrap.h"
#include "main/main_session.h"
@ -168,13 +167,11 @@ void Controller::choose(not_null<ChannelData*> chat) {
const auto onstack = _callback;
onstack(chat);
};
delegate()->peerListShowBox(
Ui::MakeConfirmBox({
.text = text,
.confirmed = sure,
.confirmText = tr::lng_manage_discussion_group_link(tr::now),
}),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(Ui::MakeConfirmBox({
.text = text,
.confirmed = sure,
.confirmText = tr::lng_manage_discussion_group_link(tr::now),
}));
}
void Controller::choose(not_null<ChatData*> chat) {
@ -201,13 +198,11 @@ void Controller::choose(not_null<ChatData*> chat) {
};
chat->session().api().migrateChat(chat, crl::guard(this, done));
};
delegate()->peerListShowBox(
Ui::MakeConfirmBox({
.text = text,
.confirmed = sure,
.confirmText = tr::lng_manage_discussion_group_link(tr::now),
}),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(Ui::MakeConfirmBox({
.text = text,
.confirmed = sure,
.confirmText = tr::lng_manage_discussion_group_link(tr::now),
}));
}
[[nodiscard]] rpl::producer<TextWithEntities> About(
@ -279,13 +274,11 @@ void Controller::choose(not_null<ChatData*> chat) {
{ &st::settingsIconChat, Settings::kIconLightBlue }
)->addClickHandler([=, parent = above.data()] {
const auto guarded = crl::guard(parent, callback);
Window::Show(navigation).showBox(
Box<GroupInfoBox>(
navigation,
GroupInfoBox::Type::Megagroup,
channel->name() + " Chat",
guarded),
Ui::LayerOption::KeepOther);
navigation->uiShow()->showBox(Box<GroupInfoBox>(
navigation,
GroupInfoBox::Type::Megagroup,
channel->name() + " Chat",
guarded));
});
}
box->peerListSetAboveWidget(std::move(above));
@ -363,10 +356,8 @@ object_ptr<Ui::BoxContent> EditLinkedChatBox(
void ShowForumForDiscussionError(
not_null<Window::SessionNavigation*> navigation) {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(navigation).toastParent(),
.text = tr::lng_forum_topics_no_discussion(
navigation->showToast(
tr::lng_forum_topics_no_discussion(
tr::now,
Ui::Text::RichLangValue),
});
Ui::Text::RichLangValue));
}

View File

@ -203,7 +203,6 @@ EditAdminBox::EditAdminBox(
peer,
user,
(rights.flags != 0))
, _show(this)
, _oldRights(rights)
, _oldRank(rank)
, _addingBot(std::move(addingBot)) {
@ -399,7 +398,7 @@ void EditAdminBox::prepare() {
Ui::Text::Bold(peer()->name()),
Ui::Text::WithEntities),
crl::guard(this, [=] { finishAddAdmin(); })
}), Ui::LayerOption::KeepOther);
}));
} else {
_finishSave();
}
@ -623,16 +622,15 @@ void EditAdminBox::sendTransferRequestFrom(
if (!box && !weak) {
return;
}
Ui::Toast::Show(
(box ? Ui::BoxShow(box) : weak->_show).toastParent(),
const auto show = box ? box->uiShow() : weak->uiShow();
show->showToast(
(channel->isBroadcast()
? tr::lng_rights_transfer_done_channel
: tr::lng_rights_transfer_done_group)(
tr::now,
lt_user,
user->shortName()));
(box ? Ui::BoxShow(box) : weak->_show).hideLayer();
show->hideLayer();
}).fail(crl::guard(this, [=](const MTP::Error &error) {
if (weak) {
_transferRequestId = 0;
@ -694,7 +692,6 @@ EditRestrictedBox::EditRestrictedBox(
bool hasAdminRights,
ChatRestrictionsInfo rights)
: EditParticipantBox(nullptr, peer, user, hasAdminRights)
, _show(this)
, _oldRights(rights) {
}
@ -788,7 +785,7 @@ ChatRestrictionsInfo EditRestrictedBox::defaultRights() const {
}
void EditRestrictedBox::showRestrictUntil() {
_show.showBox(Box([=](not_null<Ui::GenericBox*> box) {
uiShow()->showBox(Box([=](not_null<Ui::GenericBox*> box) {
const auto save = [=](TimeId result) {
if (!result) {
return;

View File

@ -114,7 +114,6 @@ private:
not_null<Ui::VerticalLayout*> container,
bool isGroup);
const Ui::BoxShow _show;
const ChatAdminRightsInfo _oldRights;
const QString _oldRank;
Fn<void(
@ -168,7 +167,6 @@ private:
void createUntilVariants();
TimeId getRealUntilValue() const;
const Ui::BoxShow _show;
const ChatRestrictionsInfo _oldRights;
TimeId _until = 0;
Fn<void(ChatRestrictionsInfo, ChatRestrictionsInfo)> _saveCallback;

View File

@ -1254,7 +1254,7 @@ void ParticipantsBoxController::rebuild() {
QPointer<Ui::BoxContent> ParticipantsBoxController::showBox(
object_ptr<Ui::BoxContent> box) const {
const auto weak = Ui::MakeWeak(box.data());
delegate()->peerListShowBox(std::move(box), Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(std::move(box));
return weak;
}

View File

@ -48,7 +48,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/controls/userpic_button.h"
#include "ui/rp_widget.h"
#include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/text/text_utilities.h"
#include "ui/widgets/checkbox.h"
#include "ui/widgets/buttons.h"
@ -241,9 +240,7 @@ void ShowEditPermissions(
};
ShowEditPeerPermissionsBox(box, navigation, peer, std::move(done));
};
navigation->parentController()->show(
Box(std::move(createBox)),
Ui::LayerOption::KeepOther);
navigation->parentController()->show(Box(std::move(createBox)));
}
} // namespace
@ -606,8 +603,7 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
rpl::single(QString()), //Empty count.
[=, controller = _navigation->parentController()] {
controller->show(
Box<StickersBox>(controller, channel),
Ui::LayerOption::KeepOther);
Box<StickersBox>(controller->uiShow(), channel));
},
{ &st::settingsIconStickers, Settings::kIconLightOrange });
@ -674,8 +670,7 @@ void Controller::showEditPeerTypeBox(
_channelHasLocationOriginalValue,
boxCallback,
_typeDataSavedValue,
error),
Ui::LayerOption::KeepOther);
error));
box->boxClosing(
) | rpl::start_with_next([peer = _peer] {
peer->session().api().usernames().requestToCache(peer);
@ -709,14 +704,12 @@ void Controller::showEditLinkedChatBox() {
|| channel->canEditPreHistoryHidden()));
if (const auto chat = *_linkedChatSavedValue) {
*box = _navigation->parentController()->show(
EditLinkedChatBox(
_navigation,
channel,
chat,
canEdit,
callback),
Ui::LayerOption::KeepOther);
*box = _navigation->parentController()->show(EditLinkedChatBox(
_navigation,
channel,
chat,
canEdit,
callback));
return;
} else if (!canEdit || _linkedChatsRequestId) {
return;
@ -743,13 +736,11 @@ void Controller::showEditLinkedChatBox() {
for (const auto &item : list) {
chats.emplace_back(_peer->owner().processChat(item));
}
*box = _navigation->parentController()->show(
EditLinkedChatBox(
_navigation,
channel,
std::move(chats),
callback),
Ui::LayerOption::KeepOther);
*box = _navigation->parentController()->show(EditLinkedChatBox(
_navigation,
channel,
std::move(chats),
callback));
}).fail([=] {
_linkedChatsRequestId = 0;
}).send();
@ -887,14 +878,12 @@ void Controller::fillForumButton() {
if (_linkedChatSavedValue && *_linkedChatSavedValue) {
ShowForumForDiscussionError(_navigation);
} else {
Ui::ShowMultilineToast({
.parentOverride = Window::Show(_navigation).toastParent(),
.text = tr::lng_forum_topics_not_enough(
_navigation->showToast(
tr::lng_forum_topics_not_enough(
tr::now,
lt_count,
EnableForumMinMembers(_peer),
Ui::Text::RichLangValue),
});
Ui::Text::RichLangValue));
}
} else {
_forumSavedValue = toggled;
@ -1231,14 +1220,12 @@ void Controller::fillManageSection() {
tr::lng_manage_peer_invite_links(),
rpl::duplicate(count) | ToPositiveNumberString(),
[=] {
_navigation->parentController()->show(
Box(
ManageInviteLinksBox,
_peer,
_peer->session().user(),
0,
0),
Ui::LayerOption::KeepOther);
_navigation->parentController()->show(Box(
ManageInviteLinksBox,
_peer,
_peer->session().user(),
0,
0));
},
{ &st::infoRoundedIconInviteLinks, Settings::kIconLightOrange });
wrap->toggle(true, anim::type::instant);
@ -1407,9 +1394,7 @@ void Controller::fillBotUsernamesButton() {
std::move(leftLabel),
std::move(rightLabel),
[=] {
Window::Show(_navigation).showBox(
Box(UsernamesBox, user),
Ui::LayerOption::KeepOther);
_navigation->uiShow()->showBox(Box(UsernamesBox, user));
},
{ &st::infoRoundedIconInviteLinks, Settings::kIconLightOrange });
}
@ -2120,8 +2105,7 @@ void Controller::deleteWithConfirmation() {
.confirmed = deleteCallback,
.confirmText = tr::lng_box_delete(),
.confirmStyle = &st::attentionBoxButton,
}),
Ui::LayerOption::KeepOther);
}));
}
void Controller::deleteChannel() {

View File

@ -26,7 +26,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/popup_menu.h"
#include "ui/abstract_button.h"
#include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/text/text_utilities.h"
#include "ui/boxes/edit_invite_link.h"
#include "ui/painter.h"
@ -275,12 +274,12 @@ void QrBox(
not_null<Ui::GenericBox*> box,
const QString &link,
rpl::producer<QString> about,
Fn<void(QImage, std::shared_ptr<Ui::BoxShow>)> share) {
Fn<void(QImage, std::shared_ptr<Ui::Show>)> share) {
box->setTitle(tr::lng_group_invite_qr_title());
box->addButton(tr::lng_about_done(), [=] { box->closeBox(); });
const auto copyCallback = [=, show = std::make_shared<Ui::BoxShow>(box)] {
const auto copyCallback = [=, show = box->uiShow()] {
share(QrForShare(link), show);
};
@ -346,32 +345,23 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
const auto admin = current.admin;
const auto weak = Ui::MakeWeak(container);
const auto copyLink = crl::guard(weak, [=] {
CopyInviteLink(delegate()->peerListToastParent(), link);
CopyInviteLink(delegate()->peerListUiShow(), link);
});
const auto shareLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(
ShareInviteLinkBox(_peer, link),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(ShareInviteLinkBox(_peer, link));
});
const auto getLinkQr = crl::guard(weak, [=] {
delegate()->peerListShowBox(
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()),
Ui::LayerOption::KeepOther);
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()));
});
const auto revokeLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(
RevokeLinkBox(_peer, admin, link),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(RevokeLinkBox(_peer, admin, link));
});
const auto editLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(
EditLinkBox(_peer, _data.current()),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(EditLinkBox(_peer, _data.current()));
});
const auto deleteLink = crl::guard(weak, [=] {
delegate()->peerListShowBox(
DeleteLinkBox(_peer, admin, link),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(DeleteLinkBox(_peer, admin, link));
});
const auto createMenu = [=] {
@ -809,16 +799,13 @@ void Controller::processRequest(
delegate()->peerListRefreshRows();
}
if (approved) {
Ui::ShowMultilineToast({
.parentOverride = delegate()->peerListToastParent(),
.text = (_peer->isBroadcast()
? tr::lng_group_requests_was_added_channel
: tr::lng_group_requests_was_added)(
tr::now,
lt_user,
Ui::Text::Bold(user->name()),
Ui::Text::WithEntities)
});
delegate()->peerListUiShow()->showToast((_peer->isBroadcast()
? tr::lng_group_requests_was_added_channel
: tr::lng_group_requests_was_added)(
tr::now,
lt_user,
Ui::Text::Bold(user->name()),
Ui::Text::WithEntities));
}
});
const auto fail = crl::guard(this, [=] {
@ -961,30 +948,24 @@ void AddPermanentLinkBlock(
const auto weak = Ui::MakeWeak(container);
const auto copyLink = crl::guard(weak, [=] {
if (const auto current = value->current(); !current.link.isEmpty()) {
CopyInviteLink(show->toastParent(), current.link);
CopyInviteLink(show, current.link);
}
});
const auto shareLink = crl::guard(weak, [=] {
if (const auto current = value->current(); !current.link.isEmpty()) {
show->showBox(
ShareInviteLinkBox(peer, current.link),
Ui::LayerOption::KeepOther);
show->showBox(ShareInviteLinkBox(peer, current.link));
}
});
const auto getLinkQr = crl::guard(weak, [=] {
if (const auto current = value->current(); !current.link.isEmpty()) {
show->showBox(
InviteLinkQrBox(
current.link,
tr::lng_group_invite_qr_about()),
Ui::LayerOption::KeepOther);
show->showBox(InviteLinkQrBox(
current.link,
tr::lng_group_invite_qr_about()));
}
});
const auto revokeLink = crl::guard(weak, [=] {
if (const auto current = value->current(); !current.link.isEmpty()) {
show->showBox(
RevokeLinkBox(peer, admin, current.link, true),
Ui::LayerOption::KeepOther);
show->showBox(RevokeLinkBox(peer, admin, current.link, true));
}
});
@ -1111,9 +1092,7 @@ void AddPermanentLinkBlock(
st::inviteLinkJoinedRowPadding
)->setClickedCallback([=] {
if (!currentLinkFields->link.isEmpty()) {
show->showBox(
ShowInviteLinkBox(peer, *currentLinkFields),
Ui::LayerOption::KeepOther);
show->showBox(ShowInviteLinkBox(peer, *currentLinkFields));
}
});
@ -1128,9 +1107,9 @@ void AddPermanentLinkBlock(
}));
}
void CopyInviteLink(not_null<QWidget*> toastParent, const QString &link) {
void CopyInviteLink(std::shared_ptr<Ui::Show> show, const QString &link) {
QGuiApplication::clipboard()->setText(link);
Ui::Toast::Show(toastParent, tr::lng_group_invite_copied(tr::now));
show->showToast(tr::lng_group_invite_copied(tr::now));
}
object_ptr<Ui::BoxContent> ShareInviteLinkBox(
@ -1147,7 +1126,7 @@ object_ptr<Ui::BoxContent> ShareInviteLinkBox(
const auto showToast = [=](const QString &text) {
if (*box) {
Ui::Toast::Show(Ui::BoxShow(*box).toastParent(), text);
(*box)->showToast(text);
}
};
@ -1184,9 +1163,7 @@ object_ptr<Ui::BoxContent> ShareInviteLinkBox(
}
text.append(error.first);
if (*box) {
Ui::BoxShow(*box).showBox(
Ui::MakeInformBox(text),
Ui::LayerOption::KeepOther);
(*box)->uiShow()->showBox(Ui::MakeInformBox(text));
}
return;
}
@ -1232,14 +1209,11 @@ object_ptr<Ui::BoxContent> InviteLinkQrBox(
rpl::producer<QString> about) {
return Box(QrBox, link, std::move(about), [=](
const QImage &image,
std::shared_ptr<Ui::BoxShow> show) {
std::shared_ptr<Ui::Show> show) {
auto mime = std::make_unique<QMimeData>();
mime->setImageData(image);
QGuiApplication::clipboard()->setMimeData(mime.release());
Ui::Toast::Show(
show->toastParent(),
tr::lng_group_invite_qr_copied(tr::now));
show->showToast(tr::lng_group_invite_qr_copied(tr::now));
});
}

View File

@ -38,7 +38,7 @@ void AddPermanentLinkBlock(
not_null<UserData*> admin,
rpl::producer<Api::InviteLink> fromList);
void CopyInviteLink(not_null<QWidget*> toastParent, const QString &link);
void CopyInviteLink(std::shared_ptr<Ui::Show> show, const QString &link);
[[nodiscard]] object_ptr<Ui::BoxContent> ShareInviteLinkBox(
not_null<PeerData*> peer,
const QString &link);

View File

@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat.h"
#include "data/data_channel.h"
#include "data/data_session.h"
#include "main/session/session_show.h"
#include "main/main_session.h"
#include "api/api_invite_links.h"
#include "ui/wrap/slide_wrap.h"
@ -543,8 +544,7 @@ void LinksController::appendSlice(const InviteLinksSlice &slice) {
void LinksController::rowClicked(not_null<PeerListRow*> row) {
delegate()->peerListShowBox(
ShowInviteLinkBox(_peer, static_cast<Row*>(row.get())->data()),
Ui::LayerOption::KeepOther);
ShowInviteLinkBox(_peer, static_cast<Row*>(row.get())->data()));
}
void LinksController::rowRightActionClicked(not_null<PeerListRow*> row) {
@ -579,33 +579,25 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
st::popupMenuWithIcons);
if (data.revoked) {
result->addAction(tr::lng_group_invite_context_delete(tr::now), [=] {
delegate()->peerListShowBox(
DeleteLinkBox(_peer, _admin, link),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(DeleteLinkBox(_peer, _admin, link));
}, &st::menuIconDelete);
} else {
result->addAction(tr::lng_group_invite_context_copy(tr::now), [=] {
CopyInviteLink(delegate()->peerListToastParent(), link);
CopyInviteLink(delegate()->peerListUiShow(), link);
}, &st::menuIconCopy);
result->addAction(tr::lng_group_invite_context_share(tr::now), [=] {
delegate()->peerListShowBox(
ShareInviteLinkBox(_peer, link),
Ui::LayerOption::KeepOther);
ShareInviteLinkBox(_peer, link));
}, &st::menuIconShare);
result->addAction(tr::lng_group_invite_context_qr(tr::now), [=] {
delegate()->peerListShowBox(
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()),
Ui::LayerOption::KeepOther);
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()));
}, &st::menuIconQrCode);
result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] {
delegate()->peerListShowBox(
EditLinkBox(_peer, data),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(EditLinkBox(_peer, data));
}, &st::menuIconEdit);
result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] {
delegate()->peerListShowBox(
RevokeLinkBox(_peer, _admin, link),
Ui::LayerOption::KeepOther);
delegate()->peerListShowBox(RevokeLinkBox(_peer, _admin, link));
}, &st::menuIconRemove);
}
return result;
@ -813,8 +805,7 @@ void AdminsController::loadMoreRows() {
void AdminsController::rowClicked(not_null<PeerListRow*> row) {
delegate()->peerListShowBox(
Box(ManageInviteLinksBox, _peer, row->peer()->asUser(), 0, 0),
Ui::LayerOption::KeepOther);
Box(ManageInviteLinksBox, _peer, row->peer()->asUser(), 0, 0));
}
Main::Session &AdminsController::session() const {
@ -836,7 +827,7 @@ struct LinksList {
};
LinksList AddLinksList(
std::shared_ptr<Ui::BoxShow> show,
std::shared_ptr<Main::SessionShow> show,
not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer,
not_null<UserData*> admin,
@ -861,7 +852,7 @@ LinksList AddLinksList(
}
not_null<Ui::RpWidget*> AddAdminsList(
std::shared_ptr<Ui::BoxShow> show,
std::shared_ptr<Main::SessionShow> show,
not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer,
not_null<UserData*> admin) {
@ -889,7 +880,9 @@ void ManageInviteLinksBox(
int revokedCount) {
using namespace Settings;
const auto show = std::make_shared<Ui::BoxShow>(box);
const auto show = Main::MakeSessionShow(
box->uiShow(),
&peer->session());
box->setTitle(tr::lng_group_invite_title());
box->setWidth(st::boxWideWidth);
@ -925,8 +918,7 @@ void ManageInviteLinksBox(
const auto add = AddCreateLinkButton(container);
add->setClickedCallback([=] {
show->showBox(
EditLinkBox(peer, InviteLinkData{ .admin = admin }),
Ui::LayerOption::KeepOther);
EditLinkBox(peer, InviteLinkData{ .admin = admin }));
});
} else {
otherHeader = container->add(object_ptr<Ui::SlideWrap<>>(
@ -1006,8 +998,8 @@ void ManageInviteLinksBox(
top + st::inviteLinkRevokedTitlePadding.top(),
outerWidth);
}, deleteAll->lifetime());
deleteAll->setClickedCallback([=, show = Ui::BoxShow(box)] {
show.showBox(DeleteAllRevokedBox(peer, admin));
deleteAll->setClickedCallback([=, show = box->uiShow()] {
show->showBox(DeleteAllRevokedBox(peer, admin));
});
rpl::combine(

View File

@ -21,7 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/continuous_sliders.h"
#include "ui/widgets/box_content_divider.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/toast/toast.h"
#include "info/profile/info_profile_icon.h"
#include "info/profile/info_profile_values.h"
#include "boxes/peers/edit_participants_box.h"
@ -417,10 +417,7 @@ not_null<Ui::RpWidget*> AddInnerToggle(
const auto handleLocked = [=] {
if (locked.has_value()) {
Ui::ShowMultilineToast({
.parentOverride = container,
.text = { *locked },
});
Ui::Toast::Show(container, *locked);
return true;
}
return false;
@ -597,8 +594,7 @@ template <typename Flags>
) | rpl::start_with_next([=](bool checked) {
if (checked && state->forceDisabled.current()) {
if (!state->toast) {
state->toast = Ui::ShowMultilineToast({
.parentOverride = container,
state->toast = Ui::Toast::Show(container, {
.text = { state->forceDisabledMessage.current() },
.duration = kForceDisableTooltipDuration,
});
@ -607,8 +603,7 @@ template <typename Flags>
} else if (locked.has_value()) {
if (checked != toggled) {
if (!state->toast) {
state->toast = Ui::ShowMultilineToast({
.parentOverride = container,
state->toast = Ui::Toast::Show(container, {
.text = { *locked },
.duration = kForceDisableTooltipDuration,
});
@ -970,23 +965,20 @@ Fn<void()> AboutGigagroupCallback(
channel->inputChannel
)).done([=](const MTPUpdates &result) {
channel->session().api().applyUpdates(result);
if (const auto strongController = weak.get()) {
strongController->window().hideSettingsAndLayer();
Ui::ShowMultilineToast({
.parentOverride = strongController->widget(),
.text = { tr::lng_gigagroup_done(tr::now) },
});
if (const auto strong = weak.get()) {
strong->window().hideSettingsAndLayer();
strong->showToast(tr::lng_gigagroup_done(tr::now));
}
}).fail([=] {
*converting = false;
}).send();
};
const auto convertWarn = [=] {
const auto strongController = weak.get();
if (*converting || !strongController) {
const auto strong = weak.get();
if (*converting || !strong) {
return;
}
strongController->show(Box([=](not_null<Ui::GenericBox*> box) {
strong->show(Box([=](not_null<Ui::GenericBox*> box) {
box->setTitle(tr::lng_gigagroup_warning_title());
box->addRow(
object_ptr<Ui::FlatLabel>(
@ -996,14 +988,14 @@ Fn<void()> AboutGigagroupCallback(
st::infoAboutGigagroup));
box->addButton(tr::lng_gigagroup_convert_sure(), convertSure);
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
}), Ui::LayerOption::KeepOther);
}));
};
return [=] {
const auto strongController = weak.get();
if (*converting || !strongController) {
const auto strong = weak.get();
if (*converting || !strong) {
return;
}
strongController->show(Box([=](not_null<Ui::GenericBox*> box) {
strong->show(Box([=](not_null<Ui::GenericBox*> box) {
box->setTitle(tr::lng_gigagroup_convert_title());
const auto addFeature = [&](rpl::producer<QString> text) {
using namespace rpl::mappers;
@ -1024,7 +1016,7 @@ Fn<void()> AboutGigagroupCallback(
addFeature(tr::lng_gigagroup_convert_feature3());
box->addButton(tr::lng_gigagroup_convert_sure(), convertWarn);
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
}), Ui::LayerOption::KeepOther);
}));
};
}

View File

@ -22,7 +22,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_session.h"
#include "mtproto/sender.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/painter.h"
#include "lang/lang_keys.h"
#include "window/window_session_controller.h"
@ -382,16 +381,13 @@ void RequestsBoxController::processRequest(
const auto done = crl::guard(this, [=] {
remove();
if (approved) {
Ui::ShowMultilineToast({
.parentOverride = delegate()->peerListToastParent(),
.text = (_peer->isBroadcast()
? tr::lng_group_requests_was_added_channel
: tr::lng_group_requests_was_added)(
tr::now,
lt_user,
Ui::Text::Bold(user->name()),
Ui::Text::WithEntities)
});
delegate()->peerListUiShow()->showToast((_peer->isBroadcast()
? tr::lng_group_requests_was_added_channel
: tr::lng_group_requests_was_added)(
tr::now,
lt_user,
Ui::Text::Bold(user->name()),
Ui::Text::WithEntities));
}
});
const auto fail = crl::guard(this, remove);

View File

@ -52,7 +52,7 @@ class Controller : public base::has_weak_ptr {
public:
Controller(
Window::SessionNavigation *navigation,
std::shared_ptr<Ui::BoxShow> show,
std::shared_ptr<Ui::Show> show,
not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer,
bool useLocationPhrases,
@ -140,7 +140,7 @@ private:
rpl::producer<QString> about);
Window::SessionNavigation *_navigation = nullptr;
std::shared_ptr<Ui::BoxShow> _show;
std::shared_ptr<Ui::Show> _show;
not_null<PeerData*> _peer;
bool _linkOnly = false;
@ -168,7 +168,7 @@ private:
Controller::Controller(
Window::SessionNavigation *navigation,
std::shared_ptr<Ui::BoxShow> show,
std::shared_ptr<Ui::Show> show,
not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer,
bool useLocationPhrases,
@ -601,9 +601,7 @@ void Controller::askUsernameRevoke() {
_controls.privacy->setValue(Privacy::HasUsername);
checkUsernameAvailability();
});
_show->showBox(
Box(PublicLinksLimitBox, _navigation, revokeCallback),
Ui::LayerOption::KeepOther);
_show->showBox(Box(PublicLinksLimitBox, _navigation, revokeCallback));
}
void Controller::usernameChanged() {
@ -735,7 +733,7 @@ void EditPeerTypeBox::prepare() {
const auto controller = Ui::CreateChild<Controller>(
this,
_navigation,
std::make_shared<Ui::BoxShow>(this),
uiShow(),
content.data(),
_peer,
_useLocationPhrases,

View File

@ -117,8 +117,7 @@ UsernamesList::Row::Row(
tr::lng_group_invite_context_copy(tr::now),
[=] {
QGuiApplication::clipboard()->setText(link);
Ui::Toast::Show(
show->toastParent(),
show->showToast(
tr::lng_create_channel_link_copied(tr::now));
},
&st::menuIconCopy);
@ -307,8 +306,7 @@ void UsernamesList::rebuild(const Data::Usernames &usernames) {
tr::lng_usernames_activate_error(
lt_count,
rpl::single(kMaxUsernames),
Ui::Text::RichLangValue)),
Ui::LayerOption::KeepOther);
Ui::Text::RichLangValue)));
}
load();
_toggleLifetime.destroy();
@ -321,9 +319,7 @@ void UsernamesList::rebuild(const Data::Usernames &usernames) {
}),
.confirmText = std::move(confirmText),
};
_show->showBox(
Ui::MakeConfirmBox(std::move(args)),
Ui::LayerOption::KeepOther);
_show->showBox(Ui::MakeConfirmBox(std::move(args)));
});
}

View File

@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/checkbox.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "main/main_session.h"
#include "main/main_account.h"
#include "main/main_domain.h"
@ -133,7 +132,7 @@ public:
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
not_null<QWidget*> peerListToastParent() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
void peerListSetRowChecked(
not_null<PeerListRow*> row,
bool checked) override;
@ -205,8 +204,8 @@ void InactiveDelegate::peerListShowBox(
void InactiveDelegate::peerListHideLayer() {
}
not_null<QWidget*> InactiveDelegate::peerListToastParent() {
Unexpected("...InactiveDelegate::peerListToastParent");
std::shared_ptr<Main::SessionShow> InactiveDelegate::peerListUiShow() {
Unexpected("...InactiveDelegate::peerListUiShow");
}
rpl::producer<int> InactiveDelegate::selectedCountChanges() const {
@ -385,8 +384,7 @@ void PublicsController::rowRightActionClicked(not_null<PeerListRow*> row) {
.text = text,
.confirmed = std::move(callback),
.confirmText = confirmText,
}),
Ui::LayerOption::KeepOther);
}));
}
void PublicsController::appendRow(not_null<PeerData*> participant) {
@ -602,10 +600,7 @@ void ChannelsLimitBox(
session->api().leaveChannel(channel);
}
}
Ui::ShowMultilineToast({
.parentOverride = Ui::BoxShow(box).toastParent(),
.text = { tr::lng_channels_leave_done(tr::now) },
});
box->showToast(tr::lng_channels_leave_done(tr::now));
box->closeBox();
};
box->clearButtons();

View File

@ -27,7 +27,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/chat/chat_theme.h"
#include "ui/effects/scroll_content_shadow.h"
#include "ui/layers/generic_box.h"
#include "ui/toasts/common_toasts.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
#include "ui/widgets/scroll_area.h"

View File

@ -39,13 +39,12 @@ namespace {
return Ui::ReportSource::Bot;
});
return Box([=](not_null<Ui::GenericBox*> box) {
const auto show = box->uiShow();
Ui::ReportReasonBox(box, source, [=](Ui::ReportReason reason) {
Ui::BoxShow(box).showBox(Box([=](not_null<Ui::GenericBox*> box) {
const auto show = Ui::BoxShow(box);
show->showBox(Box([=](not_null<Ui::GenericBox*> box) {
Ui::ReportDetailsBox(box, [=](const QString &text) {
const auto toastParent = show.toastParent();
Api::SendReport(toastParent, peer, reason, text, data);
show.hideLayer();
Api::SendReport(show, peer, reason, text, data);
show->hideLayer();
});
}));
});
@ -79,7 +78,7 @@ void ShowReportPeerBox(
const auto send = [=](const QString &text) {
window->clearChooseReportMessages();
Api::SendReport(
Window::Show(window).toastParent(),
window->uiShow(),
peer,
reason,
text,

View File

@ -83,9 +83,9 @@ void FileDialogCallback(
Fn<bool(const Ui::PreparedList&)> checkResult,
Fn<void(Ui::PreparedList)> callback,
bool premium,
not_null<QWidget*> toastParent) {
std::shared_ptr<Ui::Show> show) {
auto showError = [=](tr::phrase<> text) {
Ui::Toast::Show(toastParent, text(tr::now));
show->showToast(text(tr::now));
};
auto list = Storage::PreparedFileFromFilesDialog(
@ -143,7 +143,7 @@ SendFilesCheck DefaultCheckForPeer(
bool silent) {
const auto error = Data::FileRestrictionError(peer, file, compress);
if (error && !silent) {
controller->showToast({ *error });
controller->showToast(*error);
}
return !error.has_value();
};
@ -468,12 +468,12 @@ void SendFilesBox::refreshAllAfterChanges(int fromItem, Fn<void()> perform) {
}
void SendFilesBox::openDialogToAddFileToAlbum() {
const auto toastParent = Ui::BoxShow(this).toastParent();
const auto show = uiShow();
const auto checkResult = [=](const Ui::PreparedList &list) {
if (!(_limits & SendFilesAllow::OnlyOne)) {
return true;
} else if (!_list.canBeSentInSlowmodeWith(list)) {
Ui::Toast::Show(toastParent, tr::lng_slowmode_no_many(tr::now));
showToast(tr::lng_slowmode_no_many(tr::now));
return false;
}
return true;
@ -485,7 +485,7 @@ void SendFilesBox::openDialogToAddFileToAlbum() {
checkResult,
[=](Ui::PreparedList list) { addFiles(std::move(list)); },
premium,
toastParent);
show);
};
FileDialog::GetOpenPaths(
@ -748,7 +748,7 @@ void SendFilesBox::pushBlock(int from, int till) {
});
}, widget->lifetime());
const auto toastParent = Ui::BoxShow(this).toastParent();
const auto show = uiShow();
block.itemReplaceRequest(
) | rpl::start_with_next([=](int index) {
const auto replace = [=](Ui::PreparedList list) {
@ -770,9 +770,7 @@ void SendFilesBox::pushBlock(int from, int till) {
_list.files.push_back(std::move(removing));
std::swap(_list.files[index], _list.files.back());
if (!result) {
Ui::Toast::Show(
toastParent,
tr::lng_slowmode_no_many(tr::now));
show->showToast(tr::lng_slowmode_no_many(tr::now));
return false;
}
return true;
@ -815,7 +813,7 @@ void SendFilesBox::pushBlock(int from, int till) {
checkResult,
replace,
premium,
toastParent);
show);
};
FileDialog::GetOpenPath(
@ -1024,7 +1022,7 @@ void SendFilesBox::setupEmojiPanel() {
_controller,
object_ptr<Selector>(
nullptr,
_controller,
_controller->uiShow(),
Window::GifPauseReason::Layer,
Selector::Mode::EmojiOnly));
_emojiPanel->setDesiredHeightValues(
@ -1388,8 +1386,7 @@ void SendFilesBox::sendScheduled() {
: _sendMenuType;
const auto callback = [=](Api::SendOptions options) { send(options); };
_controller->show(
HistoryView::PrepareScheduleBox(this, type, callback),
Ui::LayerOption::KeepOther);
HistoryView::PrepareScheduleBox(this, type, callback));
}
void SendFilesBox::sendWhenOnline() {

View File

@ -846,7 +846,7 @@ void SessionsContent::terminate(Fn<void()> terminateRequest, QString message) {
.confirmStyle = &st::attentionBoxButton,
});
_terminateBox = Ui::MakeWeak(box.data());
_controller->show(std::move(box), Ui::LayerOption::KeepOther);
_controller->show(std::move(box));
}
void SessionsContent::terminateOne(uint64 hash) {
@ -928,7 +928,7 @@ void SessionsContent::Inner::setupContent() {
rename->moveToRight(x, y, outer.width());
}, rename->lifetime());
rename->setClickedCallback([=] {
_controller->show(Box(RenameBox), Ui::LayerOption::KeepOther);
_controller->show(Box(RenameBox));
});
const auto session = &_controller->session();

View File

@ -63,7 +63,7 @@ public:
Inner(
QWidget *parent,
const Descriptor &descriptor,
std::shared_ptr<Ui::BoxShow> show);
std::shared_ptr<Ui::Show> show);
void setPeerSelectedChangedCallback(
Fn<void(not_null<Data::Thread*> thread, bool selected)> callback);
@ -146,7 +146,7 @@ private:
void refresh();
const Descriptor &_descriptor;
const std::shared_ptr<Ui::BoxShow> _show;
const std::shared_ptr<Ui::Show> _show;
const style::PeerList &_st;
float64 _columnSkip = 0.;
@ -181,7 +181,6 @@ private:
ShareBox::ShareBox(QWidget*, Descriptor &&descriptor)
: _descriptor(std::move(descriptor))
, _api(&_descriptor.session->mtp())
, _show(std::make_shared<Ui::BoxShow>(this))
, _select(
this,
(_descriptor.stMultiSelect
@ -231,10 +230,10 @@ void ShareBox::prepareCommentField() {
connect(field, &Ui::InputField::submitted, [=] {
submit({});
});
if (_show->valid()) {
if (const auto show = uiShow(); show->valid()) {
InitMessageFieldHandlers(
_descriptor.session,
_show,
Main::MakeSessionShow(show, _descriptor.session),
field,
nullptr,
nullptr,
@ -257,7 +256,7 @@ void ShareBox::prepare() {
setTitle(tr::lng_share_title());
_inner = setInnerWidget(
object_ptr<Inner>(this, _descriptor, _show),
object_ptr<Inner>(this, _descriptor, uiShow()),
getTopScrollSkip(),
getBottomScrollSkip());
@ -590,14 +589,13 @@ void ShareBox::submitSilent() {
void ShareBox::submitScheduled() {
const auto callback = [=](Api::SendOptions options) { submit(options); };
_show->showBox(
uiShow()->showBox(
HistoryView::PrepareScheduleBox(
this,
sendMenuType(),
callback,
HistoryView::DefaultScheduleTime(),
_descriptor.scheduleBoxStyle),
Ui::LayerOption::KeepOther);
_descriptor.scheduleBoxStyle));
}
void ShareBox::submitWhenOnline() {
@ -643,7 +641,7 @@ void ShareBox::scrollAnimationCallback() {
ShareBox::Inner::Inner(
QWidget *parent,
const Descriptor &descriptor,
std::shared_ptr<Ui::BoxShow> show)
std::shared_ptr<Ui::Show> show)
: RpWidget(parent)
, _descriptor(descriptor)
, _show(std::move(show))
@ -1373,9 +1371,7 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback(
).append("\n\n");
}
text.append(error.first);
show->showBox(
Ui::MakeInformBox(text),
Ui::LayerOption::KeepOther);
show->showBox(Ui::MakeInformBox(text));
return;
}
@ -1441,23 +1437,18 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback(
state->requests.remove(reqId);
if (state->requests.empty()) {
if (show->valid()) {
Ui::Toast::Show(
show->toastParent(),
tr::lng_share_done(tr::now));
show->showToast(tr::lng_share_done(tr::now));
show->hideLayer();
}
}
finish();
}).fail([=](const MTP::Error &error) {
if (error.type() == u"VOICE_MESSAGES_FORBIDDEN"_q) {
if (show->valid()) {
Ui::Toast::Show(
show->toastParent(),
tr::lng_restricted_send_voice_messages(
tr::now,
lt_user,
peer->name()));
}
show->showToast(
tr::lng_restricted_send_voice_messages(
tr::now,
lt_user,
peer->name()));
}
finish();
}).afterRequest(history->sendRequestId).send();
@ -1471,7 +1462,7 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback(
void FastShareMessage(
not_null<Window::SessionController*> controller,
not_null<HistoryItem*> item) {
const auto show = std::make_shared<Window::Show>(controller);
const auto show = controller->uiShow();
const auto history = item->history();
const auto owner = &history->owner();
const auto session = &history->session();
@ -1493,7 +1484,7 @@ void FastShareMessage(
return item->media() && item->media()->forceForwardedInfo();
});
auto copyCallback = [=, toastParent = show->toastParent()] {
auto copyCallback = [=] {
const auto item = owner->message(msgIds[0]);
if (!item) {
return;
@ -1509,8 +1500,7 @@ void FastShareMessage(
QGuiApplication::clipboard()->setText(link);
Ui::Toast::Show(
toastParent,
show->showToast(
tr::lng_share_game_link_copied(tr::now));
}
}

View File

@ -147,8 +147,6 @@ private:
Descriptor _descriptor;
MTP::Sender _api;
std::shared_ptr<Ui::BoxShow> _show;
object_ptr<Ui::MultiSelect> _select;
object_ptr<Ui::SlideWrap<Ui::InputField>> _comment;
object_ptr<Ui::RpWidget> _bottomWidget;

View File

@ -38,10 +38,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/cached_round_corners.h"
#include "lottie/lottie_multi_player.h"
#include "lottie/lottie_animation.h"
#include "chat_helpers/compose/compose_show.h"
#include "chat_helpers/stickers_lottie.h"
#include "chat_helpers/stickers_list_widget.h"
#include "media/clip/media_clip_reader.h"
#include "window/window_session_controller.h"
#include "window/window_controller.h"
#include "settings/settings_premium.h"
#include "base/unixtime.h"
@ -230,7 +230,7 @@ class StickerSetBox::Inner final : public Ui::RpWidget {
public:
Inner(
QWidget *parent,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
const StickerSetIdentifier &set,
Data::StickersType type);
@ -322,11 +322,14 @@ private:
not_null<Lottie::MultiPlayer*> getLottiePlayer();
void showPreview();
void showPreviewAt(QPoint globalPos);
void updateItems();
void repaintItems(crl::time now = 0);
const not_null<Window::SessionController*> _controller;
const std::shared_ptr<ChatHelpers::Show> _show;
const not_null<Main::Session*> _session;
MTP::Sender _api;
std::vector<Element> _elements;
std::unique_ptr<Lottie::MultiPlayer> _lottiePlayer;
@ -381,33 +384,35 @@ private:
};
StickerSetBox::StickerSetBox(
QWidget*,
not_null<Window::SessionController*> controller,
QWidget *parent,
std::shared_ptr<ChatHelpers::Show> show,
const StickerSetIdentifier &set,
Data::StickersType type)
: _controller(controller)
: _show(std::move(show))
, _session(&_show->session())
, _set(set)
, _type(type) {
}
StickerSetBox::StickerSetBox(
QWidget *parent,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<Data::StickersSet*> set)
: StickerSetBox(parent, controller, set->identifier(), set->type()) {
: StickerSetBox(parent, std::move(show), set->identifier(), set->type()) {
}
QPointer<Ui::BoxContent> StickerSetBox::Show(
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document) {
if (const auto sticker = document->sticker()) {
if (sticker->set) {
return controller->show(
Box<StickerSetBox>(
controller,
sticker->set,
sticker->setType),
Ui::LayerOption::KeepOther).data();
auto box = Box<StickerSetBox>(
show,
sticker->set,
sticker->setType);
const auto result = QPointer<Ui::BoxContent>(box.data());
show->showBox(std::move(box));
return result;
}
}
return nullptr;
@ -417,9 +422,9 @@ void StickerSetBox::prepare() {
setTitle(tr::lng_contacts_loading());
_inner = setInnerWidget(
object_ptr<Inner>(this, _controller, _set, _type),
object_ptr<Inner>(this, _show, _set, _type),
st::stickersScroll);
_controller->session().data().stickers().updated(
_session->data().stickers().updated(
_type
) | rpl::start_with_next([=] {
updateButtons();
@ -441,14 +446,12 @@ void StickerSetBox::prepare() {
_inner->setInstalled(
) | rpl::start_with_next([=](uint64 setId) {
if (_inner->setType() == Data::StickersType::Masks) {
Ui::Toast::Show(
Ui::BoxShow(this).toastParent(),
tr::lng_masks_installed(tr::now));
showToast(tr::lng_masks_installed(tr::now));
} else if (_inner->setType() == Data::StickersType::Emoji) {
auto &stickers = _controller->session().data().stickers();
auto &stickers = _session->data().stickers();
stickers.notifyEmojiSetInstalled(setId);
} else if (_inner->setType() == Data::StickersType::Stickers) {
auto &stickers = _controller->session().data().stickers();
auto &stickers = _session->data().stickers();
stickers.notifyStickerSetInstalled(setId);
}
closeBox();
@ -466,20 +469,18 @@ void StickerSetBox::prepare() {
return;
}
Ui::Toast::Show(
Ui::BoxShow(this).toastParent(),
(type == Data::StickersType::Masks)
showToast((type == Data::StickersType::Masks)
? tr::lng_masks_has_been_archived(tr::now)
: tr::lng_stickers_has_been_archived(tr::now));
auto &order = (type == Data::StickersType::Masks)
? _controller->session().data().stickers().maskSetsOrderRef()
: _controller->session().data().stickers().setsOrderRef();
? _session->data().stickers().maskSetsOrderRef()
: _session->data().stickers().setsOrderRef();
const auto index = order.indexOf(setId);
if (index != -1) {
order.removeAt(index);
auto &local = _controller->session().local();
auto &local = _session->local();
if (type == Data::StickersType::Masks) {
local.writeInstalledMasks();
local.writeArchivedMasks();
@ -489,7 +490,7 @@ void StickerSetBox::prepare() {
}
}
_controller->session().data().stickers().notifyUpdated(type);
_session->data().stickers().notifyUpdated(type);
closeBox();
}, lifetime());
@ -501,7 +502,7 @@ void StickerSetBox::addStickers() {
void StickerSetBox::copyStickersLink() {
const auto part = _inner->isEmojiSet() ? u"addemoji"_q : "addstickers";
const auto url = _controller->session().createInternalLinkFull(
const auto url = _session->createInternalLinkFull(
part + '/' + _inner->shortName());
QGuiApplication::clipboard()->setText(url);
}
@ -513,7 +514,7 @@ void StickerSetBox::handleError(Error error) {
switch (error) {
case Error::NotFound:
_controller->show(
_show->showBox(
Ui::MakeInformBox(tr::lng_stickers_not_found(tr::now)));
break;
default: Unexpected("Error in StickerSetBox::handleError.");
@ -531,15 +532,13 @@ void StickerSetBox::updateButtons() {
const auto type = _inner->setType();
const auto share = [=] {
copyStickersLink();
Ui::Toast::Show(
Ui::BoxShow(this).toastParent(),
(type == Data::StickersType::Emoji
showToast(type == Data::StickersType::Emoji
? tr::lng_stickers_copied_emoji(tr::now)
: tr::lng_stickers_copied(tr::now)));
: tr::lng_stickers_copied(tr::now));
};
if (_inner->notInstalled()) {
if (!_controller->session().premium()
&& _controller->session().premiumPossible()
if (!_session->premium()
&& _session->premiumPossible()
&& _inner->premiumEmojiSet()) {
const auto &st = st::premiumPreviewDoubledLimitsBox;
setStyle(st);
@ -550,7 +549,11 @@ void StickerSetBox::updateButtons() {
- st.buttonPadding.left()
- st.buttonPadding.left());
button->setClickedCallback([=] {
Settings::ShowPremium(_controller, u"animated_emoji"_q);
using namespace ChatHelpers;
const auto usage = WindowUsage::PremiumPromo;
if (const auto window = _show->resolveWindow(usage)) {
Settings::ShowPremium(window, u"animated_emoji"_q);
}
});
addButton(std::move(button));
} else {
@ -600,14 +603,12 @@ void StickerSetBox::updateButtons() {
_inner->archiveStickers();
};
const auto remove = [=] {
const auto session = &_controller->session();
const auto session = &_show->session();
auto box = ChatHelpers::MakeConfirmRemoveSetBox(
session,
_inner->setId());
if (box) {
_controller->show(
std::move(box),
Ui::LayerOption::KeepOther);
_show->showBox(std::move(box));
}
};
const auto menu =
@ -647,12 +648,13 @@ void StickerSetBox::resizeEvent(QResizeEvent *e) {
StickerSetBox::Inner::Inner(
QWidget *parent,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
const StickerSetIdentifier &set,
Data::StickersType type)
: RpWidget(parent)
, _controller(controller)
, _api(&_controller->session().mtp())
, _show(std::move(show))
, _session(&_show->session())
, _api(&_session->mtp())
, _setId(set.id)
, _setAccessHash(set.accessHash)
, _setShortName(set.shortName)
@ -660,7 +662,7 @@ StickerSetBox::Inner::Inner(
st::windowBgRipple,
st::windowBgOver,
[=] { repaintItems(); }))
, _premiumMark(&controller->session())
, _premiumMark(_session)
, _updateItemsTimer([=] { updateItems(); })
, _input(set)
, _padding((type == Data::StickersType::Emoji)
@ -679,9 +681,9 @@ StickerSetBox::Inner::Inner(
_errors.fire(Error::NotFound);
}).send();
_controller->session().api().updateStickers();
_session->api().updateStickers();
_controller->session().downloaderTaskFinished(
_session->downloaderTaskFinished(
) | rpl::start_with_next([=] {
updateItems();
}, lifetime());
@ -695,8 +697,8 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
_elements.clear();
_selected = -1;
setCursor(style::cur_default);
const auto owner = &_controller->session().data();
const auto premiumPossible = _controller->session().premiumPossible();
const auto owner = &_session->data();
const auto premiumPossible = _session->premiumPossible();
set.match([&](const MTPDmessages_stickerSet &data) {
const auto &v = data.vdocuments().v;
_pack.reserve(v.size());
@ -724,7 +726,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
auto p = StickersPack();
p.reserve(stickers.size());
for (auto j = 0, c = int(stickers.size()); j != c; ++j) {
auto doc = _controller->session().data().document(stickers[j].v);
auto doc = _session->data().document(stickers[j].v);
if (!doc || !doc->sticker()) continue;
p.push_back(doc);
@ -734,7 +736,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
});
}
data.vset().match([&](const MTPDstickerSet &set) {
_setTitle = _controller->session().data().stickers().getSetTitle(
_setTitle = _session->data().stickers().getSetTitle(
set);
_setShortName = qs(set.vshort_name());
_setId = set.vid().v;
@ -748,7 +750,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
if (const auto thumbs = set.vthumbs()) {
for (const auto &thumb : thumbs->v) {
const auto result = Images::FromPhotoSize(
&_controller->session(),
_session,
set,
thumb);
if (result.location.valid()) {
@ -758,7 +760,7 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
}
return ImageWithLocation();
}();
const auto &sets = _controller->session().data().stickers().sets();
const auto &sets = _session->data().stickers().sets();
const auto it = sets.find(_setId);
if (it != sets.cend()) {
const auto set = it->second.get();
@ -814,7 +816,7 @@ rpl::producer<StickerSetBox::Error> StickerSetBox::Inner::errors() const {
void StickerSetBox::Inner::installDone(
const MTPmessages_StickerSetInstallResult &result) {
auto &stickers = _controller->session().data().stickers();
auto &stickers = _session->data().stickers();
auto &sets = stickers.setsRef();
const auto type = setType();
@ -837,7 +839,7 @@ void StickerSetBox::Inner::installDone(
it = sets.emplace(
_setId,
std::make_unique<StickersSet>(
&_controller->session().data(),
&_session->data(),
_setId,
_setAccessHash,
_setHash,
@ -887,7 +889,7 @@ void StickerSetBox::Inner::installDone(
stickers.applyArchivedResult(
result.c_messages_stickerSetInstallResultArchive());
} else {
auto &storage = _controller->session().local();
auto &storage = _session->local();
if (wasArchived && type != Data::StickersType::Emoji) {
if (type == Data::StickersType::Masks) {
storage.writeArchivedMasks();
@ -921,13 +923,19 @@ void StickerSetBox::Inner::mousePressEvent(QMouseEvent *e) {
void StickerSetBox::Inner::mouseMoveEvent(QMouseEvent *e) {
updateSelected();
if (_previewShown >= 0) {
int index = stickerFromGlobalPos(e->globalPos());
if (index >= 0 && index < _pack.size() && index != _previewShown) {
_previewShown = index;
_controller->widget()->showMediaPreview(
Data::FileOriginStickerSet(_setId, _setAccessHash),
_pack[_previewShown]);
}
showPreviewAt(e->globalPos());
}
}
void StickerSetBox::Inner::showPreviewAt(QPoint globalPos) {
const auto index = stickerFromGlobalPos(globalPos);
if (index >= 0
&& index < _pack.size()
&& index != _previewShown) {
_previewShown = index;
_show->showMediaPreview(
Data::FileOriginStickerSet(_setId, _setAccessHash),
_pack[_previewShown]);
}
}
@ -955,16 +963,13 @@ void StickerSetBox::Inner::chosen(
int index,
not_null<DocumentData*> sticker,
Api::SendOptions options) {
const auto controller = _controller;
const auto animation = options.scheduled
? Ui::MessageSendingAnimationFrom()
: messageSentAnimationInfo(index, sticker);
Ui::PostponeCall(controller, [=] {
controller->stickerOrEmojiChosen({
.document = sticker,
.options = options,
.messageSendingFrom = animation,
});
_show->processChosenSticker({
.document = sticker,
.options = options,
.messageSendingFrom = animation,
});
}
@ -988,7 +993,7 @@ auto StickerSetBox::Inner::messageSentAnimationInfo(
(rect.height() - size.height()) / 2);
return {
.type = Ui::MessageSendingAnimationFrom::Type::Sticker,
.localId = _controller->session().data().nextLocalMessageId(),
.localId = _session->data().nextLocalMessageId(),
.globalStartGeometry = mapToGlobal(
QRect(rect.topLeft() + innerPos, size)),
};
@ -1005,7 +1010,7 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
_menu = base::make_unique_q<Ui::PopupMenu>(
this,
st::popupMenuWithIcons);
const auto type = _controller->content()->sendMenuType();
const auto type = _show->sendMenuType();
if (setType() == Data::StickersType::Emoji) {
if (const auto t = PrepareTextFromEmoji(_pack[index]); !t.empty()) {
_menu->addAction(tr::lng_mediaview_copy(tr::now), [=] {
@ -1026,10 +1031,10 @@ void StickerSetBox::Inner::contextMenuEvent(QContextMenuEvent *e) {
SendMenu::DefaultScheduleCallback(this, type, sendSelected),
SendMenu::DefaultWhenOnlineCallback(sendSelected));
const auto controller = _controller;
const auto show = _show;
const auto toggleFavedSticker = [=] {
Api::ToggleFavedSticker(
controller,
show,
document,
Data::FileOriginStickerSet(Data::Stickers::FavedSetId, 0));
};
@ -1078,13 +1083,8 @@ void StickerSetBox::Inner::startOverAnimation(int index, float64 from, float64 t
}
void StickerSetBox::Inner::showPreview() {
int index = stickerFromGlobalPos(QCursor::pos());
if (index >= 0 && index < _pack.size()) {
_previewShown = index;
_controller->widget()->showMediaPreview(
Data::FileOriginStickerSet(_setId, _setAccessHash),
_pack[_previewShown]);
}
_previewShown = -1;
showPreviewAt(QCursor::pos());
}
not_null<Lottie::MultiPlayer*> StickerSetBox::Inner::getLottiePlayer() {
@ -1128,7 +1128,7 @@ void StickerSetBox::Inner::paintEvent(QPaintEvent *e) {
const auto now = crl::now();
const auto paused = On(PowerSaving::kStickersPanel)
|| _controller->isGifPausedAtLeastFor(Window::GifPauseReason::Layer);
|| _show->paused(ChatHelpers::PauseReason::Layer);
for (int32 i = from; i < to; ++i) {
for (int32 j = 0; j < _perRow; ++j) {
int32 index = i * _perRow + j;
@ -1392,7 +1392,7 @@ bool StickerSetBox::Inner::notInstalled() const {
if (!_loaded) {
return false;
}
const auto &sets = _controller->session().data().stickers().sets();
const auto &sets = _session->data().stickers().sets();
const auto it = sets.find(_setId);
if ((it == sets.cend())
|| !(it->second->flags & SetFlag::Installed)
@ -1436,7 +1436,6 @@ void StickerSetBox::Inner::install() {
}
void StickerSetBox::Inner::archiveStickers() {
const auto toastParent = Window::Show(_controller).toastParent();
_api.request(MTPmessages_InstallStickerSet(
Data::InputStickerSet(_input),
MTP_boolTrue()
@ -1444,9 +1443,9 @@ void StickerSetBox::Inner::archiveStickers() {
if (result.type() == mtpc_messages_stickerSetInstallResultSuccess) {
_setArchived.fire_copy(_setId);
}
}).fail(crl::guard(toastParent, [=] {
Ui::Toast::Show(toastParent, Lang::Hard::ServerError());
})).send();
}).fail([=] {
_show->showToast(Lang::Hard::ServerError());
}).send();
}
void StickerSetBox::Inner::updateItems() {

View File

@ -23,6 +23,15 @@ namespace Data {
class StickersSet;
} // namespace Data
namespace SendMenu {
enum class Type;
} // namespace SendMenu
namespace ChatHelpers {
struct FileChosen;
class Show;
} // namespace ChatHelpers
class StickerPremiumMark final {
public:
explicit StickerPremiumMark(not_null<Main::Session*> session);
@ -51,16 +60,16 @@ class StickerSetBox final : public Ui::BoxContent {
public:
StickerSetBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
const StickerSetIdentifier &set,
Data::StickersType type);
StickerSetBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<Data::StickersSet*> set);
static QPointer<Ui::BoxContent> Show(
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document);
protected:
@ -79,7 +88,8 @@ private:
void copyStickersLink();
void handleError(Error error);
const not_null<Window::SessionController*> _controller;
const std::shared_ptr<ChatHelpers::Show> _show;
const not_null<Main::Session*> _session;
const StickerSetIdentifier _set;
const Data::StickersType _type;

View File

@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "apiwrap.h"
#include "storage/storage_account.h"
#include "lottie/lottie_single_player.h"
#include "chat_helpers/compose/compose_show.h"
#include "chat_helpers/stickers_lottie.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
@ -35,7 +36,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/cached_round_corners.h"
#include "ui/painter.h"
#include "ui/unread_badge_paint.h"
#include "window/window_session_controller.h"
#include "media/clip/media_clip_reader.h"
#include "main/main_session.h"
#include "styles/style_layers.h"
@ -77,11 +77,11 @@ public:
Inner(
QWidget *parent,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
Section section);
Inner(
QWidget *parent,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<ChannelData*> megagroup);
[[nodiscard]] Main::Session &session() const;
@ -250,7 +250,8 @@ private:
int countMaxNameWidth() const;
[[nodiscard]] bool skipPremium() const;
const not_null<Window::SessionController*> _controller;
const std::shared_ptr<ChatHelpers::Show> _show;
const not_null<Main::Session*> _session;
MTP::Sender _api;
const Section _section;
@ -380,35 +381,37 @@ void StickersBox::Tab::saveScrollTop() {
StickersBox::StickersBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
Section section,
bool masks)
: _controller(controller)
, _api(&controller->session().mtp())
: _show(std::move(show))
, _session(&_show->session())
, _api(&_session->mtp())
, _tabs(this, st::stickersTabs)
, _unreadBadge(
this,
controller->session().data().stickers().featuredSetsUnreadCountValue())
_session->data().stickers().featuredSetsUnreadCountValue())
, _section(section)
, _isMasks(masks)
, _isEmoji(false)
, _installed(_isMasks ? Tab() : Tab(0, this, controller, Section::Installed))
, _masks(_isMasks ? Tab(0, this, controller, Section::Masks) : Tab())
, _featured(_isMasks ? Tab() : Tab(1, this, controller, Section::Featured))
, _archived((_isMasks ? 1 : 2), this, controller, Section::Archived) {
, _installed(_isMasks ? Tab() : Tab(0, this, _show, Section::Installed))
, _masks(_isMasks ? Tab(0, this, _show, Section::Masks) : Tab())
, _featured(_isMasks ? Tab() : Tab(1, this, _show, Section::Featured))
, _archived((_isMasks ? 1 : 2), this, _show, Section::Archived) {
_tabs->setRippleTopRoundRadius(st::boxRadius);
}
StickersBox::StickersBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<ChannelData*> megagroup)
: _controller(controller)
, _api(&controller->session().mtp())
: _show(std::move(show))
, _session(&_show->session())
, _api(&_session->mtp())
, _section(Section::Installed)
, _isMasks(false)
, _isEmoji(false)
, _installed(0, this, controller, megagroup)
, _installed(0, this, _show, megagroup)
, _megagroupSet(megagroup) {
_installed.widget()->scrollsToY(
) | rpl::start_with_next([=](int y) {
@ -418,34 +421,36 @@ StickersBox::StickersBox(
StickersBox::StickersBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
const QVector<MTPStickerSetCovered> &attachedSets)
: _controller(controller)
, _api(&controller->session().mtp())
: _show(std::move(show))
, _session(&_show->session())
, _api(&_session->mtp())
, _section(Section::Attached)
, _isMasks(false)
, _isEmoji(false)
, _attached(0, this, controller, Section::Attached)
, _attached(0, this, _show, Section::Attached)
, _attachedType(Data::StickersType::Stickers)
, _attachedSets(attachedSets) {
}
StickersBox::StickersBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
const std::vector<StickerSetIdentifier> &emojiSets)
: _controller(controller)
, _api(&controller->session().mtp())
: _show(std::move(show))
, _session(&_show->session())
, _api(&_session->mtp())
, _section(Section::Attached)
, _isMasks(false)
, _isEmoji(true)
, _attached(0, this, controller, Section::Attached)
, _attached(0, this, _show, Section::Attached)
, _attachedType(Data::StickersType::Emoji)
, _emojiSets(emojiSets) {
}
Main::Session &StickersBox::session() const {
return _controller->session();
return *_session;
}
void StickersBox::showAttachedStickers() {
@ -1121,11 +1126,12 @@ bool StickersBox::Inner::Row::isArchived() const {
StickersBox::Inner::Inner(
QWidget *parent,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
StickersBox::Section section)
: RpWidget(parent)
, _controller(controller)
, _api(&_controller->session().mtp())
, _show(std::move(show))
, _session(&_show->session())
, _api(&_session->mtp())
, _section(section)
, _isInstalled(_section == Section::Installed || _section == Section::Masks)
, _buttonBgOver(
@ -1152,11 +1158,12 @@ StickersBox::Inner::Inner(
StickersBox::Inner::Inner(
QWidget *parent,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<ChannelData*> megagroup)
: RpWidget(parent)
, _controller(controller)
, _api(&_controller->session().mtp())
, _show(std::move(show))
, _session(&_show->session())
, _api(&_session->mtp())
, _section(StickersBox::Section::Installed)
, _isInstalled(_section == Section::Installed || _section == Section::Masks)
, _buttonBgOver(
@ -1181,11 +1188,11 @@ StickersBox::Inner::Inner(
st::groupStickersField,
rpl::single(u"stickerset"_q),
QString(),
_controller->session().createInternalLink(QString()))
_session->createInternalLink(QString()))
, _megagroupDivider(this)
, _megagroupSubTitle(this, tr::lng_stickers_group_from_your(tr::now), st::boxTitle) {
_megagroupSetField->setLinkPlaceholder(
_controller->session().createInternalLink(u"addstickers/"_q));
_session->createInternalLink(u"addstickers/"_q));
_megagroupSetField->setPlaceholderHidden(false);
_megagroupSetAddressChangedTimer.setCallback([this] { handleMegagroupSetAddressChange(); });
connect(
@ -1207,7 +1214,7 @@ StickersBox::Inner::Inner(
}
Main::Session &StickersBox::Inner::session() const {
return _controller->session();
return *_session;
}
void StickersBox::Inner::setup() {
@ -1429,8 +1436,7 @@ void StickersBox::Inner::paintRowThumbnail(
: row->stickerMedia
? row->stickerMedia->thumbnail()
: nullptr;
const auto paused = _controller->isGifPausedAtLeastFor(
Window::GifPauseReason::Layer);
const auto paused = _show->paused(ChatHelpers::PauseReason::Layer);
const auto x = left + (st::contactsPhotoSize - row->pixw) / 2;
const auto y = st::contactsPadding.top() + (st::contactsPhotoSize - row->pixh) / 2;
if (row->lottie && row->lottie->ready()) {
@ -1858,9 +1864,7 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
}();
const auto showSetByRow = [&](const Row &row) {
setSelected(SelectedRow());
_controller->show(
Box<StickerSetBox>(_controller, row.set),
Ui::LayerOption::KeepOther);
_show->showBox(Box<StickerSetBox>(_show, row.set));
};
if (selectedIndex >= 0 && !_inDragArea) {
const auto row = _rows[selectedIndex].get();
@ -2252,7 +2256,7 @@ bool StickersBox::Inner::appendSet(not_null<StickersSet*> set) {
}
bool StickersBox::Inner::skipPremium() const {
return !_controller->session().premiumPossible();
return !_session->premiumPossible();
}
int StickersBox::Inner::countMaxNameWidth() const {

View File

@ -27,9 +27,9 @@ class CrossButton;
class BoxContentDivider;
} // namespace Ui
namespace Window {
class SessionController;
} // namespace Window
namespace ChatHelpers {
class Show;
} // namespace ChatHelpers
namespace Main {
class Session;
@ -60,20 +60,20 @@ public:
StickersBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
Section section,
bool masks = false);
StickersBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<ChannelData*> megagroup);
StickersBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
const QVector<MTPStickerSetCovered> &attachedSets);
StickersBox(
QWidget*,
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
const std::vector<StickerSetIdentifier> &emojiSets);
~StickersBox();
@ -142,7 +142,8 @@ private:
std::array<Inner*, 5> widgets() const;
const not_null<Window::SessionController*> _controller;
const std::shared_ptr<ChatHelpers::Show> _show;
const not_null<Main::Session*> _session;
MTP::Sender _api;
object_ptr<Ui::SettingsSlider> _tabs = { nullptr };

View File

@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/loading_element.h"
#include "ui/layers/generic_box.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/painter.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h"
@ -263,7 +262,7 @@ void TranslateBox(
if (loading->toggled()) {
return;
}
Ui::BoxShow(box).showBox(ChooseTranslateToBox(
box->uiShow()->showBox(ChooseTranslateToBox(
state->to.current(),
crl::guard(box, [=](LanguageId id) { state->to = id; })));
});
@ -314,11 +313,9 @@ object_ptr<BoxContent> EditSkipTranslationLanguages() {
}
if (already && selected->empty()) {
if (const auto strong = weak->data()) {
Ui::ShowMultilineToast({
.parentOverride = BoxShow(strong).toastParent(),
.text = { tr::lng_translate_settings_one(tr::now) },
.duration = kSkipAtLeastOneDuration,
});
strong->showToast(
tr::lng_translate_settings_one(tr::now),
kSkipAtLeastOneDuration);
}
return false;
}

View File

@ -375,7 +375,7 @@ void UsernamesBox(
object_ptr<UsernamesList>(
box,
peer,
std::make_shared<Ui::BoxShow>(box),
box->uiShow(),
!isBot
? [=] { box->scrollToY(0); editor->setInnerFocus(); }
: Fn<void()>(nullptr)),

View File

@ -568,8 +568,7 @@ base::unique_qptr<Ui::PopupMenu> BoxController::rowContextMenu(
st::popupMenuWithIcons);
result->addAction(tr::lng_context_delete_selected(tr::now), [=] {
_window->show(
Box<DeleteMessagesBox>(session, base::duplicate(ids)),
Ui::LayerOption::KeepOther);
Box<DeleteMessagesBox>(session, base::duplicate(ids)));
}, &st::menuIconDelete);
return result;
}

View File

@ -292,8 +292,7 @@ void TopBar::initControls() {
call->setMuted(!call->muted());
} else if (const auto group = _groupCall.get()) {
if (group->mutedByAdmin()) {
Ui::Toast::Show(
_show->toastParent(),
_show->showToast(
tr::lng_group_call_force_muted_sub(tr::now));
} else {
group->setMuted((group->muted() == MuteState::Muted)

View File

@ -406,9 +406,7 @@ void ChooseJoinAsProcess::processList(
auto info = JoinInfo{ .peer = peer, .joinAs = self };
const auto selectedId = peer->groupCallDefaultJoinAs();
if (list.empty()) {
Ui::Toast::Show(
_request->show->toastParent(),
Lang::Hard::ServerError());
_request->show->showToast(Lang::Hard::ServerError());
return;
}
info.joinAs = [&]() -> not_null<PeerData*> {

View File

@ -15,7 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "lang/lang_hardcoded.h"
#include "boxes/peers/edit_participants_box.h" // SubscribeToMigration.
#include "ui/toasts/common_toasts.h"
#include "ui/toast/toast.h"
#include "base/unixtime.h"
#include "core/application.h"
#include "core/core_settings.h"
@ -1413,11 +1413,9 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
}
hangup();
Ui::ShowMultilineToast({
.text = { type == u"GROUPCALL_FORBIDDEN"_q
? tr::lng_group_not_accessible(tr::now)
: Lang::Hard::ServerError() },
});
Ui::Toast::Show((type == u"GROUPCALL_FORBIDDEN"_q)
? tr::lng_group_not_accessible(tr::now)
: Lang::Hard::ServerError());
}).send();
});
});

View File

@ -259,9 +259,7 @@ object_ptr<Ui::BoxContent> PrepareInviteBox(
finish();
};
const auto done = [=] {
const auto show = (*shared)
? std::make_shared<Ui::BoxShow>(*shared)
: nullptr;
const auto show = (*shared) ? (*shared)->uiShow() : nullptr;
inviteWithAdd(show, users, nonMembers, finishWithConfirm);
};
auto box = ConfirmBox({

View File

@ -1983,8 +1983,8 @@ void Members::peerListShowBox(
void Members::peerListHideLayer() {
}
not_null<QWidget*> Members::peerListToastParent() {
Unexpected("...Members::peerListToastParent");
std::shared_ptr<Main::SessionShow> Members::peerListUiShow() {
Unexpected("...Members::peerListUiShow");
}
} // namespace Calls::Group

View File

@ -92,7 +92,7 @@ private:
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override;
not_null<QWidget*> peerListToastParent() override;
std::shared_ptr<Main::SessionShow> peerListUiShow() override;
void setupAddMember(not_null<GroupCall*> call);
void resizeToList();

View File

@ -32,7 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/layers/generic_box.h"
#include "ui/text/text_utilities.h"
#include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/image/image_prepare.h"
#include "ui/painter.h"
#include "ui/round_rect.h"
@ -46,6 +45,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_group_call.h"
#include "data/data_session.h"
#include "data/data_changes.h"
#include "main/session/session_show.h"
#include "main/main_session.h"
#include "base/event_filter.h"
#include "base/unixtime.h"
@ -75,6 +75,67 @@ constexpr auto kControlsBackgroundOpacity = 0.8;
constexpr auto kOverrideActiveColorBgAlpha = 172;
constexpr auto kHideControlsTimeout = 5 * crl::time(1000);
class Show final : public Main::SessionShow {
public:
explicit Show(not_null<Panel*> panel);
~Show();
void showBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options
= Ui::LayerOption::KeepOther) const override;
void hideLayer() const override;
[[nodiscard]] not_null<QWidget*> toastParent() const override;
[[nodiscard]] bool valid() const override;
operator bool() const override;
[[nodiscard]] Main::Session &session() const override;
private:
const base::weak_ptr<Panel> _panel;
};
Show::Show(not_null<Panel*> panel)
: _panel(base::make_weak(panel)) {
}
Show::~Show() = default;
void Show::showBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) const {
if (const auto panel = _panel.get()) {
panel->showBox(std::move(content), options);
}
}
void Show::hideLayer() const {
if (const auto panel = _panel.get()) {
panel->hideLayer();
}
}
not_null<QWidget*> Show::toastParent() const {
const auto panel = _panel.get();
Assert(panel != nullptr);
return panel->widget();
}
bool Show::valid() const {
return !_panel.empty();
}
Show::operator bool() const {
return valid();
}
Main::Session &Show::session() const {
const auto panel = _panel.get();
Assert(panel != nullptr);
return panel->call()->peer()->session();
}
} // namespace
struct Panel::ControlsBackgroundNarrow {
@ -176,15 +237,25 @@ bool Panel::isActive() const {
&& !(window()->windowState() & Qt::WindowMinimized);
}
void Panel::showToast(TextWithEntities &&text, crl::time duration) {
if (const auto strong = _lastToast.get()) {
strong->hideAnimated();
}
_lastToast = Ui::ShowMultilineToast({
.parentOverride = widget(),
.text = std::move(text),
.duration = duration,
});
base::weak_ptr<Ui::Toast::Instance> Panel::showToast(
const QString &text,
crl::time duration) {
return Show(this).showToast(text, duration);
}
base::weak_ptr<Ui::Toast::Instance> Panel::showToast(
TextWithEntities &&text,
crl::time duration) {
return Show(this).showToast(std::move(text), duration);
}
base::weak_ptr<Ui::Toast::Instance> Panel::showToast(
Ui::Toast::Config &&config) {
return Show(this).showToast(std::move(config));
}
std::shared_ptr<Main::SessionShow> Panel::uiShow() {
return std::make_shared<Show>(this);
}
void Panel::minimize() {
@ -634,16 +705,9 @@ void Panel::hideNiceTooltip() {
}
void Panel::initShareAction() {
const auto showBoxCallback = [=](object_ptr<Ui::BoxContent> next) {
showBox(std::move(next));
};
const auto showToastCallback = [=](QString text) {
showToast({ text });
};
auto [shareLinkCallback, shareLinkLifetime] = ShareInviteLinkAction(
_peer,
showBoxCallback,
showToastCallback);
uiShow());
_callShareLinkCallback = [=, callback = std::move(shareLinkCallback)] {
if (_call->lookupReal()) {
callback();
@ -1467,6 +1531,10 @@ void Panel::hideLayer(anim::type animated) {
_layerBg->hideAll(animated);
}
bool Panel::isLayerShown() const {
return _layerBg->topShownLayer() != nullptr;
}
void Panel::kickParticipantSure(not_null<PeerData*> participantPeer) {
if (const auto chat = _peer->asChat()) {
chat->session().api().chatParticipants().kick(chat, participantPeer);
@ -2550,38 +2618,4 @@ not_null<Ui::RpWidget*> Panel::widget() const {
return _window.widget();
}
Show::Show(not_null<Panel*> panel)
: _panel(base::make_weak(panel)) {
}
Show::~Show() = default;
void Show::showBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) const {
if (const auto panel = _panel.get()) {
panel->showBox(std::move(content), options);
}
}
void Show::hideLayer() const {
if (const auto panel = _panel.get()) {
panel->hideLayer();
}
}
not_null<QWidget*> Show::toastParent() const {
const auto panel = _panel.get();
Assert(panel != nullptr);
return panel->widget();
}
bool Show::valid() const {
return !_panel.empty();
}
Show::operator bool() const {
return valid();
}
} // namespace Calls::Group

View File

@ -52,14 +52,21 @@ class ScrollArea;
class GenericBox;
class LayerManager;
class GroupCallScheduledLeft;
namespace Toast {
class Instance;
} // namespace Toast
namespace Platform {
struct SeparateTitleControls;
} // namespace Platform
} // namespace Ui
namespace Ui::Toast {
class Instance;
struct Config;
} // namespace Ui::Toast
namespace Ui::Platform {
struct SeparateTitleControls;
} // namespace Ui::Platform
namespace Main {
class SessionShow;
} // namespace Main
namespace style {
struct CallSignalBars;
struct CallBodyLayout;
@ -85,13 +92,22 @@ public:
[[nodiscard]] not_null<GroupCall*> call() const;
[[nodiscard]] bool isActive() const;
void showToast(TextWithEntities &&text, crl::time duration = 0);
base::weak_ptr<Ui::Toast::Instance> showToast(
const QString &text,
crl::time duration = 0);
base::weak_ptr<Ui::Toast::Instance> showToast(
TextWithEntities &&text,
crl::time duration = 0);
base::weak_ptr<Ui::Toast::Instance> showToast(
Ui::Toast::Config &&config);
void showBox(object_ptr<Ui::BoxContent> box);
void showBox(
object_ptr<Ui::BoxContent> box,
Ui::LayerOptions options,
anim::type animated = anim::type::normal);
void hideLayer(anim::type animated = anim::type::normal);
[[nodiscard]] bool isLayerShown() const;
void minimize();
void toggleFullScreen();
@ -99,6 +115,8 @@ public:
void showAndActivate();
void closeBeforeDestroy();
[[nodiscard]] std::shared_ptr<Main::SessionShow> uiShow();
rpl::lifetime &lifetime();
private:
@ -260,7 +278,6 @@ private:
Fn<void()> _callShareLinkCallback;
const std::unique_ptr<Toasts> _toasts;
base::weak_ptr<Ui::Toast::Instance> _lastToast;
std::unique_ptr<MicLevelTester> _micLevelTester;
@ -272,21 +289,4 @@ private:
};
class Show : public Ui::Show {
public:
explicit Show(not_null<Panel*> panel);
~Show();
void showBox(
object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) const override;
void hideLayer() const override;
[[nodiscard]] not_null<QWidget*> toastParent() const override;
[[nodiscard]] bool valid() const override;
operator bool() const override;
private:
const base::weak_ptr<Panel> _panel;
};
} // namespace Calls::Group

View File

@ -151,9 +151,7 @@ void StartRtmpProcess::requestUrl(bool revoke) {
});
processUrl(std::move(data));
}).fail([=] {
Ui::Toast::Show(
_request->show->toastParent(),
Lang::Hard::ServerError());
_request->show->showToast(Lang::Hard::ServerError());
}).send();
}
@ -229,7 +227,7 @@ void StartRtmpProcess::FillRtmpRows(
) | rpl::map([=](const auto &d) { return d.url; });
const auto showToast = [=](const QString &text) {
Ui::Toast::Show(show->toastParent(), text);
show->showToast(text);
};
const auto addButton = [&](
bool key,

View File

@ -20,7 +20,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/popup_menu.h"
#include "ui/wrap/slide_wrap.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "lang/lang_keys.h"
#include "boxes/share_box.h"
#include "history/view/history_view_schedule_box.h"
@ -108,7 +107,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
not_null<PeerData*> peer,
const QString &linkSpeaker,
const QString &linkListener,
Fn<void(QString)> showToast) {
std::shared_ptr<Ui::Show> show) {
const auto sending = std::make_shared<bool>();
const auto box = std::make_shared<QPointer<ShareBox>>();
@ -130,7 +129,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
};
auto copyCallback = [=] {
QGuiApplication::clipboard()->setText(currentLink());
showToast(tr::lng_group_invite_copied(tr::now));
show->showToast(tr::lng_group_invite_copied(tr::now));
};
auto submitCallback = [=](
std::vector<not_null<Data::Thread*>> &&result,
@ -191,7 +190,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
if (*box) {
(*box)->closeBox();
}
showToast(tr::lng_share_done(tr::now));
show->showToast(tr::lng_share_done(tr::now));
};
auto filterCallback = [](not_null<Data::Thread*> thread) {
return Data::CanSend(thread, ChatRestriction::SendOther);
@ -591,15 +590,11 @@ void SettingsBox(
box->getDelegate()->show(std::move(next));
});
const auto showToast = crl::guard(box, [=](QString text) {
Ui::ShowMultilineToast({
.parentOverride = Ui::BoxShow(box).toastParent(),
.text = { text },
});
box->showToast(text);
});
auto [shareLinkCallback, shareLinkLifetime] = ShareInviteLinkAction(
peer,
showBox,
showToast);
box->uiShow());
shareLink = std::move(shareLinkCallback);
box->lifetime().add(std::move(shareLinkLifetime));
} else {
@ -635,10 +630,8 @@ void SettingsBox(
}
QGuiApplication::clipboard()->setText(link);
if (weakBox) {
Ui::ShowMultilineToast({
.parentOverride = Ui::BoxShow(box).toastParent(),
.text = { tr::lng_create_channel_link_copied(tr::now) },
});
box->showToast(
tr::lng_create_channel_link_copied(tr::now));
}
return true;
};
@ -735,7 +728,7 @@ void SettingsBox(
StartRtmpProcess::FillRtmpRows(
layout,
false,
std::make_shared<Ui::BoxShow>(box),
box->uiShow(),
state->data.events(),
&st::groupCallBoxLabel,
&st::groupCallSettingsRtmpShowButton,
@ -795,8 +788,7 @@ void SettingsBox(
std::pair<Fn<void()>, rpl::lifetime> ShareInviteLinkAction(
not_null<PeerData*> peer,
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
Fn<void(QString)> showToast) {
std::shared_ptr<Ui::Show> show) {
auto lifetime = rpl::lifetime();
struct State {
State(not_null<Main::Session*> session) : session(session) {
@ -823,11 +815,11 @@ std::pair<Fn<void()>, rpl::lifetime> ShareInviteLinkAction(
|| state->linkListener.isEmpty()) {
return false;
}
showBox(ShareInviteLinkBox(
show->showBox(ShareInviteLinkBox(
peer,
*state->linkSpeaker,
state->linkListener,
showToast));
show));
return true;
};
auto callback = [=] {

View File

@ -25,8 +25,7 @@ void SettingsBox(
[[nodiscard]] std::pair<Fn<void()>, rpl::lifetime> ShareInviteLinkAction(
not_null<PeerData*> peer,
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
Fn<void(QString)> showToast);
std::shared_ptr<Ui::Show> show);
class MicLevelTester final {
public:

View File

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_peer.h"
#include "data/data_group_call.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/toast/toast.h"
#include "lang/lang_keys.h"
namespace Calls::Group {
@ -83,15 +83,13 @@ void Toasts::setupAllowedToSpeak() {
_call->allowedToSpeakNotifications(
) | rpl::start_with_next([=] {
if (_panel->isActive()) {
_panel->showToast({
tr::lng_group_call_can_speak_here(tr::now),
});
_panel->showToast(tr::lng_group_call_can_speak_here(tr::now));
} else {
const auto real = _call->lookupReal();
const auto name = (real && !real->title().isEmpty())
? real->title()
: _call->peer()->name();
Ui::ShowMultilineToast({
Ui::Toast::Show({
.text = tr::lng_group_call_can_speak(
tr::now,
lt_chat,
@ -139,7 +137,7 @@ void Toasts::setupPinnedVideo() {
: tr::lng_group_call_unpinned_screen);
return key(tr::now, lt_user, peer->shortName());
}();
_panel->showToast({ text });
_panel->showToast(text);
}, _lifetime);
}
@ -148,9 +146,8 @@ void Toasts::setupRequestedToSpeak() {
) | rpl::combine_previous(
) | rpl::start_with_next([=](MuteState was, MuteState now) {
if (was == MuteState::ForceMuted && now == MuteState::RaisedHand) {
_panel->showToast({
tr::lng_group_call_tooltip_raised_hand(tr::now),
});
_panel->showToast(
tr::lng_group_call_tooltip_raised_hand(tr::now));
}
}, _lifetime);
}

View File

@ -0,0 +1,46 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "chat_helpers/compose/compose_show.h"
#include "core/application.h"
#include "main/main_session.h"
#include "window/window_controller.h"
#include "window/window_session_controller.h"
namespace ChatHelpers {
rpl::producer<bool> Show::adjustShadowLeft() const {
return rpl::single(false);
}
Window::SessionController *Show::resolveWindow(WindowUsage usage) const {
const auto session = &this->session();
const auto check = [&](Window::Controller *window) {
if (const auto controller = window->sessionController()) {
if (&controller->session() == session) {
return controller;
}
}
return (Window::SessionController*)nullptr;
};
auto &app = Core::App();
if (const auto a = check(app.activeWindow())) {
return a;
} else if (const auto b = check(app.activePrimaryWindow())) {
return b;
} else if (const auto c = check(app.windowFor(&session->account()))) {
return c;
} else if (const auto d = check(
app.ensureSeparateWindowForAccount(
&session->account()))) {
return d;
}
return nullptr;
}
} // namespace ChatHelpers

View File

@ -0,0 +1,68 @@
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "base/flags.h"
#include "main/session/session_show.h"
class PhotoData;
class DocumentData;
namespace Data {
struct FileOrigin;
} // namespace Data
namespace Window {
class SessionController;
} // namespace Window
namespace SendMenu {
enum class Type;
} // namespace SendMenu
namespace ChatHelpers {
struct FileChosen;
enum class PauseReason {
Any = 0,
InlineResults = (1 << 0),
TabbedPanel = (1 << 1),
Layer = (1 << 2),
RoundPlaying = (1 << 3),
MediaPreview = (1 << 4),
};
using PauseReasons = base::flags<PauseReason>;
inline constexpr bool is_flag_type(PauseReason) { return true; };
enum class WindowUsage {
PremiumPromo,
};
class Show : public Main::SessionShow {
public:
[[nodiscard]] virtual bool paused(PauseReason reason) const = 0;
[[nodiscard]] virtual rpl::producer<> pauseChanged() const = 0;
[[nodiscard]] virtual rpl::producer<bool> adjustShadowLeft() const;
[[nodiscard]] virtual SendMenu::Type sendMenuType() const = 0;
virtual bool showMediaPreview(
Data::FileOrigin origin,
not_null<DocumentData*> document) const = 0;
virtual bool showMediaPreview(
Data::FileOrigin origin,
not_null<PhotoData*> photo) const = 0;
virtual void processChosenSticker(FileChosen chosen) const = 0;
[[nodiscard]] virtual Window::SessionController *resolveWindow(
WindowUsage) const;
};
} // namespace ChatHelpers

View File

@ -370,12 +370,11 @@ void EmojiColorPicker::drawVariant(QPainter &p, int variant) {
EmojiListWidget::EmojiListWidget(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level,
PauseReason level,
Mode mode)
: EmojiListWidget(parent, {
.session = &controller->session(),
.show = controller->uiShow(),
.mode = mode,
.controller = controller,
.paused = Window::PausedIn(controller, level),
}) {
}
@ -386,9 +385,9 @@ EmojiListWidget::EmojiListWidget(
: Inner(
parent,
descriptor.st ? *descriptor.st : st::defaultEmojiPan,
descriptor.session,
descriptor.show,
std::move(descriptor.paused))
, _controller(descriptor.controller)
, _show(std::move(descriptor.show))
, _mode(descriptor.mode)
, _staticCount(_mode == Mode::Full ? kEmojiSectionCount : 1)
, _premiumIcon(_mode == Mode::EmojiStatus
@ -466,7 +465,7 @@ EmojiListWidget::~EmojiListWidget() {
}
void EmojiListWidget::setupSearch() {
const auto session = &_controller->session();
const auto session = &_show->session();
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
_nextSearchQuery = std::move(query);
InvokeQueued(this, [=] {
@ -1419,26 +1418,27 @@ void EmojiListWidget::mouseReleaseEvent(QMouseEvent *e) {
Assert(button->section >= _staticCount
&& button->section < _staticCount + _custom.size());
const auto id = _custom[button->section - _staticCount].id;
const auto usage = ChatHelpers::WindowUsage::PremiumPromo;
if (hasRemoveButton(button->section)) {
removeSet(id);
} else if (hasAddButton(button->section)) {
_localSetsManager->install(id);
} else if (_controller) {
} else if (const auto resolved = _show->resolveWindow(usage)) {
_jumpedToPremium.fire({});
switch (_mode) {
case Mode::Full:
case Mode::UserpicBuilder:
Settings::ShowPremium(_controller, u"animated_emoji"_q);
Settings::ShowPremium(resolved, u"animated_emoji"_q);
break;
case Mode::FullReactions:
case Mode::RecentReactions:
Settings::ShowPremium(_controller, u"infinite_reactions"_q);
Settings::ShowPremium(resolved, u"infinite_reactions"_q);
break;
case Mode::EmojiStatus:
Settings::ShowPremium(_controller, u"emoji_status"_q);
Settings::ShowPremium(resolved, u"emoji_status"_q);
break;
case Mode::TopicIcon:
Settings::ShowPremium(_controller, u"forum_topic_icon"_q);
Settings::ShowPremium(resolved, u"forum_topic_icon"_q);
break;
}
}
@ -1448,20 +1448,14 @@ void EmojiListWidget::mouseReleaseEvent(QMouseEvent *e) {
void EmojiListWidget::displaySet(uint64 setId) {
const auto &sets = session().data().stickers().sets();
auto it = sets.find(setId);
if (it != sets.cend() && _controller) {
checkHideWithBox(_controller->show(
Box<StickerSetBox>(_controller, it->second.get()),
Ui::LayerOption::KeepOther).data());
if (it != sets.cend()) {
checkHideWithBox(Box<StickerSetBox>(_show, it->second.get()));
}
}
void EmojiListWidget::removeSet(uint64 setId) {
if (auto box = MakeConfirmRemoveSetBox(&session(), setId)) {
if (_controller) {
checkHideWithBox(_controller->show(
std::move(box),
Ui::LayerOption::KeepOther));
}
checkHideWithBox(std::move(box));
}
}

View File

@ -76,9 +76,8 @@ enum class EmojiListMode {
};
struct EmojiListDescriptor {
not_null<Main::Session*> session;
std::shared_ptr<Show> show;
EmojiListMode mode = EmojiListMode::Full;
Window::SessionController *controller = nullptr;
Fn<bool()> paused;
std::vector<DocumentId> customRecentList;
Fn<std::unique_ptr<Ui::Text::CustomEmoji>(
@ -87,7 +86,7 @@ struct EmojiListDescriptor {
const style::EmojiPan *st = nullptr;
};
class EmojiListWidget
class EmojiListWidget final
: public TabbedSelector::Inner
, public Ui::AbstractTooltipShower {
public:
@ -96,7 +95,7 @@ public:
EmojiListWidget(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level,
PauseReason level,
Mode mode);
EmojiListWidget(QWidget *parent, EmojiListDescriptor &&descriptor);
~EmojiListWidget();
@ -345,7 +344,7 @@ private:
void applyNextSearchQuery();
Window::SessionController *_controller = nullptr;
const std::shared_ptr<Show> _show;
Mode _mode = Mode::Full;
std::unique_ptr<Ui::TabbedSearch> _search;
const int _staticCount = 0;

View File

@ -51,11 +51,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include <QtWidgets/QApplication>
namespace {
[[nodiscard]] QString PrimaryUsername(not_null<UserData*> user) {
const auto &usernames = user->usernames();
return usernames.empty() ? user->username() : usernames.front();
}
} // namespace
class FieldAutocomplete::Inner final : public Ui::RpWidget {
public:
struct ScrollTo {
@ -64,7 +68,7 @@ public:
};
Inner(
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<FieldAutocomplete*> parent,
not_null<MentionRows*> mrows,
not_null<HashtagRows*> hrows,
@ -120,7 +124,8 @@ private:
Media::Clip::Notification notification,
not_null<DocumentData*> document);
const not_null<Window::SessionController*> _controller;
const std::shared_ptr<ChatHelpers::Show> _show;
const not_null<Main::Session*> _session;
const not_null<FieldAutocomplete*> _parent;
const not_null<MentionRows*> _mrows;
const not_null<HashtagRows*> _hrows;
@ -140,7 +145,7 @@ private:
bool _previewShown = false;
bool _isOneColumn = false;
bool _adjustShadowLeft = false;
const std::unique_ptr<Ui::PathShiftGradient> _pathGradient;
StickerPremiumMark _premiumMark;
@ -182,8 +187,15 @@ struct FieldAutocomplete::BotCommandRow {
FieldAutocomplete::FieldAutocomplete(
QWidget *parent,
not_null<Window::SessionController*> controller)
: FieldAutocomplete(parent, controller->uiShow()) {
}
FieldAutocomplete::FieldAutocomplete(
QWidget *parent,
std::shared_ptr<ChatHelpers::Show> show)
: RpWidget(parent)
, _controller(controller)
, _show(std::move(show))
, _session(&_show->session())
, _scroll(this) {
hide();
@ -191,7 +203,7 @@ FieldAutocomplete::FieldAutocomplete(
_inner = _scroll->setOwnedWidget(
object_ptr<Inner>(
_controller,
_show,
this,
&_mrows,
&_hrows,
@ -215,8 +227,8 @@ FieldAutocomplete::FieldAutocomplete(
}), lifetime());
}
not_null<Window::SessionController*> FieldAutocomplete::controller() const {
return _controller;
std::shared_ptr<ChatHelpers::Show> FieldAutocomplete::uiShow() const {
return _show;
}
auto FieldAutocomplete::mentionChosen() const
@ -365,7 +377,7 @@ inline int indexOfInFirstN(const T &v, const U &elem, int last) {
}
FieldAutocomplete::StickerRows FieldAutocomplete::getStickerSuggestions() {
const auto data = &_controller->session().data().stickers();
const auto data = &_session->data().stickers();
const auto list = data->getListByEmoji({ _emoji }, _stickersSeed);
auto result = ranges::views::all(
list
@ -804,13 +816,14 @@ bool FieldAutocomplete::eventFilter(QObject *obj, QEvent *e) {
}
FieldAutocomplete::Inner::Inner(
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<FieldAutocomplete*> parent,
not_null<MentionRows*> mrows,
not_null<HashtagRows*> hrows,
not_null<BotCommandRows*> brows,
not_null<StickerRows*> srows)
: _controller(controller)
: _show(std::move(show))
, _session(&_show->session())
, _parent(parent)
, _mrows(mrows)
, _hrows(hrows)
@ -820,16 +833,16 @@ FieldAutocomplete::Inner::Inner(
st::windowBgRipple,
st::windowBgOver,
[=] { update(); }))
, _premiumMark(&controller->session())
, _premiumMark(_session)
, _previewTimer([=] { showPreview(); }) {
controller->session().downloaderTaskFinished(
_session->downloaderTaskFinished(
) | rpl::start_with_next([=] {
update();
}, lifetime());
controller->adaptive().value(
) | rpl::start_with_next([=] {
_isOneColumn = controller->adaptive().isOneColumn();
_show->adjustShadowLeft(
) | rpl::start_with_next([=](bool adjust) {
_adjustShadowLeft = adjust;
update();
}, lifetime());
}
@ -891,8 +904,8 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) {
}
media->checkStickerSmall();
const auto paused = _controller->isGifPausedAtLeastFor(
Window::GifPauseReason::TabbedPanel);
const auto paused = _show->paused(
ChatHelpers::PauseReason::TabbedPanel);
const auto size = ChatHelpers::ComputeStickerSize(
document,
stickerBoundingBox());
@ -1062,9 +1075,19 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) {
}
}
}
p.fillRect(_isOneColumn ? 0 : st::lineWidth, _parent->innerBottom() - st::lineWidth, width() - (_isOneColumn ? 0 : st::lineWidth), st::lineWidth, st::shadowFg);
p.fillRect(
_adjustShadowLeft ? st::lineWidth : 0,
_parent->innerBottom() - st::lineWidth,
width() - (_adjustShadowLeft ? st::lineWidth : 0),
st::lineWidth,
st::shadowFg);
}
p.fillRect(_isOneColumn ? 0 : st::lineWidth, _parent->innerTop(), width() - (_isOneColumn ? 0 : st::lineWidth), st::lineWidth, st::shadowFg);
p.fillRect(
_adjustShadowLeft ? st::lineWidth : 0,
_parent->innerTop(),
width() - (_adjustShadowLeft ? st::lineWidth : 0),
st::lineWidth,
st::shadowFg);
}
void FieldAutocomplete::Inner::resizeEvent(QResizeEvent *e) {
@ -1158,7 +1181,7 @@ bool FieldAutocomplete::Inner::chooseAtIndex(
contentRect.moveCenter(bounding.center());
return {
Ui::MessageSendingAnimationFrom::Type::Sticker,
_controller->session().data().nextLocalMessageId(),
_show->session().data().nextLocalMessageId(),
mapToGlobal(std::move(contentRect)),
};
};
@ -1231,7 +1254,7 @@ void FieldAutocomplete::Inner::mousePressEvent(QMouseEvent *e) {
}
}
if (removed) {
_controller->session().local().writeRecentHashtagsAndBots();
_show->session().local().writeRecentHashtagsAndBots();
}
_parent->updateFiltered();
@ -1483,11 +1506,7 @@ void FieldAutocomplete::Inner::selectByMouse(QPoint globalPosition) {
setSel(sel);
if (_down >= 0 && _sel >= 0 && _down != _sel) {
_down = _sel;
if (_down >= 0 && _down < _srows->size()) {
_controller->widget()->showMediaPreview(
(*_srows)[_down].document->stickerSetOrigin(),
(*_srows)[_down].document);
}
showPreview();
}
}
}
@ -1504,9 +1523,8 @@ void FieldAutocomplete::Inner::onParentGeometryChanged() {
void FieldAutocomplete::Inner::showPreview() {
if (_down >= 0 && _down < _srows->size()) {
_controller->widget()->showMediaPreview(
(*_srows)[_down].document->stickerSetOrigin(),
(*_srows)[_down].document);
const auto document = (*_srows)[_down].document;
_show->showMediaPreview(document->stickerSetOrigin(), document);
_previewShown = true;
}
}

View File

@ -25,6 +25,10 @@ class SinglePlayer;
class FrameRenderer;
} // namespace Lottie;
namespace Main {
class Session;
} // namespace Main
namespace Window {
class SessionController;
} // namespace Window
@ -39,6 +43,7 @@ enum class Type;
namespace ChatHelpers {
struct FileChosen;
class Show;
} // namespace ChatHelpers
class FieldAutocomplete final : public Ui::RpWidget {
@ -46,9 +51,12 @@ public:
FieldAutocomplete(
QWidget *parent,
not_null<Window::SessionController*> controller);
FieldAutocomplete(
QWidget *parent,
std::shared_ptr<ChatHelpers::Show> show);
~FieldAutocomplete();
[[nodiscard]] not_null<Window::SessionController*> controller() const;
[[nodiscard]] std::shared_ptr<ChatHelpers::Show> uiShow() const;
bool clearFilteredBotCommands();
void showFiltered(
@ -112,6 +120,8 @@ public:
void setSendMenuType(Fn<SendMenu::Type()> &&callback);
void hideFast();
void showAnimated();
void hideAnimated();
rpl::producer<MentionChosen> mentionChosen() const;
rpl::producer<HashtagChosen> hashtagChosen() const;
@ -119,10 +129,6 @@ public:
rpl::producer<StickerChosen> stickerChosen() const;
rpl::producer<Type> choosingProcesses() const;
public Q_SLOTS:
void showAnimated();
void hideAnimated();
protected:
void paintEvent(QPaintEvent *e) override;
@ -145,7 +151,8 @@ private:
void recount(bool resetScroll = false);
StickerRows getStickerSuggestions();
const not_null<Window::SessionController*> _controller;
const std::shared_ptr<ChatHelpers::Show> _show;
const not_null<Main::Session*> _session;
QPixmap _cache;
MentionRows _mrows;
HashtagRows _hrows;

View File

@ -56,7 +56,7 @@ constexpr auto kMinAfterScrollDelay = crl::time(33);
void AddGifAction(
Fn<void(QString, Fn<void()> &&, const style::icon*)> callback,
Window::SessionController *controller,
std::shared_ptr<Show> show,
not_null<DocumentData*> document) {
if (!document->isGifv()) {
return;
@ -69,7 +69,7 @@ void AddGifAction(
: tr::lng_context_save_gif)(tr::now);
callback(text, [=] {
Api::ToggleSavedGif(
controller,
show,
document,
Data::FileOriginSavedGifs(),
!saved);
@ -86,13 +86,22 @@ void AddGifAction(
GifsListWidget::GifsListWidget(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level)
PauseReason level)
: GifsListWidget(parent, {
.show = controller->uiShow(),
.paused = Window::PausedIn(controller, level),
}) {
}
GifsListWidget::GifsListWidget(
QWidget *parent,
GifsListDescriptor &&descriptor)
: Inner(
parent,
st::defaultEmojiPan,
&controller->session(),
Window::PausedIn(controller, level))
, _controller(controller)
descriptor.show,
descriptor.paused)
, _show(std::move(descriptor.show))
, _api(&session().mtp())
, _section(Section::Gifs)
, _updateInlineItems([=] { updateInlineItems(); })
@ -120,7 +129,7 @@ GifsListWidget::GifsListWidget(
updateInlineItems();
}, lifetime());
controller->gifPauseLevelChanged(
_show->pauseChanged(
) | rpl::start_with_next([=] {
if (!paused()) {
updateInlineItems();
@ -395,7 +404,7 @@ base::unique_qptr<Ui::PopupMenu> GifsListWidget::fillContextMenu(
const style::icon *icon) {
menu->addAction(text, std::move(done), icon);
};
AddGifAction(std::move(callback), _controller, document);
AddGifAction(std::move(callback), _show, document);
}
}
return menu;
@ -425,7 +434,7 @@ void GifsListWidget::mouseReleaseEvent(QMouseEvent *e) {
ActivateClickHandler(window(), activated, {
e->button(),
QVariant::fromValue(ClickHandlerContext{
.sessionWindow = base::make_weak(_controller),
.show = _show,
})
});
}
@ -794,7 +803,7 @@ bool GifsListWidget::refreshInlineRows(int32 *added) {
}
void GifsListWidget::setupSearch() {
const auto session = &_controller->session();
const auto session = &_show->session();
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
const auto accumulated = ranges::accumulate(query, QString(), [](
QString a,
@ -939,13 +948,11 @@ void GifsListWidget::updateSelected() {
_pressed = _selected;
if (item) {
if (const auto preview = item->getPreviewDocument()) {
_controller->widget()->showMediaPreview(
_show->showMediaPreview(
Data::FileOriginSavedGifs(),
preview);
} else if (const auto preview = item->getPreviewPhoto()) {
_controller->widget()->showMediaPreview(
Data::FileOrigin(),
preview);
_show->showMediaPreview(Data::FileOrigin(), preview);
}
}
}
@ -961,11 +968,11 @@ void GifsListWidget::showPreview() {
}
if (const auto layout = _mosaic.maybeItemAt(_pressed)) {
if (const auto previewDocument = layout->getPreviewDocument()) {
_previewShown = _controller->widget()->showMediaPreview(
_previewShown = _show->showMediaPreview(
Data::FileOriginSavedGifs(),
previewDocument);
} else if (const auto previewPhoto = layout->getPreviewPhoto()) {
_previewShown = _controller->widget()->showMediaPreview(
_previewShown = _show->showMediaPreview(
Data::FileOrigin(),
previewPhoto);
}

View File

@ -47,21 +47,28 @@ namespace ChatHelpers {
void AddGifAction(
Fn<void(QString, Fn<void()> &&, const style::icon*)> callback,
Window::SessionController *controller,
std::shared_ptr<Show> show,
not_null<DocumentData*> document);
class StickersListFooter;
struct StickerIcon;
struct GifSection;
class GifsListWidget
struct GifsListDescriptor {
std::shared_ptr<Show> show;
Fn<bool()> paused;
const style::EmojiPan *st = nullptr;
};
class GifsListWidget final
: public TabbedSelector::Inner
, public InlineBots::Layout::Context {
public:
GifsListWidget(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level);
PauseReason level);
GifsListWidget(QWidget *parent, GifsListDescriptor &&descriptor);
rpl::producer<FileChosen> fileChosen() const;
rpl::producer<PhotoChosen> photoChosen() const;
@ -162,7 +169,7 @@ private:
Api::SendOptions options,
bool forceSend = false);
not_null<Window::SessionController*> _controller;
const std::shared_ptr<Show> _show;
std::unique_ptr<Ui::TabbedSearch> _search;
MTP::Sender _api;

View File

@ -125,8 +125,7 @@ QString FieldTagMimeProcessor::operator()(QStringView mimeTag) {
void EditLinkBox(
not_null<Ui::GenericBox*> box,
std::shared_ptr<Ui::Show> show,
not_null<Main::Session*> session,
std::shared_ptr<Main::SessionShow> show,
const QString &startText,
const QString &startLink,
Fn<void(QString, QString)> callback,
@ -149,8 +148,8 @@ void EditLinkBox(
Ui::Emoji::SuggestionsController::Init(
box->getDelegate()->outerContainer(),
text,
session);
InitSpellchecker(std::move(show), session, text, fieldStyle != nullptr);
&show->session());
InitSpellchecker(show, text, fieldStyle != nullptr);
const auto placeholder = content->add(
object_ptr<Ui::RpWidget>(content),
@ -284,8 +283,7 @@ Fn<bool(
QString text,
QString link,
EditLinkAction action)> DefaultEditLinkCallback(
std::shared_ptr<Ui::Show> show,
not_null<Main::Session*> session,
std::shared_ptr<Main::SessionShow> show,
not_null<Ui::InputField*> field,
const style::InputField *fieldStyle) {
const auto weak = Ui::MakeWeak(field);
@ -303,23 +301,20 @@ Fn<bool(
strong->commitMarkdownLinkEdit(selection, text, link);
}
};
show->showBox(
Box(
EditLinkBox,
show,
session,
text,
link,
std::move(callback),
fieldStyle),
Ui::LayerOption::KeepOther);
show->showBox(Box(
EditLinkBox,
show,
text,
link,
std::move(callback),
fieldStyle));
return true;
};
}
void InitMessageFieldHandlers(
not_null<Main::Session*> session,
std::shared_ptr<Ui::Show> show,
std::shared_ptr<Main::SessionShow> show,
not_null<Ui::InputField*> field,
Fn<bool()> customEmojiPaused,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji,
@ -338,19 +333,19 @@ void InitMessageFieldHandlers(
field->setMarkdownReplacesEnabled(rpl::single(true));
if (show) {
field->setEditLinkCallback(
DefaultEditLinkCallback(show, session, field, fieldStyle));
InitSpellchecker(show, session, field, fieldStyle != nullptr);
DefaultEditLinkCallback(show, field, fieldStyle));
InitSpellchecker(show, field, fieldStyle != nullptr);
}
}
void InitMessageFieldHandlers(
not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field,
Window::GifPauseReason pauseReasonLevel,
ChatHelpers::PauseReason pauseReasonLevel,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji) {
InitMessageFieldHandlers(
&controller->session(),
std::make_shared<Window::Show>(controller),
controller->uiShow(),
field,
[=] { return controller->isGifPausedAtLeastFor(pauseReasonLevel); },
allowPremiumEmoji);
@ -366,25 +361,36 @@ void InitMessageFieldGeometry(not_null<Ui::InputField*> field) {
}
void InitMessageField(
not_null<Window::SessionController*> controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::InputField*> field,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji) {
InitMessageFieldHandlers(
controller,
&show->session(),
show,
field,
Window::GifPauseReason::Any,
allowPremiumEmoji);
[=] { return show->paused(ChatHelpers::PauseReason::Any); },
std::move(allowPremiumEmoji));
InitMessageFieldGeometry(field);
field->customTab(true);
}
void InitMessageField(
not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji) {
return InitMessageField(
controller->uiShow(),
field,
std::move(allowPremiumEmoji));
}
void InitSpellchecker(
std::shared_ptr<Ui::Show> show,
not_null<Main::Session*> session,
std::shared_ptr<Main::SessionShow> show,
not_null<Ui::InputField*> field,
bool skipDictionariesManager) {
#ifndef TDESKTOP_DISABLE_SPELLCHECK
using namespace Spellchecker;
const auto session = &show->session();
const auto menuItem = skipDictionariesManager
? std::nullopt
: std::make_optional(SpellingHighlighter::CustomContextMenuItem{
@ -856,7 +862,7 @@ base::unique_qptr<Ui::RpWidget> CreateDisabledFieldView(
*toast = Ui::Toast::Show(parent, {
.text = { tr::lng_send_text_no_about(tr::now, lt_types, types) },
.st = &st::defaultMultilineToast,
.durationMs = kTypesDuration,
.duration = kTypesDuration,
.multiline = true,
.slideSide = RectPart::Bottom,
});

View File

@ -20,16 +20,20 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
namespace Main {
class Session;
class SessionShow;
} // namespace Main
namespace Window {
class SessionController;
enum class GifPauseReason;
} // namespace Window
namespace ChatHelpers {
enum class PauseReason;
class Show;
} // namespace ChatHelpers
namespace Ui {
class PopupMenu;
class Show;
} // namespace Ui
QString PrepareMentionTag(not_null<UserData*> user);
@ -40,13 +44,12 @@ Fn<bool(
QString text,
QString link,
Ui::InputField::EditLinkAction action)> DefaultEditLinkCallback(
std::shared_ptr<Ui::Show> show,
not_null<Main::Session*> session,
std::shared_ptr<Main::SessionShow> show,
not_null<Ui::InputField*> field,
const style::InputField *fieldStyle = nullptr);
void InitMessageFieldHandlers(
not_null<Main::Session*> session,
std::shared_ptr<Ui::Show> show,
std::shared_ptr<Main::SessionShow> show, // may be null
not_null<Ui::InputField*> field,
Fn<bool()> customEmojiPaused,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji = nullptr,
@ -54,16 +57,19 @@ void InitMessageFieldHandlers(
void InitMessageFieldHandlers(
not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field,
Window::GifPauseReason pauseReasonLevel,
ChatHelpers::PauseReason pauseReasonLevel,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji = nullptr);
void InitMessageField(
std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::InputField*> field,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji);
void InitMessageField(
not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji);
void InitSpellchecker(
std::shared_ptr<Ui::Show> show,
not_null<Main::Session*> session,
std::shared_ptr<Main::SessionShow> show,
not_null<Ui::InputField*> field,
bool skipDictionariesManager = false);

View File

@ -165,19 +165,29 @@ void StickersListWidget::Sticker::ensureMediaCreated() {
StickersListWidget::StickersListWidget(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level,
PauseReason level,
Mode mode)
: StickersListWidget(parent, {
.show = controller->uiShow(),
.mode = mode,
.paused = Window::PausedIn(controller, level),
}) {
}
StickersListWidget::StickersListWidget(
QWidget *parent,
StickersListDescriptor &&descriptor)
: Inner(
parent,
st::defaultEmojiPan,
&controller->session(),
Window::PausedIn(controller, level))
, _mode(mode)
, _controller(controller)
descriptor.show,
descriptor.paused)
, _mode(descriptor.mode)
, _show(std::move(descriptor.show))
, _api(&session().mtp())
, _localSetsManager(std::make_unique<LocalStickersManager>(&session()))
, _section(Section::Stickers)
, _isMasks(mode == Mode::Masks)
, _isMasks(_mode == Mode::Masks)
, _updateItemsTimer([=] { updateItems(); })
, _updateSetsTimer([=] { updateSets(); })
, _trendingAddBgOver(
@ -210,9 +220,8 @@ StickersListWidget::StickersListWidget(
_settings->addClickHandler([=] {
using Section = StickersBox::Section;
controller->show(
Box<StickersBox>(controller, Section::Installed, _isMasks),
Ui::LayerOption::KeepOther);
_show->showBox(
Box<StickersBox>(_show, Section::Installed, _isMasks));
});
session().downloaderTaskFinished(
@ -287,15 +296,14 @@ object_ptr<TabbedSelector::InnerFooter> StickersListWidget::createFooter() {
_footer->openSettingsRequests(
) | rpl::start_with_next([=] {
const auto onlyFeatured = _footer->hasOnlyFeaturedSets();
_controller->show(Box<StickersBox>(
_controller,
_show->showBox(Box<StickersBox>(
_show,
(onlyFeatured
? StickersBox::Section::Featured
: _isMasks
? StickersBox::Section::Masks
: StickersBox::Section::Installed),
onlyFeatured ? false : _isMasks),
Ui::LayerOption::KeepOther);
onlyFeatured ? false : _isMasks));
}, _footer->lifetime());
return result;
@ -1569,7 +1577,10 @@ QPoint StickersListWidget::buttonRippleTopLeft(int section) const {
void StickersListWidget::showStickerSetBox(not_null<DocumentData*> document) {
if (document->sticker() && document->sticker()->set) {
checkHideWithBox(StickerSetBox::Show(_controller, document));
checkHideWithBox(Box<StickerSetBox>(
_show,
document->sticker()->set,
document->sticker()->setType));
}
}
@ -1611,10 +1622,10 @@ base::unique_qptr<Ui::PopupMenu> StickersListWidget::fillContextMenu(
SendMenu::DefaultScheduleCallback(this, type, send),
SendMenu::DefaultWhenOnlineCallback(send));
const auto window = _controller;
const auto show = _show;
const auto toggleFavedSticker = [=] {
Api::ToggleFavedSticker(
window,
show,
document,
Data::FileOriginStickerSet(Data::Stickers::FavedSetId, 0));
};
@ -1716,7 +1727,7 @@ void StickersListWidget::mouseReleaseEvent(QMouseEvent *e) {
removeSet(sets[button->section].id);
}
} else if (std::get_if<OverGroupAdd>(&pressed)) {
_controller->show(Box<StickersBox>(_controller, _megagroupSet));
_show->showBox(Box<StickersBox>(_show, _megagroupSet));
}
}
}
@ -1774,9 +1785,9 @@ void StickersListWidget::removeFavedSticker(int section, int index) {
clearSelection();
const auto &sticker = _mySets[section].stickers[index];
const auto document = sticker.document;
session().data().stickers().setFaved(_controller, document, false);
session().data().stickers().setFaved(_show, document, false);
Api::ToggleFavedSticker(
_controller,
_show,
document,
Data::FileOriginStickerSet(Data::Stickers::FavedSetId, 0),
false);
@ -2427,9 +2438,7 @@ void StickersListWidget::setSelected(OverState newSelected) {
const auto &set = sets[sticker->section];
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
const auto document = set.stickers[sticker->index].document;
_controller->widget()->showMediaPreview(
document->stickerSetOrigin(),
document);
_show->showMediaPreview(document->stickerSetOrigin(), document);
}
}
}
@ -2442,9 +2451,7 @@ void StickersListWidget::showPreview() {
const auto &set = sets[sticker->section];
Assert(sticker->index >= 0 && sticker->index < set.stickers.size());
const auto document = set.stickers[sticker->index].document;
_controller->widget()->showMediaPreview(
document->stickerSetOrigin(),
document);
_show->showMediaPreview(document->stickerSetOrigin(), document);
_previewShown = true;
}
}
@ -2565,7 +2572,7 @@ void StickersListWidget::beforeHiding() {
}
void StickersListWidget::setupSearch() {
const auto session = &_controller->session();
const auto session = &_show->session();
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
auto set = base::flat_set<EmojiPtr>();
auto text = ranges::accumulate(query, QString(), [](
@ -2580,9 +2587,7 @@ void StickersListWidget::setupSearch() {
void StickersListWidget::displaySet(uint64 setId) {
if (setId == Data::Stickers::MegagroupSetId) {
if (_megagroupSet->canEditStickers()) {
checkHideWithBox(_controller->show(
Box<StickersBox>(_controller, _megagroupSet),
Ui::LayerOption::KeepOther).data());
checkHideWithBox(Box<StickersBox>(_show, _megagroupSet));
return;
} else if (_megagroupSet->mgInfo->stickerSet.id) {
setId = _megagroupSet->mgInfo->stickerSet.id;
@ -2593,9 +2598,7 @@ void StickersListWidget::displaySet(uint64 setId) {
const auto &sets = session().data().stickers().sets();
auto it = sets.find(setId);
if (it != sets.cend()) {
checkHideWithBox(_controller->show(
Box<StickerSetBox>(_controller, it->second.get()),
Ui::LayerOption::KeepOther).data());
checkHideWithBox(Box<StickerSetBox>(_show, it->second.get()));
}
}
@ -2606,10 +2609,7 @@ void StickersListWidget::removeMegagroupSet(bool locally) {
refreshStickers();
return;
}
const auto cancelled = [](Fn<void()> &&close) {
close();
};
checkHideWithBox(_controller->show(Ui::MakeConfirmBox({
checkHideWithBox(Ui::MakeConfirmBox({
.text = tr::lng_stickers_remove_group_set(),
.confirmed = crl::guard(this, [this, group = _megagroupSet](
Fn<void()> &&close) {
@ -2620,8 +2620,8 @@ void StickersListWidget::removeMegagroupSet(bool locally) {
}
close();
}),
.cancelled = cancelled,
})));
.cancelled = [](Fn<void()> &&close) { close(); },
}));
}
void StickersListWidget::removeSet(uint64 setId) {
@ -2633,9 +2633,7 @@ void StickersListWidget::removeSet(uint64 setId) {
|| !_megagroupSet->canEditStickers();
removeMegagroupSet(removeLocally);
} else if (auto box = MakeConfirmRemoveSetBox(&session(), setId)) {
checkHideWithBox(_controller->show(
std::move(box),
Ui::LayerOption::KeepOther));
checkHideWithBox(std::move(box));
}
}

View File

@ -65,6 +65,13 @@ enum class StickersListMode {
UserpicBuilder,
};
struct StickersListDescriptor {
std::shared_ptr<Show> show;
StickersListMode mode = StickersListMode::Full;
Fn<bool()> paused;
const style::EmojiPan *st = nullptr;
};
class StickersListWidget final : public TabbedSelector::Inner {
public:
using Mode = StickersListMode;
@ -72,8 +79,11 @@ public:
StickersListWidget(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level,
PauseReason level,
Mode mode = Mode::Full);
StickersListWidget(
QWidget *parent,
StickersListDescriptor &&descriptor);
rpl::producer<FileChosen> chosen() const;
rpl::producer<> scrollUpdated() const;
@ -340,8 +350,7 @@ private:
not_null<DocumentData*> document);
const Mode _mode;
not_null<Window::SessionController*> _controller;
const std::shared_ptr<Show> _show;
std::unique_ptr<Ui::TabbedSearch> _search;
MTP::Sender _api;
std::unique_ptr<LocalStickersManager> _localSetsManager;

View File

@ -37,25 +37,31 @@ TabbedPanel::TabbedPanel(
QWidget *parent,
not_null<Window::SessionController*> controller,
not_null<TabbedSelector*> selector)
: TabbedPanel(parent, controller, { nullptr }, selector) {
: TabbedPanel(parent, {
.regularWindow = controller,
.nonOwnedSelector = selector,
}) {
}
TabbedPanel::TabbedPanel(
QWidget *parent,
not_null<Window::SessionController*> controller,
object_ptr<TabbedSelector> selector)
: TabbedPanel(parent, controller, std::move(selector), nullptr) {
: TabbedPanel(parent, {
.regularWindow = controller,
.ownedSelector = std::move(selector),
}) {
}
TabbedPanel::TabbedPanel(
QWidget *parent,
not_null<Window::SessionController*> controller,
object_ptr<TabbedSelector> ownedSelector,
TabbedSelector *nonOwnedSelector)
TabbedPanelDescriptor &&descriptor)
: RpWidget(parent)
, _controller(controller)
, _ownedSelector(std::move(ownedSelector))
, _selector(nonOwnedSelector ? nonOwnedSelector : _ownedSelector.data())
, _regularWindow(descriptor.regularWindow)
, _ownedSelector(std::move(descriptor.ownedSelector))
, _selector(descriptor.nonOwnedSelector
? descriptor.nonOwnedSelector
: _ownedSelector.data())
, _heightRatio(st::emojiPanHeightRatio)
, _minContentHeight(st::emojiPanMinHeight)
, _maxContentHeight(st::emojiPanMaxHeight) {
@ -64,17 +70,25 @@ TabbedPanel::TabbedPanel(
_selector->setParent(this);
_selector->setRoundRadius(st::emojiPanRadius);
_selector->setAfterShownCallback([=](SelectorTab tab) {
_controller->enableGifPauseReason(_selector->level());
if (_regularWindow) {
_regularWindow->enableGifPauseReason(_selector->level());
}
_pauseAnimations.fire(true);
});
_selector->setBeforeHidingCallback([=](SelectorTab tab) {
_controller->disableGifPauseReason(_selector->level());
if (_regularWindow) {
_regularWindow->disableGifPauseReason(_selector->level());
}
_pauseAnimations.fire(false);
});
_selector->showRequests(
) | rpl::start_with_next([=] {
showFromSelector();
}, lifetime());
resize(QRect(0, 0, st::emojiPanWidth, st::emojiPanMaxHeight).marginsAdded(innerPadding()).size());
resize(
QRect(0, 0, st::emojiPanWidth, st::emojiPanMaxHeight).marginsAdded(
innerPadding()).size());
_contentMaxHeight = st::emojiPanMaxHeight;
_contentHeight = _contentMaxHeight;
@ -122,6 +136,10 @@ not_null<TabbedSelector*> TabbedPanel::selector() const {
return _selector;
}
rpl::producer<bool> TabbedPanel::pauseAnimations() const {
return _pauseAnimations.events();
}
bool TabbedPanel::isSelectorStolen() const {
return (_selector->parent() != this);
}
@ -478,8 +496,8 @@ bool TabbedPanel::overlaps(const QRect &globalRect) const {
TabbedPanel::~TabbedPanel() {
hideFast();
if (!_ownedSelector) {
_controller->takeTabbedSelectorOwnershipFrom(this);
if (!_ownedSelector && _regularWindow) {
_regularWindow->takeTabbedSelectorOwnershipFrom(this);
}
}

View File

@ -26,6 +26,12 @@ class TabbedSelector;
extern const char kOptionTabbedPanelShowOnClick[];
struct TabbedPanelDescriptor {
Window::SessionController *regularWindow = nullptr;
object_ptr<TabbedSelector> ownedSelector = { nullptr };
TabbedSelector *nonOwnedSelector = nullptr;
};;
class TabbedPanel : public Ui::RpWidget {
public:
TabbedPanel(
@ -36,9 +42,11 @@ public:
QWidget *parent,
not_null<Window::SessionController*> controller,
object_ptr<TabbedSelector> selector);
TabbedPanel(QWidget *parent, TabbedPanelDescriptor &&descriptor);
[[nodiscard]] bool isSelectorStolen() const;
[[nodiscard]] not_null<TabbedSelector*> selector() const;
[[nodiscard]] rpl::producer<bool> pauseAnimations() const;
void moveBottomRight(int bottom, int right);
void moveTopRight(int top, int right);
@ -71,12 +79,6 @@ protected:
bool eventFilter(QObject *obj, QEvent *e) override;
private:
TabbedPanel(
QWidget *parent,
not_null<Window::SessionController*> controller,
object_ptr<TabbedSelector> ownedSelector,
TabbedSelector *nonOwnedSelector);
void hideByTimerOrLeave();
void moveHorizontally();
void showFromSelector();
@ -99,9 +101,10 @@ private:
bool preventAutoHide() const;
void updateContentHeight();
const not_null<Window::SessionController*> _controller;
Window::SessionController * const _regularWindow = nullptr;
const object_ptr<TabbedSelector> _ownedSelector = { nullptr };
const not_null<TabbedSelector*> _selector;
rpl::event_stream<bool> _pauseAnimations;
int _contentMaxHeight = 0;
int _contentHeight = 0;

View File

@ -322,12 +322,12 @@ std::unique_ptr<Ui::TabbedSearch> MakeSearch(
TabbedSelector::TabbedSelector(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level,
std::shared_ptr<Show> show,
PauseReason level,
Mode mode)
: RpWidget(parent)
, _st((mode == Mode::EmojiStatus) ? st::statusEmojiPan : st::defaultEmojiPan)
, _controller(controller)
, _show(std::move(show))
, _level(level)
, _mode(mode)
, _panelRounding(Ui::PrepareCornerPixmaps(st::emojiPanRadius, _st.bg))
@ -470,38 +470,59 @@ TabbedSelector::TabbedSelector(
TabbedSelector::~TabbedSelector() = default;
Main::Session &TabbedSelector::session() const {
return _controller->session();
return _show->session();
}
Window::GifPauseReason TabbedSelector::level() const {
PauseReason TabbedSelector::level() const {
return _level;
}
TabbedSelector::Tab TabbedSelector::createTab(SelectorTab type, int index) {
auto createWidget = [&]() -> object_ptr<Inner> {
const auto paused = [show = _show, level = _level] {
return show->paused(level);
};
switch (type) {
case SelectorTab::Emoji:
case SelectorTab::Emoji: {
using EmojiMode = EmojiListWidget::Mode;
using Descriptor = EmojiListDescriptor;
return object_ptr<EmojiListWidget>(this, Descriptor{
.session = &_controller->session(),
.show = _show,
.mode = (_mode == Mode::EmojiStatus
? EmojiMode::EmojiStatus
: EmojiMode::Full),
.controller = _controller,
.paused = Window::PausedIn(_controller, _level),
.paused = paused,
.st = &_st,
});
case SelectorTab::Stickers:
return object_ptr<StickersListWidget>(this, _controller, _level);
case SelectorTab::Gifs:
return object_ptr<GifsListWidget>(this, _controller, _level);
case SelectorTab::Masks:
return object_ptr<StickersListWidget>(
this,
_controller,
_level,
StickersListWidget::Mode::Masks);
}
case SelectorTab::Stickers: {
using StickersMode = StickersListWidget::Mode;
using Descriptor = StickersListDescriptor;
return object_ptr<StickersListWidget>(this, Descriptor{
.show = _show,
.mode = StickersMode::Full,
.paused = paused,
.st = &_st,
});
}
case SelectorTab::Gifs: {
using Descriptor = GifsListDescriptor;
return object_ptr<GifsListWidget>(this, Descriptor{
.show = _show,
.paused = paused,
.st = &_st,
});
}
case SelectorTab::Masks: {
using StickersMode = StickersListWidget::Mode;
using Descriptor = StickersListDescriptor;
return object_ptr<StickersListWidget>(this, Descriptor{
.show = _show,
.mode = StickersMode::Masks,
.paused = paused,
.st = &_st,
});
}
}
Unexpected("Type in TabbedSelector::createTab.");
};
@ -1237,23 +1258,24 @@ not_null<const TabbedSelector::Tab*> TabbedSelector::currentTab() const {
TabbedSelector::Inner::Inner(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level)
std::shared_ptr<Show> show,
PauseReason level)
: Inner(
parent,
st::defaultEmojiPan,
&controller->session(),
Window::PausedIn(controller, level)) {
show,
[show, level] { return show->paused(level); }) {
}
TabbedSelector::Inner::Inner(
QWidget *parent,
const style::EmojiPan &st,
not_null<Main::Session*> session,
std::shared_ptr<Show> show,
Fn<bool()> paused)
: RpWidget(parent)
, _st(st)
, _session(session)
, _show(std::move(show))
, _session(&_show->session())
, _paused(paused) {
}
@ -1273,12 +1295,15 @@ void TabbedSelector::Inner::disableScroll(bool disabled) {
_disableScrollRequests.fire_copy(disabled);
}
void TabbedSelector::Inner::checkHideWithBox(QPointer<Ui::BoxContent> box) {
if (!box) {
void TabbedSelector::Inner::checkHideWithBox(
object_ptr<Ui::BoxContent> box) {
const auto raw = QPointer<Ui::BoxContent>(box.data());
_show->showBox(std::move(box));
if (!raw) {
return;
}
_preventHideWithBox = true;
connect(box, &QObject::destroyed, this, [=] {
connect(raw, &QObject::destroyed, this, [=] {
_preventHideWithBox = false;
_checkForHide.fire({});
});

View File

@ -34,11 +34,6 @@ class BoxContent;
class TabbedSearch;
} // namespace Ui
namespace Window {
class SessionController;
enum class GifPauseReason;
} // namespace Window
namespace SendMenu {
enum class Type;
} // namespace SendMenu
@ -49,9 +44,11 @@ struct EmojiPan;
namespace ChatHelpers {
class Show;
class EmojiListWidget;
class StickersListWidget;
class GifsListWidget;
enum class PauseReason;
enum class SelectorTab {
Emoji,
@ -102,31 +99,32 @@ public:
TabbedSelector(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level,
std::shared_ptr<Show> show,
PauseReason level,
Mode mode = Mode::Full);
~TabbedSelector();
Main::Session &session() const;
Window::GifPauseReason level() const;
[[nodiscard]] Main::Session &session() const;
[[nodiscard]] PauseReason level() const;
rpl::producer<EmojiChosen> emojiChosen() const;
rpl::producer<FileChosen> customEmojiChosen() const;
rpl::producer<FileChosen> fileChosen() const;
rpl::producer<PhotoChosen> photoChosen() const;
rpl::producer<InlineChosen> inlineResultChosen() const;
[[nodiscard]] rpl::producer<EmojiChosen> emojiChosen() const;
[[nodiscard]] rpl::producer<FileChosen> customEmojiChosen() const;
[[nodiscard]] rpl::producer<FileChosen> fileChosen() const;
[[nodiscard]] rpl::producer<PhotoChosen> photoChosen() const;
[[nodiscard]] rpl::producer<InlineChosen> inlineResultChosen() const;
rpl::producer<> cancelled() const;
rpl::producer<> checkForHide() const;
rpl::producer<> slideFinished() const;
rpl::producer<> contextMenuRequested() const;
rpl::producer<Action> choosingStickerUpdated() const;
[[nodiscard]] rpl::producer<> cancelled() const;
[[nodiscard]] rpl::producer<> checkForHide() const;
[[nodiscard]] rpl::producer<> slideFinished() const;
[[nodiscard]] rpl::producer<> contextMenuRequested() const;
[[nodiscard]] rpl::producer<Action> choosingStickerUpdated() const;
void setAllowEmojiWithoutPremium(bool allow);
void setRoundRadius(int radius);
void refreshStickers();
void setCurrentPeer(PeerData *peer);
void provideRecentEmoji(const std::vector<DocumentId> &customRecentList);
void provideRecentEmoji(
const std::vector<DocumentId> &customRecentList);
void hideFinished();
void showStarted();
@ -256,8 +254,8 @@ private:
not_null<StickersListWidget*> masks() const;
const style::EmojiPan &_st;
const not_null<Window::SessionController*> _controller;
const Window::GifPauseReason _level = {};
const std::shared_ptr<Show> _show;
const PauseReason _level = {};
Mode _mode = Mode::Full;
int _roundRadius = 0;
@ -299,12 +297,12 @@ class TabbedSelector::Inner : public Ui::RpWidget {
public:
Inner(
QWidget *parent,
not_null<Window::SessionController*> controller,
Window::GifPauseReason level);
std::shared_ptr<Show> show,
PauseReason level);
Inner(
QWidget *parent,
const style::EmojiPan &st,
not_null<Main::Session*> session,
std::shared_ptr<Show> show,
Fn<bool()> paused);
[[nodiscard]] Main::Session &session() const {
@ -374,7 +372,7 @@ protected:
void scrollTo(int y);
void disableScroll(bool disabled);
void checkHideWithBox(QPointer<Ui::BoxContent> box);
void checkHideWithBox(object_ptr<Ui::BoxContent> box);
void paintEmptySearchResults(
Painter &p,
@ -383,6 +381,7 @@ protected:
private:
const style::EmojiPan &_st;
const std::shared_ptr<Show> _show;
const not_null<Main::Session*> _session;
const Fn<bool()> _paused;

View File

@ -917,6 +917,14 @@ rpl::producer<bool> Application::appDeactivatedValue() const {
});
}
void Application::materializeLocalDrafts() {
_materializeLocalDraftsRequests.fire({});
}
rpl::producer<> Application::materializeLocalDraftsRequests() const {
return _materializeLocalDraftsRequests.events();
}
void Application::switchDebugMode() {
if (Logs::DebugEnabled()) {
Logs::SetDebugEnabled(false);

View File

@ -314,6 +314,9 @@ public:
void handleAppDeactivated();
[[nodiscard]] rpl::producer<bool> appDeactivatedValue() const;
void materializeLocalDrafts();
[[nodiscard]] rpl::producer<> materializeLocalDraftsRequests() const;
void switchDebugMode();
void writeInstallBetaVersionsSetting();
@ -444,6 +447,8 @@ private:
rpl::event_stream<Media::View::OpenRequest> _openInMediaViewRequests;
rpl::event_stream<> _materializeLocalDraftsRequests;
rpl::lifetime _lifetime;
crl::time _lastNonIdleTime = 0;

View File

@ -146,7 +146,7 @@ void HiddenUrlClickHandler::Open(QString url, QVariant context) {
if (my.show) {
my.show->showBox(std::move(box));
} else if (use) {
use->show(std::move(box), Ui::LayerOption::KeepOther);
use->show(std::move(box));
}
} else {
open();
@ -335,16 +335,13 @@ void MonospaceClickHandler::onClick(ClickContext context) const {
const auto hasCopyRestriction = item
&& (!item->history()->peer->allowsForwarding()
|| item->forbidsForward());
const auto toastParent = Window::Show(controller).toastParent();
if (hasCopyRestriction) {
Ui::Toast::Show(
toastParent,
item->history()->peer->isBroadcast()
? tr::lng_error_nocopy_channel(tr::now)
: tr::lng_error_nocopy_group(tr::now));
controller->showToast(item->history()->peer->isBroadcast()
? tr::lng_error_nocopy_channel(tr::now)
: tr::lng_error_nocopy_group(tr::now));
return;
}
Ui::Toast::Show(toastParent, tr::lng_text_copied(tr::now));
controller->showToast(tr::lng_text_copied(tr::now));
}
TextUtilities::SetClipboardText(TextForMimeData::Simple(_text.trimmed()));
}

View File

@ -100,7 +100,7 @@ bool ShowStickerSet(
}
Core::App().hideMediaView();
controller->show(Box<StickerSetBox>(
controller,
controller->uiShow(),
StickerSetIdentifier{ .shortName = match->captured(2) },
(match->captured(1) == "addemoji"
? Data::StickersType::Emoji
@ -607,9 +607,7 @@ bool ShowInviteLink(
return false;
}
QGuiApplication::clipboard()->setText(link);
Ui::Toast::Show(
Window::Show(controller).toastParent(),
tr::lng_group_invite_copied(tr::now));
controller->showToast(tr::lng_group_invite_copied(tr::now));
return true;
}
@ -626,12 +624,12 @@ void ExportTestChatTheme(
not_null<Window::SessionController*> controller,
not_null<const Data::CloudTheme*> theme) {
const auto session = &controller->session();
const auto show = std::make_shared<Window::Show>(controller);
const auto show = controller->uiShow();
const auto inputSettings = [&](Data::CloudThemeType type)
-> std::optional<MTPInputThemeSettings> {
const auto i = theme->settings.find(type);
if (i == end(theme->settings)) {
Ui::Toast::Show(show->toastParent(), "Something went wrong :(");
show->showToast(u"Something went wrong :("_q);
return std::nullopt;
}
const auto &fields = i->second;
@ -639,17 +637,15 @@ void ExportTestChatTheme(
|| !fields.paper->isPattern()
|| fields.paper->backgroundColors().empty()
|| !fields.paper->hasShareUrl()) {
Ui::Toast::Show(show->toastParent(), "Something went wrong :(");
show->showToast(u"Something went wrong :("_q);
return std::nullopt;
}
const auto &bg = fields.paper->backgroundColors();
const auto url = fields.paper->shareUrl(session);
const auto url = fields.paper->shareUrl(&show->session());
const auto from = url.indexOf("bg/");
const auto till = url.indexOf("?");
if (from < 0 || till <= from) {
Ui::Toast::Show(
show->toastParent(),
"Bad WallPaper link: " + url);
show->showToast(u"Bad WallPaper link: "_q + url);
return std::nullopt;
}
@ -731,15 +727,9 @@ void ExportTestChatTheme(
const auto slug = Data::CloudTheme::Parse(session, result, true).slug;
QGuiApplication::clipboard()->setText(
session->createInternalLinkFull("addtheme/" + slug));
if (show->valid()) {
Ui::Toast::Show(
show->toastParent(),
tr::lng_background_link_copied(tr::now));
}
show->showToast(tr::lng_background_link_copied(tr::now));
}).fail([=](const MTP::Error &error) {
if (show->valid()) {
Ui::Toast::Show(show->toastParent(), "Error: " + error.type());
}
show->showToast(u"Error: "_q + error.type());
}).send();
}

View File

@ -62,7 +62,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/click_handler_types.h" // ClickHandlerContext
#include "lang/lang_keys.h"
#include "storage/file_upload.h"
#include "window/window_session_controller.h" // Window::Show
#include "window/window_session_controller.h" // SessionController::uiShow.
#include "apiwrap.h"
#include "styles/style_chat.h"
#include "styles/style_dialogs.h"
@ -1828,7 +1828,7 @@ ClickHandlerPtr MediaDice::MakeHandler(
auto config = Ui::Toast::Config{
.text = { tr::lng_about_random(tr::now, lt_emoji, emoji) },
.st = &st::historyDiceToast,
.durationMs = Ui::Toast::kDefaultDuration * 2,
.duration = Ui::Toast::kDefaultDuration * 2,
.multiline = true,
};
if (CanSend(history->peer, ChatRestriction::SendOther)) {
@ -1857,9 +1857,7 @@ ClickHandlerPtr MediaDice::MakeHandler(
const auto my = context.other.value<ClickHandlerContext>();
const auto weak = my.sessionWindow;
if (const auto strong = weak.get()) {
ShownToast = Ui::Toast::Show(
Window::Show(strong).toastParent(),
config);
ShownToast = strong->showToast(std::move(config));
} else {
ShownToast = Ui::Toast::Show(config);
}

View File

@ -39,7 +39,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/image/image.h"
#include "ui/empty_userpic.h"
#include "ui/text/text_options.h"
#include "ui/toasts/common_toasts.h"
#include "ui/painter.h"
#include "ui/ui_utility.h"
#include "history/history.h"

View File

@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/stickers/data_stickers.h"
#include "api/api_hash.h"
#include "chat_helpers/compose/compose_show.h"
#include "data/data_document.h"
#include "data/data_session.h"
#include "data/data_user.h"
@ -29,7 +30,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_app_config.h"
#include "mtproto/mtproto_config.h"
#include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/image/image_location_factory.h"
#include "window/window_controller.h"
#include "window/window_session_controller.h"
@ -78,24 +78,24 @@ using SetFlag = StickersSetFlag;
}
void MaybeShowPremiumToast(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
TextWithEntities text,
const QString &ref) {
if (!controller) {
if (!show) {
return;
}
const auto session = &controller->session();
const auto session = &show->session();
if (session->user()->isPremium()) {
return;
}
const auto widget = QPointer<Ui::RpWidget>(
controller->window().widget()->bodyWidget());
const auto filter = [=](const auto ...) {
Settings::ShowPremium(controller, ref);
const auto usage = ChatHelpers::WindowUsage::PremiumPromo;
if (const auto controller = show->resolveWindow(usage)) {
Settings::ShowPremium(controller, ref);
}
return false;
};
Ui::ShowMultilineToast({
.parentOverride = widget,
show->showToast({
.text = std::move(text),
.duration = kPremiumToastDuration,
.filter = filter,
@ -313,7 +313,7 @@ void Stickers::incrementSticker(not_null<DocumentData*> document) {
}
void Stickers::addSavedGif(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document) {
const auto index = _savedGifs.indexOf(document);
if (!index) {
@ -328,7 +328,7 @@ void Stickers::addSavedGif(
if (_savedGifs.size() > limits.gifsCurrent()) {
_savedGifs.pop_back();
MaybeShowPremiumToast(
controller,
show,
SavedGifsToast(limits),
LimitsPremiumRef("saved_gifs"));
}
@ -518,7 +518,7 @@ bool Stickers::isFaved(not_null<const DocumentData*> document) {
void Stickers::checkFavedLimit(
StickersSet &set,
Window::SessionController *controller) {
std::shared_ptr<ChatHelpers::Show> show) {
const auto session = &_owner->session();
const auto limits = Data::PremiumLimits(session);
if (set.stickers.size() <= limits.stickersFavedCurrent()) {
@ -538,21 +538,21 @@ void Stickers::checkFavedLimit(
++i;
}
MaybeShowPremiumToast(
controller,
std::move(show),
FaveStickersToast(limits),
LimitsPremiumRef("stickers_faved"));
}
void Stickers::pushFavedToFront(
StickersSet &set,
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
const std::vector<not_null<EmojiPtr>> &emojiList) {
set.stickers.push_front(document);
for (auto emoji : emojiList) {
set.emoji[emoji].push_front(document);
}
checkFavedLimit(set, controller);
checkFavedLimit(set, std::move(show));
}
void Stickers::moveFavedToFront(StickersSet &set, int index) {
@ -575,7 +575,7 @@ void Stickers::moveFavedToFront(StickersSet &set, int index) {
}
void Stickers::setIsFaved(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
std::optional<std::vector<not_null<EmojiPtr>>> emojiList) {
auto &sets = setsRef();
@ -600,11 +600,11 @@ void Stickers::setIsFaved(
if (index > 0) {
moveFavedToFront(*set, index);
} else if (emojiList) {
pushFavedToFront(*set, controller, document, *emojiList);
pushFavedToFront(*set, show, document, *emojiList);
} else if (auto list = getEmojiListFromSet(document)) {
pushFavedToFront(*set, controller, document, *list);
pushFavedToFront(*set, show, document, *list);
} else {
requestSetToPushFaved(controller, document);
requestSetToPushFaved(show, document);
return;
}
session().local().writeFavedStickers();
@ -613,10 +613,8 @@ void Stickers::setIsFaved(
}
void Stickers::requestSetToPushFaved(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document) {
controller = nullptr;
const auto weak = base::make_weak(controller);
auto addAnyway = [=](std::vector<not_null<EmojiPtr>> list) {
if (list.empty()) {
if (auto sticker = document->sticker()) {
@ -625,7 +623,7 @@ void Stickers::requestSetToPushFaved(
}
}
}
setIsFaved(weak.get(), document, std::move(list));
setIsFaved(nullptr, document, std::move(list));
};
session().api().request(MTPmessages_GetStickerSet(
Data::InputStickerSet(document->sticker()->set),
@ -668,11 +666,11 @@ void Stickers::setIsNotFaved(not_null<DocumentData*> document) {
}
void Stickers::setFaved(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
bool faved) {
if (faved) {
setIsFaved(controller, document);
setIsFaved(std::move(show), document);
} else {
setIsNotFaved(document);
}

View File

@ -22,6 +22,10 @@ namespace Window {
class SessionController;
} // namespace Window
namespace ChatHelpers {
class Show;
} // namespace ChatHelpers
namespace Data {
class Session;
@ -200,7 +204,7 @@ public:
void removeFromRecentSet(not_null<DocumentData*> document);
void addSavedGif(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document);
void checkSavedGif(not_null<HistoryItem*> item);
@ -210,7 +214,7 @@ public:
void undoInstallLocally(uint64 setId);
bool isFaved(not_null<const DocumentData*> document);
void setFaved(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
bool faved);
@ -260,21 +264,21 @@ private:
}
void checkFavedLimit(
StickersSet &set,
Window::SessionController *controller = nullptr);
std::shared_ptr<ChatHelpers::Show> show);
void setIsFaved(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
std::optional<std::vector<not_null<EmojiPtr>>> emojiList
= std::nullopt);
void setIsNotFaved(not_null<DocumentData*> document);
void pushFavedToFront(
StickersSet &set,
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document,
const std::vector<not_null<EmojiPtr>> &emojiList);
void moveFavedToFront(StickersSet &set, int index);
void requestSetToPushFaved(
Window::SessionController *controller,
std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document);
void setPackAndEmoji(
StickersSet &set,

View File

@ -2286,7 +2286,7 @@ void Widget::showSearchFrom() {
}),
crl::guard(this, [=] { _filter->setFocus(); }));
if (box) {
Window::Show(controller()).showBox(std::move(box));
controller()->show(std::move(box));
}
}
}

View File

@ -24,7 +24,7 @@ StickersPanelController::StickersPanelController(
controller,
object_ptr<ChatHelpers::TabbedSelector>(
nullptr,
controller,
controller->uiShow(),
Window::GifPauseReason::Layer,
ChatHelpers::TabbedSelector::Mode::MediaEditor))) {
_stickersPanel->setDesiredHeightValues(

View File

@ -61,7 +61,7 @@ PhotoEditor::PhotoEditor(
controller->sessionController())
: nullptr,
std::make_unique<UndoController>(),
std::make_shared<Window::Show>(controller)))
controller->uiShow()))
, _content(base::make_unique_q<PhotoEditorContent>(
this,
photo,

View File

@ -1362,7 +1362,7 @@ void InnerWidget::copySelectedText() {
}
void InnerWidget::showStickerPackInfo(not_null<DocumentData*> document) {
StickerSetBox::Show(_controller, document);
StickerSetBox::Show(_controller->uiShow(), document);
}
void InnerWidget::cancelContextDownload(not_null<DocumentData*> document) {

View File

@ -1117,7 +1117,7 @@ void GenerateItems(
if (const auto controller = my.sessionWindow.get()) {
controller->show(
Box<StickerSetBox>(
controller,
controller->uiShow(),
Data::FromInputSet(set),
Data::StickersType::Stickers),
Ui::LayerOption::CloseOther);

Some files were not shown because too many files have changed in this diff Show More