Show empty search results in emoji panel.

This commit is contained in:
John Preston 2023-02-09 12:55:44 +04:00
parent cbd9dd0c2c
commit 8f908ab9c0
8 changed files with 56 additions and 21 deletions

View file

@ -1877,6 +1877,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_masks_archive_pack" = "Archive Masks"; "lng_masks_archive_pack" = "Archive Masks";
"lng_masks_has_been_archived" = "Mask pack has been archived."; "lng_masks_has_been_archived" = "Mask pack has been archived.";
"lng_masks_installed" = "Mask pack has been installed."; "lng_masks_installed" = "Mask pack has been installed.";
"lng_emoji_nothing_found" = "No emoji found";
"lng_in_dlg_photo" = "Photo"; "lng_in_dlg_photo" = "Photo";
"lng_in_dlg_album" = "Album"; "lng_in_dlg_album" = "Album";

View file

@ -335,6 +335,7 @@ stickersToast: Toast(defaultToast) {
} }
stickersEmpty: icon {{ "stickers_empty", windowSubTextFg }}; stickersEmpty: icon {{ "stickers_empty", windowSubTextFg }};
emojiEmpty: icon {{ "stickers_empty", windowSubTextFg }};
inlineBotsScroll: ScrollArea(defaultSolidScroll) { inlineBotsScroll: ScrollArea(defaultSolidScroll) {
deltat: stickerPanPadding; deltat: stickerPanPadding;
@ -396,7 +397,7 @@ reactStripBubble: icon{
{ "chat/reactions_bubble", windowBg }, { "chat/reactions_bubble", windowBg },
}; };
reactStripBubbleRight: 20px; reactStripBubbleRight: 20px;
reactPanelEmojiPan: EmojiPan(statusEmojiPan) { userpicBuilderEmojiPan: EmojiPan(statusEmojiPan) {
margin: margins(reactStripSkip, 0px, reactStripSkip, 0px); margin: margins(reactStripSkip, 0px, reactStripSkip, 0px);
padding: margins(reactStripSkip, 0px, reactStripSkip, reactStripSkip); padding: margins(reactStripSkip, 0px, reactStripSkip, reactStripSkip);
desiredSize: reactStripSize; desiredSize: reactStripSize;
@ -405,6 +406,8 @@ reactPanelEmojiPan: EmojiPan(statusEmojiPan) {
search: TabbedSearch(defaultTabbedSearch) { search: TabbedSearch(defaultTabbedSearch) {
defaultFieldWidth: 88px; defaultFieldWidth: 88px;
} }
}
reactPanelEmojiPan: EmojiPan(userpicBuilderEmojiPan) {
searchMargin: margins(1px, 10px, 2px, 6px); searchMargin: margins(1px, 10px, 2px, 6px);
} }
emojiScroll: ScrollArea(defaultSolidScroll) { emojiScroll: ScrollArea(defaultSolidScroll) {

View file

@ -621,7 +621,7 @@ void EmojiListWidget::prepareExpanding() {
} }
void EmojiListWidget::paintExpanding( void EmojiListWidget::paintExpanding(
QPainter &p, Painter &p,
QRect clip, QRect clip,
int finalBottom, int finalBottom,
float64 progress, float64 progress,
@ -974,7 +974,7 @@ base::unique_qptr<Ui::PopupMenu> EmojiListWidget::fillContextMenu(
} }
void EmojiListWidget::paintEvent(QPaintEvent *e) { void EmojiListWidget::paintEvent(QPaintEvent *e) {
auto p = QPainter(this); auto p = Painter(this);
const auto clip = e ? e->rect() : rect(); const auto clip = e ? e->rect() : rect();
@ -1018,7 +1018,7 @@ void EmojiListWidget::validateEmojiPaintContext(
} }
void EmojiListWidget::paint( void EmojiListWidget::paint(
QPainter &p, Painter &p,
ExpandingContext context, ExpandingContext context,
QRect clip) { QRect clip) {
validateEmojiPaintContext(context); validateEmojiPaintContext(context);
@ -1042,6 +1042,9 @@ void EmojiListWidget::paint(
auto selectedButton = std::get_if<OverButton>(!v::is_null(_pressed) auto selectedButton = std::get_if<OverButton>(!v::is_null(_pressed)
? &_pressed ? &_pressed
: &_selected); : &_selected);
if (_searchResults.empty() && _searchMode) {
paintEmptySearchResults(p);
}
enumerateSections([&](const SectionInfo &info) { enumerateSections([&](const SectionInfo &info) {
if (clip.top() >= info.rowsBottom) { if (clip.top() >= info.rowsBottom) {
return true; return true;
@ -2007,6 +2010,13 @@ int EmojiListWidget::paintButtonGetWidth(
return emojiRight() - rect.x(); 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) { bool EmojiListWidget::eventHook(QEvent *e) {
if (e->type() == QEvent::ParentChange) { if (e->type() == QEvent::ParentChange) {
if (_picker->parentWidget() != parentWidget()) { if (_picker->parentWidget() != parentWidget()) {

View file

@ -125,7 +125,7 @@ public:
void prepareExpanding(); void prepareExpanding();
void paintExpanding( void paintExpanding(
QPainter &p, Painter &p,
QRect clip, QRect clip,
int finalBottom, int finalBottom,
float64 progress, float64 progress,
@ -271,7 +271,7 @@ private:
Api::SendOptions options = Api::SendOptions()); Api::SendOptions options = Api::SendOptions());
void selectEmoji(EmojiChosen data); void selectEmoji(EmojiChosen data);
void selectCustom(FileChosen 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 drawCollapsedBadge(QPainter &p, QPoint position, int count);
void drawRecent( void drawRecent(
QPainter &p, QPainter &p,
@ -313,6 +313,7 @@ private:
const SectionInfo &info, const SectionInfo &info,
bool selected, bool selected,
QRect clip) const; QRect clip) const;
void paintEmptySearchResults(Painter &p);
void displaySet(uint64 setId); void displaySet(uint64 setId);
void removeSet(uint64 setId); void removeSet(uint64 setId);

View file

@ -1080,20 +1080,10 @@ void StickersListWidget::pauseInvisibleLottieIn(const SectionInfo &info) {
} }
void StickersListWidget::paintEmptySearchResults(Painter &p) { void StickersListWidget::paintEmptySearchResults(Painter &p) {
const auto iconLeft = (width() - st::stickersEmpty.width()) / 2; Inner::paintEmptySearchResults(
const auto iconTop = (height() / 3) - (st::stickersEmpty.height() / 2); p,
st::stickersEmpty.paint(p, iconLeft, iconTop, width()); st::stickersEmpty,
tr::lng_stickers_nothing_found(tr::now));
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);
} }
int StickersListWidget::megagroupSetInfoLeft() const { int StickersListWidget::megagroupSetInfoLeft() const {

View file

@ -21,6 +21,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/layers/box_content.h" #include "ui/layers/box_content.h"
#include "ui/image/image_prepare.h" #include "ui/image/image_prepare.h"
#include "ui/cached_round_corners.h" #include "ui/cached_round_corners.h"
#include "ui/painter.h"
#include "window/window_session_controller.h" #include "window/window_session_controller.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
@ -1283,6 +1284,30 @@ void TabbedSelector::Inner::checkHideWithBox(QPointer<Ui::BoxContent> 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( void TabbedSelector::Inner::visibleTopBottomUpdated(
int visibleTop, int visibleTop,
int visibleBottom) { int visibleBottom) {

View file

@ -376,6 +376,11 @@ protected:
void checkHideWithBox(QPointer<Ui::BoxContent> box); void checkHideWithBox(QPointer<Ui::BoxContent> box);
void paintEmptySearchResults(
Painter &p,
const style::icon &icon,
const QString &text) const;
private: private:
const style::EmojiPan &_st; const style::EmojiPan &_st;
const not_null<Main::Session*> _session; const not_null<Main::Session*> _session;

View file

@ -250,7 +250,7 @@ EmojiSelector::Selector EmojiSelector::createEmojiList(
.customRecentFactory = [=](DocumentId id, Fn<void()> repaint) { .customRecentFactory = [=](DocumentId id, Fn<void()> repaint) {
return manager->create(id, std::move(repaint), tag); return manager->create(id, std::move(repaint), tag);
}, },
.st = &st::reactPanelEmojiPan, .st = &st::userpicBuilderEmojiPan,
}; };
const auto list = scroll->setOwnedWidget( const auto list = scroll->setOwnedWidget(
object_ptr<ChatHelpers::EmojiListWidget>(scroll, std::move(args))); object_ptr<ChatHelpers::EmojiListWidget>(scroll, std::move(args)));