mirror of https://github.com/procxx/kepka.git
Add sticker sets search.
This commit is contained in:
parent
e6dd7d7684
commit
b007fcb537
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 3.8 KiB |
|
@ -926,6 +926,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_stickers_remove_group_set" = "Remove group sticker set?";
|
"lng_stickers_remove_group_set" = "Remove group sticker set?";
|
||||||
"lng_stickers_group_from_your" = "Choose from your stickers";
|
"lng_stickers_group_from_your" = "Choose from your stickers";
|
||||||
"lng_stickers_group_from_featured" = "Choose from trending stickers";
|
"lng_stickers_group_from_featured" = "Choose from trending stickers";
|
||||||
|
"lng_stickers_search_sets" = "Search sticker sets";
|
||||||
|
"lng_stickers_nothing_found" = "No stickers found";
|
||||||
|
|
||||||
"lng_in_dlg_photo" = "Photo";
|
"lng_in_dlg_photo" = "Photo";
|
||||||
"lng_in_dlg_album" = "Album";
|
"lng_in_dlg_album" = "Album";
|
||||||
|
|
|
@ -957,7 +957,7 @@ dialogPeer#e56dbf05 peer:Peer = DialogPeer;
|
||||||
dialogPeerFeed#da429411 feed_id:int = DialogPeer;
|
dialogPeerFeed#da429411 feed_id:int = DialogPeer;
|
||||||
|
|
||||||
messages.foundStickerSetsNotModified#d54b65d = messages.FoundStickerSets;
|
messages.foundStickerSetsNotModified#d54b65d = messages.FoundStickerSets;
|
||||||
messages.foundStickerSets#b35bcea9 hash:int sets:Vector<StickerSet> = messages.FoundStickerSets;
|
messages.foundStickerSets#5108d648 hash:int sets:Vector<StickerSetCovered> = messages.FoundStickerSets;
|
||||||
|
|
||||||
feedPosition#5059dc73 date:int peer:Peer id:int = FeedPosition;
|
feedPosition#5059dc73 date:int peer:Peer id:int = FeedPosition;
|
||||||
|
|
||||||
|
|
|
@ -568,6 +568,7 @@ PeerListContent::PeerListContent(
|
||||||
|
|
||||||
void PeerListContent::appendRow(std::unique_ptr<PeerListRow> row) {
|
void PeerListContent::appendRow(std::unique_ptr<PeerListRow> row) {
|
||||||
Expects(row != nullptr);
|
Expects(row != nullptr);
|
||||||
|
|
||||||
if (_rowsById.find(row->id()) == _rowsById.cend()) {
|
if (_rowsById.find(row->id()) == _rowsById.cend()) {
|
||||||
row->setAbsoluteIndex(_rows.size());
|
row->setAbsoluteIndex(_rows.size());
|
||||||
addRowEntry(row.get());
|
addRowEntry(row.get());
|
||||||
|
@ -578,6 +579,7 @@ void PeerListContent::appendRow(std::unique_ptr<PeerListRow> row) {
|
||||||
void PeerListContent::appendSearchRow(std::unique_ptr<PeerListRow> row) {
|
void PeerListContent::appendSearchRow(std::unique_ptr<PeerListRow> row) {
|
||||||
Expects(row != nullptr);
|
Expects(row != nullptr);
|
||||||
Expects(showingSearch());
|
Expects(showingSearch());
|
||||||
|
|
||||||
if (_rowsById.find(row->id()) == _rowsById.cend()) {
|
if (_rowsById.find(row->id()) == _rowsById.cend()) {
|
||||||
row->setAbsoluteIndex(_searchRows.size());
|
row->setAbsoluteIndex(_searchRows.size());
|
||||||
row->setIsSearchResult(true);
|
row->setIsSearchResult(true);
|
||||||
|
@ -589,13 +591,17 @@ void PeerListContent::appendSearchRow(std::unique_ptr<PeerListRow> row) {
|
||||||
|
|
||||||
void PeerListContent::appendFoundRow(not_null<PeerListRow*> row) {
|
void PeerListContent::appendFoundRow(not_null<PeerListRow*> row) {
|
||||||
Expects(showingSearch());
|
Expects(showingSearch());
|
||||||
|
|
||||||
auto index = findRowIndex(row);
|
auto index = findRowIndex(row);
|
||||||
if (index.value < 0) {
|
if (index.value < 0) {
|
||||||
_filterResults.push_back(row);
|
_filterResults.push_back(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListContent::changeCheckState(not_null<PeerListRow*> row, bool checked, PeerListRow::SetStyle style) {
|
void PeerListContent::changeCheckState(
|
||||||
|
not_null<PeerListRow*> row,
|
||||||
|
bool checked,
|
||||||
|
PeerListRow::SetStyle style) {
|
||||||
row->setChecked(
|
row->setChecked(
|
||||||
checked,
|
checked,
|
||||||
style,
|
style,
|
||||||
|
|
|
@ -163,8 +163,7 @@ void StickersBox::getArchivedDone(uint64 offsetId, const MTPmessages_ArchivedSti
|
||||||
|
|
||||||
auto addedSet = false;
|
auto addedSet = false;
|
||||||
auto changedSets = false;
|
auto changedSets = false;
|
||||||
auto &v = stickers.vsets.v;
|
for_const (const auto &stickerSet, stickers.vsets.v) {
|
||||||
for_const (auto &stickerSet, v) {
|
|
||||||
const MTPDstickerSet *setData = nullptr;
|
const MTPDstickerSet *setData = nullptr;
|
||||||
switch (stickerSet.type()) {
|
switch (stickerSet.type()) {
|
||||||
case mtpc_stickerSetCovered: {
|
case mtpc_stickerSetCovered: {
|
||||||
|
@ -202,7 +201,8 @@ void StickersBox::getArchivedDone(uint64 offsetId, const MTPmessages_ArchivedSti
|
||||||
if (addedSet) {
|
if (addedSet) {
|
||||||
_archived.widget()->updateSize();
|
_archived.widget()->updateSize();
|
||||||
} else {
|
} else {
|
||||||
_allArchivedLoaded = v.isEmpty() || (!changedSets && offsetId != 0);
|
_allArchivedLoaded = stickers.vsets.v.isEmpty()
|
||||||
|
|| (!changedSets && offsetId != 0);
|
||||||
if (changedSets) {
|
if (changedSets) {
|
||||||
loadMoreArchived();
|
loadMoreArchived();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,17 +21,17 @@ stickersRestrictedLabel: FlatLabel(defaultFlatLabel) {
|
||||||
textFg: noContactsColor;
|
textFg: noContactsColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
stickersTrendingHeader: 45px;
|
stickersTrendingHeader: 56px;
|
||||||
stickersTrendingSkip: 15px;
|
stickersTrendingSkip: 4px;
|
||||||
|
|
||||||
stickersTrendingHeaderFont: semiboldFont;
|
stickersTrendingHeaderFont: semiboldFont;
|
||||||
stickersTrendingHeaderFg: windowFg;
|
stickersTrendingHeaderFg: windowFg;
|
||||||
stickersTrendingHeaderTop: 0px;
|
stickersTrendingHeaderTop: 11px;
|
||||||
stickersTrendingSubheaderFont: normalFont;
|
stickersTrendingSubheaderFont: normalFont;
|
||||||
stickersTrendingSubheaderFg: windowSubTextFg;
|
stickersTrendingSubheaderFg: windowSubTextFg;
|
||||||
stickersTrendingSubheaderTop: 20px;
|
stickersTrendingSubheaderTop: 31px;
|
||||||
|
|
||||||
stickersTrendingAddTop: 3px;
|
stickersTrendingAddTop: 14px;
|
||||||
stickersTrendingAdd: RoundButton(defaultActiveButton) {
|
stickersTrendingAdd: RoundButton(defaultActiveButton) {
|
||||||
width: -16px;
|
width: -16px;
|
||||||
height: 26px;
|
height: 26px;
|
||||||
|
@ -91,6 +91,7 @@ stickersRowDuration: 200;
|
||||||
stickersSettings: icon {{ "emoji_settings", emojiIconFg }};
|
stickersSettings: icon {{ "emoji_settings", emojiIconFg }};
|
||||||
stickersTrending: icon {{ "emoji_trending", emojiIconFg }};
|
stickersTrending: icon {{ "emoji_trending", emojiIconFg }};
|
||||||
stickersFaved: icon {{ "emoji_faved", emojiIconFg }};
|
stickersFaved: icon {{ "emoji_faved", emojiIconFg }};
|
||||||
|
stickersSearch: icon {{ "title_search", emojiIconFg, point(0px, 5px) }};
|
||||||
|
|
||||||
stickersSettingsUnreadSize: 17px;
|
stickersSettingsUnreadSize: 17px;
|
||||||
stickersSettingsUnreadPosition: point(4px, 5px);
|
stickersSettingsUnreadPosition: point(4px, 5px);
|
||||||
|
@ -209,6 +210,8 @@ stickerGroupCategoryAdd: stickersTrendingAdd;
|
||||||
stickersToastMaxWidth: 340px;
|
stickersToastMaxWidth: 340px;
|
||||||
stickersToastPadding: margins(16px, 13px, 16px, 12px);
|
stickersToastPadding: margins(16px, 13px, 16px, 12px);
|
||||||
|
|
||||||
|
stickersEmpty: icon {{ "stickers_empty", windowSubTextFg }};
|
||||||
|
|
||||||
inlineBotsScroll: ScrollArea(defaultSolidScroll) {
|
inlineBotsScroll: ScrollArea(defaultSolidScroll) {
|
||||||
deltat: stickerPanPadding;
|
deltat: stickerPanPadding;
|
||||||
deltab: stickerPanPadding;
|
deltab: stickerPanPadding;
|
||||||
|
|
|
@ -744,7 +744,11 @@ Set *FeedSet(const MTPDstickerSet &set) {
|
||||||
it->title = title;
|
it->title = title;
|
||||||
it->shortName = qs(set.vshort_name);
|
it->shortName = qs(set.vshort_name);
|
||||||
flags = it->flags;
|
flags = it->flags;
|
||||||
auto clientFlags = it->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special);
|
auto clientFlags = it->flags
|
||||||
|
& (MTPDstickerSet_ClientFlag::f_featured
|
||||||
|
| MTPDstickerSet_ClientFlag::f_unread
|
||||||
|
| MTPDstickerSet_ClientFlag::f_not_loaded
|
||||||
|
| MTPDstickerSet_ClientFlag::f_special);
|
||||||
it->flags = set.vflags.v | clientFlags;
|
it->flags = set.vflags.v | clientFlags;
|
||||||
it->installDate = set.has_installed_date()
|
it->installDate = set.has_installed_date()
|
||||||
? set.vinstalled_date.v
|
? set.vinstalled_date.v
|
||||||
|
|
|
@ -52,6 +52,7 @@ struct Set {
|
||||||
MTPDstickerSet::Flags flags;
|
MTPDstickerSet::Flags flags;
|
||||||
TimeId installDate = 0;
|
TimeId installDate = 0;
|
||||||
Pack stickers;
|
Pack stickers;
|
||||||
|
Pack covers;
|
||||||
ByEmojiMap emoji;
|
ByEmojiMap emoji;
|
||||||
};
|
};
|
||||||
using Sets = QMap<uint64, Set>;
|
using Sets = QMap<uint64, Set>;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "chat_helpers/tabbed_selector.h"
|
#include "chat_helpers/tabbed_selector.h"
|
||||||
#include "chat_helpers/stickers.h"
|
#include "chat_helpers/stickers.h"
|
||||||
#include "base/variant.h"
|
#include "base/variant.h"
|
||||||
|
#include "base/timer.h"
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
class Controller;
|
class Controller;
|
||||||
|
@ -31,7 +32,9 @@ class StickersListWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StickersListWidget(QWidget *parent, not_null<Window::Controller*> controller);
|
StickersListWidget(
|
||||||
|
QWidget *parent,
|
||||||
|
not_null<Window::Controller*> controller);
|
||||||
|
|
||||||
void refreshRecent() override;
|
void refreshRecent() override;
|
||||||
void preloadImages() override;
|
void preloadImages() override;
|
||||||
|
@ -41,6 +44,9 @@ public:
|
||||||
void showStickerSet(uint64 setId);
|
void showStickerSet(uint64 setId);
|
||||||
void showMegagroupSet(ChannelData *megagroup);
|
void showMegagroupSet(ChannelData *megagroup);
|
||||||
|
|
||||||
|
void afterShown() override;
|
||||||
|
void beforeHiding() override;
|
||||||
|
|
||||||
void refreshStickers();
|
void refreshStickers();
|
||||||
|
|
||||||
void fillIcons(QList<StickerIcon> &icons);
|
void fillIcons(QList<StickerIcon> &icons);
|
||||||
|
@ -52,6 +58,9 @@ public:
|
||||||
void notInstalledLocally(uint64 setId);
|
void notInstalledLocally(uint64 setId);
|
||||||
void clearInstalledLocally();
|
void clearInstalledLocally();
|
||||||
|
|
||||||
|
void sendSearchRequest();
|
||||||
|
void searchForSets(const QString &query);
|
||||||
|
|
||||||
~StickersListWidget();
|
~StickersListWidget();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -88,6 +97,7 @@ private:
|
||||||
enum class Section {
|
enum class Section {
|
||||||
Featured,
|
Featured,
|
||||||
Stickers,
|
Stickers,
|
||||||
|
Search,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OverSticker {
|
struct OverSticker {
|
||||||
|
@ -131,17 +141,18 @@ private:
|
||||||
uint64 id,
|
uint64 id,
|
||||||
MTPDstickerSet::Flags flags,
|
MTPDstickerSet::Flags flags,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
int hoversSize,
|
bool externalLayout,
|
||||||
const Stickers::Pack &pack = Stickers::Pack());
|
const Stickers::Pack &pack = Stickers::Pack());
|
||||||
Set(Set &&other);
|
Set(Set &&other);
|
||||||
Set &operator=(Set &&other);
|
Set &operator=(Set &&other);
|
||||||
~Set();
|
~Set();
|
||||||
|
|
||||||
uint64 id;
|
uint64 id = 0;
|
||||||
MTPDstickerSet::Flags flags;
|
MTPDstickerSet::Flags flags = MTPDstickerSet::Flags();
|
||||||
QString title;
|
QString title;
|
||||||
Stickers::Pack pack;
|
Stickers::Pack pack;
|
||||||
std::unique_ptr<Ui::RippleAnimation> ripple;
|
std::unique_ptr<Ui::RippleAnimation> ripple;
|
||||||
|
bool externalLayout = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Callback>
|
template <typename Callback>
|
||||||
|
@ -153,6 +164,11 @@ private:
|
||||||
void installSet(uint64 setId);
|
void installSet(uint64 setId);
|
||||||
void removeMegagroupSet(bool locally);
|
void removeMegagroupSet(bool locally);
|
||||||
void removeSet(uint64 setId);
|
void removeSet(uint64 setId);
|
||||||
|
void sendInstallRequest(
|
||||||
|
uint64 setId,
|
||||||
|
const MTPInputStickerSet &input);
|
||||||
|
void refreshSearchSets();
|
||||||
|
void refreshSearchIndex();
|
||||||
|
|
||||||
bool setHasTitle(const Set &set) const;
|
bool setHasTitle(const Set &set) const;
|
||||||
bool stickerHasDeleteButton(const Set &set, int index) const;
|
bool stickerHasDeleteButton(const Set &set, int index) const;
|
||||||
|
@ -178,12 +194,8 @@ private:
|
||||||
};
|
};
|
||||||
void validateSelectedIcon(ValidateIconAnimations animations);
|
void validateSelectedIcon(ValidateIconAnimations animations);
|
||||||
|
|
||||||
std::vector<Set> &shownSets() {
|
std::vector<Set> &shownSets();
|
||||||
return (_section == Section::Featured) ? _featuredSets : _mySets;
|
const std::vector<Set> &shownSets() const;
|
||||||
}
|
|
||||||
const std::vector<Set> &shownSets() const {
|
|
||||||
return (_section == Section::Featured) ? _featuredSets : _mySets;
|
|
||||||
}
|
|
||||||
int featuredRowHeight() const;
|
int featuredRowHeight() const;
|
||||||
void readVisibleSets();
|
void readVisibleSets();
|
||||||
|
|
||||||
|
@ -191,6 +203,7 @@ private:
|
||||||
void paintStickers(Painter &p, QRect clip);
|
void paintStickers(Painter &p, QRect clip);
|
||||||
void paintMegagroupEmptySet(Painter &p, int y, bool buttonSelected, TimeMs ms);
|
void paintMegagroupEmptySet(Painter &p, int y, bool buttonSelected, TimeMs ms);
|
||||||
void paintSticker(Painter &p, Set &set, int y, int index, bool selected, bool deleteSelected);
|
void paintSticker(Painter &p, Set &set, int y, int index, bool selected, bool deleteSelected);
|
||||||
|
void paintEmptySearchResults(Painter &p);
|
||||||
|
|
||||||
int stickersRight() const;
|
int stickersRight() const;
|
||||||
bool featuredHasAddButton(int index) const;
|
bool featuredHasAddButton(int index) const;
|
||||||
|
@ -209,6 +222,7 @@ private:
|
||||||
void appendSet(
|
void appendSet(
|
||||||
std::vector<Set> &to,
|
std::vector<Set> &to,
|
||||||
uint64 setId,
|
uint64 setId,
|
||||||
|
bool externalLayout,
|
||||||
AppendSkip skip = AppendSkip::None);
|
AppendSkip skip = AppendSkip::None);
|
||||||
|
|
||||||
void selectEmoji(EmojiPtr emoji);
|
void selectEmoji(EmojiPtr emoji);
|
||||||
|
@ -220,9 +234,19 @@ private:
|
||||||
void setColumnCount(int count);
|
void setColumnCount(int count);
|
||||||
void refreshFooterIcons();
|
void refreshFooterIcons();
|
||||||
|
|
||||||
|
void cancelSetsSearch();
|
||||||
|
void showSearchResults();
|
||||||
|
void searchResultsDone(const MTPmessages_FoundStickerSets &result);
|
||||||
|
void refreshSearchRows();
|
||||||
|
void refreshSearchRows(const std::vector<Stickers::Set*> *cloudSets);
|
||||||
|
void fillLocalSearchRows(const QString &query);
|
||||||
|
void fillCloudSearchRows(const std::vector<Stickers::Set*> &sets);
|
||||||
|
void addSearchRow(not_null<const Stickers::Set*> set);
|
||||||
|
|
||||||
ChannelData *_megagroupSet = nullptr;
|
ChannelData *_megagroupSet = nullptr;
|
||||||
std::vector<Set> _mySets;
|
std::vector<Set> _mySets;
|
||||||
std::vector<Set> _featuredSets;
|
std::vector<Set> _featuredSets;
|
||||||
|
std::vector<Set> _searchSets;
|
||||||
base::flat_set<uint64> _installedLocallySets;
|
base::flat_set<uint64> _installedLocallySets;
|
||||||
std::vector<bool> _custom;
|
std::vector<bool> _custom;
|
||||||
base::flat_set<not_null<DocumentData*>> _favedStickersMap;
|
base::flat_set<not_null<DocumentData*>> _favedStickersMap;
|
||||||
|
@ -255,6 +279,12 @@ private:
|
||||||
QTimer _previewTimer;
|
QTimer _previewTimer;
|
||||||
bool _previewShown = false;
|
bool _previewShown = false;
|
||||||
|
|
||||||
|
std::map<QString, std::vector<Stickers::Set*>> _searchCache;
|
||||||
|
std::vector<std::pair<uint64, QStringList>> _searchIndex;
|
||||||
|
base::Timer _searchRequestTimer;
|
||||||
|
QString _searchQuery, _searchNextQuery;
|
||||||
|
mtpRequestId _searchRequestId = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ChatHelpers
|
} // namespace ChatHelpers
|
||||||
|
|
Loading…
Reference in New Issue