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_bubble.h
calls/calls_video_incoming.cpp calls/calls_video_incoming.cpp
calls/calls_video_incoming.h 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.cpp
chat_helpers/bot_command.h chat_helpers/bot_command.h
chat_helpers/bot_keyboard.cpp chat_helpers/bot_keyboard.cpp
@ -934,6 +936,8 @@ PRIVATE
main/main_session_settings.h main/main_session_settings.h
main/session/send_as_peers.cpp main/session/send_as_peers.cpp
main/session/send_as_peers.h 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.h
media/system_media_controls_manager.cpp media/system_media_controls_manager.cpp
media/audio/media_audio.cpp media/audio/media_audio.cpp

View file

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

View file

@ -82,7 +82,7 @@ void SendBotCallbackData(
flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_password; flags |= MTPmessages_GetBotCallbackAnswer::Flag::f_password;
} }
const auto weak = base::make_weak(controller); 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( button->requestId = api->request(MTPmessages_GetBotCallbackAnswer(
MTP_flags(flags), MTP_flags(flags),
history->peer->input, history->peer->input,
@ -119,7 +119,7 @@ void SendBotCallbackData(
if (withPassword) { if (withPassword) {
show->hideLayer(); show->hideLayer();
} }
Ui::Toast::Show(show->toastParent(), message); show->showToast(message);
} }
} else if (!link.isEmpty()) { } else if (!link.isEmpty()) {
if (!isGame) { if (!isGame) {
@ -210,7 +210,7 @@ void SendBotCallbackDataWithPassword(
} }
api->cloudPassword().reload(); api->cloudPassword().reload();
const auto weak = base::make_weak(controller); 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, {}, {}, [=]( SendBotCallbackData(controller, item, row, column, {}, {}, [=](
const QString &error) { const QString &error) {
auto box = PrePasswordErrorBox( 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/boxes/confirm_box.h"
#include "ui/controls/filter_link_header.h" #include "ui/controls/filter_link_header.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/filter_icons.h" #include "ui/filter_icons.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
@ -515,13 +514,9 @@ void ShowImportError(
} else if (error == u"CHATLISTS_TOO_MUCH"_q) { } else if (error == u"CHATLISTS_TOO_MUCH"_q) {
window->show(Box(ShareableFiltersLimitBox, session)); window->show(Box(ShareableFiltersLimitBox, session));
} else { } 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) ? tr::lng_group_invite_bad_link(tr::now)
: error; : error);
Ui::ShowMultilineToast({
.parentOverride = Window::Show(window).toastParent(),
.text = { text },
});
} }
} }
@ -545,10 +540,7 @@ void ShowImportToast(
: tr::lng_filters_updated_also; : tr::lng_filters_updated_also;
text.append('\n').append(phrase(tr::now, lt_count, added)); text.append('\n').append(phrase(tr::now, lt_count, added));
} }
Ui::ShowMultilineToast({ strong->showToast(std::move(text));
.parentOverride = Window::Show(strong).toastParent(),
.text = { std::move(text) },
});
} }
void ProcessFilterInvite( void ProcessFilterInvite(
@ -565,10 +557,7 @@ void ProcessFilterInvite(
} }
Core::App().hideMediaView(); Core::App().hideMediaView();
if (peers.empty() && !filterId) { if (peers.empty() && !filterId) {
Ui::ShowMultilineToast({ strong->showToast(tr::lng_group_invite_bad_link(tr::now));
.parentOverride = Window::Show(strong).toastParent(),
.text = { tr::lng_group_invite_bad_link(tr::now) },
});
return; return;
} }
const auto fullyAdded = (peers.empty() && filterId); const auto fullyAdded = (peers.empty() && filterId);
@ -661,10 +650,7 @@ void ProcessFilterInvite(
const auto &list = strong->session().data().chatsFilters().list(); const auto &list = strong->session().data().chatsFilters().list();
const auto it = ranges::find(list, filterId, &Data::ChatFilter::id); const auto it = ranges::find(list, filterId, &Data::ChatFilter::id);
if (it == end(list)) { if (it == end(list)) {
Ui::ShowMultilineToast({ strong->showToast(u"Filter not found :shrug:"_q);
.parentOverride = Window::Show(strong).toastParent(),
.text = { u"Filter not found :shrug:"_q },
});
return; return;
} }
ProcessFilterInvite( ProcessFilterInvite(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -386,10 +386,7 @@ void EditExceptions(
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
}; };
window->window().show( window->window().show(
Box<PeerListBox>( Box<PeerListBox>(std::move(controller), std::move(initBox)));
std::move(controller),
std::move(initBox)),
Ui::LayerOption::KeepOther);
} }
void CreateIconSelector( void CreateIconSelector(
@ -812,7 +809,7 @@ void EditFilterBox(
tr::lng_filters_link_about_many(), tr::lng_filters_link_about_many(),
tr::lng_filters_link_about())); tr::lng_filters_link_about()));
const auto show = std::make_shared<Ui::BoxShow>(box); const auto show = box->uiShow();
const auto refreshPreviews = [=] { const auto refreshPreviews = [=] {
include->updateData( include->updateData(
data->current().flags() & kTypes, 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_buttons.h"
#include "ui/controls/invite_link_label.h" #include "ui/controls/invite_link_label.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "ui/widgets/popup_menu.h" #include "ui/widgets/popup_menu.h"
@ -118,7 +117,7 @@ void ShowSaveError(
window->showToast( window->showToast(
{ tr::lng_filters_link_group_admin_error(tr::now) }); { tr::lng_filters_link_group_admin_error(tr::now) });
} else { } 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 link = _data.url;
const auto weak = Ui::MakeWeak(container); const auto weak = Ui::MakeWeak(container);
const auto copyLink = crl::guard(weak, [=] { const auto copyLink = crl::guard(weak, [=] {
CopyInviteLink(delegate()->peerListToastParent(), link); CopyInviteLink(delegate()->peerListUiShow(), link);
}); });
const auto shareLink = crl::guard(weak, [=] { const auto shareLink = crl::guard(weak, [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(
ShareInviteLinkBox(&_window->session(), link), ShareInviteLinkBox(&_window->session(), link));
Ui::LayerOption::KeepOther);
}); });
const auto getLinkQr = crl::guard(weak, [=] { const auto getLinkQr = crl::guard(weak, [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()), InviteLinkQrBox(link, tr::lng_filters_link_qr_about()));
Ui::LayerOption::KeepOther);
}); });
const auto editLink = crl::guard(weak, [=] { const auto editLink = crl::guard(weak, [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(
Box(ChatFilterLinkBox, &_window->session(), _data), Box(ChatFilterLinkBox, &_window->session(), _data));
Ui::LayerOption::KeepOther);
}); });
const auto deleteLink = crl::guard(weak, [=] { const auto deleteLink = crl::guard(weak, [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(DeleteLinkBox(_window, _data));
DeleteLinkBox(_window, _data),
Ui::LayerOption::KeepOther);
}); });
const auto createMenu = [=] { const auto createMenu = [=] {
@ -702,10 +696,7 @@ void LinkController::rowClicked(not_null<PeerListRow*> row) {
const auto peer = row->peer(); const auto peer = row->peer();
if (const auto i = _denied.find(peer); i != end(_denied)) { if (const auto i = _denied.find(peer); i != end(_denied)) {
if (!i->second.isEmpty()) { if (!i->second.isEmpty()) {
Ui::ShowMultilineToast({ delegate()->peerListUiShow()->showToast(i->second);
.parentOverride = delegate()->peerListToastParent(),
.text = { i->second },
});
} }
} else { } else {
const auto checked = row->checked(); const auto checked = row->checked();
@ -866,8 +857,7 @@ void LinksController::rebuild(const std::vector<InviteLinkData> &rows) {
void LinksController::rowClicked(not_null<PeerListRow*> row) { void LinksController::rowClicked(not_null<PeerListRow*> row) {
const auto link = static_cast<LinkRow*>(row.get())->data(); const auto link = static_cast<LinkRow*>(row.get())->data();
delegate()->peerListShowBox( delegate()->peerListShowBox(
ShowLinkBox(_window, _currentFilter(), link), ShowLinkBox(_window, _currentFilter(), link));
Ui::LayerOption::KeepOther);
} }
void LinksController::rowRightActionClicked(not_null<PeerListRow*> row) { 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 data = real->data();
const auto link = data.url; const auto link = data.url;
const auto copyLink = [=] { const auto copyLink = [=] {
CopyInviteLink(delegate()->peerListToastParent(), link); CopyInviteLink(delegate()->peerListUiShow(), link);
}; };
const auto shareLink = [=] { const auto shareLink = [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(
ShareInviteLinkBox(&_window->session(), link), ShareInviteLinkBox(&_window->session(), link));
Ui::LayerOption::KeepOther);
}; };
const auto getLinkQr = [=] { const auto getLinkQr = [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(
InviteLinkQrBox(link, tr::lng_filters_link_qr_about()), InviteLinkQrBox(link, tr::lng_filters_link_qr_about()));
Ui::LayerOption::KeepOther);
}; };
const auto editLink = [=] { const auto editLink = [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(
Box(ChatFilterLinkBox, &_window->session(), data), Box(ChatFilterLinkBox, &_window->session(), data));
Ui::LayerOption::KeepOther);
}; };
const auto deleteLink = [=] { const auto deleteLink = [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(DeleteLinkBox(_window, data));
DeleteLinkBox(_window, data),
Ui::LayerOption::KeepOther);
}; };
auto result = base::make_unique_q<Ui::PopupMenu>( auto result = base::make_unique_q<Ui::PopupMenu>(
parent, parent,
@ -1008,10 +993,7 @@ bool GoodForExportFilterLink(
using Flag = Data::ChatFilter::Flag; using Flag = Data::ChatFilter::Flag;
const auto listflags = Flag::Chatlist | Flag::HasMyLinks; const auto listflags = Flag::Chatlist | Flag::HasMyLinks;
if (!filter.never().empty() || (filter.flags() & ~listflags)) { if (!filter.never().empty() || (filter.flags() & ~listflags)) {
Ui::ShowMultilineToast({ window->showToast(tr::lng_filters_link_cant(tr::now));
.parentOverride = Window::Show(window).toastParent(),
.text = { tr::lng_filters_link_cant(tr::now) },
});
return false; return false;
} }
return true; return true;
@ -1151,7 +1133,7 @@ void SetupFilterLinks(
Fn<Data::ChatFilter()> currentFilter) { Fn<Data::ChatFilter()> currentFilter) {
auto &lifetime = container->lifetime(); auto &lifetime = container->lifetime();
const auto delegate = lifetime.make_state<PeerListContentDelegateShow>( const auto delegate = lifetime.make_state<PeerListContentDelegateShow>(
std::make_shared<Window::Show>(window)); window->uiShow());
const auto controller = lifetime.make_state<LinksController>( const auto controller = lifetime.make_state<LinksController>(
window, window,
std::move(value), std::move(value),

View file

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

View file

@ -91,9 +91,7 @@ void MaxInviteBox::mousePressEvent(QMouseEvent *e) {
if (_linkOver) { if (_linkOver) {
if (!_channel->inviteLink().isEmpty()) { if (!_channel->inviteLink().isEmpty()) {
QGuiApplication::clipboard()->setText(_channel->inviteLink()); QGuiApplication::clipboard()->setText(_channel->inviteLink());
Ui::Toast::Show( showToast(tr::lng_create_channel_link_copied(tr::now));
Ui::BoxShow(this).toastParent(),
tr::lng_create_channel_link_copied(tr::now));
} else if (_channel->isFullLoaded() && !_creatingInviteLink) { } else if (_channel->isFullLoaded() && !_creatingInviteLink) {
_creatingInviteLink = true; _creatingInviteLink = true;
_channel->session().api().inviteLinks().create(_channel); _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 "boxes/peer_list_box.h"
#include "main/session/session_show.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "ui/widgets/multi_select.h" #include "ui/widgets/multi_select.h"
@ -74,7 +75,7 @@ PaintRoundImageCallback ForceRoundUserpicCallback(not_null<PeerData*> peer) {
} }
PeerListContentDelegateShow::PeerListContentDelegateShow( PeerListContentDelegateShow::PeerListContentDelegateShow(
std::shared_ptr<Ui::Show> show) std::shared_ptr<Main::SessionShow> show)
: _show(show) { : _show(show) {
} }
@ -88,15 +89,16 @@ void PeerListContentDelegateShow::peerListHideLayer() {
_show->hideLayer(); _show->hideLayer();
} }
not_null<QWidget*> PeerListContentDelegateShow::peerListToastParent() { auto PeerListContentDelegateShow::peerListUiShow()
return _show->toastParent(); -> std::shared_ptr<Main::SessionShow>{
return _show;
} }
PeerListBox::PeerListBox( PeerListBox::PeerListBox(
QWidget*, QWidget*,
std::unique_ptr<PeerListController> controller, std::unique_ptr<PeerListController> controller,
Fn<void(not_null<PeerListBox*>)> init) Fn<void(not_null<PeerListBox*>)> init)
: _show(this) : _show(Main::MakeSessionShow(uiShow(), &controller->session()))
, _controller(std::move(controller)) , _controller(std::move(controller))
, _init(std::move(init)) { , _init(std::move(init)) {
Expects(_controller != nullptr); Expects(_controller != nullptr);
@ -311,18 +313,20 @@ void PeerListBox::peerListSetSearchMode(PeerListSearchMode mode) {
void PeerListBox::peerListShowBox( void PeerListBox::peerListShowBox(
object_ptr<Ui::BoxContent> content, object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) { Ui::LayerOptions options) {
_show.showBox(std::move(content), options); _show->showBox(std::move(content), options);
} }
void PeerListBox::peerListHideLayer() { void PeerListBox::peerListHideLayer() {
_show.hideLayer(); _show->hideLayer();
} }
not_null<QWidget*> PeerListBox::peerListToastParent() { std::shared_ptr<Main::SessionShow> PeerListBox::peerListUiShow() {
return _show.toastParent(); 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) { if (_searchController) {
_searchController->setDelegate(this); _searchController->setDelegate(this);
} }

View file

@ -24,6 +24,7 @@ struct MultiSelect;
namespace Main { namespace Main {
class Session; class Session;
class SessionShow;
} // namespace Main } // namespace Main
namespace Ui { namespace Ui {
@ -329,7 +330,7 @@ public:
object_ptr<Ui::BoxContent> content, object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) = 0; Ui::LayerOptions options = Ui::LayerOption::KeepOther) = 0;
virtual void peerListHideLayer() = 0; virtual void peerListHideLayer() = 0;
virtual not_null<QWidget*> peerListToastParent() = 0; virtual std::shared_ptr<Main::SessionShow> peerListUiShow() = 0;
template <typename PeerDataRange> template <typename PeerDataRange>
void peerListAddSelectedPeers(PeerDataRange &&range) { void peerListAddSelectedPeers(PeerDataRange &&range) {
@ -999,22 +1000,24 @@ public:
void peerListHideLayer() override { void peerListHideLayer() override {
Unexpected("...DelegateSimple::peerListHideLayer"); Unexpected("...DelegateSimple::peerListHideLayer");
} }
not_null<QWidget*> peerListToastParent() override { std::shared_ptr<Main::SessionShow> peerListUiShow() override {
Unexpected("...DelegateSimple::peerListToastParent"); Unexpected("...DelegateSimple::peerListUiShow");
} }
}; };
class PeerListContentDelegateShow : public PeerListContentDelegateSimple { class PeerListContentDelegateShow : public PeerListContentDelegateSimple {
public: public:
PeerListContentDelegateShow(std::shared_ptr<Ui::Show> show); explicit PeerListContentDelegateShow(
std::shared_ptr<Main::SessionShow> show);
void peerListShowBox( void peerListShowBox(
object_ptr<Ui::BoxContent> content, object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override; Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override; void peerListHideLayer() override;
not_null<QWidget*> peerListToastParent() override; std::shared_ptr<Main::SessionShow> peerListUiShow() override;
private: private:
std::shared_ptr<Ui::Show> _show; std::shared_ptr<Main::SessionShow> _show;
}; };
@ -1050,7 +1053,7 @@ public:
object_ptr<Ui::BoxContent> content, object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options = Ui::LayerOption::KeepOther) override; Ui::LayerOptions options = Ui::LayerOption::KeepOther) override;
void peerListHideLayer() override; void peerListHideLayer() override;
not_null<QWidget*> peerListToastParent() override; std::shared_ptr<Main::SessionShow> peerListUiShow() override;
void setAddedTopScrollSkip(int skip); void setAddedTopScrollSkip(int skip);
@ -1092,7 +1095,7 @@ private:
object_ptr<Ui::SlideWrap<Ui::MultiSelect>> _select = { nullptr }; object_ptr<Ui::SlideWrap<Ui::MultiSelect>> _select = { nullptr };
const Ui::BoxShow _show; const std::shared_ptr<Main::SessionShow> _show;
std::unique_ptr<PeerListController> _controller; std::unique_ptr<PeerListController> _controller;
Fn<void(PeerListBox*)> _init; Fn<void(PeerListBox*)> _init;
bool _scrollBottomFixed = false; 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/wrap/vertical_layout.h"
#include "ui/widgets/multi_select.h" #include "ui/widgets/multi_select.h"
#include "ui/widgets/scroll_area.h" #include "ui/widgets/scroll_area.h"
#include "main/session/session_show.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_peer.h" #include "data/data_peer.h"
@ -301,7 +302,7 @@ PeerListsBox::Delegate::Delegate(
not_null<PeerListController*> controller) not_null<PeerListController*> controller)
: _box(box) : _box(box)
, _controller(controller) , _controller(controller)
, _show(_box) { , _show(Main::MakeSessionShow(_box->uiShow(), &_controller->session())) {
} }
void PeerListsBox::Delegate::peerListSetTitle(rpl::producer<QString> title) { void PeerListsBox::Delegate::peerListSetTitle(rpl::producer<QString> title) {
@ -374,15 +375,16 @@ void PeerListsBox::Delegate::peerListFinishSelectedRowsBunch() {
void PeerListsBox::Delegate::peerListShowBox( void PeerListsBox::Delegate::peerListShowBox(
object_ptr<Ui::BoxContent> content, object_ptr<Ui::BoxContent> content,
Ui::LayerOptions options) { Ui::LayerOptions options) {
_show.showBox(std::move(content), options); _show->showBox(std::move(content), options);
} }
void PeerListsBox::Delegate::peerListHideLayer() { void PeerListsBox::Delegate::peerListHideLayer() {
_show.hideLayer(); _show->hideLayer();
} }
not_null<QWidget*> PeerListsBox::Delegate::peerListToastParent() { auto PeerListsBox::Delegate::peerListUiShow()
return _show.toastParent(); -> std::shared_ptr<Main::SessionShow> {
return _show;
} }
bool PeerListsBox::Delegate::peerListIsRowChecked( bool PeerListsBox::Delegate::peerListIsRowChecked(

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -274,12 +274,9 @@ struct IconSelector {
}; };
const auto selector = body->add( const auto selector = body->add(
object_ptr<EmojiListWidget>(body, EmojiListDescriptor{ object_ptr<EmojiListWidget>(body, EmojiListDescriptor{
.session = &controller->session(), .show = controller->uiShow(),
.mode = EmojiListWidget::Mode::TopicIcon, .mode = EmojiListWidget::Mode::TopicIcon,
.controller = controller, .paused = Window::PausedIn(controller, PauseReason::Layer),
.paused = Window::PausedIn(
controller,
Window::GifPauseReason::Layer),
.customRecentList = recent(), .customRecentList = recent(),
.customRecentFactory = std::move(factory), .customRecentFactory = std::move(factory),
.st = &st::reactPanelEmojiPan, .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 "ui/text/text_utilities.h" // Ui::Text::ToUpper
#include "boxes/peer_list_box.h" #include "boxes/peer_list_box.h"
#include "ui/boxes/confirm_box.h" #include "ui/boxes/confirm_box.h"
#include "ui/toasts/common_toasts.h"
#include "boxes/add_contact_box.h" #include "boxes/add_contact_box.h"
#include "apiwrap.h" #include "apiwrap.h"
#include "main/main_session.h" #include "main/main_session.h"
@ -168,13 +167,11 @@ void Controller::choose(not_null<ChannelData*> chat) {
const auto onstack = _callback; const auto onstack = _callback;
onstack(chat); onstack(chat);
}; };
delegate()->peerListShowBox( delegate()->peerListShowBox(Ui::MakeConfirmBox({
Ui::MakeConfirmBox({ .text = text,
.text = text, .confirmed = sure,
.confirmed = sure, .confirmText = tr::lng_manage_discussion_group_link(tr::now),
.confirmText = tr::lng_manage_discussion_group_link(tr::now), }));
}),
Ui::LayerOption::KeepOther);
} }
void Controller::choose(not_null<ChatData*> chat) { 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)); chat->session().api().migrateChat(chat, crl::guard(this, done));
}; };
delegate()->peerListShowBox( delegate()->peerListShowBox(Ui::MakeConfirmBox({
Ui::MakeConfirmBox({ .text = text,
.text = text, .confirmed = sure,
.confirmed = sure, .confirmText = tr::lng_manage_discussion_group_link(tr::now),
.confirmText = tr::lng_manage_discussion_group_link(tr::now), }));
}),
Ui::LayerOption::KeepOther);
} }
[[nodiscard]] rpl::producer<TextWithEntities> About( [[nodiscard]] rpl::producer<TextWithEntities> About(
@ -279,13 +274,11 @@ void Controller::choose(not_null<ChatData*> chat) {
{ &st::settingsIconChat, Settings::kIconLightBlue } { &st::settingsIconChat, Settings::kIconLightBlue }
)->addClickHandler([=, parent = above.data()] { )->addClickHandler([=, parent = above.data()] {
const auto guarded = crl::guard(parent, callback); const auto guarded = crl::guard(parent, callback);
Window::Show(navigation).showBox( navigation->uiShow()->showBox(Box<GroupInfoBox>(
Box<GroupInfoBox>( navigation,
navigation, GroupInfoBox::Type::Megagroup,
GroupInfoBox::Type::Megagroup, channel->name() + " Chat",
channel->name() + " Chat", guarded));
guarded),
Ui::LayerOption::KeepOther);
}); });
} }
box->peerListSetAboveWidget(std::move(above)); box->peerListSetAboveWidget(std::move(above));
@ -363,10 +356,8 @@ object_ptr<Ui::BoxContent> EditLinkedChatBox(
void ShowForumForDiscussionError( void ShowForumForDiscussionError(
not_null<Window::SessionNavigation*> navigation) { not_null<Window::SessionNavigation*> navigation) {
Ui::ShowMultilineToast({ navigation->showToast(
.parentOverride = Window::Show(navigation).toastParent(), tr::lng_forum_topics_no_discussion(
.text = tr::lng_forum_topics_no_discussion(
tr::now, tr::now,
Ui::Text::RichLangValue), Ui::Text::RichLangValue));
});
} }

View file

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

View file

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

View file

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

View file

@ -48,7 +48,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/controls/userpic_button.h" #include "ui/controls/userpic_button.h"
#include "ui/rp_widget.h" #include "ui/rp_widget.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
@ -241,9 +240,7 @@ void ShowEditPermissions(
}; };
ShowEditPeerPermissionsBox(box, navigation, peer, std::move(done)); ShowEditPeerPermissionsBox(box, navigation, peer, std::move(done));
}; };
navigation->parentController()->show( navigation->parentController()->show(Box(std::move(createBox)));
Box(std::move(createBox)),
Ui::LayerOption::KeepOther);
} }
} // namespace } // namespace
@ -606,8 +603,7 @@ object_ptr<Ui::RpWidget> Controller::createStickersEdit() {
rpl::single(QString()), //Empty count. rpl::single(QString()), //Empty count.
[=, controller = _navigation->parentController()] { [=, controller = _navigation->parentController()] {
controller->show( controller->show(
Box<StickersBox>(controller, channel), Box<StickersBox>(controller->uiShow(), channel));
Ui::LayerOption::KeepOther);
}, },
{ &st::settingsIconStickers, Settings::kIconLightOrange }); { &st::settingsIconStickers, Settings::kIconLightOrange });
@ -674,8 +670,7 @@ void Controller::showEditPeerTypeBox(
_channelHasLocationOriginalValue, _channelHasLocationOriginalValue,
boxCallback, boxCallback,
_typeDataSavedValue, _typeDataSavedValue,
error), error));
Ui::LayerOption::KeepOther);
box->boxClosing( box->boxClosing(
) | rpl::start_with_next([peer = _peer] { ) | rpl::start_with_next([peer = _peer] {
peer->session().api().usernames().requestToCache(peer); peer->session().api().usernames().requestToCache(peer);
@ -709,14 +704,12 @@ void Controller::showEditLinkedChatBox() {
|| channel->canEditPreHistoryHidden())); || channel->canEditPreHistoryHidden()));
if (const auto chat = *_linkedChatSavedValue) { if (const auto chat = *_linkedChatSavedValue) {
*box = _navigation->parentController()->show( *box = _navigation->parentController()->show(EditLinkedChatBox(
EditLinkedChatBox( _navigation,
_navigation, channel,
channel, chat,
chat, canEdit,
canEdit, callback));
callback),
Ui::LayerOption::KeepOther);
return; return;
} else if (!canEdit || _linkedChatsRequestId) { } else if (!canEdit || _linkedChatsRequestId) {
return; return;
@ -743,13 +736,11 @@ void Controller::showEditLinkedChatBox() {
for (const auto &item : list) { for (const auto &item : list) {
chats.emplace_back(_peer->owner().processChat(item)); chats.emplace_back(_peer->owner().processChat(item));
} }
*box = _navigation->parentController()->show( *box = _navigation->parentController()->show(EditLinkedChatBox(
EditLinkedChatBox( _navigation,
_navigation, channel,
channel, std::move(chats),
std::move(chats), callback));
callback),
Ui::LayerOption::KeepOther);
}).fail([=] { }).fail([=] {
_linkedChatsRequestId = 0; _linkedChatsRequestId = 0;
}).send(); }).send();
@ -887,14 +878,12 @@ void Controller::fillForumButton() {
if (_linkedChatSavedValue && *_linkedChatSavedValue) { if (_linkedChatSavedValue && *_linkedChatSavedValue) {
ShowForumForDiscussionError(_navigation); ShowForumForDiscussionError(_navigation);
} else { } else {
Ui::ShowMultilineToast({ _navigation->showToast(
.parentOverride = Window::Show(_navigation).toastParent(), tr::lng_forum_topics_not_enough(
.text = tr::lng_forum_topics_not_enough(
tr::now, tr::now,
lt_count, lt_count,
EnableForumMinMembers(_peer), EnableForumMinMembers(_peer),
Ui::Text::RichLangValue), Ui::Text::RichLangValue));
});
} }
} else { } else {
_forumSavedValue = toggled; _forumSavedValue = toggled;
@ -1231,14 +1220,12 @@ void Controller::fillManageSection() {
tr::lng_manage_peer_invite_links(), tr::lng_manage_peer_invite_links(),
rpl::duplicate(count) | ToPositiveNumberString(), rpl::duplicate(count) | ToPositiveNumberString(),
[=] { [=] {
_navigation->parentController()->show( _navigation->parentController()->show(Box(
Box( ManageInviteLinksBox,
ManageInviteLinksBox, _peer,
_peer, _peer->session().user(),
_peer->session().user(), 0,
0, 0));
0),
Ui::LayerOption::KeepOther);
}, },
{ &st::infoRoundedIconInviteLinks, Settings::kIconLightOrange }); { &st::infoRoundedIconInviteLinks, Settings::kIconLightOrange });
wrap->toggle(true, anim::type::instant); wrap->toggle(true, anim::type::instant);
@ -1407,9 +1394,7 @@ void Controller::fillBotUsernamesButton() {
std::move(leftLabel), std::move(leftLabel),
std::move(rightLabel), std::move(rightLabel),
[=] { [=] {
Window::Show(_navigation).showBox( _navigation->uiShow()->showBox(Box(UsernamesBox, user));
Box(UsernamesBox, user),
Ui::LayerOption::KeepOther);
}, },
{ &st::infoRoundedIconInviteLinks, Settings::kIconLightOrange }); { &st::infoRoundedIconInviteLinks, Settings::kIconLightOrange });
} }
@ -2120,8 +2105,7 @@ void Controller::deleteWithConfirmation() {
.confirmed = deleteCallback, .confirmed = deleteCallback,
.confirmText = tr::lng_box_delete(), .confirmText = tr::lng_box_delete(),
.confirmStyle = &st::attentionBoxButton, .confirmStyle = &st::attentionBoxButton,
}), }));
Ui::LayerOption::KeepOther);
} }
void Controller::deleteChannel() { 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/widgets/popup_menu.h"
#include "ui/abstract_button.h" #include "ui/abstract_button.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/boxes/edit_invite_link.h" #include "ui/boxes/edit_invite_link.h"
#include "ui/painter.h" #include "ui/painter.h"
@ -275,12 +274,12 @@ void QrBox(
not_null<Ui::GenericBox*> box, not_null<Ui::GenericBox*> box,
const QString &link, const QString &link,
rpl::producer<QString> about, 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->setTitle(tr::lng_group_invite_qr_title());
box->addButton(tr::lng_about_done(), [=] { box->closeBox(); }); 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); share(QrForShare(link), show);
}; };
@ -346,32 +345,23 @@ void Controller::addHeaderBlock(not_null<Ui::VerticalLayout*> container) {
const auto admin = current.admin; const auto admin = current.admin;
const auto weak = Ui::MakeWeak(container); const auto weak = Ui::MakeWeak(container);
const auto copyLink = crl::guard(weak, [=] { const auto copyLink = crl::guard(weak, [=] {
CopyInviteLink(delegate()->peerListToastParent(), link); CopyInviteLink(delegate()->peerListUiShow(), link);
}); });
const auto shareLink = crl::guard(weak, [=] { const auto shareLink = crl::guard(weak, [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(ShareInviteLinkBox(_peer, link));
ShareInviteLinkBox(_peer, link),
Ui::LayerOption::KeepOther);
}); });
const auto getLinkQr = crl::guard(weak, [=] { const auto getLinkQr = crl::guard(weak, [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()), InviteLinkQrBox(link, tr::lng_group_invite_qr_about()));
Ui::LayerOption::KeepOther);
}); });
const auto revokeLink = crl::guard(weak, [=] { const auto revokeLink = crl::guard(weak, [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(RevokeLinkBox(_peer, admin, link));
RevokeLinkBox(_peer, admin, link),
Ui::LayerOption::KeepOther);
}); });
const auto editLink = crl::guard(weak, [=] { const auto editLink = crl::guard(weak, [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(EditLinkBox(_peer, _data.current()));
EditLinkBox(_peer, _data.current()),
Ui::LayerOption::KeepOther);
}); });
const auto deleteLink = crl::guard(weak, [=] { const auto deleteLink = crl::guard(weak, [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(DeleteLinkBox(_peer, admin, link));
DeleteLinkBox(_peer, admin, link),
Ui::LayerOption::KeepOther);
}); });
const auto createMenu = [=] { const auto createMenu = [=] {
@ -809,16 +799,13 @@ void Controller::processRequest(
delegate()->peerListRefreshRows(); delegate()->peerListRefreshRows();
} }
if (approved) { if (approved) {
Ui::ShowMultilineToast({ delegate()->peerListUiShow()->showToast((_peer->isBroadcast()
.parentOverride = delegate()->peerListToastParent(), ? tr::lng_group_requests_was_added_channel
.text = (_peer->isBroadcast() : tr::lng_group_requests_was_added)(
? tr::lng_group_requests_was_added_channel tr::now,
: tr::lng_group_requests_was_added)( lt_user,
tr::now, Ui::Text::Bold(user->name()),
lt_user, Ui::Text::WithEntities));
Ui::Text::Bold(user->name()),
Ui::Text::WithEntities)
});
} }
}); });
const auto fail = crl::guard(this, [=] { const auto fail = crl::guard(this, [=] {
@ -961,30 +948,24 @@ void AddPermanentLinkBlock(
const auto weak = Ui::MakeWeak(container); const auto weak = Ui::MakeWeak(container);
const auto copyLink = crl::guard(weak, [=] { const auto copyLink = crl::guard(weak, [=] {
if (const auto current = value->current(); !current.link.isEmpty()) { if (const auto current = value->current(); !current.link.isEmpty()) {
CopyInviteLink(show->toastParent(), current.link); CopyInviteLink(show, current.link);
} }
}); });
const auto shareLink = crl::guard(weak, [=] { const auto shareLink = crl::guard(weak, [=] {
if (const auto current = value->current(); !current.link.isEmpty()) { if (const auto current = value->current(); !current.link.isEmpty()) {
show->showBox( show->showBox(ShareInviteLinkBox(peer, current.link));
ShareInviteLinkBox(peer, current.link),
Ui::LayerOption::KeepOther);
} }
}); });
const auto getLinkQr = crl::guard(weak, [=] { const auto getLinkQr = crl::guard(weak, [=] {
if (const auto current = value->current(); !current.link.isEmpty()) { if (const auto current = value->current(); !current.link.isEmpty()) {
show->showBox( show->showBox(InviteLinkQrBox(
InviteLinkQrBox( current.link,
current.link, tr::lng_group_invite_qr_about()));
tr::lng_group_invite_qr_about()),
Ui::LayerOption::KeepOther);
} }
}); });
const auto revokeLink = crl::guard(weak, [=] { const auto revokeLink = crl::guard(weak, [=] {
if (const auto current = value->current(); !current.link.isEmpty()) { if (const auto current = value->current(); !current.link.isEmpty()) {
show->showBox( show->showBox(RevokeLinkBox(peer, admin, current.link, true));
RevokeLinkBox(peer, admin, current.link, true),
Ui::LayerOption::KeepOther);
} }
}); });
@ -1111,9 +1092,7 @@ void AddPermanentLinkBlock(
st::inviteLinkJoinedRowPadding st::inviteLinkJoinedRowPadding
)->setClickedCallback([=] { )->setClickedCallback([=] {
if (!currentLinkFields->link.isEmpty()) { if (!currentLinkFields->link.isEmpty()) {
show->showBox( show->showBox(ShowInviteLinkBox(peer, *currentLinkFields));
ShowInviteLinkBox(peer, *currentLinkFields),
Ui::LayerOption::KeepOther);
} }
}); });
@ -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); 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( object_ptr<Ui::BoxContent> ShareInviteLinkBox(
@ -1147,7 +1126,7 @@ object_ptr<Ui::BoxContent> ShareInviteLinkBox(
const auto showToast = [=](const QString &text) { const auto showToast = [=](const QString &text) {
if (*box) { 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); text.append(error.first);
if (*box) { if (*box) {
Ui::BoxShow(*box).showBox( (*box)->uiShow()->showBox(Ui::MakeInformBox(text));
Ui::MakeInformBox(text),
Ui::LayerOption::KeepOther);
} }
return; return;
} }
@ -1232,14 +1209,11 @@ object_ptr<Ui::BoxContent> InviteLinkQrBox(
rpl::producer<QString> about) { rpl::producer<QString> about) {
return Box(QrBox, link, std::move(about), [=]( return Box(QrBox, link, std::move(about), [=](
const QImage &image, const QImage &image,
std::shared_ptr<Ui::BoxShow> show) { std::shared_ptr<Ui::Show> show) {
auto mime = std::make_unique<QMimeData>(); auto mime = std::make_unique<QMimeData>();
mime->setImageData(image); mime->setImageData(image);
QGuiApplication::clipboard()->setMimeData(mime.release()); QGuiApplication::clipboard()->setMimeData(mime.release());
show->showToast(tr::lng_group_invite_qr_copied(tr::now));
Ui::Toast::Show(
show->toastParent(),
tr::lng_group_invite_qr_copied(tr::now));
}); });
} }

View file

@ -38,7 +38,7 @@ void AddPermanentLinkBlock(
not_null<UserData*> admin, not_null<UserData*> admin,
rpl::producer<Api::InviteLink> fromList); 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( [[nodiscard]] object_ptr<Ui::BoxContent> ShareInviteLinkBox(
not_null<PeerData*> peer, not_null<PeerData*> peer,
const QString &link); 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_chat.h"
#include "data/data_channel.h" #include "data/data_channel.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "main/session/session_show.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "api/api_invite_links.h" #include "api/api_invite_links.h"
#include "ui/wrap/slide_wrap.h" #include "ui/wrap/slide_wrap.h"
@ -543,8 +544,7 @@ void LinksController::appendSlice(const InviteLinksSlice &slice) {
void LinksController::rowClicked(not_null<PeerListRow*> row) { void LinksController::rowClicked(not_null<PeerListRow*> row) {
delegate()->peerListShowBox( delegate()->peerListShowBox(
ShowInviteLinkBox(_peer, static_cast<Row*>(row.get())->data()), ShowInviteLinkBox(_peer, static_cast<Row*>(row.get())->data()));
Ui::LayerOption::KeepOther);
} }
void LinksController::rowRightActionClicked(not_null<PeerListRow*> row) { void LinksController::rowRightActionClicked(not_null<PeerListRow*> row) {
@ -579,33 +579,25 @@ base::unique_qptr<Ui::PopupMenu> LinksController::createRowContextMenu(
st::popupMenuWithIcons); st::popupMenuWithIcons);
if (data.revoked) { if (data.revoked) {
result->addAction(tr::lng_group_invite_context_delete(tr::now), [=] { result->addAction(tr::lng_group_invite_context_delete(tr::now), [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(DeleteLinkBox(_peer, _admin, link));
DeleteLinkBox(_peer, _admin, link),
Ui::LayerOption::KeepOther);
}, &st::menuIconDelete); }, &st::menuIconDelete);
} else { } else {
result->addAction(tr::lng_group_invite_context_copy(tr::now), [=] { result->addAction(tr::lng_group_invite_context_copy(tr::now), [=] {
CopyInviteLink(delegate()->peerListToastParent(), link); CopyInviteLink(delegate()->peerListUiShow(), link);
}, &st::menuIconCopy); }, &st::menuIconCopy);
result->addAction(tr::lng_group_invite_context_share(tr::now), [=] { result->addAction(tr::lng_group_invite_context_share(tr::now), [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(
ShareInviteLinkBox(_peer, link), ShareInviteLinkBox(_peer, link));
Ui::LayerOption::KeepOther);
}, &st::menuIconShare); }, &st::menuIconShare);
result->addAction(tr::lng_group_invite_context_qr(tr::now), [=] { result->addAction(tr::lng_group_invite_context_qr(tr::now), [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(
InviteLinkQrBox(link, tr::lng_group_invite_qr_about()), InviteLinkQrBox(link, tr::lng_group_invite_qr_about()));
Ui::LayerOption::KeepOther);
}, &st::menuIconQrCode); }, &st::menuIconQrCode);
result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] { result->addAction(tr::lng_group_invite_context_edit(tr::now), [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(EditLinkBox(_peer, data));
EditLinkBox(_peer, data),
Ui::LayerOption::KeepOther);
}, &st::menuIconEdit); }, &st::menuIconEdit);
result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] { result->addAction(tr::lng_group_invite_context_revoke(tr::now), [=] {
delegate()->peerListShowBox( delegate()->peerListShowBox(RevokeLinkBox(_peer, _admin, link));
RevokeLinkBox(_peer, _admin, link),
Ui::LayerOption::KeepOther);
}, &st::menuIconRemove); }, &st::menuIconRemove);
} }
return result; return result;
@ -813,8 +805,7 @@ void AdminsController::loadMoreRows() {
void AdminsController::rowClicked(not_null<PeerListRow*> row) { void AdminsController::rowClicked(not_null<PeerListRow*> row) {
delegate()->peerListShowBox( delegate()->peerListShowBox(
Box(ManageInviteLinksBox, _peer, row->peer()->asUser(), 0, 0), Box(ManageInviteLinksBox, _peer, row->peer()->asUser(), 0, 0));
Ui::LayerOption::KeepOther);
} }
Main::Session &AdminsController::session() const { Main::Session &AdminsController::session() const {
@ -836,7 +827,7 @@ struct LinksList {
}; };
LinksList AddLinksList( LinksList AddLinksList(
std::shared_ptr<Ui::BoxShow> show, std::shared_ptr<Main::SessionShow> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer, not_null<PeerData*> peer,
not_null<UserData*> admin, not_null<UserData*> admin,
@ -861,7 +852,7 @@ LinksList AddLinksList(
} }
not_null<Ui::RpWidget*> AddAdminsList( not_null<Ui::RpWidget*> AddAdminsList(
std::shared_ptr<Ui::BoxShow> show, std::shared_ptr<Main::SessionShow> show,
not_null<Ui::VerticalLayout*> container, not_null<Ui::VerticalLayout*> container,
not_null<PeerData*> peer, not_null<PeerData*> peer,
not_null<UserData*> admin) { not_null<UserData*> admin) {
@ -889,7 +880,9 @@ void ManageInviteLinksBox(
int revokedCount) { int revokedCount) {
using namespace Settings; 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->setTitle(tr::lng_group_invite_title());
box->setWidth(st::boxWideWidth); box->setWidth(st::boxWideWidth);
@ -925,8 +918,7 @@ void ManageInviteLinksBox(
const auto add = AddCreateLinkButton(container); const auto add = AddCreateLinkButton(container);
add->setClickedCallback([=] { add->setClickedCallback([=] {
show->showBox( show->showBox(
EditLinkBox(peer, InviteLinkData{ .admin = admin }), EditLinkBox(peer, InviteLinkData{ .admin = admin }));
Ui::LayerOption::KeepOther);
}); });
} else { } else {
otherHeader = container->add(object_ptr<Ui::SlideWrap<>>( otherHeader = container->add(object_ptr<Ui::SlideWrap<>>(
@ -1006,8 +998,8 @@ void ManageInviteLinksBox(
top + st::inviteLinkRevokedTitlePadding.top(), top + st::inviteLinkRevokedTitlePadding.top(),
outerWidth); outerWidth);
}, deleteAll->lifetime()); }, deleteAll->lifetime());
deleteAll->setClickedCallback([=, show = Ui::BoxShow(box)] { deleteAll->setClickedCallback([=, show = box->uiShow()] {
show.showBox(DeleteAllRevokedBox(peer, admin)); show->showBox(DeleteAllRevokedBox(peer, admin));
}); });
rpl::combine( 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/continuous_sliders.h"
#include "ui/widgets/box_content_divider.h" #include "ui/widgets/box_content_divider.h"
#include "ui/text/text_utilities.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_icon.h"
#include "info/profile/info_profile_values.h" #include "info/profile/info_profile_values.h"
#include "boxes/peers/edit_participants_box.h" #include "boxes/peers/edit_participants_box.h"
@ -417,10 +417,7 @@ not_null<Ui::RpWidget*> AddInnerToggle(
const auto handleLocked = [=] { const auto handleLocked = [=] {
if (locked.has_value()) { if (locked.has_value()) {
Ui::ShowMultilineToast({ Ui::Toast::Show(container, *locked);
.parentOverride = container,
.text = { *locked },
});
return true; return true;
} }
return false; return false;
@ -597,8 +594,7 @@ template <typename Flags>
) | rpl::start_with_next([=](bool checked) { ) | rpl::start_with_next([=](bool checked) {
if (checked && state->forceDisabled.current()) { if (checked && state->forceDisabled.current()) {
if (!state->toast) { if (!state->toast) {
state->toast = Ui::ShowMultilineToast({ state->toast = Ui::Toast::Show(container, {
.parentOverride = container,
.text = { state->forceDisabledMessage.current() }, .text = { state->forceDisabledMessage.current() },
.duration = kForceDisableTooltipDuration, .duration = kForceDisableTooltipDuration,
}); });
@ -607,8 +603,7 @@ template <typename Flags>
} else if (locked.has_value()) { } else if (locked.has_value()) {
if (checked != toggled) { if (checked != toggled) {
if (!state->toast) { if (!state->toast) {
state->toast = Ui::ShowMultilineToast({ state->toast = Ui::Toast::Show(container, {
.parentOverride = container,
.text = { *locked }, .text = { *locked },
.duration = kForceDisableTooltipDuration, .duration = kForceDisableTooltipDuration,
}); });
@ -970,23 +965,20 @@ Fn<void()> AboutGigagroupCallback(
channel->inputChannel channel->inputChannel
)).done([=](const MTPUpdates &result) { )).done([=](const MTPUpdates &result) {
channel->session().api().applyUpdates(result); channel->session().api().applyUpdates(result);
if (const auto strongController = weak.get()) { if (const auto strong = weak.get()) {
strongController->window().hideSettingsAndLayer(); strong->window().hideSettingsAndLayer();
Ui::ShowMultilineToast({ strong->showToast(tr::lng_gigagroup_done(tr::now));
.parentOverride = strongController->widget(),
.text = { tr::lng_gigagroup_done(tr::now) },
});
} }
}).fail([=] { }).fail([=] {
*converting = false; *converting = false;
}).send(); }).send();
}; };
const auto convertWarn = [=] { const auto convertWarn = [=] {
const auto strongController = weak.get(); const auto strong = weak.get();
if (*converting || !strongController) { if (*converting || !strong) {
return; 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->setTitle(tr::lng_gigagroup_warning_title());
box->addRow( box->addRow(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
@ -996,14 +988,14 @@ Fn<void()> AboutGigagroupCallback(
st::infoAboutGigagroup)); st::infoAboutGigagroup));
box->addButton(tr::lng_gigagroup_convert_sure(), convertSure); box->addButton(tr::lng_gigagroup_convert_sure(), convertSure);
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
}), Ui::LayerOption::KeepOther); }));
}; };
return [=] { return [=] {
const auto strongController = weak.get(); const auto strong = weak.get();
if (*converting || !strongController) { if (*converting || !strong) {
return; return;
} }
strongController->show(Box([=](not_null<Ui::GenericBox*> box) { strong->show(Box([=](not_null<Ui::GenericBox*> box) {
box->setTitle(tr::lng_gigagroup_convert_title()); box->setTitle(tr::lng_gigagroup_convert_title());
const auto addFeature = [&](rpl::producer<QString> text) { const auto addFeature = [&](rpl::producer<QString> text) {
using namespace rpl::mappers; using namespace rpl::mappers;
@ -1024,7 +1016,7 @@ Fn<void()> AboutGigagroupCallback(
addFeature(tr::lng_gigagroup_convert_feature3()); addFeature(tr::lng_gigagroup_convert_feature3());
box->addButton(tr::lng_gigagroup_convert_sure(), convertWarn); box->addButton(tr::lng_gigagroup_convert_sure(), convertWarn);
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); 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 "main/main_session.h"
#include "mtproto/sender.h" #include "mtproto/sender.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
@ -382,16 +381,13 @@ void RequestsBoxController::processRequest(
const auto done = crl::guard(this, [=] { const auto done = crl::guard(this, [=] {
remove(); remove();
if (approved) { if (approved) {
Ui::ShowMultilineToast({ delegate()->peerListUiShow()->showToast((_peer->isBroadcast()
.parentOverride = delegate()->peerListToastParent(), ? tr::lng_group_requests_was_added_channel
.text = (_peer->isBroadcast() : tr::lng_group_requests_was_added)(
? tr::lng_group_requests_was_added_channel tr::now,
: tr::lng_group_requests_was_added)( lt_user,
tr::now, Ui::Text::Bold(user->name()),
lt_user, Ui::Text::WithEntities));
Ui::Text::Bold(user->name()),
Ui::Text::WithEntities)
});
} }
}); });
const auto fail = crl::guard(this, remove); const auto fail = crl::guard(this, remove);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -27,9 +27,9 @@ class CrossButton;
class BoxContentDivider; class BoxContentDivider;
} // namespace Ui } // namespace Ui
namespace Window { namespace ChatHelpers {
class SessionController; class Show;
} // namespace Window } // namespace ChatHelpers
namespace Main { namespace Main {
class Session; class Session;
@ -60,20 +60,20 @@ public:
StickersBox( StickersBox(
QWidget*, QWidget*,
not_null<Window::SessionController*> controller, std::shared_ptr<ChatHelpers::Show> show,
Section section, Section section,
bool masks = false); bool masks = false);
StickersBox( StickersBox(
QWidget*, QWidget*,
not_null<Window::SessionController*> controller, std::shared_ptr<ChatHelpers::Show> show,
not_null<ChannelData*> megagroup); not_null<ChannelData*> megagroup);
StickersBox( StickersBox(
QWidget*, QWidget*,
not_null<Window::SessionController*> controller, std::shared_ptr<ChatHelpers::Show> show,
const QVector<MTPStickerSetCovered> &attachedSets); const QVector<MTPStickerSetCovered> &attachedSets);
StickersBox( StickersBox(
QWidget*, QWidget*,
not_null<Window::SessionController*> controller, std::shared_ptr<ChatHelpers::Show> show,
const std::vector<StickerSetIdentifier> &emojiSets); const std::vector<StickerSetIdentifier> &emojiSets);
~StickersBox(); ~StickersBox();
@ -142,7 +142,8 @@ private:
std::array<Inner*, 5> widgets() const; 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; MTP::Sender _api;
object_ptr<Ui::SettingsSlider> _tabs = { nullptr }; 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/effects/loading_element.h"
#include "ui/layers/generic_box.h" #include "ui/layers/generic_box.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
@ -263,7 +262,7 @@ void TranslateBox(
if (loading->toggled()) { if (loading->toggled()) {
return; return;
} }
Ui::BoxShow(box).showBox(ChooseTranslateToBox( box->uiShow()->showBox(ChooseTranslateToBox(
state->to.current(), state->to.current(),
crl::guard(box, [=](LanguageId id) { state->to = id; }))); crl::guard(box, [=](LanguageId id) { state->to = id; })));
}); });
@ -314,11 +313,9 @@ object_ptr<BoxContent> EditSkipTranslationLanguages() {
} }
if (already && selected->empty()) { if (already && selected->empty()) {
if (const auto strong = weak->data()) { if (const auto strong = weak->data()) {
Ui::ShowMultilineToast({ strong->showToast(
.parentOverride = BoxShow(strong).toastParent(), tr::lng_translate_settings_one(tr::now),
.text = { tr::lng_translate_settings_one(tr::now) }, kSkipAtLeastOneDuration);
.duration = kSkipAtLeastOneDuration,
});
} }
return false; return false;
} }

View file

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

View file

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

View file

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

View file

@ -406,9 +406,7 @@ void ChooseJoinAsProcess::processList(
auto info = JoinInfo{ .peer = peer, .joinAs = self }; auto info = JoinInfo{ .peer = peer, .joinAs = self };
const auto selectedId = peer->groupCallDefaultJoinAs(); const auto selectedId = peer->groupCallDefaultJoinAs();
if (list.empty()) { if (list.empty()) {
Ui::Toast::Show( _request->show->showToast(Lang::Hard::ServerError());
_request->show->toastParent(),
Lang::Hard::ServerError());
return; return;
} }
info.joinAs = [&]() -> not_null<PeerData*> { 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_keys.h"
#include "lang/lang_hardcoded.h" #include "lang/lang_hardcoded.h"
#include "boxes/peers/edit_participants_box.h" // SubscribeToMigration. #include "boxes/peers/edit_participants_box.h" // SubscribeToMigration.
#include "ui/toasts/common_toasts.h" #include "ui/toast/toast.h"
#include "base/unixtime.h" #include "base/unixtime.h"
#include "core/application.h" #include "core/application.h"
#include "core/core_settings.h" #include "core/core_settings.h"
@ -1413,11 +1413,9 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
} }
hangup(); hangup();
Ui::ShowMultilineToast({ Ui::Toast::Show((type == u"GROUPCALL_FORBIDDEN"_q)
.text = { type == u"GROUPCALL_FORBIDDEN"_q ? tr::lng_group_not_accessible(tr::now)
? tr::lng_group_not_accessible(tr::now) : Lang::Hard::ServerError());
: Lang::Hard::ServerError() },
});
}).send(); }).send();
}); });
}); });

View file

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

View file

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

View file

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

View file

@ -32,7 +32,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/layers/generic_box.h" #include "ui/layers/generic_box.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/image/image_prepare.h" #include "ui/image/image_prepare.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "ui/round_rect.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_group_call.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_changes.h" #include "data/data_changes.h"
#include "main/session/session_show.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "base/event_filter.h" #include "base/event_filter.h"
#include "base/unixtime.h" #include "base/unixtime.h"
@ -75,6 +75,67 @@ constexpr auto kControlsBackgroundOpacity = 0.8;
constexpr auto kOverrideActiveColorBgAlpha = 172; constexpr auto kOverrideActiveColorBgAlpha = 172;
constexpr auto kHideControlsTimeout = 5 * crl::time(1000); 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 } // namespace
struct Panel::ControlsBackgroundNarrow { struct Panel::ControlsBackgroundNarrow {
@ -176,15 +237,25 @@ bool Panel::isActive() const {
&& !(window()->windowState() & Qt::WindowMinimized); && !(window()->windowState() & Qt::WindowMinimized);
} }
void Panel::showToast(TextWithEntities &&text, crl::time duration) { base::weak_ptr<Ui::Toast::Instance> Panel::showToast(
if (const auto strong = _lastToast.get()) { const QString &text,
strong->hideAnimated(); crl::time duration) {
} return Show(this).showToast(text, duration);
_lastToast = Ui::ShowMultilineToast({ }
.parentOverride = widget(),
.text = std::move(text), base::weak_ptr<Ui::Toast::Instance> Panel::showToast(
.duration = duration, 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() { void Panel::minimize() {
@ -634,16 +705,9 @@ void Panel::hideNiceTooltip() {
} }
void Panel::initShareAction() { 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( auto [shareLinkCallback, shareLinkLifetime] = ShareInviteLinkAction(
_peer, _peer,
showBoxCallback, uiShow());
showToastCallback);
_callShareLinkCallback = [=, callback = std::move(shareLinkCallback)] { _callShareLinkCallback = [=, callback = std::move(shareLinkCallback)] {
if (_call->lookupReal()) { if (_call->lookupReal()) {
callback(); callback();
@ -1467,6 +1531,10 @@ void Panel::hideLayer(anim::type animated) {
_layerBg->hideAll(animated); _layerBg->hideAll(animated);
} }
bool Panel::isLayerShown() const {
return _layerBg->topShownLayer() != nullptr;
}
void Panel::kickParticipantSure(not_null<PeerData*> participantPeer) { void Panel::kickParticipantSure(not_null<PeerData*> participantPeer) {
if (const auto chat = _peer->asChat()) { if (const auto chat = _peer->asChat()) {
chat->session().api().chatParticipants().kick(chat, participantPeer); chat->session().api().chatParticipants().kick(chat, participantPeer);
@ -2550,38 +2618,4 @@ not_null<Ui::RpWidget*> Panel::widget() const {
return _window.widget(); 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 } // namespace Calls::Group

View file

@ -52,14 +52,21 @@ class ScrollArea;
class GenericBox; class GenericBox;
class LayerManager; class LayerManager;
class GroupCallScheduledLeft; class GroupCallScheduledLeft;
namespace Toast {
class Instance;
} // namespace Toast
namespace Platform {
struct SeparateTitleControls;
} // namespace Platform
} // namespace Ui } // 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 { namespace style {
struct CallSignalBars; struct CallSignalBars;
struct CallBodyLayout; struct CallBodyLayout;
@ -85,13 +92,22 @@ public:
[[nodiscard]] not_null<GroupCall*> call() const; [[nodiscard]] not_null<GroupCall*> call() const;
[[nodiscard]] bool isActive() 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);
void showBox( void showBox(
object_ptr<Ui::BoxContent> box, object_ptr<Ui::BoxContent> box,
Ui::LayerOptions options, Ui::LayerOptions options,
anim::type animated = anim::type::normal); anim::type animated = anim::type::normal);
void hideLayer(anim::type animated = anim::type::normal); void hideLayer(anim::type animated = anim::type::normal);
[[nodiscard]] bool isLayerShown() const;
void minimize(); void minimize();
void toggleFullScreen(); void toggleFullScreen();
@ -99,6 +115,8 @@ public:
void showAndActivate(); void showAndActivate();
void closeBeforeDestroy(); void closeBeforeDestroy();
[[nodiscard]] std::shared_ptr<Main::SessionShow> uiShow();
rpl::lifetime &lifetime(); rpl::lifetime &lifetime();
private: private:
@ -260,7 +278,6 @@ private:
Fn<void()> _callShareLinkCallback; Fn<void()> _callShareLinkCallback;
const std::unique_ptr<Toasts> _toasts; const std::unique_ptr<Toasts> _toasts;
base::weak_ptr<Ui::Toast::Instance> _lastToast;
std::unique_ptr<MicLevelTester> _micLevelTester; 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 } // namespace Calls::Group

View file

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

View file

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

View file

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

View file

@ -13,7 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_peer.h" #include "data/data_peer.h"
#include "data/data_group_call.h" #include "data/data_group_call.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h" #include "ui/toast/toast.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
namespace Calls::Group { namespace Calls::Group {
@ -83,15 +83,13 @@ void Toasts::setupAllowedToSpeak() {
_call->allowedToSpeakNotifications( _call->allowedToSpeakNotifications(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
if (_panel->isActive()) { if (_panel->isActive()) {
_panel->showToast({ _panel->showToast(tr::lng_group_call_can_speak_here(tr::now));
tr::lng_group_call_can_speak_here(tr::now),
});
} else { } else {
const auto real = _call->lookupReal(); const auto real = _call->lookupReal();
const auto name = (real && !real->title().isEmpty()) const auto name = (real && !real->title().isEmpty())
? real->title() ? real->title()
: _call->peer()->name(); : _call->peer()->name();
Ui::ShowMultilineToast({ Ui::Toast::Show({
.text = tr::lng_group_call_can_speak( .text = tr::lng_group_call_can_speak(
tr::now, tr::now,
lt_chat, lt_chat,
@ -139,7 +137,7 @@ void Toasts::setupPinnedVideo() {
: tr::lng_group_call_unpinned_screen); : tr::lng_group_call_unpinned_screen);
return key(tr::now, lt_user, peer->shortName()); return key(tr::now, lt_user, peer->shortName());
}(); }();
_panel->showToast({ text }); _panel->showToast(text);
}, _lifetime); }, _lifetime);
} }
@ -148,9 +146,8 @@ void Toasts::setupRequestedToSpeak() {
) | rpl::combine_previous( ) | rpl::combine_previous(
) | rpl::start_with_next([=](MuteState was, MuteState now) { ) | rpl::start_with_next([=](MuteState was, MuteState now) {
if (was == MuteState::ForceMuted && now == MuteState::RaisedHand) { if (was == MuteState::ForceMuted && now == MuteState::RaisedHand) {
_panel->showToast({ _panel->showToast(
tr::lng_group_call_tooltip_raised_hand(tr::now), tr::lng_group_call_tooltip_raised_hand(tr::now));
});
} }
}, _lifetime); }, _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( EmojiListWidget::EmojiListWidget(
QWidget *parent, QWidget *parent,
not_null<Window::SessionController*> controller, not_null<Window::SessionController*> controller,
Window::GifPauseReason level, PauseReason level,
Mode mode) Mode mode)
: EmojiListWidget(parent, { : EmojiListWidget(parent, {
.session = &controller->session(), .show = controller->uiShow(),
.mode = mode, .mode = mode,
.controller = controller,
.paused = Window::PausedIn(controller, level), .paused = Window::PausedIn(controller, level),
}) { }) {
} }
@ -386,9 +385,9 @@ EmojiListWidget::EmojiListWidget(
: Inner( : Inner(
parent, parent,
descriptor.st ? *descriptor.st : st::defaultEmojiPan, descriptor.st ? *descriptor.st : st::defaultEmojiPan,
descriptor.session, descriptor.show,
std::move(descriptor.paused)) std::move(descriptor.paused))
, _controller(descriptor.controller) , _show(std::move(descriptor.show))
, _mode(descriptor.mode) , _mode(descriptor.mode)
, _staticCount(_mode == Mode::Full ? kEmojiSectionCount : 1) , _staticCount(_mode == Mode::Full ? kEmojiSectionCount : 1)
, _premiumIcon(_mode == Mode::EmojiStatus , _premiumIcon(_mode == Mode::EmojiStatus
@ -466,7 +465,7 @@ EmojiListWidget::~EmojiListWidget() {
} }
void EmojiListWidget::setupSearch() { void EmojiListWidget::setupSearch() {
const auto session = &_controller->session(); const auto session = &_show->session();
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) { _search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
_nextSearchQuery = std::move(query); _nextSearchQuery = std::move(query);
InvokeQueued(this, [=] { InvokeQueued(this, [=] {
@ -1419,26 +1418,27 @@ void EmojiListWidget::mouseReleaseEvent(QMouseEvent *e) {
Assert(button->section >= _staticCount Assert(button->section >= _staticCount
&& button->section < _staticCount + _custom.size()); && button->section < _staticCount + _custom.size());
const auto id = _custom[button->section - _staticCount].id; const auto id = _custom[button->section - _staticCount].id;
const auto usage = ChatHelpers::WindowUsage::PremiumPromo;
if (hasRemoveButton(button->section)) { if (hasRemoveButton(button->section)) {
removeSet(id); removeSet(id);
} else if (hasAddButton(button->section)) { } else if (hasAddButton(button->section)) {
_localSetsManager->install(id); _localSetsManager->install(id);
} else if (_controller) { } else if (const auto resolved = _show->resolveWindow(usage)) {
_jumpedToPremium.fire({}); _jumpedToPremium.fire({});
switch (_mode) { switch (_mode) {
case Mode::Full: case Mode::Full:
case Mode::UserpicBuilder: case Mode::UserpicBuilder:
Settings::ShowPremium(_controller, u"animated_emoji"_q); Settings::ShowPremium(resolved, u"animated_emoji"_q);
break; break;
case Mode::FullReactions: case Mode::FullReactions:
case Mode::RecentReactions: case Mode::RecentReactions:
Settings::ShowPremium(_controller, u"infinite_reactions"_q); Settings::ShowPremium(resolved, u"infinite_reactions"_q);
break; break;
case Mode::EmojiStatus: case Mode::EmojiStatus:
Settings::ShowPremium(_controller, u"emoji_status"_q); Settings::ShowPremium(resolved, u"emoji_status"_q);
break; break;
case Mode::TopicIcon: case Mode::TopicIcon:
Settings::ShowPremium(_controller, u"forum_topic_icon"_q); Settings::ShowPremium(resolved, u"forum_topic_icon"_q);
break; break;
} }
} }
@ -1448,20 +1448,14 @@ void EmojiListWidget::mouseReleaseEvent(QMouseEvent *e) {
void EmojiListWidget::displaySet(uint64 setId) { void EmojiListWidget::displaySet(uint64 setId) {
const auto &sets = session().data().stickers().sets(); const auto &sets = session().data().stickers().sets();
auto it = sets.find(setId); auto it = sets.find(setId);
if (it != sets.cend() && _controller) { if (it != sets.cend()) {
checkHideWithBox(_controller->show( checkHideWithBox(Box<StickerSetBox>(_show, it->second.get()));
Box<StickerSetBox>(_controller, it->second.get()),
Ui::LayerOption::KeepOther).data());
} }
} }
void EmojiListWidget::removeSet(uint64 setId) { void EmojiListWidget::removeSet(uint64 setId) {
if (auto box = MakeConfirmRemoveSetBox(&session(), setId)) { if (auto box = MakeConfirmRemoveSetBox(&session(), setId)) {
if (_controller) { checkHideWithBox(std::move(box));
checkHideWithBox(_controller->show(
std::move(box),
Ui::LayerOption::KeepOther));
}
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -62,7 +62,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/click_handler_types.h" // ClickHandlerContext #include "core/click_handler_types.h" // ClickHandlerContext
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "storage/file_upload.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 "apiwrap.h"
#include "styles/style_chat.h" #include "styles/style_chat.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
@ -1828,7 +1828,7 @@ ClickHandlerPtr MediaDice::MakeHandler(
auto config = Ui::Toast::Config{ auto config = Ui::Toast::Config{
.text = { tr::lng_about_random(tr::now, lt_emoji, emoji) }, .text = { tr::lng_about_random(tr::now, lt_emoji, emoji) },
.st = &st::historyDiceToast, .st = &st::historyDiceToast,
.durationMs = Ui::Toast::kDefaultDuration * 2, .duration = Ui::Toast::kDefaultDuration * 2,
.multiline = true, .multiline = true,
}; };
if (CanSend(history->peer, ChatRestriction::SendOther)) { if (CanSend(history->peer, ChatRestriction::SendOther)) {
@ -1857,9 +1857,7 @@ ClickHandlerPtr MediaDice::MakeHandler(
const auto my = context.other.value<ClickHandlerContext>(); const auto my = context.other.value<ClickHandlerContext>();
const auto weak = my.sessionWindow; const auto weak = my.sessionWindow;
if (const auto strong = weak.get()) { if (const auto strong = weak.get()) {
ShownToast = Ui::Toast::Show( ShownToast = strong->showToast(std::move(config));
Window::Show(strong).toastParent(),
config);
} else { } else {
ShownToast = Ui::Toast::Show(config); 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/image/image.h"
#include "ui/empty_userpic.h" #include "ui/empty_userpic.h"
#include "ui/text/text_options.h" #include "ui/text/text_options.h"
#include "ui/toasts/common_toasts.h"
#include "ui/painter.h" #include "ui/painter.h"
#include "ui/ui_utility.h" #include "ui/ui_utility.h"
#include "history/history.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 "data/stickers/data_stickers.h"
#include "api/api_hash.h" #include "api/api_hash.h"
#include "chat_helpers/compose/compose_show.h"
#include "data/data_document.h" #include "data/data_document.h"
#include "data/data_session.h" #include "data/data_session.h"
#include "data/data_user.h" #include "data/data_user.h"
@ -29,7 +30,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "main/main_app_config.h" #include "main/main_app_config.h"
#include "mtproto/mtproto_config.h" #include "mtproto/mtproto_config.h"
#include "ui/toast/toast.h" #include "ui/toast/toast.h"
#include "ui/toasts/common_toasts.h"
#include "ui/image/image_location_factory.h" #include "ui/image/image_location_factory.h"
#include "window/window_controller.h" #include "window/window_controller.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
@ -78,24 +78,24 @@ using SetFlag = StickersSetFlag;
} }
void MaybeShowPremiumToast( void MaybeShowPremiumToast(
Window::SessionController *controller, std::shared_ptr<ChatHelpers::Show> show,
TextWithEntities text, TextWithEntities text,
const QString &ref) { const QString &ref) {
if (!controller) { if (!show) {
return; return;
} }
const auto session = &controller->session(); const auto session = &show->session();
if (session->user()->isPremium()) { if (session->user()->isPremium()) {
return; return;
} }
const auto widget = QPointer<Ui::RpWidget>(
controller->window().widget()->bodyWidget());
const auto filter = [=](const auto ...) { 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; return false;
}; };
Ui::ShowMultilineToast({ show->showToast({
.parentOverride = widget,
.text = std::move(text), .text = std::move(text),
.duration = kPremiumToastDuration, .duration = kPremiumToastDuration,
.filter = filter, .filter = filter,
@ -313,7 +313,7 @@ void Stickers::incrementSticker(not_null<DocumentData*> document) {
} }
void Stickers::addSavedGif( void Stickers::addSavedGif(
Window::SessionController *controller, std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document) { not_null<DocumentData*> document) {
const auto index = _savedGifs.indexOf(document); const auto index = _savedGifs.indexOf(document);
if (!index) { if (!index) {
@ -328,7 +328,7 @@ void Stickers::addSavedGif(
if (_savedGifs.size() > limits.gifsCurrent()) { if (_savedGifs.size() > limits.gifsCurrent()) {
_savedGifs.pop_back(); _savedGifs.pop_back();
MaybeShowPremiumToast( MaybeShowPremiumToast(
controller, show,
SavedGifsToast(limits), SavedGifsToast(limits),
LimitsPremiumRef("saved_gifs")); LimitsPremiumRef("saved_gifs"));
} }
@ -518,7 +518,7 @@ bool Stickers::isFaved(not_null<const DocumentData*> document) {
void Stickers::checkFavedLimit( void Stickers::checkFavedLimit(
StickersSet &set, StickersSet &set,
Window::SessionController *controller) { std::shared_ptr<ChatHelpers::Show> show) {
const auto session = &_owner->session(); const auto session = &_owner->session();
const auto limits = Data::PremiumLimits(session); const auto limits = Data::PremiumLimits(session);
if (set.stickers.size() <= limits.stickersFavedCurrent()) { if (set.stickers.size() <= limits.stickersFavedCurrent()) {
@ -538,21 +538,21 @@ void Stickers::checkFavedLimit(
++i; ++i;
} }
MaybeShowPremiumToast( MaybeShowPremiumToast(
controller, std::move(show),
FaveStickersToast(limits), FaveStickersToast(limits),
LimitsPremiumRef("stickers_faved")); LimitsPremiumRef("stickers_faved"));
} }
void Stickers::pushFavedToFront( void Stickers::pushFavedToFront(
StickersSet &set, StickersSet &set,
Window::SessionController *controller, std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document, not_null<DocumentData*> document,
const std::vector<not_null<EmojiPtr>> &emojiList) { const std::vector<not_null<EmojiPtr>> &emojiList) {
set.stickers.push_front(document); set.stickers.push_front(document);
for (auto emoji : emojiList) { for (auto emoji : emojiList) {
set.emoji[emoji].push_front(document); set.emoji[emoji].push_front(document);
} }
checkFavedLimit(set, controller); checkFavedLimit(set, std::move(show));
} }
void Stickers::moveFavedToFront(StickersSet &set, int index) { void Stickers::moveFavedToFront(StickersSet &set, int index) {
@ -575,7 +575,7 @@ void Stickers::moveFavedToFront(StickersSet &set, int index) {
} }
void Stickers::setIsFaved( void Stickers::setIsFaved(
Window::SessionController *controller, std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document, not_null<DocumentData*> document,
std::optional<std::vector<not_null<EmojiPtr>>> emojiList) { std::optional<std::vector<not_null<EmojiPtr>>> emojiList) {
auto &sets = setsRef(); auto &sets = setsRef();
@ -600,11 +600,11 @@ void Stickers::setIsFaved(
if (index > 0) { if (index > 0) {
moveFavedToFront(*set, index); moveFavedToFront(*set, index);
} else if (emojiList) { } else if (emojiList) {
pushFavedToFront(*set, controller, document, *emojiList); pushFavedToFront(*set, show, document, *emojiList);
} else if (auto list = getEmojiListFromSet(document)) { } else if (auto list = getEmojiListFromSet(document)) {
pushFavedToFront(*set, controller, document, *list); pushFavedToFront(*set, show, document, *list);
} else { } else {
requestSetToPushFaved(controller, document); requestSetToPushFaved(show, document);
return; return;
} }
session().local().writeFavedStickers(); session().local().writeFavedStickers();
@ -613,10 +613,8 @@ void Stickers::setIsFaved(
} }
void Stickers::requestSetToPushFaved( void Stickers::requestSetToPushFaved(
Window::SessionController *controller, std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document) { not_null<DocumentData*> document) {
controller = nullptr;
const auto weak = base::make_weak(controller);
auto addAnyway = [=](std::vector<not_null<EmojiPtr>> list) { auto addAnyway = [=](std::vector<not_null<EmojiPtr>> list) {
if (list.empty()) { if (list.empty()) {
if (auto sticker = document->sticker()) { 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( session().api().request(MTPmessages_GetStickerSet(
Data::InputStickerSet(document->sticker()->set), Data::InputStickerSet(document->sticker()->set),
@ -668,11 +666,11 @@ void Stickers::setIsNotFaved(not_null<DocumentData*> document) {
} }
void Stickers::setFaved( void Stickers::setFaved(
Window::SessionController *controller, std::shared_ptr<ChatHelpers::Show> show,
not_null<DocumentData*> document, not_null<DocumentData*> document,
bool faved) { bool faved) {
if (faved) { if (faved) {
setIsFaved(controller, document); setIsFaved(std::move(show), document);
} else { } else {
setIsNotFaved(document); setIsNotFaved(document);
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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