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_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";

View File

@ -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) {

View File

@ -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<Ui::PopupMenu> 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<OverButton>(!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()) {

View File

@ -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);

View File

@ -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 {

View File

@ -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<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(
int visibleTop,
int visibleBottom) {

View File

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

View File

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