mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-25 06:54:43 +00:00
Nice toast after reminder from formatted date.
This commit is contained in:
@@ -1724,6 +1724,8 @@ PRIVATE
|
||||
ui/image/image_location_factory.h
|
||||
ui/text/format_song_document_name.cpp
|
||||
ui/text/format_song_document_name.h
|
||||
ui/toast/toast_lottie_icon.cpp
|
||||
ui/toast/toast_lottie_icon.h
|
||||
ui/widgets/expandable_peer_list.cpp
|
||||
ui/widgets/expandable_peer_list.h
|
||||
ui/widgets/chat_filters_tabs_strip.cpp
|
||||
|
||||
@@ -5580,6 +5580,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
"lng_context_copy_date" = "Copy Date";
|
||||
"lng_context_add_to_calendar" = "Add to Calendar";
|
||||
"lng_context_set_reminder" = "Set a Reminder";
|
||||
"lng_reminder_scheduled_in" = "Reminder scheduled in {link}.";
|
||||
|
||||
"lng_spellchecker_submenu" = "Spelling";
|
||||
"lng_spellchecker_add" = "Add to Dictionary";
|
||||
|
||||
@@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "main/main_session.h"
|
||||
#include "ui/boxes/confirm_box.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/toast/toast_lottie_icon.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "base/qthelp_regex.h"
|
||||
#include "base/qt/qt_key_modifiers.h"
|
||||
@@ -33,9 +34,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "window/window_session_controller_link_info.h"
|
||||
#include "apiwrap.h"
|
||||
#include "history/view/history_view_schedule_box.h"
|
||||
#include "history/view/history_view_scheduled_section.h"
|
||||
#include "menu/menu_send.h"
|
||||
#include "data/data_types.h"
|
||||
#include "styles/style_calls.h" // groupCallBoxLabel
|
||||
#include "styles/style_chat_helpers.h"
|
||||
#include "styles/style_layers.h"
|
||||
#include "styles/style_menu_icons.h"
|
||||
|
||||
@@ -44,6 +47,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto kReminderSetToastDuration = 4 * crl::time(1000);
|
||||
|
||||
[[nodiscard]] TextWithEntities BoldDomainInUrl(const QString &url) {
|
||||
auto result = TextWithEntities{ .text = url };
|
||||
|
||||
@@ -159,6 +164,42 @@ void ExportToCalendar(int32 date, const QString &messageText) {
|
||||
}
|
||||
}
|
||||
|
||||
void DoneSetReminder(std::shared_ptr<ChatHelpers::Show> show) {
|
||||
if (!show->valid()) {
|
||||
return;
|
||||
}
|
||||
const auto text = tr::lng_reminder_scheduled_in(
|
||||
tr::now,
|
||||
lt_link,
|
||||
tr::link(tr::bold(tr::lng_saved_messages(tr::now))),
|
||||
tr::marked);
|
||||
const auto session = &show->session();
|
||||
const auto filter = [=](
|
||||
const ClickHandlerPtr &,
|
||||
Qt::MouseButton) {
|
||||
if (const auto controller = show->resolveWindow()) {
|
||||
controller->showSection(
|
||||
std::make_shared<HistoryView::ScheduledMemento>(
|
||||
session->data().history(session->user())));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
const auto toast = show->showToast({
|
||||
.text = text,
|
||||
.filter = filter,
|
||||
.st = &st::selfForwardsTaggerToast,
|
||||
.attach = RectPart::Top,
|
||||
.duration = kReminderSetToastDuration,
|
||||
});
|
||||
if (const auto strong = toast.get()) {
|
||||
Ui::AddLottieToToast(
|
||||
strong->widget(),
|
||||
st::selfForwardsTaggerToast,
|
||||
st::selfForwardsTaggerIcon,
|
||||
u"toast/saved_messages"_q);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
bool UrlRequiresConfirmation(const QUrl &url) {
|
||||
@@ -577,7 +618,8 @@ void FormattedDateClickHandler::onClick(ClickContext context) const {
|
||||
Data::ResolvedForwardDraft{
|
||||
.items = { item },
|
||||
},
|
||||
action);
|
||||
action,
|
||||
[=] { DoneSetReminder(show); });
|
||||
}));
|
||||
},
|
||||
&st::menuIconNotifications);
|
||||
|
||||
@@ -21,13 +21,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "history/history_item.h"
|
||||
#include "history/view/reactions/history_view_reactions_selector.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "lottie/lottie_icon.h"
|
||||
#include "main/main_session.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/effects/show_animation.h"
|
||||
#include "ui/text/text_utilities.h"
|
||||
#include "ui/toast/toast_widget.h"
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/toast/toast_lottie_icon.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "ui/widgets/tooltip.h"
|
||||
@@ -245,28 +245,11 @@ void SelfForwardsTagger::showToast(
|
||||
void SelfForwardsTagger::createLottieIcon(
|
||||
not_null<QWidget*> widget,
|
||||
const QString &name) {
|
||||
const auto lottieWidget = Ui::CreateChild<Ui::RpWidget>(widget);
|
||||
struct State {
|
||||
std::unique_ptr<Lottie::Icon> lottieIcon;
|
||||
};
|
||||
const auto state = lottieWidget->lifetime().make_state<State>();
|
||||
state->lottieIcon = Lottie::MakeIcon({
|
||||
.name = name,
|
||||
.sizeOverride = st::selfForwardsTaggerIcon,
|
||||
});
|
||||
const auto icon = state->lottieIcon.get();
|
||||
lottieWidget->resize(st::selfForwardsTaggerIcon);
|
||||
lottieWidget->move(st::selfForwardsTaggerToast.iconPosition);
|
||||
lottieWidget->show();
|
||||
lottieWidget->raise();
|
||||
icon->animate(
|
||||
[=] { lottieWidget->update(); },
|
||||
0,
|
||||
icon->framesCount() - 1);
|
||||
lottieWidget->paintRequest() | rpl::on_next([=] {
|
||||
auto p = QPainter(lottieWidget);
|
||||
icon->paint(p, 0, 0);
|
||||
}, lottieWidget->lifetime());
|
||||
Ui::AddLottieToToast(
|
||||
widget,
|
||||
st::selfForwardsTaggerToast,
|
||||
st::selfForwardsTaggerIcon,
|
||||
name);
|
||||
}
|
||||
|
||||
void SelfForwardsTagger::showTaggedToast(DocumentId reaction) {
|
||||
|
||||
@@ -11,10 +11,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
|
||||
class History;
|
||||
|
||||
namespace Lottie {
|
||||
class Icon;
|
||||
} // namespace Lottie
|
||||
|
||||
namespace Data {
|
||||
class Session;
|
||||
} // namespace Data
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
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 "ui/toast/toast_lottie_icon.h"
|
||||
|
||||
#include "lottie/lottie_icon.h"
|
||||
#include "ui/rp_widget.h"
|
||||
#include "styles/style_widgets.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
void AddLottieToToast(
|
||||
not_null<QWidget*> widget,
|
||||
const style::Toast &st,
|
||||
QSize iconSize,
|
||||
const QString &name) {
|
||||
const auto lottieWidget = CreateChild<RpWidget>(widget);
|
||||
struct State {
|
||||
std::unique_ptr<Lottie::Icon> lottieIcon;
|
||||
};
|
||||
const auto state = lottieWidget->lifetime().make_state<State>();
|
||||
state->lottieIcon = Lottie::MakeIcon({
|
||||
.name = name,
|
||||
.sizeOverride = iconSize,
|
||||
});
|
||||
const auto icon = state->lottieIcon.get();
|
||||
lottieWidget->resize(iconSize);
|
||||
lottieWidget->move(st.iconPosition);
|
||||
lottieWidget->show();
|
||||
lottieWidget->raise();
|
||||
icon->animate(
|
||||
[=] { lottieWidget->update(); },
|
||||
0,
|
||||
icon->framesCount() - 1);
|
||||
lottieWidget->paintRequest() | rpl::on_next([=] {
|
||||
auto p = QPainter(lottieWidget);
|
||||
icon->paint(p, 0, 0);
|
||||
}, lottieWidget->lifetime());
|
||||
}
|
||||
|
||||
} // namespace Ui
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
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
|
||||
|
||||
class QWidget;
|
||||
|
||||
namespace style {
|
||||
struct Toast;
|
||||
} // namespace style
|
||||
|
||||
namespace Ui {
|
||||
|
||||
void AddLottieToToast(
|
||||
not_null<QWidget*> widget,
|
||||
const style::Toast &st,
|
||||
QSize iconSize,
|
||||
const QString &name);
|
||||
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user