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

@@ -223,10 +223,7 @@ void Calls::setupContent() {
if (!GetVideoInputList().empty()) {
AddSkip(content);
AddSubsectionTitle(content, tr::lng_settings_call_camera());
AddCameraSubsection(
std::make_shared<Window::Show>(_controller),
content,
true);
AddCameraSubsection(_controller->uiShow(), content, true);
AddSkip(content);
AddDivider(content);
}

View File

@@ -807,8 +807,9 @@ void SetupStickersEmoji(
st::settingsButton,
{ &st::settingsIconStickers, kIconLightOrange }
)->addClickHandler([=] {
controller->show(
Box<StickersBox>(controller, StickersBox::Section::Installed));
controller->show(Box<StickersBox>(
controller->uiShow(),
StickersBox::Section::Installed));
});
AddButton(
@@ -991,8 +992,8 @@ void SetupMessages(
Core::App().saveSettingsDelayed();
});
buttonRight->setClickedCallback([=, show = Window::Show(controller)] {
show.showBox(Box(ReactionsSettingsBox, controller));
buttonRight->setClickedCallback([=, show = controller->uiShow()] {
show->showBox(Box(ReactionsSettingsBox, controller));
});
AddSkip(inner, st::settingsSendTypeSkip);

View File

@@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/painter.h"
#include "ui/text/format_values.h"
#include "ui/text/text_utilities.h"
#include "ui/toasts/common_toasts.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/checkbox.h"
#include "ui/widgets/labels.h"
@@ -119,10 +118,8 @@ void TTLChatsBoxController::prepareViewHook() {
void TTLChatsBoxController::rowClicked(not_null<PeerListRow*> row) {
if (!TTLMenu::TTLValidator(nullptr, row->peer()).can()) {
Ui::ShowMultilineToast({
.parentOverride = delegate()->peerListToastParent(),
.text = { tr::lng_settings_ttl_select_chats_sorry(tr::now) },
});
delegate()->peerListUiShow()->showToast(
{ tr::lng_settings_ttl_select_chats_sorry(tr::now) });
return;
}
delegate()->peerListSetRowChecked(row, !row->checked());
@@ -208,7 +205,7 @@ private:
const not_null<Window::SessionController*> _controller;
const std::shared_ptr<Ui::RadiobuttonGroup> _group;
const std::shared_ptr<Window::Show> _show;
const std::shared_ptr<Main::SessionShow> _show;
not_null<Ui::VerticalLayout*> _buttons;
@@ -223,7 +220,7 @@ GlobalTTL::GlobalTTL(
: Section(parent)
, _controller(controller)
, _group(std::make_shared<Ui::RadiobuttonGroup>(0))
, _show(std::make_shared<Window::Show>(controller))
, _show(controller->uiShow())
, _buttons(Ui::CreateChild<Ui::VerticalLayout>(this)) {
setupContent();
}
@@ -244,14 +241,11 @@ void GlobalTTL::showSure(TimeId ttl, bool rebuild) const {
}
_group->setChangedCallback([=](int value) {
_group->setChangedCallback(nullptr);
Ui::ShowMultilineToast({
.parentOverride = _show->toastParent(),
.text = tr::lng_settings_ttl_after_toast(
tr::now,
lt_after_duration,
{ .text = ttlText },
Ui::Text::WithEntities)
});
_show->showToast(tr::lng_settings_ttl_after_toast(
tr::now,
lt_after_duration,
{ .text = ttlText },
Ui::Text::WithEntities));
_show->hideLayer(); // Don't use close().
});
request(ttl);
@@ -348,7 +342,7 @@ void GlobalTTL::setupContent() {
) | rpl::start_with_next(rebuild, content->lifetime());
}
const auto show = std::make_shared<Window::Show>(_controller);
const auto show = _controller->uiShow();
AddButton(
content,
tr::lng_settings_ttl_after_custom(),
@@ -398,29 +392,25 @@ void GlobalTTL::setupContent() {
peer->session().api().applyUpdates(result);
}).send();
}
Ui::ShowMultilineToast({
.parentOverride = Ui::BoxShow(box).toastParent(),
.text = ttl
? tr::lng_settings_ttl_select_chats_toast(
tr::now,
lt_count,
peers.size(),
lt_duration,
{ .text = Ui::FormatTTL(ttl) },
Ui::Text::WithEntities)
: tr::lng_settings_ttl_select_chats_disabled_toast(
tr::now,
lt_count,
peers.size(),
Ui::Text::WithEntities),
});
box->showToast(ttl
? tr::lng_settings_ttl_select_chats_toast(
tr::now,
lt_count,
peers.size(),
lt_duration,
{ .text = Ui::FormatTTL(ttl) },
Ui::Text::WithEntities)
: tr::lng_settings_ttl_select_chats_disabled_toast(
tr::now,
lt_count,
peers.size(),
Ui::Text::WithEntities));
box->closeBox();
}));
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
};
_controller->show(
Box<PeerListBox>(std::move(controller), std::move(initBox)),
Ui::LayerOption::KeepOther);
Box<PeerListBox>(std::move(controller), std::move(initBox)));
}));
content->add(object_ptr<Ui::DividerLabel>(
content,

View File

@@ -213,9 +213,7 @@ void Cover::initViewers() {
} else {
QGuiApplication::clipboard()->setText(
_user->session().createInternalLinkFull(username));
Ui::Toast::Show(
Window::Show(_controller).toastParent(),
tr::lng_username_copied(tr::now));
_controller->showToast(tr::lng_username_copied(tr::now));
}
});
}

