diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 94c2eacd1..fab389b02 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -30,12 +30,13 @@ get_filename_component(src_loc SourceFiles REALPATH) get_filename_component(res_loc Resources REALPATH) include(cmake/telegram_options.cmake) -include(cmake/lib_export.cmake) include(cmake/lib_ffmpeg.cmake) -include(cmake/lib_mtproto.cmake) -include(cmake/lib_scheme.cmake) include(cmake/lib_tgvoip.cmake) include(cmake/lib_tgcalls.cmake) +include(cmake/td_export.cmake) +include(cmake/td_mtproto.cmake) +include(cmake/td_scheme.cmake) +include(cmake/td_ui.cmake) set(style_files boxes/boxes.style @@ -61,6 +62,7 @@ set(dependent_style_files ${submodules_loc}/lib_ui/ui/basic.style ${submodules_loc}/lib_ui/ui/layers/layers.style ${submodules_loc}/lib_ui/ui/widgets/widgets.style + ${src_loc}/ui/td_common.style ) generate_styles(Telegram ${src_loc} "${style_files}" "${dependent_style_files}") @@ -74,9 +76,10 @@ PRIVATE tdesktop::lib_tgcalls_legacy tdesktop::lib_tgcalls tdesktop::lib_tgvoip - tdesktop::lib_mtproto - tdesktop::lib_scheme - tdesktop::lib_export + tdesktop::td_export + tdesktop::td_mtproto + tdesktop::td_scheme + tdesktop::td_ui desktop-app::lib_webrtc desktop-app::lib_base desktop-app::lib_crl @@ -1147,6 +1150,7 @@ PRIVATE qt_static_plugins.cpp settings.cpp settings.h + stdafx.h ) if (NOT LINUX) diff --git a/Telegram/SourceFiles/history/history.style b/Telegram/SourceFiles/history/history.style index 0d3c6817d..60cffe609 100644 --- a/Telegram/SourceFiles/history/history.style +++ b/Telegram/SourceFiles/history/history.style @@ -389,9 +389,6 @@ historyDiceToast: Toast(defaultToast) { maxWidth: 640px; durationFadeOut: 200; } -historyErrorToast: Toast(defaultToast) { - minWidth: msgMinWidth; -} historyInfoToast: Toast(defaultToast) { minWidth: msgMinWidth; maxWidth: 380px; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 622b64ed6..423cf4a62 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/edit_caption_box.h" #include "core/file_utilities.h" #include "ui/toast/toast.h" +#include "ui/toasts/common_toasts.h" #include "ui/special_buttons.h" #include "ui/emoji_config.h" #include "ui/widgets/buttons.h" @@ -139,14 +140,6 @@ constexpr auto kCommonModifiers = 0 | Qt::ControlModifier; const auto kPsaAboutPrefix = "cloud_lng_about_psa_"; -void ShowErrorToast(const QString &text) { - Ui::Toast::Show(Ui::Toast::Config{ - .text = { text }, - .st = &st::historyErrorToast, - .multiline = true, - }); -} - [[nodiscard]] crl::time CountToastDuration(const TextWithEntities &text) { return std::clamp( crl::time(1000) * text.text.size() / 14, @@ -3029,7 +3022,9 @@ void HistoryWidget::send(Api::SendOptions options) { message.textWithTags, options.scheduled); if (!error.isEmpty()) { - ShowErrorToast(error); + Ui::ShowMultilineToast({ + .text = { error }, + }); return; } } @@ -3275,7 +3270,9 @@ void HistoryWidget::chooseAttach() { } else if (const auto error = Data::RestrictionError( _peer, ChatRestriction::f_send_media)) { - ShowErrorToast(*error); + Ui::ShowMultilineToast({ + .text = { *error }, + }); return; } else if (showSlowmodeError()) { return; @@ -4118,7 +4115,9 @@ bool HistoryWidget::showSendingFilesError( return false; } - ShowErrorToast(text); + Ui::ShowMultilineToast({ + .text = { text }, + }); return true; } @@ -4308,7 +4307,9 @@ void HistoryWidget::uploadFilesAfterConfirmation( || (!list.files.empty() && !caption.text.isEmpty() && !list.canAddCaption(isAlbum, compressImages)))) { - ShowErrorToast(tr::lng_slowmode_no_many(tr::now)); + Ui::ShowMultilineToast({ + .text = { tr::lng_slowmode_no_many(tr::now) }, + }); return; } @@ -5111,7 +5112,9 @@ bool HistoryWidget::showSlowmodeError() { if (text.isEmpty()) { return false; } - ShowErrorToast(text); + Ui::ShowMultilineToast({ + .text = { text }, + }); return true; } diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index 2cf6bafb5..23d478b60 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/toast/toast.h" #include "ui/special_buttons.h" #include "ui/ui_utility.h" +#include "ui/toasts/common_toasts.h" #include "api/api_common.h" #include "api/api_editing.h" #include "api/api_sending.h" @@ -62,14 +63,6 @@ namespace { constexpr auto kReadRequestTimeout = 3 * crl::time(1000); -void ShowErrorToast(const QString &text) { - Ui::Toast::Show(Ui::Toast::Config{ - .text = { text }, - .st = &st::historyErrorToast, - .multiline = true, - }); -} - bool CanSendFiles(not_null data) { if (data->hasImage()) { return true; @@ -510,7 +503,9 @@ void RepliesWidget::chooseAttach() { if (const auto error = Data::RestrictionError( _history->peer, ChatRestriction::f_send_media)) { - ShowErrorToast(*error); + Ui::ShowMultilineToast({ + .text = { *error }, + }); return; } @@ -703,7 +698,9 @@ void RepliesWidget::uploadFilesAfterConfirmation( || (!list.files.empty() && !caption.text.isEmpty() && !list.canAddCaption(isAlbum, compressImages)))) { - ShowErrorToast(tr::lng_slowmode_no_many(tr::now)); + Ui::ShowMultilineToast({ + .text = { tr::lng_slowmode_no_many(tr::now) } + }); return; } auto action = Api::SendAction(_history); @@ -806,7 +803,9 @@ bool RepliesWidget::showSendingFilesError( return false; } - ShowErrorToast(text); + Ui::ShowMultilineToast({ + .text = { text }, + }); return true; } @@ -849,7 +848,9 @@ void RepliesWidget::send(Api::SendOptions options) { // _toForward, // message.textWithTags); //if (!error.isEmpty()) { - // ShowErrorToast(error); + // Ui::ShowMultilineToast({ + // .text = { error }, + // }); // return; //} diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.h b/Telegram/SourceFiles/history/view/history_view_replies_section.h index f3a029002..3df08c90b 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.h +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.h @@ -234,6 +234,8 @@ private: not_null bot, Api::SendOptions options); + [[nodiscard]] bool showSlowmodeError(); + const not_null _history; const MsgId _rootId = 0; HistoryItem *_root = nullptr; diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 6c0295c3e..a1327cab6 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/toast/toast.h" #include "ui/special_buttons.h" #include "ui/ui_utility.h" +#include "ui/toasts/common_toasts.h" #include "api/api_common.h" #include "api/api_editing.h" #include "api/api_sending.h" @@ -56,14 +57,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace HistoryView { namespace { -void ShowErrorToast(const QString &text) { - Ui::Toast::Show(Ui::Toast::Config{ - .text = { text }, - .st = &st::historyErrorToast, - .multiline = true, - }); -} - bool CanSendFiles(not_null data) { if (data->hasImage()) { return true; @@ -265,9 +258,11 @@ void ScheduledWidget::setupComposeControls() { void ScheduledWidget::chooseAttach() { if (const auto error = Data::RestrictionError( - _history->peer, - ChatRestriction::f_send_media)) { - ShowErrorToast(*error); + _history->peer, + ChatRestriction::f_send_media)) { + Ui::ShowMultilineToast({ + .text = { *error }, + }); return; } @@ -458,7 +453,9 @@ void ScheduledWidget::uploadFilesAfterConfirmation( || (!list.files.empty() && !caption.text.isEmpty() && !list.canAddCaption(isAlbum, compressImages)))) { - ShowErrorToast(tr::lng_slowmode_no_many(tr::now)); + Ui::ShowMultilineToast({ + .text = { tr::lng_slowmode_no_many(tr::now) }, + }); return; } auto action = Api::SendAction(_history); @@ -515,7 +512,9 @@ bool ScheduledWidget::showSendingFilesError( return false; } - ShowErrorToast(text); + Ui::ShowMultilineToast({ + .text = { text }, + }); return true; } @@ -547,7 +546,9 @@ void ScheduledWidget::send(Api::SendOptions options) { // _toForward, // message.textWithTags); //if (!error.isEmpty()) { - // ShowErrorToast(error); + // Ui::ShowMultilineToast({ + // .text = { error }, + // }); // return; //} diff --git a/Telegram/SourceFiles/stdafx.cpp b/Telegram/SourceFiles/stdafx.cpp deleted file mode 100644 index d140f5eef..000000000 --- a/Telegram/SourceFiles/stdafx.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* -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 "stdafx.h" - -// Precompiled header helper. diff --git a/Telegram/SourceFiles/export/export_pch.cpp b/Telegram/SourceFiles/ui/td_common.style similarity index 64% rename from Telegram/SourceFiles/export/export_pch.cpp rename to Telegram/SourceFiles/ui/td_common.style index 712f6a0b6..6b3d95210 100644 --- a/Telegram/SourceFiles/export/export_pch.cpp +++ b/Telegram/SourceFiles/ui/td_common.style @@ -5,6 +5,9 @@ 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 "export/export_pch.h" +using "ui/colors.palette"; +using "ui/widgets/widgets.style"; -// Precompiled header helper. +defaultMultilineToast: Toast(defaultToast) { + minWidth: msgMinWidth; +} diff --git a/Telegram/SourceFiles/ui/toasts/common_toasts.cpp b/Telegram/SourceFiles/ui/toasts/common_toasts.cpp new file mode 100644 index 000000000..ad68b758c --- /dev/null +++ b/Telegram/SourceFiles/ui/toasts/common_toasts.cpp @@ -0,0 +1,23 @@ +/* +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/toasts/common_toasts.h" + +#include "ui/toast/toast.h" +#include "styles/style_td_common.h" + +namespace Ui { + +void ShowMultilineToast(MultilineToastArgs &&args) { + Ui::Toast::Show(Ui::Toast::Config{ + .text = std::move(args.text), + .st = &st::defaultMultilineToast, + .multiline = true, + }); +} + +} // namespace Ui diff --git a/Telegram/SourceFiles/mtproto/mtproto_pch.cpp b/Telegram/SourceFiles/ui/toasts/common_toasts.h similarity index 55% rename from Telegram/SourceFiles/mtproto/mtproto_pch.cpp rename to Telegram/SourceFiles/ui/toasts/common_toasts.h index bdad25fc3..ea2fe9282 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_pch.cpp +++ b/Telegram/SourceFiles/ui/toasts/common_toasts.h @@ -5,6 +5,16 @@ 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 "mtproto/mtproto_pch.h" +#pragma once -// Precompiled header helper. +#include "ui/text/text_entity.h" + +namespace Ui { + +struct MultilineToastArgs { + TextWithEntities text; +}; + +void ShowMultilineToast(MultilineToastArgs &&args); + +} // namespace Ui diff --git a/Telegram/SourceFiles/ui/ui_pch.h b/Telegram/SourceFiles/ui/ui_pch.h new file mode 100644 index 000000000..1894747b8 --- /dev/null +++ b/Telegram/SourceFiles/ui/ui_pch.h @@ -0,0 +1,33 @@ +// This file is part of Desktop App Toolkit, +// a set of libraries for developing nice desktop applications. +// +// For license and copyright information please follow this link: +// https://github.com/desktop-app/legal/blob/master/LEGAL +// + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "base/algorithm.h" +#include "base/basic_types.h" +#include "base/flat_map.h" +#include "base/flat_set.h" diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 688544cf4..6b0a3ea34 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/labels.h" #include "ui/widgets/checkbox.h" #include "ui/layers/generic_box.h" +#include "ui/toasts/common_toasts.h" #include "main/main_session.h" #include "main/main_session_settings.h" #include "apiwrap.h" @@ -57,7 +58,6 @@ 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 @@ -1052,10 +1052,8 @@ QPointer ShowSendNowMessagesBox( session->data().idsToItems(items), TextWithTags()); if (!error.isEmpty()) { - Ui::Toast::Show(Ui::Toast::Config{ + Ui::ShowMultilineToast({ .text = { error }, - .st = &st::historyErrorToast, - .multiline = true, }); return { nullptr }; } diff --git a/Telegram/cmake/lib_export.cmake b/Telegram/cmake/td_export.cmake similarity index 76% rename from Telegram/cmake/lib_export.cmake rename to Telegram/cmake/td_export.cmake index ef312a0a5..734cc3f3f 100644 --- a/Telegram/cmake/lib_export.cmake +++ b/Telegram/cmake/td_export.cmake @@ -4,17 +4,18 @@ # For license and copyright information please follow this link: # https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -add_library(lib_export OBJECT) -init_target(lib_export) -add_library(tdesktop::lib_export ALIAS lib_export) +add_library(td_export OBJECT) +init_target(td_export) +add_library(tdesktop::td_export ALIAS td_export) -target_precompile_headers(lib_export PRIVATE ${src_loc}/export/export_pch.h) -nice_target_sources(lib_export ${src_loc} +target_precompile_headers(td_export PRIVATE ${src_loc}/export/export_pch.h) +nice_target_sources(td_export ${src_loc} PRIVATE export/export_api_wrap.cpp export/export_api_wrap.h export/export_controller.cpp export/export_controller.h + export/export_pch.h export/export_settings.cpp export/export_settings.h export/data/export_data_types.cpp @@ -34,13 +35,13 @@ PRIVATE export/output/export_output_text.h ) -target_include_directories(lib_export +target_include_directories(td_export PUBLIC ${src_loc} ) -target_link_libraries(lib_export +target_link_libraries(td_export PUBLIC desktop-app::lib_base - tdesktop::lib_scheme + tdesktop::td_scheme ) diff --git a/Telegram/cmake/lib_mtproto.cmake b/Telegram/cmake/td_mtproto.cmake similarity index 84% rename from Telegram/cmake/lib_mtproto.cmake rename to Telegram/cmake/td_mtproto.cmake index 6ede5106f..8535fb1ec 100644 --- a/Telegram/cmake/lib_mtproto.cmake +++ b/Telegram/cmake/td_mtproto.cmake @@ -4,12 +4,12 @@ # For license and copyright information please follow this link: # https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -add_library(lib_mtproto OBJECT) -init_target(lib_mtproto) -add_library(tdesktop::lib_mtproto ALIAS lib_mtproto) +add_library(td_mtproto OBJECT) +init_target(td_mtproto) +add_library(tdesktop::td_mtproto ALIAS td_mtproto) -target_precompile_headers(lib_mtproto PRIVATE ${src_loc}/mtproto/mtproto_pch.h) -nice_target_sources(lib_mtproto ${src_loc} +target_precompile_headers(td_mtproto PRIVATE ${src_loc}/mtproto/mtproto_pch.h) +nice_target_sources(td_mtproto ${src_loc} PRIVATE mtproto/details/mtproto_abstract_socket.cpp mtproto/details/mtproto_abstract_socket.h @@ -45,20 +45,21 @@ PRIVATE mtproto/mtproto_dc_options.h mtproto/mtproto_dh_utils.cpp mtproto/mtproto_dh_utils.h + mtproto/mtproto_pch.h mtproto/mtproto_proxy_data.cpp mtproto/mtproto_proxy_data.h mtproto/mtproto_rpc_sender.cpp mtproto/mtproto_rpc_sender.h ) -target_include_directories(lib_mtproto +target_include_directories(td_mtproto PUBLIC ${src_loc} ) -target_link_libraries(lib_mtproto +target_link_libraries(td_mtproto PUBLIC - tdesktop::lib_scheme + tdesktop::td_scheme PRIVATE desktop-app::external_zlib ) diff --git a/Telegram/cmake/lib_scheme.cmake b/Telegram/cmake/td_scheme.cmake similarity index 61% rename from Telegram/cmake/lib_scheme.cmake rename to Telegram/cmake/td_scheme.cmake index 81777adf4..81778c27f 100644 --- a/Telegram/cmake/lib_scheme.cmake +++ b/Telegram/cmake/td_scheme.cmake @@ -4,9 +4,9 @@ # For license and copyright information please follow this link: # https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -add_library(lib_scheme OBJECT) -init_target(lib_scheme) -add_library(tdesktop::lib_scheme ALIAS lib_scheme) +add_library(td_scheme OBJECT) +init_target(td_scheme) +add_library(tdesktop::td_scheme ALIAS td_scheme) include(cmake/generate_scheme.cmake) @@ -15,20 +15,20 @@ set(scheme_files ${res_loc}/tl/api.tl ) -generate_scheme(lib_scheme ${src_loc}/codegen/scheme/codegen_scheme.py "${scheme_files}") +generate_scheme(td_scheme ${src_loc}/codegen/scheme/codegen_scheme.py "${scheme_files}") -nice_target_sources(lib_scheme ${res_loc} +nice_target_sources(td_scheme ${res_loc} PRIVATE tl/mtproto.tl tl/api.tl ) -target_include_directories(lib_scheme +target_include_directories(td_scheme PUBLIC ${src_loc} ) -target_link_libraries(lib_scheme +target_link_libraries(td_scheme PUBLIC desktop-app::lib_base desktop-app::lib_tl diff --git a/Telegram/cmake/td_ui.cmake b/Telegram/cmake/td_ui.cmake new file mode 100644 index 000000000..935fbc13b --- /dev/null +++ b/Telegram/cmake/td_ui.cmake @@ -0,0 +1,44 @@ +# 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 + +add_library(td_ui OBJECT) +init_target(td_ui) +add_library(tdesktop::td_ui ALIAS td_ui) + +include(lib_ui/cmake/generate_styles.cmake) + +set(style_files + ui/td_common.style +) + +set(dependent_style_files + ${submodules_loc}/lib_ui/ui/colors.palette + ${submodules_loc}/lib_ui/ui/basic.style + ${submodules_loc}/lib_ui/ui/layers/layers.style + ${submodules_loc}/lib_ui/ui/widgets/widgets.style +) + +generate_styles(td_ui ${src_loc} "${style_files}" "${dependent_style_files}") + +target_precompile_headers(td_ui PRIVATE ${src_loc}/ui/ui_pch.h) +nice_target_sources(td_ui ${src_loc} +PRIVATE + ${style_files} + + ui/ui_pch.h + ui/toasts/common_toasts.cpp + ui/toasts/common_toasts.h +) + +target_include_directories(td_ui +PUBLIC + ${src_loc} +) + +target_link_libraries(td_ui +PUBLIC + desktop-app::lib_ui +) diff --git a/Telegram/lib_base b/Telegram/lib_base index c886914f8..c28f55ab2 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit c886914f8992614aac5717c858ac2a231ca86a08 +Subproject commit c28f55ab25c9ee7aee7e960c6a4127b008742bdd diff --git a/Telegram/lib_spellcheck b/Telegram/lib_spellcheck index c650fe72d..58263c071 160000 --- a/Telegram/lib_spellcheck +++ b/Telegram/lib_spellcheck @@ -1 +1 @@ -Subproject commit c650fe72d6c486bbee1d92f73f97b02c523dd37b +Subproject commit 58263c0715ebfbf586c71e856a2ad962301bdc05 diff --git a/Telegram/lib_storage b/Telegram/lib_storage index cbd295476..6fc06b5f9 160000 --- a/Telegram/lib_storage +++ b/Telegram/lib_storage @@ -1 +1 @@ -Subproject commit cbd295476b7910cc7fad7039e5da4a04edf33200 +Subproject commit 6fc06b5f9645005143f09f72e1c052a28d5f26ed diff --git a/Telegram/lib_ui b/Telegram/lib_ui index b5d6851c9..03ea7a05e 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit b5d6851c976ef87a9f662a8aaae3db45d6141cef +Subproject commit 03ea7a05e62332ee4e41d00606e9f80cfdd95f33 diff --git a/Telegram/lib_webrtc b/Telegram/lib_webrtc index 37768e47a..d7c4f1f0b 160000 --- a/Telegram/lib_webrtc +++ b/Telegram/lib_webrtc @@ -1 +1 @@ -Subproject commit 37768e47ab0c75a44a9185435475484f6fbcbe8e +Subproject commit d7c4f1f0b902158f065ea9fb6b7ec80fa0ceac45