mirror of https://github.com/procxx/kepka.git
Use sticker set thumbnails in the panel.
This commit is contained in:
parent
386600baf9
commit
72d9ac508a
|
@ -46,13 +46,20 @@ bool SetInMyList(MTPDstickerSet::Flags flags) {
|
|||
struct StickerIcon {
|
||||
StickerIcon(uint64 setId) : setId(setId) {
|
||||
}
|
||||
StickerIcon(uint64 setId, DocumentData *sticker, int pixw, int pixh)
|
||||
StickerIcon(
|
||||
uint64 setId,
|
||||
ImagePtr thumbnail,
|
||||
DocumentData *sticker,
|
||||
int pixw,
|
||||
int pixh)
|
||||
: setId(setId)
|
||||
, thumbnail(thumbnail)
|
||||
, sticker(sticker)
|
||||
, pixw(pixw)
|
||||
, pixh(pixh) {
|
||||
}
|
||||
uint64 setId = 0;
|
||||
ImagePtr thumbnail;
|
||||
DocumentData *sticker = nullptr;
|
||||
ChannelData *megagroup = nullptr;
|
||||
int pixw = 0;
|
||||
|
@ -152,6 +159,7 @@ StickersListWidget::Set::Set(
|
|||
MTPDstickerSet::Flags flags,
|
||||
const QString &title,
|
||||
const QString &shortName,
|
||||
ImagePtr thumbnail,
|
||||
bool externalLayout,
|
||||
int count,
|
||||
const Stickers::Pack &pack)
|
||||
|
@ -159,6 +167,7 @@ StickersListWidget::Set::Set(
|
|||
, flags(flags)
|
||||
, title(title)
|
||||
, shortName(shortName)
|
||||
, thumbnail(thumbnail)
|
||||
, pack(pack)
|
||||
, externalLayout(externalLayout)
|
||||
, count(count) {
|
||||
|
@ -258,9 +267,14 @@ void StickersListWidget::Footer::enumerateVisibleIcons(Callback callback) {
|
|||
}
|
||||
|
||||
void StickersListWidget::Footer::preloadImages() {
|
||||
enumerateVisibleIcons([](const StickerIcon &icon, int x) {
|
||||
enumerateVisibleIcons([](const StickerIcon & icon, int x) {
|
||||
if (const auto sticker = icon.sticker) {
|
||||
sticker->loadThumbnail(sticker->stickerSetOrigin());
|
||||
const auto origin = sticker->stickerSetOrigin();
|
||||
if (icon.thumbnail) {
|
||||
icon.thumbnail->load(origin);
|
||||
} else {
|
||||
sticker->loadThumbnail(origin);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -631,7 +645,10 @@ void StickersListWidget::Footer::paintSetIcon(
|
|||
int x) const {
|
||||
if (icon.sticker) {
|
||||
const auto origin = icon.sticker->stickerSetOrigin();
|
||||
if (const auto thumb = icon.sticker->thumbnail()) {
|
||||
const auto thumb = icon.thumbnail
|
||||
? icon.thumbnail.get()
|
||||
: icon.sticker->thumbnail();
|
||||
if (thumb) {
|
||||
thumb->load(origin);
|
||||
auto pix = thumb->pix(origin, icon.pixw, icon.pixh);
|
||||
|
||||
|
@ -1032,14 +1049,15 @@ void StickersListWidget::fillCloudSearchRows(
|
|||
}
|
||||
|
||||
void StickersListWidget::addSearchRow(not_null<const Stickers::Set*> set) {
|
||||
_searchSets.push_back(Set(
|
||||
_searchSets.emplace_back(
|
||||
set->id,
|
||||
set->flags,
|
||||
set->title,
|
||||
set->shortName,
|
||||
set->thumbnail,
|
||||
!SetInMyList(set->flags),
|
||||
set->count,
|
||||
set->stickers.empty() ? set->covers : set->stickers));
|
||||
set->stickers.empty() ? set->covers : set->stickers);
|
||||
}
|
||||
|
||||
auto StickersListWidget::shownSets() const -> const std::vector<Set> & {
|
||||
|
@ -1831,14 +1849,15 @@ void StickersListWidget::appendSet(
|
|||
}
|
||||
}
|
||||
|
||||
to.push_back(Set(
|
||||
to.emplace_back(
|
||||
it->id,
|
||||
it->flags,
|
||||
it->title,
|
||||
it->shortName,
|
||||
it->thumbnail,
|
||||
externalLayout,
|
||||
it->count,
|
||||
it->stickers));
|
||||
it->stickers);
|
||||
}
|
||||
|
||||
void StickersListWidget::refreshRecent() {
|
||||
|
@ -1909,16 +1928,18 @@ void StickersListWidget::refreshRecentStickers(bool performResize) {
|
|||
if (!recentPack.empty()) {
|
||||
if (recentIt == _mySets.end()) {
|
||||
const auto shortName = QString();
|
||||
const auto thumbnail = ImagePtr();
|
||||
const auto externalLayout = false;
|
||||
_mySets.push_back(Set(
|
||||
_mySets.emplace_back(
|
||||
Stickers::RecentSetId,
|
||||
(MTPDstickerSet::Flag::f_official
|
||||
| MTPDstickerSet_ClientFlag::f_special),
|
||||
lang(lng_recent_stickers),
|
||||
shortName,
|
||||
thumbnail,
|
||||
externalLayout,
|
||||
recentPack.size(),
|
||||
recentPack));
|
||||
recentPack);
|
||||
} else {
|
||||
recentIt->pack = recentPack;
|
||||
}
|
||||
|
@ -1941,15 +1962,17 @@ void StickersListWidget::refreshFavedStickers() {
|
|||
}
|
||||
const auto externalLayout = false;
|
||||
const auto shortName = QString();
|
||||
_mySets.push_back(Set(
|
||||
const auto thumbnail = ImagePtr();
|
||||
_mySets.emplace_back(
|
||||
Stickers::FavedSetId,
|
||||
(MTPDstickerSet::Flag::f_official
|
||||
| MTPDstickerSet_ClientFlag::f_special),
|
||||
Lang::Hard::FavedSetTitle(),
|
||||
shortName,
|
||||
thumbnail,
|
||||
externalLayout,
|
||||
it->count,
|
||||
it->stickers));
|
||||
it->stickers);
|
||||
_favedStickersMap = base::flat_set<not_null<DocumentData*>> { it->stickers.begin(), it->stickers.end() };
|
||||
}
|
||||
|
||||
|
@ -1966,15 +1989,17 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
|||
auto hidden = Auth().settings().isGroupStickersSectionHidden(_megagroupSet->id);
|
||||
if (isShownHere(hidden)) {
|
||||
const auto shortName = QString();
|
||||
const auto thumbnail = ImagePtr();
|
||||
const auto externalLayout = false;
|
||||
const auto count = 0;
|
||||
_mySets.push_back(Set(
|
||||
_mySets.emplace_back(
|
||||
Stickers::MegagroupSetId,
|
||||
MTPDstickerSet_ClientFlag::f_special | 0,
|
||||
lang(lng_group_stickers),
|
||||
QString(),
|
||||
shortName,
|
||||
thumbnail,
|
||||
externalLayout,
|
||||
count));
|
||||
count);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -2001,15 +2026,17 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
|||
removeHiddenForGroup();
|
||||
} else if (isShownHere(hidden)) {
|
||||
const auto shortName = QString();
|
||||
const auto thumbnail = ImagePtr();
|
||||
const auto externalLayout = false;
|
||||
_mySets.push_back(Set(
|
||||
_mySets.emplace_back(
|
||||
Stickers::MegagroupSetId,
|
||||
MTPDstickerSet_ClientFlag::f_special | 0,
|
||||
lang(lng_group_stickers),
|
||||
shortName,
|
||||
thumbnail,
|
||||
externalLayout,
|
||||
it->count,
|
||||
it->stickers));
|
||||
it->stickers);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2049,9 +2076,13 @@ void StickersListWidget::fillIcons(QList<StickerIcon> &icons) {
|
|||
icons.back().megagroup = _megagroupSet;
|
||||
continue;
|
||||
}
|
||||
auto s = _mySets[i].pack[0];
|
||||
auto availw = st::stickerIconWidth - 2 * st::stickerIconPadding, availh = st::emojiFooterHeight - 2 * st::stickerIconPadding;
|
||||
const auto size = s->hasThumbnail()
|
||||
const auto thumbnail = _mySets[i].thumbnail;
|
||||
const auto s = _mySets[i].pack[0];
|
||||
const auto availw = st::stickerIconWidth - 2 * st::stickerIconPadding;
|
||||
const auto availh = st::emojiFooterHeight - 2 * st::stickerIconPadding;
|
||||
const auto size = thumbnail
|
||||
? thumbnail->size()
|
||||
: s->hasThumbnail()
|
||||
? s->thumbnail()->size()
|
||||
: QSize();
|
||||
auto thumbw = size.width(), thumbh = size.height(), pixw = 1, pixh = 1;
|
||||
|
@ -2064,7 +2095,12 @@ void StickersListWidget::fillIcons(QList<StickerIcon> &icons) {
|
|||
}
|
||||
if (pixw < 1) pixw = 1;
|
||||
if (pixh < 1) pixh = 1;
|
||||
icons.push_back(StickerIcon(_mySets[i].id, s, pixw, pixh));
|
||||
icons.push_back(StickerIcon(
|
||||
_mySets[i].id,
|
||||
thumbnail,
|
||||
s,
|
||||
pixw,
|
||||
pixh));
|
||||
}
|
||||
|
||||
if (!Auth().data().featuredStickerSetsUnreadCount()
|
||||
|
|
|
@ -135,6 +135,7 @@ private:
|
|||
MTPDstickerSet::Flags flags,
|
||||
const QString &title,
|
||||
const QString &shortName,
|
||||
ImagePtr thumbnail,
|
||||
bool externalLayout,
|
||||
int count,
|
||||
const Stickers::Pack &pack = Stickers::Pack());
|
||||
|
@ -146,6 +147,7 @@ private:
|
|||
MTPDstickerSet::Flags flags = MTPDstickerSet::Flags();
|
||||
QString title;
|
||||
QString shortName;
|
||||
ImagePtr thumbnail;
|
||||
Stickers::Pack pack;
|
||||
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||
bool externalLayout = false;
|
||||
|
|
Loading…
Reference in New Issue