diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index 4eb75eded..ac5b74139 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -218,8 +218,11 @@ stickerGroupCategoryAbout: defaultTextStyle; stickerGroupCategoryAddMargin: margins(0px, 10px, 0px, 5px); stickerGroupCategoryAdd: stickersTrendingAdd; -stickersToastMaxWidth: 340px; -stickersToastPadding: margins(16px, 13px, 16px, 12px); +stickersToast: Toast(defaultToast) { + minWidth: 340px; + maxWidth: 340px; + padding: margins(16px, 13px, 16px, 12px); +} stickersEmpty: icon {{ "stickers_empty", windowSubTextFg }}; diff --git a/Telegram/SourceFiles/chat_helpers/stickers.cpp b/Telegram/SourceFiles/chat_helpers/stickers.cpp index 32f38c3d0..bfe0d206a 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers.cpp @@ -77,12 +77,11 @@ void ApplyArchivedResult(const MTPDmessages_stickerSetInstallResultArchive &d) { Local::writeInstalledStickers(); Local::writeArchivedStickers(); - auto toast = Ui::Toast::Config(); - toast.text = { tr::lng_stickers_packs_archived(tr::now) }; - toast.maxWidth = toast.minWidth = st::stickersToastMaxWidth; - toast.multiline = true; - toast.padding = st::stickersToastPadding; - Ui::Toast::Show(toast); + Ui::Toast::Show(Ui::Toast::Config{ + .text = { tr::lng_stickers_packs_archived(tr::now) }, + .st = &st::stickersToast, + .multiline = true, + }); // Ui::show(Box(archived, &Auth()), Ui::LayerOption::KeepOther); Auth().data().notifyStickersUpdated(); diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index 6cdd10442..920f32d61 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -379,6 +379,17 @@ botKbTinyButton: BotKeyboardButton { botKbScroll: defaultSolidScroll; historyDateFadeDuration: 200; +historyDiceToast: Toast(defaultToast) { + minWidth: msgMinWidth; + maxWidth: 640px; +} +historyErrorToast: Toast(defaultToast) { + minWidth: msgMinWidth; +} +historyInfoToast: Toast(defaultToast) { + minWidth: msgMinWidth; + maxWidth: 380px; +} historyPhotoLeft: 14px; historyPhotoBubbleMinWidth: 200px; diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 6bea30897..f88181b59 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -2484,19 +2484,18 @@ void HistoryInner::elementStartStickerLoop( } void HistoryInner::elementShowPollResults( - not_null poll, - FullMsgId context) { - _controller->showPollResults(poll, context); + not_null poll, + FullMsgId context) { } void HistoryInner::elementShowTooltip(const TextWithEntities &text) { - auto config = Ui::Toast::Config(); - config.multiline = config.dark = true; - config.minWidth = st::msgMinWidth; - config.maxWidth = st::windowMinWidth; - config.text = text; - config.durationMs = CountToastDuration(config.text); - Ui::Toast::Show(_widget, config); + Ui::Toast::Show(_widget, Ui::Toast::Config{ + .text = text, + .st = &st::historyInfoToast, + .durationMs = CountToastDuration(text), + .multiline = true, + .dark = true, + }); } auto HistoryInner::getSelectionState() const diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index e122320cd..38c36dd7a 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -236,11 +236,11 @@ object_ptr SetupDiscussButton( } void ShowErrorToast(const QString &text) { - auto config = Ui::Toast::Config(); - config.multiline = true; - config.minWidth = st::msgMinWidth; - config.text = { text }; - Ui::Toast::Show(config); + Ui::Toast::Show(Ui::Toast::Config{ + .text = { text }, + .st = &st::historyErrorToast, + .multiline = true, + }); } } // namespace diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 3bce43e3f..8d6b4329b 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -48,11 +48,11 @@ namespace HistoryView { namespace { void ShowErrorToast(const QString &text) { - auto config = Ui::Toast::Config(); - config.multiline = true; - config.minWidth = st::msgMinWidth; - config.text = { text }; - Ui::Toast::Show(config); + Ui::Toast::Show(Ui::Toast::Config{ + .text = { text }, + .st = &st::historyErrorToast, + .multiline = true, + }); } } // namespace diff --git a/Telegram/SourceFiles/history/view/media/history_view_dice.cpp b/Telegram/SourceFiles/history/view/media/history_view_dice.cpp index 1d1a24a22..ee089ef96 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_dice.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_dice.cpp @@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/text/text_utilities.h" #include "lang/lang_keys.h" #include "main/main_session.h" +#include "styles/style_history.h" namespace HistoryView { namespace { @@ -35,12 +36,12 @@ namespace { not_null history, const QString &emoji) { return std::make_shared([=] { - auto config = Ui::Toast::Config(); - config.multiline = true; - config.minWidth = st::msgMinWidth; - config.maxWidth = st::toastMaxWidth + st::msgMinWidth; - config.text = { tr::lng_about_random(tr::now, lt_emoji, emoji) }; - config.durationMs = Ui::Toast::kDefaultDuration * 2; + auto config = Ui::Toast::Config{ + .text = { tr::lng_about_random(tr::now, lt_emoji, emoji) }, + .st = &st::historyDiceToast, + .durationMs = Ui::Toast::kDefaultDuration * 2, + .multiline = true, + }; auto link = Ui::Text::Link( tr::lng_about_random_send(tr::now).toUpper()); link.entities.push_back( diff --git a/Telegram/SourceFiles/passport/passport_form_controller.cpp b/Telegram/SourceFiles/passport/passport_form_controller.cpp index 05b3c88b1..f7f794c82 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_controller.cpp @@ -759,9 +759,9 @@ std::vector> FormController::submitGetErrors() { _view->showToast(tr::lng_passport_success(tr::now)); base::call_delayed( - (st::toastFadeInDuration + (st::defaultToast.durationFadeIn + Ui::Toast::kDefaultDuration - + st::toastFadeOutDuration), + + st::defaultToast.durationFadeOut), this, [=] { cancel(); }); }).fail([=](const RPCError &error) { diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index e6bcd6ab5..affba64ce 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -828,7 +828,7 @@ void ForwardsPrivacyController::PaintForwardedTooltip( } Unexpected("Option value in ForwardsPrivacyController."); }(); - const auto &font = st::toastTextStyle.font; + const auto &font = st::defaultToast.style.font; const auto textWidth = font->width(text); const auto arrowSkip = st::settingsForwardPrivacyArrowSkip; const auto arrowSize = st::settingsForwardPrivacyArrowSize; diff --git a/Telegram/SourceFiles/window/window.style b/Telegram/SourceFiles/window/window.style index 1699c2c0a..8afbd5a7c 100644 --- a/Telegram/SourceFiles/window/window.style +++ b/Telegram/SourceFiles/window/window.style @@ -310,6 +310,11 @@ windowFilterChatsSectionSubtitle: FlatLabel(defaultFlatLabel) { windowFilterChatsSectionSubtitlePadding: margins(17px, 7px, 17px, 7px); windowFilterAboutPadding: margins(22px, 0px, 22px, 19px); +windowArchiveToast: Toast(defaultToast) { + minWidth: boxWideWidth; + maxWidth: boxWideWidth; +} + // Mac specific macAccessoryWidth: 450.; diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 93a655501..2d2bc85b3 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -53,6 +53,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_window.h" // st::windowMinWidth +#include "styles/style_history.h" // st::historyErrorToast #include @@ -654,12 +655,12 @@ void FolderFiller::addTogglesForArchive() { }); _addAction(tr::lng_context_archive_to_menu(tr::now), [=] { - auto toast = Ui::Toast::Config(); - toast.text = { tr::lng_context_archive_to_menu_info(tr::now) }; - toast.minWidth = toast.maxWidth = st::boxWideWidth; - toast.multiline = true; - toast.durationMs = kArchivedToastDuration; - Ui::Toast::Show(toast); + Ui::Toast::Show(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()); @@ -949,11 +950,11 @@ QPointer ShowSendNowMessagesBox( session->data().idsToItems(items), TextWithTags()); if (!error.isEmpty()) { - auto config = Ui::Toast::Config(); - config.multiline = true; - config.minWidth = st::msgMinWidth; - config.text = { error }; - Ui::Toast::Show(config); + Ui::Toast::Show(Ui::Toast::Config{ + .text = { error }, + .st = &st::historyErrorToast, + .multiline = true, + }); return { nullptr }; } const auto box = std::make_shared>(); @@ -1060,16 +1061,16 @@ void PeerMenuAddMuteAction( // void ToggleHistoryArchived(not_null history, bool archived) { const auto callback = [=] { - auto toast = Ui::Toast::Config(); - toast.text = { archived - ? tr::lng_archived_added(tr::now) - : tr::lng_archived_removed(tr::now) }; - toast.minWidth = toast.maxWidth = st::boxWideWidth; - toast.multiline = true; - if (archived) { - toast.durationMs = kArchivedToastDuration; - } - Ui::Toast::Show(toast); + Ui::Toast::Show(Ui::Toast::Config{ + .text = { (archived + ? tr::lng_archived_added(tr::now) + : tr::lng_archived_removed(tr::now)) }, + .st = &st::windowArchiveToast, + .durationMs = (archived + ? kArchivedToastDuration + : Ui::Toast::kDefaultDuration), + .multiline = true, + }); }; history->session().api().toggleHistoryArchived( history, diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 1647b0b76..48a831574 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 1647b0b76a3352f5d9b2892441eeaf002256a481 +Subproject commit 48a83157407c555d3a0c17026aced41308138d49