mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Use TabbedSearch control for stickers panel.
This commit is contained in:
parent
d4897c8a95
commit
65b1a0c9a4
12 changed files with 104 additions and 250 deletions
|
@ -2001,7 +2001,6 @@ 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_stickers_nothing_found" = "No stickers found";
|
||||||
"lng_stickers_remove_pack_confirm" = "Remove";
|
"lng_stickers_remove_pack_confirm" = "Remove";
|
||||||
"lng_stickers_archive_pack" = "Archive Stickers";
|
"lng_stickers_archive_pack" = "Archive Stickers";
|
||||||
|
|
|
@ -321,11 +321,6 @@ stickerPanRemoveSet: IconButton(hashtagClose) {
|
||||||
iconPosition: point(-1px, -1px);
|
iconPosition: point(-1px, -1px);
|
||||||
rippleAreaPosition: point(0px, 0px);
|
rippleAreaPosition: point(0px, 0px);
|
||||||
}
|
}
|
||||||
stickerIconWidth: 42px;
|
|
||||||
stickerIconPadding: 5px;
|
|
||||||
stickerIconOpacity: 0.7;
|
|
||||||
stickerIconSel: 2px;
|
|
||||||
stickerIconSelColor: emojiIconFgActive;
|
|
||||||
stickerIconMove: 400;
|
stickerIconMove: 400;
|
||||||
stickerPreviewDuration: 150;
|
stickerPreviewDuration: 150;
|
||||||
stickerPreviewMin: 0.1;
|
stickerPreviewMin: 0.1;
|
||||||
|
@ -349,10 +344,6 @@ inlineBotsScroll: ScrollArea(defaultSolidScroll) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gifsPadding: margins(9px, 5px, 3px, 9px);
|
gifsPadding: margins(9px, 5px, 3px, 9px);
|
||||||
gifsSearchField: defaultMultiSelectSearchField;
|
|
||||||
gifsSearchFieldPosition: point(42px, 7px);
|
|
||||||
gifsSearchCancel: defaultMultiSelectSearchCancel;
|
|
||||||
gifsSearchCancelPosition: point(1px, 1px);
|
|
||||||
|
|
||||||
emojiSuggestionsDropdown: InnerDropdown(defaultInnerDropdown) {
|
emojiSuggestionsDropdown: InnerDropdown(defaultInnerDropdown) {
|
||||||
scrollMargin: margins(0px, emojiColorsPadding, 0px, emojiColorsPadding);
|
scrollMargin: margins(0px, emojiColorsPadding, 0px, emojiColorsPadding);
|
||||||
|
|
|
@ -24,7 +24,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "boxes/sticker_set_box.h"
|
#include "boxes/sticker_set_box.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "layout/layout_position.h"
|
#include "layout/layout_position.h"
|
||||||
#include "data/data_emoji_statuses.h"
|
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_peer_values.h"
|
#include "data/data_peer_values.h"
|
||||||
|
@ -414,9 +413,6 @@ EmojiListWidget::EmojiListWidget(
|
||||||
_customSingleSize = Data::FrameSizeFromTag(
|
_customSingleSize = Data::FrameSizeFromTag(
|
||||||
Data::CustomEmojiManager::SizeTag::Large
|
Data::CustomEmojiManager::SizeTag::Large
|
||||||
) / style::DevicePixelRatio();
|
) / style::DevicePixelRatio();
|
||||||
_customSetIconSize = Data::FrameSizeFromTag(
|
|
||||||
Data::CustomEmojiManager::SizeTag::SetIcon
|
|
||||||
) / style::DevicePixelRatio();
|
|
||||||
|
|
||||||
_picker->hide();
|
_picker->hide();
|
||||||
|
|
||||||
|
@ -470,23 +466,13 @@ EmojiListWidget::~EmojiListWidget() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiListWidget::setupSearch() {
|
void EmojiListWidget::setupSearch() {
|
||||||
using Descriptor = Ui::SearchDescriptor;
|
const auto session = &_controller->session();
|
||||||
_search = std::make_unique<Ui::TabbedSearch>(this, st(), Descriptor{
|
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
|
||||||
.st = st().search,
|
|
||||||
.groups = (_mode == Mode::EmojiStatus
|
|
||||||
? session().data().emojiStatuses().statusGroupsValue()
|
|
||||||
: session().data().emojiStatuses().emojiGroupsValue()),
|
|
||||||
.customEmojiFactory = session().data().customEmojiManager().factory(
|
|
||||||
Data::CustomEmojiManager::SizeTag::SetIcon,
|
|
||||||
Ui::SearchWithGroups::IconSizeOverride())
|
|
||||||
});
|
|
||||||
_search->queryValue(
|
|
||||||
) | rpl::start_with_next([=](std::vector<QString> &&query) {
|
|
||||||
_nextSearchQuery = std::move(query);
|
_nextSearchQuery = std::move(query);
|
||||||
InvokeQueued(this, [=] {
|
InvokeQueued(this, [=] {
|
||||||
applyNextSearchQuery();
|
applyNextSearchQuery();
|
||||||
});
|
});
|
||||||
}, lifetime());
|
}, session, (_mode == Mode::EmojiStatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmojiListWidget::applyNextSearchQuery() {
|
void EmojiListWidget::applyNextSearchQuery() {
|
||||||
|
@ -1940,7 +1926,7 @@ std::vector<StickerIcon> EmojiListWidget::fillIcons() {
|
||||||
} else {
|
} else {
|
||||||
result.emplace_back(AllEmojiSectionSetId());
|
result.emplace_back(AllEmojiSectionSetId());
|
||||||
}
|
}
|
||||||
const auto esize = _customSetIconSize;
|
const auto esize = StickersListFooter::IconFrameSize();
|
||||||
for (const auto &custom : _custom) {
|
for (const auto &custom : _custom) {
|
||||||
const auto set = custom.set;
|
const auto set = custom.set;
|
||||||
result.emplace_back(set, custom.thumbnailDocument, esize, esize);
|
result.emplace_back(set, custom.thumbnailDocument, esize, esize);
|
||||||
|
|
|
@ -359,7 +359,6 @@ private:
|
||||||
DocumentId,
|
DocumentId,
|
||||||
std::unique_ptr<Ui::Text::CustomEmoji>> _customRecent;
|
std::unique_ptr<Ui::Text::CustomEmoji>> _customRecent;
|
||||||
int _customSingleSize = 0;
|
int _customSingleSize = 0;
|
||||||
int _customSetIconSize = 0;
|
|
||||||
bool _allowWithoutPremium = false;
|
bool _allowWithoutPremium = false;
|
||||||
Ui::RoundRect _overBg;
|
Ui::RoundRect _overBg;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "chat_helpers/stickers_list_footer.h"
|
#include "chat_helpers/stickers_list_footer.h"
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "data/data_emoji_statuses.h"
|
|
||||||
#include "data/stickers/data_custom_emoji.h"
|
#include "data/stickers/data_custom_emoji.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
|
@ -199,26 +198,16 @@ std::vector<StickerIcon> GifsListWidget::fillIcons() {
|
||||||
auto result = std::vector<StickerIcon>();
|
auto result = std::vector<StickerIcon>();
|
||||||
result.reserve(_sections.size() + 1);
|
result.reserve(_sections.size() + 1);
|
||||||
result.emplace_back(Data::Stickers::RecentSetId);
|
result.emplace_back(Data::Stickers::RecentSetId);
|
||||||
|
const auto side = StickersListFooter::IconFrameSize();
|
||||||
for (const auto §ion : _sections) {
|
for (const auto §ion : _sections) {
|
||||||
const auto s = section.document;
|
const auto s = section.document;
|
||||||
const auto id = s->id;
|
const auto id = s->id;
|
||||||
const auto availw = st::stickerIconWidth - 2 * st::stickerIconPadding;
|
|
||||||
const auto availh = st().footer - 2 * st::stickerIconPadding;
|
|
||||||
const auto size = s->hasThumbnail()
|
const auto size = s->hasThumbnail()
|
||||||
? QSize(
|
? QSize(
|
||||||
s->thumbnailLocation().width(),
|
s->thumbnailLocation().width(),
|
||||||
s->thumbnailLocation().height())
|
s->thumbnailLocation().height())
|
||||||
: QSize();
|
: QSize();
|
||||||
auto thumbw = size.width(), thumbh = size.height(), pixw = 1, pixh = 1;
|
const auto pix = size.scaled(side, side, Qt::KeepAspectRatio);
|
||||||
if (availw * thumbh > availh * thumbw) {
|
|
||||||
pixh = availh;
|
|
||||||
pixw = (pixh * thumbw) / thumbh;
|
|
||||||
} else {
|
|
||||||
pixw = availw;
|
|
||||||
pixh = thumbw ? ((pixw * thumbh) / thumbw) : 1;
|
|
||||||
}
|
|
||||||
if (pixw < 1) pixw = 1;
|
|
||||||
if (pixh < 1) pixh = 1;
|
|
||||||
const auto owner = &s->owner();
|
const auto owner = &s->owner();
|
||||||
const auto already = _fakeSets.find(id);
|
const auto already = _fakeSets.find(id);
|
||||||
const auto set = (already != end(_fakeSets))
|
const auto set = (already != end(_fakeSets))
|
||||||
|
@ -235,7 +224,7 @@ std::vector<StickerIcon> GifsListWidget::fillIcons() {
|
||||||
0,
|
0,
|
||||||
Data::StickersSetFlag::Special,
|
Data::StickersSetFlag::Special,
|
||||||
0)).first;
|
0)).first;
|
||||||
result.emplace_back(set->second.get(), s, pixw, pixh);
|
result.emplace_back(set->second.get(), s, pix.width(), pix.height());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -802,17 +791,8 @@ bool GifsListWidget::refreshInlineRows(int32 *added) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GifsListWidget::setupSearch() {
|
void GifsListWidget::setupSearch() {
|
||||||
const auto owner = &_controller->session().data();
|
const auto session = &_controller->session();
|
||||||
using Descriptor = Ui::SearchDescriptor;
|
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
|
||||||
_search = std::make_unique<Ui::TabbedSearch>(this, st(), Descriptor{
|
|
||||||
.st = st().search,
|
|
||||||
.groups = owner->emojiStatuses().emojiGroupsValue(),
|
|
||||||
.customEmojiFactory = owner->customEmojiManager().factory(
|
|
||||||
Data::CustomEmojiManager::SizeTag::SetIcon,
|
|
||||||
Ui::SearchWithGroups::IconSizeOverride())
|
|
||||||
});
|
|
||||||
_search->queryValue(
|
|
||||||
) | rpl::start_with_next([=](std::vector<QString> &&query) {
|
|
||||||
_chosenSetId = Data::Stickers::RecentSetId;
|
_chosenSetId = Data::Stickers::RecentSetId;
|
||||||
refreshIcons();
|
refreshIcons();
|
||||||
searchForGifs(ranges::accumulate(query, QString(), [](
|
searchForGifs(ranges::accumulate(query, QString(), [](
|
||||||
|
@ -820,7 +800,7 @@ void GifsListWidget::setupSearch() {
|
||||||
QString b) {
|
QString b) {
|
||||||
return a.isEmpty() ? b : (a + ' ' + b);
|
return a.isEmpty() ? b : (a + ' ' + b);
|
||||||
}));
|
}));
|
||||||
}, lifetime());
|
}, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 GifsListWidget::showInlineRows(bool newResults) {
|
int32 GifsListWidget::showInlineRows(bool newResults) {
|
||||||
|
|
|
@ -156,8 +156,8 @@ StickerIcon::StickerIcon(
|
||||||
: setId(set->id)
|
: setId(set->id)
|
||||||
, set(set)
|
, set(set)
|
||||||
, sticker(sticker)
|
, sticker(sticker)
|
||||||
, pixw(pixw)
|
, pixw(std::max(pixw, 1))
|
||||||
, pixh(pixh) {
|
, pixh(std::max(pixh, 1)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
StickerIcon::StickerIcon(StickerIcon&&) = default;
|
StickerIcon::StickerIcon(StickerIcon&&) = default;
|
||||||
|
@ -255,14 +255,12 @@ StickersListFooter::StickersListFooter(Descriptor &&descriptor)
|
||||||
, _iconState([=] { update(); })
|
, _iconState([=] { update(); })
|
||||||
, _subiconState([=] { update(); })
|
, _subiconState([=] { update(); })
|
||||||
, _selectionBg(st::emojiPanRadius, st::windowBgRipple)
|
, _selectionBg(st::emojiPanRadius, st::windowBgRipple)
|
||||||
, _subselectionBg(st().iconArea / 2, st::windowBgRipple)
|
, _subselectionBg(st().iconArea / 2, st::windowBgRipple) {
|
||||||
, _barSelection(descriptor.barSelection) {
|
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
|
|
||||||
_iconsLeft = st().iconSkip;
|
_iconsLeft = st().iconSkip
|
||||||
_iconsRight = st().iconSkip + (_settingsButtonVisible
|
+ (_settingsButtonVisible ? st().iconWidth : 0);
|
||||||
? st::stickerIconWidth
|
_iconsRight = st().iconSkip;
|
||||||
: 0);
|
|
||||||
|
|
||||||
_session->downloaderTaskFinished(
|
_session->downloaderTaskFinished(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
@ -305,72 +303,10 @@ void StickersListFooter::paintExpanding(
|
||||||
p.setClipping(false);
|
p.setClipping(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListFooter::initSearch() {
|
int StickersListFooter::IconFrameSize() {
|
||||||
_searchField.create(
|
return Data::FrameSizeFromTag(
|
||||||
this,
|
Data::CustomEmojiManager::SizeTag::SetIcon
|
||||||
st::gifsSearchField,
|
) / style::DevicePixelRatio();
|
||||||
tr::lng_stickers_search_sets());
|
|
||||||
_searchCancel.create(this, st::gifsSearchCancel);
|
|
||||||
_searchField->show();
|
|
||||||
_searchCancel->show(anim::type::instant);
|
|
||||||
|
|
||||||
const auto cancelSearch = [=] {
|
|
||||||
if (_searchField->getLastText().isEmpty()) {
|
|
||||||
toggleSearch(false);
|
|
||||||
} else {
|
|
||||||
_searchField->setText(QString());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
connect(_searchField, &Ui::InputField::submitted, [=] {
|
|
||||||
_searchRequests.fire({
|
|
||||||
.text = _searchField->getLastText(),
|
|
||||||
.forced = true,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
connect(_searchField, &Ui::InputField::cancelled, cancelSearch);
|
|
||||||
connect(_searchField, &Ui::InputField::changed, [=] {
|
|
||||||
_searchRequests.fire({
|
|
||||||
.text = _searchField->getLastText(),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
_searchCancel->setClickedCallback(cancelSearch);
|
|
||||||
|
|
||||||
resizeSearchControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
void StickersListFooter::toggleSearch(bool visible) {
|
|
||||||
if (_searchShown == visible) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_searchShown = visible;
|
|
||||||
if (_searchShown) {
|
|
||||||
initSearch();
|
|
||||||
stealFocus();
|
|
||||||
} else if (_searchField) {
|
|
||||||
returnFocus();
|
|
||||||
_searchField.destroy();
|
|
||||||
_searchCancel.destroy();
|
|
||||||
_focusTakenFrom = nullptr;
|
|
||||||
}
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void StickersListFooter::stealFocus() {
|
|
||||||
if (_searchField) {
|
|
||||||
if (!_focusTakenFrom) {
|
|
||||||
_focusTakenFrom = QApplication::focusWidget();
|
|
||||||
}
|
|
||||||
_searchField->setFocus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StickersListFooter::returnFocus() {
|
|
||||||
if (_searchField && _focusTakenFrom) {
|
|
||||||
if (_searchField->hasFocus()) {
|
|
||||||
_focusTakenFrom->setFocus();
|
|
||||||
}
|
|
||||||
_focusTakenFrom = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListFooter::enumerateVisibleIcons(
|
void StickersListFooter::enumerateVisibleIcons(
|
||||||
|
@ -611,12 +547,6 @@ void StickersListFooter::leaveToChildEvent(QEvent *e, QWidget *child) {
|
||||||
updateSelected();
|
updateSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListFooter::setLoading(bool loading) {
|
|
||||||
if (_searchCancel) {
|
|
||||||
_searchCancel->setLoadingAnimation(loading);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void StickersListFooter::paintEvent(QPaintEvent *e) {
|
void StickersListFooter::paintEvent(QPaintEvent *e) {
|
||||||
auto p = Painter(this);
|
auto p = Painter(this);
|
||||||
|
|
||||||
|
@ -627,7 +557,7 @@ void StickersListFooter::paintEvent(QPaintEvent *e) {
|
||||||
void StickersListFooter::paint(
|
void StickersListFooter::paint(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const ExpandingContext &context) const {
|
const ExpandingContext &context) const {
|
||||||
if (_icons.empty() || _searchShown) {
|
if (_icons.empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,10 +584,7 @@ void StickersListFooter::paint(
|
||||||
} else {
|
} else {
|
||||||
p.setClipRect(clip);
|
p.setClipRect(clip);
|
||||||
}
|
}
|
||||||
|
paintSelectionBg(p, context);
|
||||||
if (!_barSelection) {
|
|
||||||
paintSelectionBg(p, context);
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto iconCacheSize = QSize(_singleWidth, st().footer);
|
const auto iconCacheSize = QSize(_singleWidth, st().footer);
|
||||||
const auto full = iconCacheSize * style::DevicePixelRatio();
|
const auto full = iconCacheSize * style::DevicePixelRatio();
|
||||||
|
@ -672,10 +599,6 @@ void StickersListFooter::paint(
|
||||||
enumerateVisibleIcons([&](const IconInfo &info) {
|
enumerateVisibleIcons([&](const IconInfo &info) {
|
||||||
paintSetIcon(p, context, info, now, paused);
|
paintSetIcon(p, context, info, now, paused);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (_barSelection) {
|
|
||||||
paintSelectionBar(p);
|
|
||||||
}
|
|
||||||
paintLeftRightFading(p, context);
|
paintLeftRightFading(p, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,21 +643,6 @@ void StickersListFooter::paintSelectionBg(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListFooter::paintSelectionBar(QPainter &p) const {
|
|
||||||
auto selxrel = _iconsLeft + qRound(_iconState.selectionX.current());
|
|
||||||
auto selx = selxrel - qRound(_iconState.x.current());
|
|
||||||
const auto selw = qRound(_iconState.selectionWidth.current());
|
|
||||||
if (rtl()) {
|
|
||||||
selx = width() - selx - selw;
|
|
||||||
}
|
|
||||||
p.fillRect(
|
|
||||||
selx,
|
|
||||||
_iconsTop + st().footer - st::stickerIconPadding,
|
|
||||||
selw,
|
|
||||||
st::stickerIconSel,
|
|
||||||
st::stickerIconSelColor);
|
|
||||||
}
|
|
||||||
|
|
||||||
void StickersListFooter::paintLeftRightFading(
|
void StickersListFooter::paintLeftRightFading(
|
||||||
QPainter &p,
|
QPainter &p,
|
||||||
const ExpandingContext &context) const {
|
const ExpandingContext &context) const {
|
||||||
|
@ -844,25 +752,9 @@ void StickersListFooter::validateFadeMask() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListFooter::resizeEvent(QResizeEvent *e) {
|
void StickersListFooter::resizeEvent(QResizeEvent *e) {
|
||||||
if (_searchField) {
|
|
||||||
resizeSearchControls();
|
|
||||||
}
|
|
||||||
refreshIconsGeometry(_activeByScrollId, ValidateIconAnimations::None);
|
refreshIconsGeometry(_activeByScrollId, ValidateIconAnimations::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListFooter::resizeSearchControls() {
|
|
||||||
Expects(_searchField != nullptr);
|
|
||||||
Expects(_searchCancel != nullptr);
|
|
||||||
|
|
||||||
const auto fieldWidth = width()
|
|
||||||
- st::gifsSearchFieldPosition.x()
|
|
||||||
- st::gifsSearchCancelPosition.x()
|
|
||||||
- st::gifsSearchCancel.width;
|
|
||||||
_searchField->resizeToWidth(fieldWidth);
|
|
||||||
_searchField->moveToLeft(st::gifsSearchFieldPosition.x(), st::gifsSearchFieldPosition.y());
|
|
||||||
_searchCancel->moveToRight(st::gifsSearchCancelPosition.x(), st::gifsSearchCancelPosition.y());
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<uint64> StickersListFooter::setChosen() const {
|
rpl::producer<uint64> StickersListFooter::setChosen() const {
|
||||||
return _setChosen.events();
|
return _setChosen.events();
|
||||||
}
|
}
|
||||||
|
@ -871,10 +763,6 @@ rpl::producer<> StickersListFooter::openSettingsRequests() const {
|
||||||
return _openSettingsRequests.events();
|
return _openSettingsRequests.events();
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<StickersListFooter::SearchRequest> StickersListFooter::searchRequests() const {
|
|
||||||
return _searchRequests.events();
|
|
||||||
}
|
|
||||||
|
|
||||||
void StickersListFooter::mousePressEvent(QMouseEvent *e) {
|
void StickersListFooter::mousePressEvent(QMouseEvent *e) {
|
||||||
if (e->button() != Qt::LeftButton) {
|
if (e->button() != Qt::LeftButton) {
|
||||||
return;
|
return;
|
||||||
|
@ -1065,8 +953,7 @@ void StickersListFooter::updateSelected() {
|
||||||
auto p = mapFromGlobal(_iconsMousePos);
|
auto p = mapFromGlobal(_iconsMousePos);
|
||||||
auto x = p.x(), y = p.y();
|
auto x = p.x(), y = p.y();
|
||||||
if (rtl()) x = width() - x;
|
if (rtl()) x = width() - x;
|
||||||
const auto settingsLeft = width() - _iconsRight;
|
const auto settingsLeft = _iconsLeft - _singleWidth;
|
||||||
const auto searchLeft = _iconsLeft - _singleWidth;
|
|
||||||
auto newOver = OverState(SpecialOver::None);
|
auto newOver = OverState(SpecialOver::None);
|
||||||
if (_settingsButtonVisible
|
if (_settingsButtonVisible
|
||||||
&& x >= settingsLeft
|
&& x >= settingsLeft
|
||||||
|
@ -1174,9 +1061,7 @@ void StickersListFooter::refreshIconsGeometry(
|
||||||
_iconState.selectionWidth.finish();
|
_iconState.selectionWidth.finish();
|
||||||
_iconState.animationStart = 0;
|
_iconState.animationStart = 0;
|
||||||
_iconState.animation.stop();
|
_iconState.animation.stop();
|
||||||
if (_barSelection) {
|
if (_icons.size() > 1
|
||||||
_singleWidth = st::stickerIconWidth;
|
|
||||||
} else if (_icons.size() > 1
|
|
||||||
&& _icons[1].setId == EmojiSectionSetId(EmojiSection::People)) {
|
&& _icons[1].setId == EmojiSectionSetId(EmojiSection::People)) {
|
||||||
_singleWidth = (width() - _iconsLeft - _iconsRight) / _icons.size();
|
_singleWidth = (width() - _iconsLeft - _iconsRight) / _icons.size();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1193,9 +1078,6 @@ void StickersListFooter::refreshIconsGeometry(
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListFooter::refreshSubiconsGeometry() {
|
void StickersListFooter::refreshSubiconsGeometry() {
|
||||||
if (_barSelection) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
using Section = Ui::Emoji::Section;
|
using Section = Ui::Emoji::Section;
|
||||||
_subiconState.x.finish();
|
_subiconState.x.finish();
|
||||||
_subiconState.animationStart = 0;
|
_subiconState.animationStart = 0;
|
||||||
|
@ -1228,7 +1110,7 @@ bool StickersListFooter::hasOnlyFeaturedSets() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListFooter::paintStickerSettingsIcon(QPainter &p) const {
|
void StickersListFooter::paintStickerSettingsIcon(QPainter &p) const {
|
||||||
const auto settingsLeft = width() - _iconsRight;
|
const auto settingsLeft = _iconsLeft - _singleWidth;
|
||||||
st::stickersSettings.paint(
|
st::stickersSettings.paint(
|
||||||
p,
|
p,
|
||||||
settingsLeft
|
settingsLeft
|
||||||
|
|
|
@ -113,7 +113,6 @@ public:
|
||||||
Fn<bool()> paused;
|
Fn<bool()> paused;
|
||||||
not_null<RpWidget*> parent;
|
not_null<RpWidget*> parent;
|
||||||
bool settingsButtonVisible = false;
|
bool settingsButtonVisible = false;
|
||||||
bool barSelection = false;
|
|
||||||
const style::EmojiPan *st = nullptr;
|
const style::EmojiPan *st = nullptr;
|
||||||
};
|
};
|
||||||
explicit StickersListFooter(Descriptor &&descriptor);
|
explicit StickersListFooter(Descriptor &&descriptor);
|
||||||
|
@ -131,27 +130,19 @@ public:
|
||||||
|
|
||||||
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
void leaveToChildEvent(QEvent *e, QWidget *child) override;
|
||||||
|
|
||||||
void stealFocus();
|
|
||||||
void returnFocus();
|
|
||||||
void setLoading(bool loading);
|
|
||||||
|
|
||||||
void clearHeavyData();
|
void clearHeavyData();
|
||||||
|
|
||||||
[[nodiscard]] rpl::producer<uint64> setChosen() const;
|
[[nodiscard]] rpl::producer<uint64> setChosen() const;
|
||||||
[[nodiscard]] rpl::producer<> openSettingsRequests() const;
|
[[nodiscard]] rpl::producer<> openSettingsRequests() const;
|
||||||
|
|
||||||
struct SearchRequest {
|
|
||||||
QString text;
|
|
||||||
bool forced = false;
|
|
||||||
};
|
|
||||||
[[nodiscard]] rpl::producer<SearchRequest> searchRequests() const;
|
|
||||||
|
|
||||||
void paintExpanding(
|
void paintExpanding(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
QRect clip,
|
QRect clip,
|
||||||
float64 radius,
|
float64 radius,
|
||||||
RectPart origin);
|
RectPart origin);
|
||||||
|
|
||||||
|
[[nodiscard]] static int IconFrameSize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
void resizeEvent(QResizeEvent *e) override;
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
|
@ -258,7 +249,6 @@ private:
|
||||||
void paintSelectionBg(
|
void paintSelectionBg(
|
||||||
QPainter &p,
|
QPainter &p,
|
||||||
const ExpandingContext &context) const;
|
const ExpandingContext &context) const;
|
||||||
void paintSelectionBar(QPainter &p) const;
|
|
||||||
void paintLeftRightFading(
|
void paintLeftRightFading(
|
||||||
QPainter &p,
|
QPainter &p,
|
||||||
const ExpandingContext &context) const;
|
const ExpandingContext &context) const;
|
||||||
|
@ -266,9 +256,6 @@ private:
|
||||||
void updateEmojiSectionWidth();
|
void updateEmojiSectionWidth();
|
||||||
void updateEmojiWidthCallback();
|
void updateEmojiWidthCallback();
|
||||||
|
|
||||||
void initSearch();
|
|
||||||
void toggleSearch(bool visible);
|
|
||||||
void resizeSearchControls();
|
|
||||||
void scrollByWheelEvent(not_null<QWheelEvent*> e);
|
void scrollByWheelEvent(not_null<QWheelEvent*> e);
|
||||||
|
|
||||||
void validateFadeLeft(int leftWidth) const;
|
void validateFadeLeft(int leftWidth) const;
|
||||||
|
@ -311,17 +298,10 @@ private:
|
||||||
Ui::Animations::Simple _subiconsWidthAnimation;
|
Ui::Animations::Simple _subiconsWidthAnimation;
|
||||||
int _subiconsWidth = 0;
|
int _subiconsWidth = 0;
|
||||||
bool _subiconsExpanded = false;
|
bool _subiconsExpanded = false;
|
||||||
bool _barSelection = false;
|
|
||||||
bool _repaintScheduled = false;
|
bool _repaintScheduled = false;
|
||||||
|
|
||||||
bool _searchShown = false;
|
|
||||||
object_ptr<Ui::InputField> _searchField = { nullptr };
|
|
||||||
object_ptr<Ui::CrossButton> _searchCancel = { nullptr };
|
|
||||||
QPointer<QWidget> _focusTakenFrom;
|
|
||||||
|
|
||||||
rpl::event_stream<> _openSettingsRequests;
|
rpl::event_stream<> _openSettingsRequests;
|
||||||
rpl::event_stream<uint64> _setChosen;
|
rpl::event_stream<uint64> _setChosen;
|
||||||
rpl::event_stream<SearchRequest> _searchRequests;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "menu/menu_send.h" // SendMenu::FillSendMenu
|
#include "menu/menu_send.h" // SendMenu::FillSendMenu
|
||||||
#include "chat_helpers/stickers_lottie.h"
|
#include "chat_helpers/stickers_lottie.h"
|
||||||
#include "chat_helpers/stickers_list_footer.h"
|
#include "chat_helpers/stickers_list_footer.h"
|
||||||
|
#include "ui/controls/tabbed_search.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/popup_menu.h"
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "ui/effects/animations.h"
|
#include "ui/effects/animations.h"
|
||||||
|
@ -201,6 +202,10 @@ StickersListWidget::StickersListWidget(
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent);
|
setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
|
|
||||||
|
if (!_isMasks) {
|
||||||
|
setupSearch();
|
||||||
|
}
|
||||||
|
|
||||||
_settings->addClickHandler([=] {
|
_settings->addClickHandler([=] {
|
||||||
using Section = StickersBox::Section;
|
using Section = StickersBox::Section;
|
||||||
controller->show(
|
controller->show(
|
||||||
|
@ -265,7 +270,6 @@ object_ptr<TabbedSelector::InnerFooter> StickersListWidget::createFooter() {
|
||||||
.paused = pausedMethod(),
|
.paused = pausedMethod(),
|
||||||
.parent = this,
|
.parent = this,
|
||||||
.settingsButtonVisible = true,
|
.settingsButtonVisible = true,
|
||||||
.barSelection = true,
|
|
||||||
});
|
});
|
||||||
_footer = result;
|
_footer = result;
|
||||||
|
|
||||||
|
@ -288,15 +292,6 @@ object_ptr<TabbedSelector::InnerFooter> StickersListWidget::createFooter() {
|
||||||
Ui::LayerOption::KeepOther);
|
Ui::LayerOption::KeepOther);
|
||||||
}, _footer->lifetime());
|
}, _footer->lifetime());
|
||||||
|
|
||||||
_footer->searchRequests(
|
|
||||||
) | rpl::start_with_next([=](StickersListFooter::SearchRequest request) {
|
|
||||||
if (request.forced) {
|
|
||||||
sendSearchRequest();
|
|
||||||
} else {
|
|
||||||
searchForSets(request.text);
|
|
||||||
}
|
|
||||||
}, _footer->lifetime());
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,6 +412,7 @@ int StickersListWidget::featuredRowHeight() const {
|
||||||
template <typename Callback>
|
template <typename Callback>
|
||||||
bool StickersListWidget::enumerateSections(Callback callback) const {
|
bool StickersListWidget::enumerateSections(Callback callback) const {
|
||||||
auto info = SectionInfo();
|
auto info = SectionInfo();
|
||||||
|
info.top = _search ? _search->height() : 0;
|
||||||
const auto &sets = shownSets();
|
const auto &sets = shownSets();
|
||||||
for (auto i = 0; i != sets.size(); ++i) {
|
for (auto i = 0; i != sets.size(); ++i) {
|
||||||
auto &set = sets[i];
|
auto &set = sets[i];
|
||||||
|
@ -517,11 +513,11 @@ void StickersListWidget::sendSearchRequest() {
|
||||||
|
|
||||||
auto it = _searchCache.find(_searchQuery);
|
auto it = _searchCache.find(_searchQuery);
|
||||||
if (it != _searchCache.cend()) {
|
if (it != _searchCache.cend()) {
|
||||||
_footer->setLoading(false);
|
_search->setLoading(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_footer->setLoading(true);
|
_search->setLoading(true);
|
||||||
const auto hash = uint64(0);
|
const auto hash = uint64(0);
|
||||||
_searchRequestId = _api.request(MTPmessages_SearchStickerSets(
|
_searchRequestId = _api.request(MTPmessages_SearchStickerSets(
|
||||||
MTP_flags(0),
|
MTP_flags(0),
|
||||||
|
@ -531,7 +527,7 @@ void StickersListWidget::sendSearchRequest() {
|
||||||
searchResultsDone(result);
|
searchResultsDone(result);
|
||||||
}).fail([=] {
|
}).fail([=] {
|
||||||
// show error?
|
// show error?
|
||||||
_footer->setLoading(false);
|
_search->setLoading(false);
|
||||||
_searchRequestId = 0;
|
_searchRequestId = 0;
|
||||||
}).handleAllErrors().send();
|
}).handleAllErrors().send();
|
||||||
}
|
}
|
||||||
|
@ -544,7 +540,7 @@ void StickersListWidget::searchForSets(const QString &query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_searchQuery != cleaned) {
|
if (_searchQuery != cleaned) {
|
||||||
_footer->setLoading(false);
|
_search->setLoading(false);
|
||||||
if (const auto requestId = base::take(_searchRequestId)) {
|
if (const auto requestId = base::take(_searchRequestId)) {
|
||||||
_api.request(requestId).cancel();
|
_api.request(requestId).cancel();
|
||||||
}
|
}
|
||||||
|
@ -560,7 +556,7 @@ void StickersListWidget::searchForSets(const QString &query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListWidget::cancelSetsSearch() {
|
void StickersListWidget::cancelSetsSearch() {
|
||||||
_footer->setLoading(false);
|
_search->setLoading(false);
|
||||||
if (const auto requestId = base::take(_searchRequestId)) {
|
if (const auto requestId = base::take(_searchRequestId)) {
|
||||||
_api.request(requestId).cancel();
|
_api.request(requestId).cancel();
|
||||||
}
|
}
|
||||||
|
@ -758,7 +754,7 @@ auto StickersListWidget::shownSets() -> std::vector<Set> & {
|
||||||
|
|
||||||
void StickersListWidget::searchResultsDone(
|
void StickersListWidget::searchResultsDone(
|
||||||
const MTPmessages_FoundStickerSets &result) {
|
const MTPmessages_FoundStickerSets &result) {
|
||||||
_footer->setLoading(false);
|
_search->setLoading(false);
|
||||||
_searchRequestId = 0;
|
_searchRequestId = 0;
|
||||||
|
|
||||||
if (result.type() == mtpc_messages_foundStickerSetsNotModified) {
|
if (result.type() == mtpc_messages_foundStickerSetsNotModified) {
|
||||||
|
@ -926,7 +922,12 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||||
set.ripple.reset();
|
set.ripple.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(selected ? st::stickerPanRemoveSet.iconOver : st::stickerPanRemoveSet.icon).paint(p, remove.topLeft() + st::stickerPanRemoveSet.iconPosition, width());
|
const auto &icon = selected ? st::stickerPanRemoveSet.iconOver : st::stickerPanRemoveSet.icon;
|
||||||
|
icon.paint(
|
||||||
|
p,
|
||||||
|
remove.x() + (remove.width() - icon.width()) / 2,
|
||||||
|
remove.y() + (remove.height() - icon.height()) / 2,
|
||||||
|
width());
|
||||||
|
|
||||||
widthForTitle -= remove.width();
|
widthForTitle -= remove.width();
|
||||||
}
|
}
|
||||||
|
@ -2253,10 +2254,6 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
||||||
std::vector<StickerIcon> StickersListWidget::fillIcons() {
|
std::vector<StickerIcon> StickersListWidget::fillIcons() {
|
||||||
auto result = std::vector<StickerIcon>();
|
auto result = std::vector<StickerIcon>();
|
||||||
result.reserve(_mySets.size() + 1);
|
result.reserve(_mySets.size() + 1);
|
||||||
if (!_officialSets.empty() && !_isMasks) {
|
|
||||||
result.emplace_back(Data::Stickers::FeaturedSetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto i = 0;
|
auto i = 0;
|
||||||
if (i != _mySets.size() && _mySets[i].id == Data::Stickers::FavedSetId) {
|
if (i != _mySets.size() && _mySets[i].id == Data::Stickers::FavedSetId) {
|
||||||
++i;
|
++i;
|
||||||
|
@ -2268,6 +2265,7 @@ std::vector<StickerIcon> StickersListWidget::fillIcons() {
|
||||||
result.emplace_back(Data::Stickers::RecentSetId);
|
result.emplace_back(Data::Stickers::RecentSetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const auto side = StickersListFooter::IconFrameSize();
|
||||||
for (auto l = _mySets.size(); i != l; ++i) {
|
for (auto l = _mySets.size(); i != l; ++i) {
|
||||||
if (_mySets[i].id == Data::Stickers::MegagroupSetId) {
|
if (_mySets[i].id == Data::Stickers::MegagroupSetId) {
|
||||||
result.emplace_back(Data::Stickers::MegagroupSetId);
|
result.emplace_back(Data::Stickers::MegagroupSetId);
|
||||||
|
@ -2277,8 +2275,6 @@ std::vector<StickerIcon> StickersListWidget::fillIcons() {
|
||||||
const auto set = _mySets[i].set;
|
const auto set = _mySets[i].set;
|
||||||
Assert(set != nullptr);
|
Assert(set != nullptr);
|
||||||
const auto s = _mySets[i].thumbnailDocument;
|
const auto s = _mySets[i].thumbnailDocument;
|
||||||
const auto availw = st::stickerIconWidth - 2 * st::stickerIconPadding;
|
|
||||||
const auto availh = st().footer - 2 * st::stickerIconPadding;
|
|
||||||
const auto size = set->hasThumbnail()
|
const auto size = set->hasThumbnail()
|
||||||
? QSize(
|
? QSize(
|
||||||
set->thumbnailLocation().width(),
|
set->thumbnailLocation().width(),
|
||||||
|
@ -2288,17 +2284,8 @@ std::vector<StickerIcon> StickersListWidget::fillIcons() {
|
||||||
s->thumbnailLocation().width(),
|
s->thumbnailLocation().width(),
|
||||||
s->thumbnailLocation().height())
|
s->thumbnailLocation().height())
|
||||||
: QSize();
|
: QSize();
|
||||||
auto thumbw = size.width(), thumbh = size.height(), pixw = 1, pixh = 1;
|
const auto pix = size.scaled(side, side, Qt::KeepAspectRatio);
|
||||||
if (availw * thumbh > availh * thumbw) {
|
result.emplace_back(set, s, pix.width(), pix.height());
|
||||||
pixh = availh;
|
|
||||||
pixw = (pixh * thumbw) / thumbh;
|
|
||||||
} else {
|
|
||||||
pixw = availw;
|
|
||||||
pixh = thumbw ? ((pixw * thumbh) / thumbw) : 1;
|
|
||||||
}
|
|
||||||
if (pixw < 1) pixw = 1;
|
|
||||||
if (pixh < 1) pixh = 1;
|
|
||||||
result.emplace_back(set, s, pixw, pixh);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -2471,7 +2458,7 @@ void StickersListWidget::showStickerSet(uint64 setId) {
|
||||||
auto y = 0;
|
auto y = 0;
|
||||||
enumerateSections([this, setId, &y](const SectionInfo &info) {
|
enumerateSections([this, setId, &y](const SectionInfo &info) {
|
||||||
if (shownSets()[info.section].id == setId) {
|
if (shownSets()[info.section].id == setId) {
|
||||||
y = info.top;
|
y = info.section ? info.top : 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -2527,17 +2514,28 @@ void StickersListWidget::showMegagroupSet(ChannelData *megagroup) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListWidget::afterShown() {
|
void StickersListWidget::afterShown() {
|
||||||
if (_footer) {
|
if (_search) {
|
||||||
_footer->stealFocus();
|
_search->stealFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersListWidget::beforeHiding() {
|
void StickersListWidget::beforeHiding() {
|
||||||
if (_footer) {
|
if (_search) {
|
||||||
_footer->returnFocus();
|
_search->returnFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StickersListWidget::setupSearch() {
|
||||||
|
const auto session = &_controller->session();
|
||||||
|
_search = MakeSearch(this, st(), [=](std::vector<QString> &&query) {
|
||||||
|
searchForSets(ranges::accumulate(query, QString(), [](
|
||||||
|
QString a,
|
||||||
|
QString b) {
|
||||||
|
return a.isEmpty() ? b : (a + ' ' + b);
|
||||||
|
}));
|
||||||
|
}, session);
|
||||||
|
}
|
||||||
|
|
||||||
void StickersListWidget::displaySet(uint64 setId) {
|
void StickersListWidget::displaySet(uint64 setId) {
|
||||||
if (setId == Data::Stickers::MegagroupSetId) {
|
if (setId == Data::Stickers::MegagroupSetId) {
|
||||||
if (_megagroupSet->canEditStickers()) {
|
if (_megagroupSet->canEditStickers()) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ class PopupMenu;
|
||||||
class RippleAnimation;
|
class RippleAnimation;
|
||||||
class BoxContent;
|
class BoxContent;
|
||||||
class PathShiftGradient;
|
class PathShiftGradient;
|
||||||
|
class TabbedSearch;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Lottie {
|
namespace Lottie {
|
||||||
|
@ -196,6 +197,7 @@ private:
|
||||||
const QVector<DocumentData*> &pack,
|
const QVector<DocumentData*> &pack,
|
||||||
bool skipPremium);
|
bool skipPremium);
|
||||||
|
|
||||||
|
void setupSearch();
|
||||||
void preloadMoreOfficial();
|
void preloadMoreOfficial();
|
||||||
QSize boundingBoxSize() const;
|
QSize boundingBoxSize() const;
|
||||||
|
|
||||||
|
@ -329,6 +331,7 @@ private:
|
||||||
not_null<DocumentData*> document);
|
not_null<DocumentData*> document);
|
||||||
|
|
||||||
not_null<Window::SessionController*> _controller;
|
not_null<Window::SessionController*> _controller;
|
||||||
|
std::unique_ptr<Ui::TabbedSearch> _search;
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
std::unique_ptr<LocalStickersManager> _localSetsManager;
|
std::unique_ptr<LocalStickersManager> _localSetsManager;
|
||||||
ChannelData *_megagroupSet = nullptr;
|
ChannelData *_megagroupSet = nullptr;
|
||||||
|
|
|
@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "chat_helpers/stickers_list_widget.h"
|
#include "chat_helpers/stickers_list_widget.h"
|
||||||
#include "chat_helpers/gifs_list_widget.h"
|
#include "chat_helpers/gifs_list_widget.h"
|
||||||
#include "menu/menu_send.h"
|
#include "menu/menu_send.h"
|
||||||
|
#include "ui/controls/tabbed_search.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/shadow.h"
|
#include "ui/widgets/shadow.h"
|
||||||
|
@ -25,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "main/main_session_settings.h"
|
#include "main/main_session_settings.h"
|
||||||
#include "storage/localstorage.h"
|
#include "storage/localstorage.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
|
#include "data/data_emoji_statuses.h"
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/stickers/data_stickers.h"
|
#include "data/stickers/data_stickers.h"
|
||||||
|
@ -288,6 +290,32 @@ void TabbedSelector::Tab::saveScrollTop() {
|
||||||
_scrollTop = widget()->getVisibleTop();
|
_scrollTop = widget()->getVisibleTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Ui::TabbedSearch> MakeSearch(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
const style::EmojiPan &st,
|
||||||
|
Fn<void(std::vector<QString>&&)> callback,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
bool statusCategories) {
|
||||||
|
using Descriptor = Ui::SearchDescriptor;
|
||||||
|
const auto owner = &session->data();
|
||||||
|
auto result = std::make_unique<Ui::TabbedSearch>(parent, st, Descriptor{
|
||||||
|
.st = st.search,
|
||||||
|
.groups = (statusCategories
|
||||||
|
? owner->emojiStatuses().statusGroupsValue()
|
||||||
|
: owner->emojiStatuses().emojiGroupsValue()),
|
||||||
|
.customEmojiFactory = owner->customEmojiManager().factory(
|
||||||
|
Data::CustomEmojiManager::SizeTag::SetIcon,
|
||||||
|
Ui::SearchWithGroups::IconSizeOverride())
|
||||||
|
});
|
||||||
|
|
||||||
|
result->queryValue(
|
||||||
|
) | rpl::skip(1) | rpl::start_with_next(
|
||||||
|
std::move(callback),
|
||||||
|
parent->lifetime());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
TabbedSelector::TabbedSelector(
|
TabbedSelector::TabbedSelector(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
not_null<Window::SessionController*> controller,
|
not_null<Window::SessionController*> controller,
|
||||||
|
|
|
@ -31,6 +31,7 @@ class ScrollArea;
|
||||||
class SettingsSlider;
|
class SettingsSlider;
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
class BoxContent;
|
class BoxContent;
|
||||||
|
class TabbedSearch;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
namespace Window {
|
namespace Window {
|
||||||
|
@ -77,6 +78,13 @@ struct EmojiChosen {
|
||||||
|
|
||||||
using InlineChosen = InlineBots::ResultSelected;
|
using InlineChosen = InlineBots::ResultSelected;
|
||||||
|
|
||||||
|
[[nodiscard]] std::unique_ptr<Ui::TabbedSearch> MakeSearch(
|
||||||
|
not_null<Ui::RpWidget*> parent,
|
||||||
|
const style::EmojiPan &st,
|
||||||
|
Fn<void(std::vector<QString>&&)> callback,
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
bool statusCategories = false);
|
||||||
|
|
||||||
class TabbedSelector : public Ui::RpWidget {
|
class TabbedSelector : public Ui::RpWidget {
|
||||||
public:
|
public:
|
||||||
static constexpr auto kPickCustomTimeId = -1;
|
static constexpr auto kPickCustomTimeId = -1;
|
||||||
|
|
|
@ -397,7 +397,7 @@ void Autocomplete::setupContent() {
|
||||||
this,
|
this,
|
||||||
object_ptr<Ui::InputField>(
|
object_ptr<Ui::InputField>(
|
||||||
this,
|
this,
|
||||||
st::gifsSearchField,
|
st::defaultMultiSelectSearchField,
|
||||||
rpl::single(u"Search for templates"_q)), // #TODO hard_lang
|
rpl::single(u"Search for templates"_q)), // #TODO hard_lang
|
||||||
st::autocompleteSearchPadding);
|
st::autocompleteSearchPadding);
|
||||||
const auto input = inputWrap->entity();
|
const auto input = inputWrap->entity();
|
||||||
|
|
Loading…
Add table
Reference in a new issue