mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
Support arbitrary content in toasts.
This commit is contained in:
parent
ac92e1c99e
commit
e89f2b55e8
23 changed files with 37 additions and 60 deletions
|
@ -763,9 +763,6 @@ void EditMessagesPrivacyBox(
|
|||
lt_link,
|
||||
link,
|
||||
Ui::Text::WithEntities),
|
||||
.st = &st::defaultMultilineToast,
|
||||
.duration = Ui::Toast::kDefaultDuration * 2,
|
||||
.multiline = true,
|
||||
.filter = crl::guard(&controller->session(), [=](
|
||||
const ClickHandlerPtr &,
|
||||
Qt::MouseButton button) {
|
||||
|
|
|
@ -932,8 +932,8 @@ void ShowAlreadyPremiumToast(
|
|||
Ui::Text::Link(
|
||||
Ui::Text::Bold(tr::lng_gift_link_already_link(tr::now))),
|
||||
Ui::Text::WithEntities),
|
||||
.duration = 6 * crl::time(1000),
|
||||
.filter = crl::guard(navigation, shareLink),
|
||||
.duration = 6 * crl::time(1000),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -554,7 +554,6 @@ void Panel::reinitWithCall(Call *call) {
|
|||
Ui::Toast::Show(widget(), Ui::Toast::Config{
|
||||
.text = { text },
|
||||
.st = &st::callErrorToast,
|
||||
.multiline = true,
|
||||
});
|
||||
}, _callLifetime);
|
||||
|
||||
|
|
|
@ -1126,10 +1126,8 @@ base::unique_qptr<Ui::RpWidget> CreateDisabledFieldView(
|
|||
: list.back();
|
||||
*toast = Ui::Toast::Show(parent, {
|
||||
.text = { tr::lng_send_text_no_about(tr::now, lt_types, types) },
|
||||
.st = &st::defaultMultilineToast,
|
||||
.attach = RectPart::Bottom,
|
||||
.duration = kTypesDuration,
|
||||
.multiline = true,
|
||||
.slideSide = RectPart::Bottom,
|
||||
});
|
||||
});
|
||||
return result;
|
||||
|
|
|
@ -2266,7 +2266,6 @@ ClickHandlerPtr MediaDice::MakeHandler(
|
|||
.text = { tr::lng_about_random(tr::now, lt_emoji, emoji) },
|
||||
.st = &st::historyDiceToast,
|
||||
.duration = Ui::Toast::kDefaultDuration * 2,
|
||||
.multiline = true,
|
||||
};
|
||||
if (CanSend(history->peer, ChatRestriction::SendOther)) {
|
||||
auto link = Ui::Text::Link(tr::lng_about_random_send(tr::now));
|
||||
|
@ -2295,7 +2294,7 @@ ClickHandlerPtr MediaDice::MakeHandler(
|
|||
if (const auto strong = weak.get()) {
|
||||
ShownToast = strong->showToast(std::move(config));
|
||||
} else {
|
||||
ShownToast = Ui::Toast::Show(config);
|
||||
ShownToast = Ui::Toast::Show(std::move(config));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -96,8 +96,8 @@ void MaybeShowPremiumToast(
|
|||
};
|
||||
show->showToast({
|
||||
.text = std::move(text),
|
||||
.duration = kPremiumToastDuration,
|
||||
.filter = filter,
|
||||
.duration = kPremiumToastDuration,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -398,7 +398,6 @@ void Stickers::applyArchivedResult(
|
|||
Ui::Toast::Show(Ui::Toast::Config{
|
||||
.text = { tr::lng_stickers_packs_archived(tr::now) },
|
||||
.st = &st::stickersToast,
|
||||
.multiline = true,
|
||||
});
|
||||
//Ui::show(
|
||||
// Box<StickersBox>(archived, &session()),
|
||||
|
|
|
@ -840,8 +840,8 @@ void ShowTrialTranscribesToast(int left, TimeId until) {
|
|||
Ui::Text::WithEntities);
|
||||
window->uiShow()->showToast(Ui::Toast::Config{
|
||||
.text = text,
|
||||
.duration = kToastDuration,
|
||||
.filter = filter,
|
||||
.duration = kToastDuration,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -40,12 +40,10 @@ void InfoTooltip::show(
|
|||
hide(anim::type::normal);
|
||||
_topToast = Ui::Toast::Show(parent, Ui::Toast::Config{
|
||||
.text = text,
|
||||
.st = &st::historyInfoToast,
|
||||
.duration = CountToastDuration(text),
|
||||
.multiline = true,
|
||||
.dark = true,
|
||||
.slideSide = RectPart::Top,
|
||||
.textContext = context,
|
||||
.st = &st::historyInfoToast,
|
||||
.attach = RectPart::Top,
|
||||
.duration = CountToastDuration(text),
|
||||
});
|
||||
if (const auto strong = _topToast.get()) {
|
||||
if (hiddenCallback) {
|
||||
|
|
|
@ -115,16 +115,14 @@ void PaidReactionToast::showFor(
|
|||
_weak = Ui::Toast::Show(_parent, Ui::Toast::Config{
|
||||
.text = text,
|
||||
.st = &_st,
|
||||
.duration = -1,
|
||||
.multiline = true,
|
||||
.dark = true,
|
||||
.slideSide = RectPart::Top,
|
||||
.attach = RectPart::Top,
|
||||
.acceptinput = true,
|
||||
.infinite = true,
|
||||
});
|
||||
const auto strong = _weak.get();
|
||||
if (!strong) {
|
||||
return;
|
||||
}
|
||||
strong->setInputUsed(true);
|
||||
const auto widget = strong->widget();
|
||||
const auto hideToast = [weak = _weak] {
|
||||
if (const auto strong = weak.get()) {
|
||||
|
@ -188,9 +186,10 @@ void PaidReactionToast::setupLottiePreview(
|
|||
|
||||
const auto bytes = document->createMediaView()->bytes();
|
||||
const auto filepath = document->filepath();
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
const auto player = widget->lifetime().make_state<Lottie::SinglePlayer>(
|
||||
Lottie::ReadContent(bytes, filepath),
|
||||
Lottie::FrameRequest{ QSize(size, size) },
|
||||
Lottie::FrameRequest{ QSize(size, size) * ratio },
|
||||
Lottie::Quality::Default);
|
||||
|
||||
widget->paintRequest(
|
||||
|
@ -200,7 +199,7 @@ void PaidReactionToast::setupLottiePreview(
|
|||
}
|
||||
const auto image = player->frame();
|
||||
QPainter(widget).drawImage(
|
||||
QRect(QPoint(), image.size() / image.devicePixelRatio()),
|
||||
QRect(QPoint(), image.size() / ratio),
|
||||
image);
|
||||
if (player->frameIndex() + 1 != player->framesCount()) {
|
||||
player->markFrameShown();
|
||||
|
|
|
@ -165,16 +165,14 @@ void StickerToast::showWithTitle(const QString &title) {
|
|||
_weak = Ui::Toast::Show(_parent, Ui::Toast::Config{
|
||||
.text = text,
|
||||
.st = &_st,
|
||||
.attach = RectPart::Bottom,
|
||||
.acceptinput = true,
|
||||
.duration = kPremiumToastDuration,
|
||||
.multiline = true,
|
||||
.dark = true,
|
||||
.slideSide = RectPart::Bottom,
|
||||
});
|
||||
const auto strong = _weak.get();
|
||||
if (!strong) {
|
||||
return;
|
||||
}
|
||||
strong->setInputUsed(true);
|
||||
const auto widget = strong->widget();
|
||||
const auto hideToast = [weak = _weak] {
|
||||
if (const auto strong = weak.get()) {
|
||||
|
@ -325,9 +323,10 @@ void StickerToast::setupLottiePreview(not_null<Ui::RpWidget*> widget, int size)
|
|||
|
||||
const auto bytes = _for->createMediaView()->bytes();
|
||||
const auto filepath = _for->filepath();
|
||||
const auto ratio = style::DevicePixelRatio();
|
||||
const auto player = widget->lifetime().make_state<Lottie::SinglePlayer>(
|
||||
Lottie::ReadContent(bytes, filepath),
|
||||
Lottie::FrameRequest{ QSize(size, size) },
|
||||
Lottie::FrameRequest{ QSize(size, size) * ratio },
|
||||
Lottie::Quality::Default);
|
||||
|
||||
widget->paintRequest(
|
||||
|
@ -337,7 +336,7 @@ void StickerToast::setupLottiePreview(not_null<Ui::RpWidget*> widget, int size)
|
|||
}
|
||||
const auto image = player->frame();
|
||||
QPainter(widget).drawImage(
|
||||
QRect(QPoint(), image.size() / image.devicePixelRatio()),
|
||||
QRect(QPoint(), image.size() / ratio),
|
||||
image);
|
||||
player->markFrameShown();
|
||||
}, widget->lifetime());
|
||||
|
|
|
@ -524,16 +524,14 @@ void TranslateBar::showToast(
|
|||
const auto weak = Ui::Toast::Show(_wrap.window(), Ui::Toast::Config{
|
||||
.text = std::move(text),
|
||||
.st = st.get(),
|
||||
.attach = RectPart::Bottom,
|
||||
.acceptinput = true,
|
||||
.duration = kToastDuration,
|
||||
.multiline = true,
|
||||
.dark = true,
|
||||
.slideSide = RectPart::Bottom,
|
||||
});
|
||||
const auto strong = weak.get();
|
||||
if (!strong) {
|
||||
return;
|
||||
}
|
||||
strong->setInputUsed(true);
|
||||
const auto widget = strong->widget();
|
||||
widget->lifetime().add([st] {});
|
||||
const auto hideToast = [weak] {
|
||||
|
|
|
@ -146,10 +146,8 @@ void ShowSetToast(
|
|||
const auto weak = controller->showToast({
|
||||
.text = text,
|
||||
.st = st.get(),
|
||||
.attach = RectPart::Bottom,
|
||||
.duration = kToastDuration,
|
||||
.multiline = true,
|
||||
.dark = true,
|
||||
.slideSide = RectPart::Bottom,
|
||||
});
|
||||
if (const auto strong = weak.get()) {
|
||||
const auto widget = strong->widget();
|
||||
|
|
|
@ -1076,9 +1076,9 @@ void CreateGiveawayBox(
|
|||
tr::lng_giveaway_created_link(
|
||||
tr::now)),
|
||||
Ui::Text::WithEntities)),
|
||||
.duration = kDoneTooltipDuration,
|
||||
.adaptive = true,
|
||||
.filter = filter,
|
||||
.adaptive = true,
|
||||
.duration = kDoneTooltipDuration,
|
||||
});
|
||||
} else if (weak) {
|
||||
state->confirmButtonBusy = false;
|
||||
|
|
|
@ -1947,9 +1947,9 @@ void MainWidget::showNonPremiumLimitToast(bool download) {
|
|||
? tr::lng_limit_download_title
|
||||
: tr::lng_limit_upload_title)(tr::now),
|
||||
.text = std::move(text),
|
||||
.duration = 5 * crl::time(1000),
|
||||
.slideSide = RectPart::Top,
|
||||
.filter = std::move(filter),
|
||||
.attach = RectPart::Top,
|
||||
.duration = 5 * crl::time(1000),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ struct Feature {
|
|||
TextWithEntities{ TimeLeftText(left) },
|
||||
Ui::Text::RichLangValue),
|
||||
.st = &st::storiesStealthToast,
|
||||
.duration = kAlreadyToastDuration,
|
||||
.adaptive = true,
|
||||
.duration = kAlreadyToastDuration,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,8 @@ struct Feature {
|
|||
tr::now,
|
||||
Ui::Text::RichLangValue),
|
||||
.st = &st::storiesStealthToast,
|
||||
.duration = kAlreadyToastDuration,
|
||||
.adaptive = true,
|
||||
.duration = kAlreadyToastDuration,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,8 @@ struct Feature {
|
|||
tr::now,
|
||||
Ui::Text::RichLangValue),
|
||||
.st = &st::storiesStealthToast,
|
||||
.duration = kAlreadyToastDuration,
|
||||
.adaptive = true,
|
||||
.duration = kAlreadyToastDuration,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1271,9 +1271,9 @@ void OverlayWidget::showPremiumDownloadPromo() {
|
|||
Ui::Text::Bold(
|
||||
tr::lng_send_as_premium_required_link(tr::now))),
|
||||
Ui::Text::WithEntities),
|
||||
.duration = kStorySavePromoDuration,
|
||||
.adaptive = true,
|
||||
.filter = filter,
|
||||
.adaptive = true,
|
||||
.duration = kStorySavePromoDuration,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -167,7 +167,6 @@ void AntiSpamValidator::addAction(
|
|||
channel = _channel] {
|
||||
window->showToast({
|
||||
.text = text,
|
||||
.duration = ApiWrap::kJoinErrorDuration,
|
||||
.filter = [=](
|
||||
const ClickHandlerPtr&,
|
||||
Qt::MouseButton) {
|
||||
|
@ -177,6 +176,7 @@ void AntiSpamValidator::addAction(
|
|||
ParticipantsRole::Admins);
|
||||
return true;
|
||||
},
|
||||
.duration = ApiWrap::kJoinErrorDuration,
|
||||
});
|
||||
};
|
||||
menu->addAction(
|
||||
|
|
|
@ -106,8 +106,8 @@ void AddAction(
|
|||
tr::lng_mediaview_downloads(tr::now),
|
||||
"internal:show_saved_message"),
|
||||
Ui::Text::WithEntities),
|
||||
.st = &st::defaultToast,
|
||||
.filter = filter,
|
||||
.st = &st::defaultToast,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -1395,10 +1395,6 @@ void ShowPremiumPromoToast(
|
|||
const auto toast = std::make_shared<WeakToast>();
|
||||
(*toast) = show->showToast({
|
||||
.text = std::move(textWithLink),
|
||||
.st = &st::defaultMultilineToast,
|
||||
.duration = Ui::Toast::kDefaultDuration * 2,
|
||||
.adaptive = true,
|
||||
.multiline = true,
|
||||
.filter = crl::guard(&show->session(), [=](
|
||||
const ClickHandlerPtr &,
|
||||
Qt::MouseButton button) {
|
||||
|
@ -1416,6 +1412,8 @@ void ShowPremiumPromoToast(
|
|||
}
|
||||
return false;
|
||||
}),
|
||||
.adaptive = true,
|
||||
.duration = Ui::Toast::kDefaultDuration * 2,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1429,9 +1429,6 @@ Fn<void()> VoicesPrivacyController::premiumClickedCallback(
|
|||
lt_link,
|
||||
link,
|
||||
Ui::Text::WithEntities),
|
||||
.st = &st::defaultMultilineToast,
|
||||
.duration = Ui::Toast::kDefaultDuration * 2,
|
||||
.multiline = true,
|
||||
.filter = crl::guard(&controller->session(), [=](
|
||||
const ClickHandlerPtr &,
|
||||
Qt::MouseButton button) {
|
||||
|
@ -1447,6 +1444,7 @@ Fn<void()> VoicesPrivacyController::premiumClickedCallback(
|
|||
}
|
||||
return false;
|
||||
}),
|
||||
.duration = Ui::Toast::kDefaultDuration * 2,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -307,9 +307,7 @@ void AddPremiumPrivacyButton(
|
|||
lt_link,
|
||||
link,
|
||||
Ui::Text::WithEntities),
|
||||
.st = &st::defaultMultilineToast,
|
||||
.duration = Ui::Toast::kDefaultDuration * 2,
|
||||
.multiline = true,
|
||||
.filter = crl::guard(&controller->session(), [=](
|
||||
const ClickHandlerPtr &,
|
||||
Qt::MouseButton button) {
|
||||
|
|
|
@ -2605,7 +2605,6 @@ void ToggleHistoryArchived(
|
|||
.duration = (archived
|
||||
? kArchivedToastDuration
|
||||
: Ui::Toast::kDefaultDuration),
|
||||
.multiline = true,
|
||||
});
|
||||
};
|
||||
history->session().api().toggleHistoryArchived(
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 40df9722c97385277f128c21a7fcfc13da52b7c7
|
||||
Subproject commit c48bbd9b910480bc4a179df7b96d84b7dfe44671
|
Loading…
Add table
Reference in a new issue