diff --git a/Telegram/SourceFiles/history/view/history_view_chat_preview.cpp b/Telegram/SourceFiles/history/view/history_view_chat_preview.cpp index da6b492d3..ced357db0 100644 --- a/Telegram/SourceFiles/history/view/history_view_chat_preview.cpp +++ b/Telegram/SourceFiles/history/view/history_view_chat_preview.cpp @@ -24,6 +24,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history.h" #include "history/history_item.h" #include "history/history_item_components.h" +#include "info/profile/info_profile_badge.h" #include "info/profile/info_profile_cover.h" #include "info/profile/info_profile_values.h" #include "lang/lang_keys.h" @@ -38,11 +39,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/widgets/popup_menu.h" #include "ui/widgets/shadow.h" #include "ui/ui_utility.h" +#include "ui/unread_badge.h" #include "window/themes/window_theme.h" #include "window/section_widget.h" #include "window/window_session_controller.h" #include "styles/style_chat.h" #include "styles/style_chat_helpers.h" +#include "styles/style_settings.h" #ifdef Q_OS_WIN #include "ui/platform/win/ui_windows_direct_manipulation.h" @@ -191,6 +194,8 @@ private: const std::unique_ptr _scroll; const std::unique_ptr _markRead; + Info::Profile::Badge _badge; + QPointer _inner; std::unique_ptr _cornerButtons; rpl::event_stream _actions; @@ -265,7 +270,14 @@ Item::Item(not_null parent, not_null thread) std::make_unique( this, tr::lng_context_mark_read(tr::now), - st::previewMarkRead)) { + st::previewMarkRead)) +, _badge( + _top.get(), + st::settingsInfoPeerBadge, + _peer, + nullptr, + nullptr, + 1) { _chatStyle->apply(_theme.get()); setPointerCursor(false); setMinWidth(st::previewMenu.menu.widthMin); @@ -359,12 +371,14 @@ void Item::setupTop() { const auto shadow = Ui::CreateChild(this); rpl::combine( _top->widthValue(), - std::move(nameValue) - ) | rpl::start_with_next([=](int width, const auto &) { + std::move(nameValue), + rpl::single(rpl::empty) | rpl::then(_badge.updated()) + ) | rpl::start_with_next([=](int width, const auto &, const auto &) { const auto &st = st::previewTop; name->resizeToNaturalWidth(width - st.namePosition.x() - - st.photoPosition.x()); + - st.photoPosition.x() + - (_badge.widget() ? _badge.widget()->width() : 0)); if (status) { name->move(st::previewTop.namePosition); } else { @@ -372,6 +386,10 @@ void Item::setupTop() { st::previewTop.namePosition.x(), (st::previewTop.height - name->height()) / 2); } + _badge.move( + name->x() + name->width() + st::normalFont->spacew, + name->y(), + name->y() + name->height()); }, name->lifetime()); _top->geometryValue() | rpl::start_with_next([=](QRect geometry) { diff --git a/Telegram/SourceFiles/settings/settings.style b/Telegram/SourceFiles/settings/settings.style index 894dac513..a64cc6e92 100644 --- a/Telegram/SourceFiles/settings/settings.style +++ b/Telegram/SourceFiles/settings/settings.style @@ -197,6 +197,10 @@ settingsInfoPhotoSkip: 7px; settingsInfoNameSkip: -1px; settingsInfoUploadLeft: 6px; settingsInfoPeerBadge: InfoPeerBadge { + verified: icon { + { "dialogs/dialogs_verified_star", dialogsVerifiedIconBg }, + { "dialogs/dialogs_verified_check", dialogsVerifiedIconFg }, + }; premium: icon {{ "dialogs/dialogs_premium", dialogsVerifiedIconBg }}; premiumFg: dialogsVerifiedIconBg; sizeTag: 0; // Normal