View File

@@ -14,7 +14,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h"
#include "settings/settings_common.h"
#include "ui/layers/generic_box.h"
#include "ui/toasts/common_toasts.h"
#include "ui/widgets/buttons.h"
#include "ui/power_saving.h"
#include "styles/style_menu_icons.h"
@@ -84,13 +83,13 @@ void PowerSavingBox(not_null<Ui::GenericBox*> box) {
: rpl::single(QString());
}) | rpl::flatten_latest();
const auto disabler = Ui::CreateChild<Ui::AbstractButton>(container.get());
const auto show = box->uiShow();
const auto disabler = Ui::CreateChild<Ui::AbstractButton>(
container.get());
disabler->setClickedCallback([=] {
Ui::ShowMultilineToast({
.parentOverride = container,
.text = { tr::lng_settings_power_turn_off(tr::now) },
.duration = kForceDisableTooltipDuration,
});
show->showToast(
tr::lng_settings_power_turn_off(tr::now),
kForceDisableTooltipDuration);
});
disabler->paintRequest() | rpl::start_with_next([=](QRect clip) {
auto color = st::boxBg->c;

View File

@@ -860,12 +860,10 @@ void TopBarUser::updateTitle(
auto link = std::make_shared<LambdaClickHandler>([=,
stickerSetIdentifier = stickerInfo->set] {
setPaused(true);
const auto box = controller->show(
Box<StickerSetBox>(
controller,
stickerSetIdentifier,
Data::StickersType::Emoji),
Ui::LayerOption::KeepOther);
const auto box = controller->show(Box<StickerSetBox>(
controller->uiShow(),
stickerSetIdentifier,
Data::StickersType::Emoji));
box->boxClosing(
) | rpl::start_with_next(crl::guard(this, [=] {

View File

@@ -418,8 +418,7 @@ void BlockedBoxController::BlockNewPeer(
box->addButton(tr::lng_cancel(), [box] { box->closeBox(); });
};
window->show(
Box<PeerListBox>(std::move(controller), std::move(initBox)),
Ui::LayerOption::KeepOther);
Box<PeerListBox>(std::move(controller), std::move(initBox)));
}
bool BlockedBoxController::appendRow(not_null<PeerData*> peer) {

View File

@@ -193,14 +193,14 @@ void AddPremiumPrivacyButton(
tr::lng_settings_privacy_premium_link(tr::now));
link.entities.push_back(
EntityInText(EntityType::Semibold, 0, link.text.size()));
const auto config = Ui::Toast::Config{
(*toast) = controller->showToast({
.text = tr::lng_settings_privacy_premium(
tr::now,
lt_link,
link,
Ui::Text::WithEntities),
.st = &st::defaultMultilineToast,
.durationMs = Ui::Toast::kDefaultDuration * 2,
.duration = Ui::Toast::kDefaultDuration * 2,
.multiline = true,
.filter = crl::guard(&controller->session(), [=](
const ClickHandlerPtr &,
@@ -215,10 +215,7 @@ void AddPremiumPrivacyButton(
}
return false;
}),
};
(*toast) = Ui::Toast::Show(
Window::Show(controller).toastParent(),
config);
});
};
button->addClickHandler([=] {
if (!session->premium()) {
@@ -232,9 +229,10 @@ void AddPremiumPrivacyButton(
) | rpl::take(
1
) | rpl::start_with_next([=](const Privacy::Rule &value) {
controller->show(
Box<EditPrivacyBox>(controller, controllerFactory(), value),
Ui::LayerOption::KeepOther);
controller->show(Box<EditPrivacyBox>(
controller,
controllerFactory(),
value));
});
});
}
@@ -833,9 +831,10 @@ void AddPrivacyButton(
) | rpl::take(
1
) | rpl::start_with_next([=](const Privacy::Rule &value) {
controller->show(
Box<EditPrivacyBox>(controller, controllerFactory(), value),
Ui::LayerOption::KeepOther);
controller->show(Box<EditPrivacyBox>(
controller,
controllerFactory(),
value));
});
});
}