mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Fixed display of most of simple toasts in corresponding window.
This commit is contained in:
parent
29910cd1f7
commit
629574685e
27 changed files with 179 additions and 79 deletions
Telegram/SourceFiles
|
@ -1056,7 +1056,9 @@ void SetupChannelBox::mousePressEvent(QMouseEvent *e) {
|
|||
return;
|
||||
} else if (!_channel->inviteLink().isEmpty()) {
|
||||
QGuiApplication::clipboard()->setText(_channel->inviteLink());
|
||||
Ui::Toast::Show(tr::lng_create_channel_link_copied(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(this).toastParent(),
|
||||
tr::lng_create_channel_link_copied(tr::now));
|
||||
} else if (_channel->isFullLoaded() && !_creatingInviteLink) {
|
||||
_creatingInviteLink = true;
|
||||
_channel->session().api().inviteLinks().create(_channel);
|
||||
|
|
|
@ -258,7 +258,9 @@ void BackgroundPreviewBox::apply() {
|
|||
void BackgroundPreviewBox::share() {
|
||||
QGuiApplication::clipboard()->setText(
|
||||
_paper.shareUrl(&_controller->session()));
|
||||
Ui::Toast::Show(tr::lng_background_link_copied(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(this).toastParent(),
|
||||
tr::lng_background_link_copied(tr::now));
|
||||
}
|
||||
|
||||
void BackgroundPreviewBox::paintEvent(QPaintEvent *e) {
|
||||
|
|
|
@ -1264,6 +1264,7 @@ object_ptr<Ui::BoxContent> ProxiesBoxController::CreateOwningBox(
|
|||
|
||||
object_ptr<Ui::BoxContent> ProxiesBoxController::create() {
|
||||
auto result = Box<ProxiesBox>(this, _settings);
|
||||
_toastParent = Ui::BoxShow(result.data()).toastParent();
|
||||
for (const auto &item : _list) {
|
||||
updateView(item);
|
||||
}
|
||||
|
@ -1549,7 +1550,9 @@ void ProxiesBoxController::share(const ProxyData &proxy) {
|
|||
+ ((proxy.type == Type::Mtproto && !proxy.password.isEmpty())
|
||||
? "&secret=" + proxy.password : "");
|
||||
QGuiApplication::clipboard()->setText(link);
|
||||
Ui::Toast::Show(tr::lng_username_copied(tr::now));
|
||||
if (_toastParent) {
|
||||
Ui::Toast::Show(_toastParent, tr::lng_username_copied(tr::now));
|
||||
}
|
||||
}
|
||||
|
||||
ProxiesBoxController::~ProxiesBoxController() {
|
||||
|
|
|
@ -117,6 +117,7 @@ private:
|
|||
rpl::event_stream<ItemView> _views;
|
||||
base::Timer _saveTimer;
|
||||
rpl::event_stream<ProxyData::Settings> _proxySettingsChanges;
|
||||
QPointer<QWidget> _toastParent;
|
||||
|
||||
ProxyData _lastSelectedProxy;
|
||||
bool _lastSelectedProxyUsed = false;
|
||||
|
|
|
@ -18,7 +18,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/widgets/labels.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/checkbox.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "main/main_session.h"
|
||||
#include "core/application.h"
|
||||
|
@ -776,7 +775,7 @@ void CreatePollBox::setInnerFocus() {
|
|||
}
|
||||
|
||||
void CreatePollBox::submitFailed(const QString &error) {
|
||||
Ui::Toast::Show(error);
|
||||
Ui::Toast::Show(Ui::BoxShow(this).toastParent(), error);
|
||||
}
|
||||
|
||||
not_null<Ui::InputField*> CreatePollBox::setupQuestion(
|
||||
|
@ -990,8 +989,11 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
|||
multiple->events(
|
||||
) | rpl::filter([=](not_null<QEvent*> e) {
|
||||
return (e->type() == QEvent::MouseButtonPress) && quiz->checked();
|
||||
}) | rpl::start_with_next([=] {
|
||||
Ui::Toast::Show(tr::lng_polls_create_one_answer(tr::now));
|
||||
}) | rpl::start_with_next([
|
||||
toastParent = Ui::BoxShow(this).toastParent()] {
|
||||
Ui::Toast::Show(
|
||||
toastParent,
|
||||
tr::lng_polls_create_one_answer(tr::now));
|
||||
}, multiple->lifetime());
|
||||
}
|
||||
|
||||
|
@ -1068,8 +1070,10 @@ object_ptr<Ui::RpWidget> CreatePollBox::setupContent() {
|
|||
*error &= ~Error::Solution;
|
||||
}
|
||||
};
|
||||
const auto showError = [](tr::phrase<> text) {
|
||||
Ui::Toast::Show(text(tr::now));
|
||||
const auto showError = [
|
||||
toastParent = Ui::BoxShow(this).toastParent()](
|
||||
tr::phrase<> text) {
|
||||
Ui::Toast::Show(toastParent, text(tr::now));
|
||||
};
|
||||
const auto send = [=](Api::SendOptions sendOptions) {
|
||||
collectError();
|
||||
|
|
|
@ -324,9 +324,10 @@ void EditCaptionBox::setupControls() {
|
|||
}
|
||||
|
||||
void EditCaptionBox::setupEditEventHandler() {
|
||||
const auto toastParent = Ui::BoxShow(this).toastParent();
|
||||
const auto callback = [=](FileDialog::OpenResult &&result) {
|
||||
auto showError = [](tr::phrase<> t) {
|
||||
Ui::Toast::Show(t(tr::now));
|
||||
auto showError = [toastParent](tr::phrase<> t) {
|
||||
Ui::Toast::Show(toastParent, t(tr::now));
|
||||
};
|
||||
|
||||
const auto checkResult = [=](const Ui::PreparedList &list) {
|
||||
|
@ -547,7 +548,9 @@ bool EditCaptionBox::setPreparedList(Ui::PreparedList &&list) {
|
|||
}
|
||||
}
|
||||
if (invalidForAlbum) {
|
||||
Ui::Toast::Show(tr::lng_edit_media_album_error(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(this).toastParent(),
|
||||
tr::lng_edit_media_album_error(tr::now));
|
||||
return false;
|
||||
}
|
||||
_preparedList = std::move(list);
|
||||
|
|
|
@ -90,7 +90,9 @@ void MaxInviteBox::mousePressEvent(QMouseEvent *e) {
|
|||
if (_linkOver) {
|
||||
if (!_channel->inviteLink().isEmpty()) {
|
||||
QGuiApplication::clipboard()->setText(_channel->inviteLink());
|
||||
Ui::Toast::Show(tr::lng_create_channel_link_copied(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(this).toastParent(),
|
||||
tr::lng_create_channel_link_copied(tr::now));
|
||||
} else if (_channel->isFullLoaded() && !_creatingInviteLink) {
|
||||
_creatingInviteLink = true;
|
||||
_channel->session().api().inviteLinks().create(_channel);
|
||||
|
|
|
@ -74,9 +74,10 @@ void FileDialogCallback(
|
|||
FileDialog::OpenResult &&result,
|
||||
Fn<bool(const Ui::PreparedList&)> checkResult,
|
||||
Fn<void(Ui::PreparedList)> callback,
|
||||
bool premium) {
|
||||
auto showError = [](tr::phrase<> text) {
|
||||
Ui::Toast::Show(text(tr::now));
|
||||
bool premium,
|
||||
not_null<QWidget*> toastParent) {
|
||||
auto showError = [=](tr::phrase<> text) {
|
||||
Ui::Toast::Show(toastParent, text(tr::now));
|
||||
};
|
||||
|
||||
auto list = Storage::PreparedFileFromFilesDialog(
|
||||
|
@ -394,11 +395,12 @@ void SendFilesBox::refreshAllAfterChanges(int fromItem) {
|
|||
}
|
||||
|
||||
void SendFilesBox::openDialogToAddFileToAlbum() {
|
||||
const auto toastParent = Ui::BoxShow(this).toastParent();
|
||||
const auto checkResult = [=](const Ui::PreparedList &list) {
|
||||
if (_sendLimit != SendLimit::One) {
|
||||
return true;
|
||||
} else if (!_list.canBeSentInSlowmodeWith(list)) {
|
||||
Ui::Toast::Show(tr::lng_slowmode_no_many(tr::now));
|
||||
Ui::Toast::Show(toastParent, tr::lng_slowmode_no_many(tr::now));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -409,7 +411,8 @@ void SendFilesBox::openDialogToAddFileToAlbum() {
|
|||
std::move(result),
|
||||
checkResult,
|
||||
[=](Ui::PreparedList list) { addFiles(std::move(list)); },
|
||||
premium);
|
||||
premium,
|
||||
toastParent);
|
||||
};
|
||||
|
||||
FileDialog::GetOpenPaths(
|
||||
|
@ -549,6 +552,7 @@ void SendFilesBox::pushBlock(int from, int till) {
|
|||
});
|
||||
}, widget->lifetime());
|
||||
|
||||
const auto toastParent = Ui::BoxShow(this).toastParent();
|
||||
block.itemReplaceRequest(
|
||||
) | rpl::start_with_next([=](int index) {
|
||||
const auto replace = [=](Ui::PreparedList list) {
|
||||
|
@ -569,7 +573,9 @@ void SendFilesBox::pushBlock(int from, int till) {
|
|||
_list.files.push_back(std::move(removing));
|
||||
std::swap(_list.files[index], _list.files.back());
|
||||
if (!result) {
|
||||
Ui::Toast::Show(tr::lng_slowmode_no_many(tr::now));
|
||||
Ui::Toast::Show(
|
||||
toastParent,
|
||||
tr::lng_slowmode_no_many(tr::now));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -580,7 +586,8 @@ void SendFilesBox::pushBlock(int from, int till) {
|
|||
std::move(result),
|
||||
checkResult,
|
||||
replace,
|
||||
premium);
|
||||
premium,
|
||||
toastParent);
|
||||
};
|
||||
|
||||
FileDialog::GetOpenPath(
|
||||
|
|
|
@ -272,7 +272,9 @@ void StickerSetBox::prepare() {
|
|||
_inner->setInstalled(
|
||||
) | rpl::start_with_next([=](uint64 setId) {
|
||||
if (_inner->isMasksSet()) {
|
||||
Ui::Toast::Show(tr::lng_masks_installed(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(this).toastParent(),
|
||||
tr::lng_masks_installed(tr::now));
|
||||
} else {
|
||||
auto &stickers = _controller->session().data().stickers();
|
||||
stickers.notifyStickerSetInstalled(setId);
|
||||
|
@ -289,9 +291,11 @@ void StickerSetBox::prepare() {
|
|||
) | rpl::start_with_next([=](uint64 setId) {
|
||||
const auto isMasks = _inner->isMasksSet();
|
||||
|
||||
Ui::Toast::Show(isMasks
|
||||
? tr::lng_masks_has_been_archived(tr::now)
|
||||
: tr::lng_stickers_has_been_archived(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(this).toastParent(),
|
||||
isMasks
|
||||
? tr::lng_masks_has_been_archived(tr::now)
|
||||
: tr::lng_stickers_has_been_archived(tr::now));
|
||||
|
||||
auto &order = isMasks
|
||||
? _controller->session().data().stickers().maskSetsOrderRef()
|
||||
|
@ -360,7 +364,9 @@ void StickerSetBox::updateButtons() {
|
|||
const auto top = addTopButton(st::infoTopBarMenu);
|
||||
const auto share = [=] {
|
||||
copyStickersLink();
|
||||
Ui::Toast::Show(tr::lng_stickers_copied(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(this).toastParent(),
|
||||
tr::lng_stickers_copied(tr::now));
|
||||
closeBox();
|
||||
};
|
||||
const auto menu =
|
||||
|
@ -384,7 +390,9 @@ void StickerSetBox::updateButtons() {
|
|||
} else {
|
||||
auto share = [=] {
|
||||
copyStickersLink();
|
||||
Ui::Toast::Show(tr::lng_stickers_copied(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(this).toastParent(),
|
||||
tr::lng_stickers_copied(tr::now));
|
||||
};
|
||||
auto shareText = isMasks
|
||||
? tr::lng_stickers_share_masks()
|
||||
|
@ -1123,8 +1131,8 @@ void StickerSetBox::Inner::archiveStickers() {
|
|||
if (result.type() == mtpc_messages_stickerSetInstallResultSuccess) {
|
||||
_setArchived.fire_copy(_setId);
|
||||
}
|
||||
}).fail([] {
|
||||
Ui::Toast::Show(Lang::Hard::ServerError());
|
||||
}).fail([toastParent = Window::Show(_controller).toastParent()] {
|
||||
Ui::Toast::Show(toastParent, Lang::Hard::ServerError());
|
||||
}).send();
|
||||
}
|
||||
|
||||
|
|
|
@ -254,7 +254,9 @@ void UsernameBox::changed() {
|
|||
void UsernameBox::linkClick() {
|
||||
QGuiApplication::clipboard()->setText(
|
||||
_session->createInternalLinkFull(getName()));
|
||||
Ui::Toast::Show(tr::lng_username_copied(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(this).toastParent(),
|
||||
tr::lng_username_copied(tr::now));
|
||||
}
|
||||
|
||||
void UsernameBox::updateFail(const QString &error) {
|
||||
|
|
|
@ -308,14 +308,17 @@ void MonospaceClickHandler::onClick(ClickContext context) const {
|
|||
const auto hasCopyRestriction = item
|
||||
&& (!item->history()->peer->allowsForwarding()
|
||||
|| item->forbidsForward());
|
||||
const auto toastParent = Window::Show(controller).toastParent();
|
||||
if (hasCopyRestriction) {
|
||||
Ui::Toast::Show(item->history()->peer->isBroadcast()
|
||||
? tr::lng_error_nocopy_channel(tr::now)
|
||||
: tr::lng_error_nocopy_group(tr::now));
|
||||
Ui::Toast::Show(
|
||||
toastParent,
|
||||
item->history()->peer->isBroadcast()
|
||||
? tr::lng_error_nocopy_channel(tr::now)
|
||||
: tr::lng_error_nocopy_group(tr::now));
|
||||
return;
|
||||
}
|
||||
Ui::Toast::Show(toastParent, tr::lng_text_copied(tr::now));
|
||||
}
|
||||
Ui::Toast::Show(tr::lng_text_copied(tr::now));
|
||||
TextUtilities::SetClipboardText(TextForMimeData::Simple(_text.trimmed()));
|
||||
}
|
||||
|
||||
|
|
|
@ -565,7 +565,9 @@ bool ShowInviteLink(
|
|||
return false;
|
||||
}
|
||||
QGuiApplication::clipboard()->setText(link);
|
||||
Ui::Toast::Show(tr::lng_group_invite_copied(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Window::Show(controller).toastParent(),
|
||||
tr::lng_group_invite_copied(tr::now));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -579,13 +581,15 @@ bool OpenExternalLink(
|
|||
}
|
||||
|
||||
void ExportTestChatTheme(
|
||||
not_null<Main::Session*> session,
|
||||
not_null<Window::SessionController*> controller,
|
||||
not_null<const Data::CloudTheme*> theme) {
|
||||
const auto session = &controller->session();
|
||||
const auto show = std::make_shared<Window::Show>(controller);
|
||||
const auto inputSettings = [&](Data::CloudThemeType type)
|
||||
-> std::optional<MTPInputThemeSettings> {
|
||||
const auto i = theme->settings.find(type);
|
||||
if (i == end(theme->settings)) {
|
||||
Ui::Toast::Show("Something went wrong :(");
|
||||
Ui::Toast::Show(show->toastParent(), "Something went wrong :(");
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto &fields = i->second;
|
||||
|
@ -593,7 +597,7 @@ void ExportTestChatTheme(
|
|||
|| !fields.paper->isPattern()
|
||||
|| fields.paper->backgroundColors().empty()
|
||||
|| !fields.paper->hasShareUrl()) {
|
||||
Ui::Toast::Show("Something went wrong :(");
|
||||
Ui::Toast::Show(show->toastParent(), "Something went wrong :(");
|
||||
return std::nullopt;
|
||||
}
|
||||
const auto &bg = fields.paper->backgroundColors();
|
||||
|
@ -601,7 +605,9 @@ void ExportTestChatTheme(
|
|||
const auto from = url.indexOf("bg/");
|
||||
const auto till = url.indexOf("?");
|
||||
if (from < 0 || till <= from) {
|
||||
Ui::Toast::Show("Bad WallPaper link: " + url);
|
||||
Ui::Toast::Show(
|
||||
show->toastParent(),
|
||||
"Bad WallPaper link: " + url);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
@ -683,9 +689,15 @@ void ExportTestChatTheme(
|
|||
const auto slug = Data::CloudTheme::Parse(session, result, true).slug;
|
||||
QGuiApplication::clipboard()->setText(
|
||||
session->createInternalLinkFull("addtheme/" + slug));
|
||||
Ui::Toast::Show(tr::lng_background_link_copied(tr::now));
|
||||
if (show->valid()) {
|
||||
Ui::Toast::Show(
|
||||
show->toastParent(),
|
||||
tr::lng_background_link_copied(tr::now));
|
||||
}
|
||||
}).fail([=](const MTP::Error &error) {
|
||||
Ui::Toast::Show("Error: " + error.type());
|
||||
if (show->valid()) {
|
||||
Ui::Toast::Show(show->toastParent(), "Error: " + error.type());
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
|
||||
|
@ -706,7 +718,7 @@ bool ResolveTestChatTheme(
|
|||
params);
|
||||
if (theme) {
|
||||
if (!params["export"].isEmpty()) {
|
||||
ExportTestChatTheme(&controller->session(), &*theme);
|
||||
ExportTestChatTheme(controller, &*theme);
|
||||
}
|
||||
const auto recache = [&](Data::CloudThemeType type) {
|
||||
[[maybe_unused]] auto value = theme->settings.contains(type)
|
||||
|
|
|
@ -52,8 +52,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "main/main_session.h"
|
||||
#include "main/main_session_settings.h"
|
||||
#include "core/application.h"
|
||||
#include "core/click_handler_types.h" // ClickHandlerContext
|
||||
#include "lang/lang_keys.h"
|
||||
#include "storage/file_upload.h"
|
||||
#include "window/window_session_controller.h" // Window::Show
|
||||
#include "styles/style_chat.h"
|
||||
#include "styles/style_dialogs.h"
|
||||
|
||||
|
@ -1646,6 +1648,7 @@ ClickHandlerPtr MediaDice::makeHandler() const {
|
|||
ClickHandlerPtr MediaDice::MakeHandler(
|
||||
not_null<History*> history,
|
||||
const QString &emoji) {
|
||||
// TODO support multi-windows.
|
||||
static auto ShownToast = base::weak_ptr<Ui::Toast::Instance>();
|
||||
static const auto HideExisting = [] {
|
||||
if (const auto toast = ShownToast.get()) {
|
||||
|
@ -1653,7 +1656,7 @@ ClickHandlerPtr MediaDice::MakeHandler(
|
|||
ShownToast = nullptr;
|
||||
}
|
||||
};
|
||||
return std::make_shared<LambdaClickHandler>([=] {
|
||||
return std::make_shared<LambdaClickHandler>([=](ClickContext context) {
|
||||
auto config = Ui::Toast::Config{
|
||||
.text = { tr::lng_about_random(tr::now, lt_emoji, emoji) },
|
||||
.st = &st::historyDiceToast,
|
||||
|
@ -1683,7 +1686,15 @@ ClickHandlerPtr MediaDice::MakeHandler(
|
|||
}
|
||||
|
||||
HideExisting();
|
||||
ShownToast = Ui::Toast::Show(config);
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
const auto weak = my.sessionWindow;
|
||||
if (const auto strong = weak.get()) {
|
||||
ShownToast = Ui::Toast::Show(
|
||||
Window::Show(strong).toastParent(),
|
||||
config);
|
||||
} else {
|
||||
ShownToast = Ui::Toast::Show(config);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -405,6 +405,7 @@ void Stickers::applyArchivedResult(
|
|||
session().local().writeArchivedMasks();
|
||||
}
|
||||
|
||||
// TODO async toast.
|
||||
Ui::Toast::Show(Ui::Toast::Config{
|
||||
.text = { tr::lng_stickers_packs_archived(tr::now) },
|
||||
.st = &st::stickersToast,
|
||||
|
|
|
@ -113,6 +113,20 @@ HiddenSenderInfo::HiddenSenderInfo(const QString &name, bool external)
|
|||
}
|
||||
}
|
||||
|
||||
ClickHandlerPtr HiddenSenderInfo::ForwardClickHandler() {
|
||||
static const auto hidden = std::make_shared<LambdaClickHandler>([](
|
||||
ClickContext context) {
|
||||
const auto my = context.other.value<ClickHandlerContext>();
|
||||
const auto weak = my.sessionWindow;
|
||||
if (const auto strong = weak.get()) {
|
||||
Ui::Toast::Show(
|
||||
Window::Show(strong).toastParent(),
|
||||
tr::lng_forwarded_hidden(tr::now));
|
||||
}
|
||||
});
|
||||
return hidden;
|
||||
}
|
||||
|
||||
bool HiddenSenderInfo::paintCustomUserpic(
|
||||
Painter &p,
|
||||
int x,
|
||||
|
@ -202,15 +216,12 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
|
|||
}
|
||||
}
|
||||
text.setMarkedText(st::fwdTextStyle, phrase);
|
||||
static const auto hidden = std::make_shared<LambdaClickHandler>([] {
|
||||
Ui::Toast::Show(tr::lng_forwarded_hidden(tr::now));
|
||||
});
|
||||
|
||||
text.setLink(1, fromChannel
|
||||
? goToMessageClickHandler(originalSender, originalId)
|
||||
: originalSender
|
||||
? originalSender->openLink()
|
||||
: hidden);
|
||||
: HiddenSenderInfo::ForwardClickHandler());
|
||||
if (via) {
|
||||
text.setLink(2, via->link);
|
||||
}
|
||||
|
|
|
@ -81,6 +81,8 @@ struct HiddenSenderInfo {
|
|||
Ui::EmptyUserpic emptyUserpic;
|
||||
mutable Data::CloudImage customUserpic;
|
||||
|
||||
[[nodiscard]] static ClickHandlerPtr ForwardClickHandler();
|
||||
|
||||
[[nodiscard]] bool paintCustomUserpic(
|
||||
Painter &p,
|
||||
int x,
|
||||
|
|
|
@ -441,6 +441,7 @@ void ContactStatus::setupBlockHandler(not_null<UserData*> user) {
|
|||
void ContactStatus::setupShareHandler(not_null<UserData*> user) {
|
||||
_bar.entity()->shareClicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
const auto show = std::make_shared<Window::Show>(_controller);
|
||||
const auto share = [=](Fn<void()> &&close) {
|
||||
user->setSettings(0);
|
||||
user->session().api().request(MTPcontacts_AcceptContact(
|
||||
|
@ -448,14 +449,18 @@ void ContactStatus::setupShareHandler(not_null<UserData*> user) {
|
|||
)).done([=](const MTPUpdates &result) {
|
||||
user->session().api().applyUpdates(result);
|
||||
|
||||
Ui::Toast::Show(tr::lng_new_contact_share_done(
|
||||
tr::now,
|
||||
lt_user,
|
||||
user->shortName()));
|
||||
if (show->valid()) {
|
||||
Ui::Toast::Show(
|
||||
show->toastParent(),
|
||||
tr::lng_new_contact_share_done(
|
||||
tr::now,
|
||||
lt_user,
|
||||
user->shortName()));
|
||||
}
|
||||
}).send();
|
||||
close();
|
||||
};
|
||||
_controller->window().show(Ui::MakeConfirmBox({
|
||||
show->showBox(Ui::MakeConfirmBox({
|
||||
.text = tr::lng_new_contact_share_sure(
|
||||
tr::now,
|
||||
lt_phone,
|
||||
|
@ -488,6 +493,7 @@ void ContactStatus::setupReportHandler(not_null<PeerData*> peer) {
|
|||
_bar.entity()->reportClicks(
|
||||
) | rpl::start_with_next([=] {
|
||||
Expects(!peer->isUser());
|
||||
const auto show = std::make_shared<Window::Show>(_controller);
|
||||
|
||||
const auto callback = crl::guard(&_bar, [=](Fn<void()> &&close) {
|
||||
close();
|
||||
|
@ -503,7 +509,11 @@ void ContactStatus::setupReportHandler(not_null<PeerData*> peer) {
|
|||
peer->session().api().deleteConversation(peer, false);
|
||||
});
|
||||
|
||||
Ui::Toast::Show(tr::lng_report_spam_done(tr::now));
|
||||
if (show->valid()) {
|
||||
Ui::Toast::Show(
|
||||
show->toastParent(),
|
||||
tr::lng_report_spam_done(tr::now));
|
||||
}
|
||||
|
||||
// Destroys _bar.
|
||||
_controller->showBackFromStack();
|
||||
|
@ -514,7 +524,7 @@ void ContactStatus::setupReportHandler(not_null<PeerData*> peer) {
|
|||
auto text = ((peer->isChat() || peer->isMegagroup())
|
||||
? tr::lng_report_spam_sure_group
|
||||
: tr::lng_report_spam_sure_channel)();
|
||||
_controller->window().show(Ui::MakeConfirmBox({
|
||||
show->showBox(Ui::MakeConfirmBox({
|
||||
.text= std::move(text),
|
||||
.confirmed = callback,
|
||||
.confirmText = tr::lng_report_spam_ok(),
|
||||
|
|
|
@ -682,10 +682,7 @@ ClickHandlerPtr Element::fromLink() const {
|
|||
return imported;
|
||||
}
|
||||
}
|
||||
static const auto hidden = std::make_shared<LambdaClickHandler>([] {
|
||||
Ui::Toast::Show(tr::lng_forwarded_hidden(tr::now));
|
||||
});
|
||||
_fromLink = hidden;
|
||||
_fromLink = HiddenSenderInfo::ForwardClickHandler();
|
||||
return _fromLink;
|
||||
}
|
||||
|
||||
|
|
|
@ -1651,6 +1651,7 @@ ClickHandlerPtr Message::createGoToCommentsLink() const {
|
|||
if (const auto channel = history->peer->asChannel()) {
|
||||
if (channel->invitePeekExpires()) {
|
||||
Ui::Toast::Show(
|
||||
Window::Show(controller).toastParent(),
|
||||
tr::lng_channel_invite_private(tr::now));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -353,12 +353,15 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
|
|||
tr::lng_info_link_label(),
|
||||
std::move(linkText),
|
||||
QString());
|
||||
link->setClickHandlerFilter([peer = _peer](auto&&...) {
|
||||
const auto controller = _controller->parentController();
|
||||
link->setClickHandlerFilter([=, peer = _peer](auto&&...) {
|
||||
const auto link = peer->session().createInternalLinkFull(
|
||||
peer->userName());
|
||||
if (!link.isEmpty()) {
|
||||
QGuiApplication::clipboard()->setText(link);
|
||||
Ui::Toast::Show(tr::lng_username_copied(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Window::Show(controller).toastParent(),
|
||||
tr::lng_username_copied(tr::now));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -199,7 +199,9 @@ void Cover::initViewers() {
|
|||
} else {
|
||||
QGuiApplication::clipboard()->setText(
|
||||
_user->session().createInternalLinkFull(username));
|
||||
Ui::Toast::Show(tr::lng_username_copied(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Window::Show(_controller).toastParent(),
|
||||
tr::lng_username_copied(tr::now));
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -760,7 +760,7 @@ void Editor::exportTheme() {
|
|||
_window->show(Ui::MakeInformBox(tr::lng_theme_editor_error()));
|
||||
return;
|
||||
}
|
||||
Ui::Toast::Show(tr::lng_theme_editor_done(tr::now));
|
||||
_window->showToast(tr::lng_theme_editor_done(tr::now));
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -817,10 +817,10 @@ QByteArray Editor::ColorizeInContent(
|
|||
|
||||
void Editor::save() {
|
||||
if (Core::App().passcodeLocked()) {
|
||||
Ui::Toast::Show(tr::lng_theme_editor_need_unlock(tr::now));
|
||||
_window->showToast(tr::lng_theme_editor_need_unlock(tr::now));
|
||||
return;
|
||||
} else if (!_window->account().sessionExists()) {
|
||||
Ui::Toast::Show(tr::lng_theme_editor_need_auth(tr::now));
|
||||
_window->showToast(tr::lng_theme_editor_need_auth(tr::now));
|
||||
return;
|
||||
} else if (_saving) {
|
||||
return;
|
||||
|
|
|
@ -893,10 +893,11 @@ void SaveThemeBox(
|
|||
type = SaveErrorType::Link;
|
||||
} else if (error == qstr("THEME_SLUG_OCCUPIED")) {
|
||||
Ui::Toast::Show(
|
||||
Ui::BoxShow(box).toastParent(),
|
||||
tr::lng_create_channel_link_occupied(tr::now));
|
||||
type = SaveErrorType::Link;
|
||||
} else if (!error.isEmpty()) {
|
||||
Ui::Toast::Show(error);
|
||||
Ui::Toast::Show(Ui::BoxShow(box).toastParent(), error);
|
||||
}
|
||||
if (type == SaveErrorType::Name) {
|
||||
name->showError();
|
||||
|
|
|
@ -592,7 +592,8 @@ void CloudList::showMenu(Element &element) {
|
|||
_contextMenu->addAction(tr::lng_theme_share(tr::now), [=] {
|
||||
QGuiApplication::clipboard()->setText(
|
||||
_window->session().createInternalLinkFull("addtheme/" + slug));
|
||||
Ui::Toast::Show(tr::lng_background_link_copied(tr::now));
|
||||
_window->window().showToast(
|
||||
tr::lng_background_link_copied(tr::now));
|
||||
}, &st::menuIconShare);
|
||||
}
|
||||
if (cloud.documentId
|
||||
|
|
|
@ -263,6 +263,7 @@ void TermsBox::prepare() {
|
|||
st::termsPadding),
|
||||
0,
|
||||
age ? age->height() : 0);
|
||||
const auto toastParent = Ui::BoxShow(this).toastParent();
|
||||
content->entity()->setClickHandlerFilter([=](
|
||||
const ClickHandlerPtr &handler,
|
||||
Qt::MouseButton button) {
|
||||
|
@ -271,7 +272,9 @@ void TermsBox::prepare() {
|
|||
: QString();
|
||||
if (TextUtilities::RegExpMention().match(link).hasMatch()) {
|
||||
_lastClickedMention = link;
|
||||
Ui::Toast::Show(tr::lng_terms_agree_to_proceed(tr::now, lt_bot, link));
|
||||
Ui::Toast::Show(
|
||||
toastParent,
|
||||
tr::lng_terms_agree_to_proceed(tr::now, lt_bot, link));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -297,10 +297,12 @@ void TogglePinnedDialog(
|
|||
|
||||
// This can happen when you remove this filter from another client.
|
||||
if (!ranges::contains(
|
||||
(&owner->session())->data().chatsFilters().list(),
|
||||
filterId,
|
||||
&Data::ChatFilter::id)) {
|
||||
Ui::Toast::Show(tr::lng_cant_do_this(tr::now));
|
||||
(&owner->session())->data().chatsFilters().list(),
|
||||
filterId,
|
||||
&Data::ChatFilter::id)) {
|
||||
Ui::Toast::Show(
|
||||
Window::Show(controller).toastParent(),
|
||||
tr::lng_cant_do_this(tr::now));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -601,6 +603,7 @@ void Filler::addViewDiscussion() {
|
|||
_addAction(tr::lng_profile_view_discussion(tr::now), [=] {
|
||||
if (channel->invitePeekExpires()) {
|
||||
Ui::Toast::Show(
|
||||
Window::Show(navigation).toastParent(),
|
||||
tr::lng_channel_invite_private(tr::now));
|
||||
return;
|
||||
}
|
||||
|
@ -895,12 +898,14 @@ void Filler::fillArchiveActions() {
|
|||
}, hidden ? &st::menuIconExpand : &st::menuIconCollapse);
|
||||
|
||||
_addAction(tr::lng_context_archive_to_menu(tr::now), [=] {
|
||||
Ui::Toast::Show(Ui::Toast::Config{
|
||||
.text = { tr::lng_context_archive_to_menu_info(tr::now) },
|
||||
.st = &st::windowArchiveToast,
|
||||
.durationMs = kArchivedToastDuration,
|
||||
.multiline = true,
|
||||
});
|
||||
Ui::Toast::Show(
|
||||
Window::Show(controller).toastParent(),
|
||||
Ui::Toast::Config{
|
||||
.text = { tr::lng_context_archive_to_menu_info(tr::now) },
|
||||
.st = &st::windowArchiveToast,
|
||||
.durationMs = kArchivedToastDuration,
|
||||
.multiline = true,
|
||||
});
|
||||
|
||||
controller->session().settings().setArchiveInMainMenu(
|
||||
!controller->session().settings().archiveInMainMenu());
|
||||
|
@ -959,7 +964,7 @@ void PeerMenuShareContactBox(
|
|||
action.clearDraft = false;
|
||||
user->session().api().shareContact(user, action);
|
||||
Ui::Toast::Show(
|
||||
navigation->parentController()->widget()->bodyWidget(),
|
||||
Window::Show(navigation).toastParent(),
|
||||
tr::lng_share_done(tr::now));
|
||||
if (auto strong = *weak) {
|
||||
strong->closeBox();
|
||||
|
@ -1152,6 +1157,7 @@ void PeerMenuBlockUserBox(
|
|||
}
|
||||
|
||||
Ui::Toast::Show(
|
||||
Window::Show(window).toastParent(),
|
||||
tr::lng_new_contact_block_done(tr::now, lt_user, name));
|
||||
}, st::attentionBoxButton);
|
||||
|
||||
|
|
|
@ -525,7 +525,9 @@ void SessionNavigation::showRepliesForMessage(
|
|||
_showingRepliesRequestId = 0;
|
||||
if (error.type() == u"CHANNEL_PRIVATE"_q
|
||||
|| error.type() == u"USER_BANNED_IN_CHANNEL"_q) {
|
||||
Ui::Toast::Show(tr::lng_group_not_accessible(tr::now));
|
||||
Ui::Toast::Show(
|
||||
Show(this).toastParent(),
|
||||
tr::lng_group_not_accessible(tr::now));
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue