2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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