mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Allow either category or set being selected.
This commit is contained in:
parent
a8decf154f
commit
cbd9dd0c2c
5 changed files with 54 additions and 10 deletions
|
@ -485,7 +485,10 @@ void EmojiListWidget::applyNextSearchQuery() {
|
||||||
if (!_searchMode && !searching) {
|
if (!_searchMode && !searching) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_searchMode = searching;
|
const auto modeChanged = (_searchMode != searching);
|
||||||
|
if (modeChanged) {
|
||||||
|
_searchMode = searching;
|
||||||
|
}
|
||||||
if (!searching) {
|
if (!searching) {
|
||||||
_searchResults.clear();
|
_searchResults.clear();
|
||||||
_searchCustomIds.clear();
|
_searchCustomIds.clear();
|
||||||
|
@ -493,6 +496,9 @@ void EmojiListWidget::applyNextSearchQuery() {
|
||||||
clearSelection();
|
clearSelection();
|
||||||
resizeToWidth(width());
|
resizeToWidth(width());
|
||||||
update();
|
update();
|
||||||
|
if (modeChanged) {
|
||||||
|
visibleTopBottomUpdated(getVisibleTop(), getVisibleBottom());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (_searchQuery.empty()) {
|
if (_searchQuery.empty()) {
|
||||||
finish(false);
|
finish(false);
|
||||||
|
@ -2190,10 +2196,13 @@ void EmojiListWidget::showSet(uint64 setId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 EmojiListWidget::sectionSetId(int section) const {
|
uint64 EmojiListWidget::sectionSetId(int section) const {
|
||||||
Expects(section < _staticCount
|
Expects(_searchMode
|
||||||
|
|| section < _staticCount
|
||||||
|| (section - _staticCount) < _custom.size());
|
|| (section - _staticCount) < _custom.size());
|
||||||
|
|
||||||
return (section < _staticCount)
|
return _searchMode
|
||||||
|
? SearchEmojiSectionSetId()
|
||||||
|
: (section < _staticCount)
|
||||||
? EmojiSectionSetId(static_cast<Section>(section))
|
? EmojiSectionSetId(static_cast<Section>(section))
|
||||||
: _custom[section - _staticCount].id;
|
: _custom[section - _staticCount].id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,6 +161,7 @@ object_ptr<TabbedSelector::InnerFooter> GifsListWidget::createFooter() {
|
||||||
.st = &st(),
|
.st = &st(),
|
||||||
});
|
});
|
||||||
_footer = result;
|
_footer = result;
|
||||||
|
_chosenSetId = Data::Stickers::RecentSetId;
|
||||||
|
|
||||||
GifSectionsValue(
|
GifSectionsValue(
|
||||||
&session()
|
&session()
|
||||||
|
@ -171,6 +172,9 @@ object_ptr<TabbedSelector::InnerFooter> GifsListWidget::createFooter() {
|
||||||
|
|
||||||
_footer->setChosen(
|
_footer->setChosen(
|
||||||
) | rpl::start_with_next([=](uint64 setId) {
|
) | rpl::start_with_next([=](uint64 setId) {
|
||||||
|
if (_search) {
|
||||||
|
_search->cancel();
|
||||||
|
}
|
||||||
_chosenSetId = setId;
|
_chosenSetId = setId;
|
||||||
refreshIcons();
|
refreshIcons();
|
||||||
const auto i = ranges::find(_sections, setId, [](GifSection value) {
|
const auto i = ranges::find(_sections, setId, [](GifSection value) {
|
||||||
|
@ -791,13 +795,16 @@ bool GifsListWidget::refreshInlineRows(int32 *added) {
|
||||||
void GifsListWidget::setupSearch() {
|
void GifsListWidget::setupSearch() {
|
||||||
const auto session = &_controller->session();
|
const auto session = &_controller->session();
|
||||||
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
|
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
|
||||||
_chosenSetId = Data::Stickers::RecentSetId;
|
const auto accumulated = ranges::accumulate(query, QString(), [](
|
||||||
refreshIcons();
|
|
||||||
searchForGifs(ranges::accumulate(query, QString(), [](
|
|
||||||
QString a,
|
QString a,
|
||||||
QString b) {
|
QString b) {
|
||||||
return a.isEmpty() ? b : (a + ' ' + b);
|
return a.isEmpty() ? b : (a + ' ' + b);
|
||||||
}));
|
});
|
||||||
|
_chosenSetId = accumulated.isEmpty()
|
||||||
|
? Data::Stickers::RecentSetId
|
||||||
|
: SearchEmojiSectionSetId();
|
||||||
|
refreshIcons();
|
||||||
|
searchForGifs(accumulated);
|
||||||
}, session);
|
}, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -417,6 +417,16 @@ void StickersListFooter::enumerateSubicons(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto StickersListFooter::iconInfo(int index) const -> IconInfo {
|
auto StickersListFooter::iconInfo(int index) const -> IconInfo {
|
||||||
|
if (index < 0) {
|
||||||
|
const auto iconsX = int(base::SafeRound(_iconState.x.current()));
|
||||||
|
return {
|
||||||
|
.index = -1,
|
||||||
|
.left = -_singleWidth - _iconsLeft,
|
||||||
|
.adjustedLeft = -_singleWidth - _iconsLeft - iconsX,
|
||||||
|
.width = _singleWidth,
|
||||||
|
.visible = false,
|
||||||
|
};
|
||||||
|
}
|
||||||
auto result = IconInfo();
|
auto result = IconInfo();
|
||||||
enumerateIcons([&](const IconInfo &info) {
|
enumerateIcons([&](const IconInfo &info) {
|
||||||
if (info.index == index) {
|
if (info.index == index) {
|
||||||
|
@ -473,7 +483,8 @@ void StickersListFooter::validateSelectedIcon(
|
||||||
&& setId == Data::Stickers::RecentSetId)) {
|
&& setId == Data::Stickers::RecentSetId)) {
|
||||||
newSelected = i;
|
newSelected = i;
|
||||||
break;
|
break;
|
||||||
} else if (_icons[i].setId == Data::Stickers::FavedSetId) {
|
} else if (_icons[i].setId == Data::Stickers::FavedSetId
|
||||||
|
&& setId != SearchEmojiSectionSetId()) {
|
||||||
favedIconIndex = i;
|
favedIconIndex = i;
|
||||||
} else if (isEmojiSection && _icons[i].setId == allEmojiSetId) {
|
} else if (isEmojiSection && _icons[i].setId == allEmojiSetId) {
|
||||||
newSelected = i;
|
newSelected = i;
|
||||||
|
@ -483,7 +494,9 @@ void StickersListFooter::validateSelectedIcon(
|
||||||
setSelectedIcon(
|
setSelectedIcon(
|
||||||
(newSelected >= 0
|
(newSelected >= 0
|
||||||
? newSelected
|
? newSelected
|
||||||
: (favedIconIndex >= 0) ? favedIconIndex : 0),
|
: (favedIconIndex >= 0)
|
||||||
|
? favedIconIndex
|
||||||
|
: -1),
|
||||||
animations);
|
animations);
|
||||||
setSelectedSubicon(
|
setSelectedSubicon(
|
||||||
(newSubSelected >= 0 ? newSubSelected : 0),
|
(newSubSelected >= 0 ? newSubSelected : 0),
|
||||||
|
@ -522,6 +535,9 @@ void StickersListFooter::setSelectedIcon(
|
||||||
if (_iconState.selected == newSelected) {
|
if (_iconState.selected == newSelected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if ((_iconState.selected < 0) != (newSelected < 0)) {
|
||||||
|
animations = ValidateIconAnimations::None;
|
||||||
|
}
|
||||||
_iconState.selected = newSelected;
|
_iconState.selected = newSelected;
|
||||||
updateEmojiSectionWidth();
|
updateEmojiSectionWidth();
|
||||||
const auto info = iconInfo(_iconState.selected);
|
const auto info = iconInfo(_iconState.selected);
|
||||||
|
@ -1113,7 +1129,7 @@ void StickersListFooter::refreshIconsGeometry(
|
||||||
(st().footer - st().iconArea) / 2);
|
(st().footer - st().iconArea) / 2);
|
||||||
refreshScrollableDimensions();
|
refreshScrollableDimensions();
|
||||||
refreshSubiconsGeometry();
|
refreshSubiconsGeometry();
|
||||||
_iconState.selected = _subiconState.selected = -1;
|
_iconState.selected = _subiconState.selected = -2;
|
||||||
validateSelectedIcon(activeSetId, animations);
|
validateSelectedIcon(activeSetId, animations);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2463,7 +2463,18 @@ auto StickersListWidget::getLottieRenderer()
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListWidget::showStickerSet(uint64 setId) {
|
void StickersListWidget::showStickerSet(uint64 setId) {
|
||||||
|
if (_showingSetById) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_showingSetById = true;
|
||||||
|
const auto guard = gsl::finally([&] { _showingSetById = false; });
|
||||||
|
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
if (_search
|
||||||
|
&& (!_searchQuery.isEmpty() || !_searchNextQuery.isEmpty())) {
|
||||||
|
_search->cancel();
|
||||||
|
cancelSetsSearch();
|
||||||
|
}
|
||||||
|
|
||||||
if (setId == Data::Stickers::FeaturedSetId) {
|
if (setId == Data::Stickers::FeaturedSetId) {
|
||||||
if (_section != Section::Featured) {
|
if (_section != Section::Featured) {
|
||||||
|
|
|
@ -355,6 +355,7 @@ private:
|
||||||
base::flat_set<not_null<DocumentData*>> _favedStickersMap;
|
base::flat_set<not_null<DocumentData*>> _favedStickersMap;
|
||||||
std::weak_ptr<Lottie::FrameRenderer> _lottieRenderer;
|
std::weak_ptr<Lottie::FrameRenderer> _lottieRenderer;
|
||||||
|
|
||||||
|
bool _showingSetById = false;
|
||||||
crl::time _lastScrolledAt = 0;
|
crl::time _lastScrolledAt = 0;
|
||||||
crl::time _lastFullUpdatedAt = 0;
|
crl::time _lastFullUpdatedAt = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue