diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 2d940c84fc..ad8d1f1466 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1877,6 +1877,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_masks_archive_pack" = "Archive Masks"; "lng_masks_has_been_archived" = "Mask pack has been archived."; "lng_masks_installed" = "Mask pack has been installed."; +"lng_emoji_nothing_found" = "No emoji found"; "lng_in_dlg_photo" = "Photo"; "lng_in_dlg_album" = "Album"; diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index c1f9668169..0290386aaf 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -335,6 +335,7 @@ stickersToast: Toast(defaultToast) { } stickersEmpty: icon {{ "stickers_empty", windowSubTextFg }}; +emojiEmpty: icon {{ "stickers_empty", windowSubTextFg }}; inlineBotsScroll: ScrollArea(defaultSolidScroll) { deltat: stickerPanPadding; @@ -396,7 +397,7 @@ reactStripBubble: icon{ { "chat/reactions_bubble", windowBg }, }; reactStripBubbleRight: 20px; -reactPanelEmojiPan: EmojiPan(statusEmojiPan) { +userpicBuilderEmojiPan: EmojiPan(statusEmojiPan) { margin: margins(reactStripSkip, 0px, reactStripSkip, 0px); padding: margins(reactStripSkip, 0px, reactStripSkip, reactStripSkip); desiredSize: reactStripSize; @@ -405,6 +406,8 @@ reactPanelEmojiPan: EmojiPan(statusEmojiPan) { search: TabbedSearch(defaultTabbedSearch) { defaultFieldWidth: 88px; } +} +reactPanelEmojiPan: EmojiPan(userpicBuilderEmojiPan) { searchMargin: margins(1px, 10px, 2px, 6px); } emojiScroll: ScrollArea(defaultSolidScroll) { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp index 5748cbc9ae..208433dfb8 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.cpp @@ -621,7 +621,7 @@ void EmojiListWidget::prepareExpanding() { } void EmojiListWidget::paintExpanding( - QPainter &p, + Painter &p, QRect clip, int finalBottom, float64 progress, @@ -974,7 +974,7 @@ base::unique_qptr EmojiListWidget::fillContextMenu( } void EmojiListWidget::paintEvent(QPaintEvent *e) { - auto p = QPainter(this); + auto p = Painter(this); const auto clip = e ? e->rect() : rect(); @@ -1018,7 +1018,7 @@ void EmojiListWidget::validateEmojiPaintContext( } void EmojiListWidget::paint( - QPainter &p, + Painter &p, ExpandingContext context, QRect clip) { validateEmojiPaintContext(context); @@ -1042,6 +1042,9 @@ void EmojiListWidget::paint( auto selectedButton = std::get_if(!v::is_null(_pressed) ? &_pressed : &_selected); + if (_searchResults.empty() && _searchMode) { + paintEmptySearchResults(p); + } enumerateSections([&](const SectionInfo &info) { if (clip.top() >= info.rowsBottom) { return true; @@ -2007,6 +2010,13 @@ int EmojiListWidget::paintButtonGetWidth( return emojiRight() - rect.x(); } +void EmojiListWidget::paintEmptySearchResults(Painter &p) { + Inner::paintEmptySearchResults( + p, + st::emojiEmpty, + tr::lng_emoji_nothing_found(tr::now)); +} + bool EmojiListWidget::eventHook(QEvent *e) { if (e->type() == QEvent::ParentChange) { if (_picker->parentWidget() != parentWidget()) { diff --git a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h index 3a74da4a4d..764263580c 100644 --- a/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h +++ b/Telegram/SourceFiles/chat_helpers/emoji_list_widget.h @@ -125,7 +125,7 @@ public: void prepareExpanding(); void paintExpanding( - QPainter &p, + Painter &p, QRect clip, int finalBottom, float64 progress, @@ -271,7 +271,7 @@ private: Api::SendOptions options = Api::SendOptions()); void selectEmoji(EmojiChosen data); void selectCustom(FileChosen data); - void paint(QPainter &p, ExpandingContext context, QRect clip); + void paint(Painter &p, ExpandingContext context, QRect clip); void drawCollapsedBadge(QPainter &p, QPoint position, int count); void drawRecent( QPainter &p, @@ -313,6 +313,7 @@ private: const SectionInfo &info, bool selected, QRect clip) const; + void paintEmptySearchResults(Painter &p); void displaySet(uint64 setId); void removeSet(uint64 setId); diff --git a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp index 0285b56566..f25751c419 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers_list_widget.cpp @@ -1080,20 +1080,10 @@ void StickersListWidget::pauseInvisibleLottieIn(const SectionInfo &info) { } void StickersListWidget::paintEmptySearchResults(Painter &p) { - const auto iconLeft = (width() - st::stickersEmpty.width()) / 2; - const auto iconTop = (height() / 3) - (st::stickersEmpty.height() / 2); - st::stickersEmpty.paint(p, iconLeft, iconTop, width()); - - const auto text = tr::lng_stickers_nothing_found(tr::now); - const auto textWidth = st::normalFont->width(text); - p.setFont(st::normalFont); - p.setPen(st::windowSubTextFg); - p.drawTextLeft( - (width() - textWidth) / 2, - iconTop + st::stickersEmpty.height() - st::normalFont->height, - width(), - text, - textWidth); + Inner::paintEmptySearchResults( + p, + st::stickersEmpty, + tr::lng_stickers_nothing_found(tr::now)); } int StickersListWidget::megagroupSetInfoLeft() const { diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index 9e510f28b7..d34884edfe 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/layers/box_content.h" #include "ui/image/image_prepare.h" #include "ui/cached_round_corners.h" +#include "ui/painter.h" #include "window/window_session_controller.h" #include "main/main_session.h" #include "main/main_session_settings.h" @@ -1283,6 +1284,30 @@ void TabbedSelector::Inner::checkHideWithBox(QPointer box) { }); } +void TabbedSelector::Inner::paintEmptySearchResults( + Painter &p, + const style::icon &icon, + const QString &text) const { + const auto iconLeft = (width() - icon.width()) / 2; + const auto iconTop = std::max( + (height() / 3) - (icon.height() / 2), + st::normalFont->height); + icon.paint(p, iconLeft, iconTop, width()); + + const auto textWidth = st::normalFont->width(text); + const auto textTop = std::min( + iconTop + icon.height() - st::normalFont->height, + height() - 2 * st::normalFont->height); + p.setFont(st::normalFont); + p.setPen(st::windowSubTextFg); + p.drawTextLeft( + (width() - textWidth) / 2, + textTop, + width(), + text, + textWidth); +} + void TabbedSelector::Inner::visibleTopBottomUpdated( int visibleTop, int visibleBottom) { diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h index b8189c1e33..74036ab302 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.h +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.h @@ -376,6 +376,11 @@ protected: void checkHideWithBox(QPointer box); + void paintEmptySearchResults( + Painter &p, + const style::icon &icon, + const QString &text) const; + private: const style::EmojiPan &_st; const not_null _session; diff --git a/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_widget.cpp b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_widget.cpp index 23e64c142d..8756628f40 100644 --- a/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_widget.cpp +++ b/Telegram/SourceFiles/info/userpic/info_userpic_emoji_builder_widget.cpp @@ -250,7 +250,7 @@ EmojiSelector::Selector EmojiSelector::createEmojiList( .customRecentFactory = [=](DocumentId id, Fn repaint) { return manager->create(id, std::move(repaint), tag); }, - .st = &st::reactPanelEmojiPan, + .st = &st::userpicBuilderEmojiPan, }; const auto list = scroll->setOwnedWidget( object_ptr(scroll, std::move(args)));