mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix saved messages tags search.
This commit is contained in:
parent
fce520c9c0
commit
42d53e5543
4 changed files with 42 additions and 26 deletions
|
@ -488,7 +488,7 @@ int InnerWidget::peerSearchOffset() const {
|
||||||
+ st::searchedBarHeight;
|
+ st::searchedBarHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::searchInChatOffset() const {
|
int InnerWidget::searchTagsOffset() const {
|
||||||
auto result = peerSearchOffset() - st::searchedBarHeight;
|
auto result = peerSearchOffset() - st::searchedBarHeight;
|
||||||
if (!_peerSearchResults.empty()) {
|
if (!_peerSearchResults.empty()) {
|
||||||
result += (_peerSearchResults.size() * st::dialogsRowHeight)
|
result += (_peerSearchResults.size() * st::dialogsRowHeight)
|
||||||
|
@ -497,6 +497,14 @@ int InnerWidget::searchInChatOffset() const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int InnerWidget::searchInChatOffset() const {
|
||||||
|
auto result = searchTagsOffset();
|
||||||
|
if (_searchTags) {
|
||||||
|
result += _searchTags->height();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int InnerWidget::searchedOffset() const {
|
int InnerWidget::searchedOffset() const {
|
||||||
return searchInChatOffset()
|
return searchInChatOffset()
|
||||||
+ searchInChatSkip()
|
+ searchInChatSkip()
|
||||||
|
@ -505,9 +513,6 @@ int InnerWidget::searchedOffset() const {
|
||||||
|
|
||||||
int InnerWidget::searchInChatSkip() const {
|
int InnerWidget::searchInChatSkip() const {
|
||||||
auto result = 0;
|
auto result = 0;
|
||||||
if (_searchTags) {
|
|
||||||
result += _searchTags->height();
|
|
||||||
}
|
|
||||||
if (_searchFromShown) {
|
if (_searchFromShown) {
|
||||||
result += st::dialogsSearchInHeight;
|
result += st::dialogsSearchInHeight;
|
||||||
}
|
}
|
||||||
|
@ -857,6 +862,17 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_searchTags) {
|
||||||
|
paintSearchTags(p, {
|
||||||
|
.st = &st::forumTopicRow,
|
||||||
|
.currentBg = currentBg(),
|
||||||
|
.now = ms,
|
||||||
|
.width = fullWidth,
|
||||||
|
.paused = videoPaused,
|
||||||
|
});
|
||||||
|
p.translate(0, _searchTags->height());
|
||||||
|
top += _searchTags->height();
|
||||||
|
}
|
||||||
if (_searchFromShown) {
|
if (_searchFromShown) {
|
||||||
paintSearchInChat(p, {
|
paintSearchInChat(p, {
|
||||||
.st = &st::forumTopicRow,
|
.st = &st::forumTopicRow,
|
||||||
|
@ -1117,20 +1133,24 @@ QBrush InnerWidget::currentBg() const {
|
||||||
_childListShown.current().shown);
|
_childListShown.current().shown);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InnerWidget::paintSearchTags(
|
||||||
|
Painter &p,
|
||||||
|
const Ui::PaintContext &context) const {
|
||||||
|
Expects(_searchTags != nullptr);
|
||||||
|
|
||||||
|
const auto height = _searchTags->height();
|
||||||
|
p.fillRect(0, 0, width(), height, currentBg());
|
||||||
|
const auto top = st::dialogsSearchTagBottom / 2;
|
||||||
|
const auto position = QPoint(_searchTagsLeft, top);
|
||||||
|
_searchTags->paint(p, position, context.now, context.paused);
|
||||||
|
}
|
||||||
|
|
||||||
void InnerWidget::paintSearchInChat(
|
void InnerWidget::paintSearchInChat(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::PaintContext &context) const {
|
const Ui::PaintContext &context) const {
|
||||||
auto height = searchInChatSkip();
|
auto height = searchInChatSkip();
|
||||||
|
|
||||||
auto top = 0;
|
auto top = 0;
|
||||||
if (_searchTags) {
|
|
||||||
const auto height = _searchTags->height();
|
|
||||||
top += st::dialogsSearchTagBottom;
|
|
||||||
p.fillRect(0, top, width(), height, currentBg());
|
|
||||||
const auto position = QPoint(_searchTagsLeft, top);
|
|
||||||
_searchTags->paint(p, position, context.now, context.paused);
|
|
||||||
top += height - st::dialogsSearchTagBottom;
|
|
||||||
}
|
|
||||||
p.setFont(st::searchedBarFont);
|
p.setFont(st::searchedBarFont);
|
||||||
auto fullRect = QRect(0, top, width(), height - top);
|
auto fullRect = QRect(0, top, width(), height - top);
|
||||||
p.fillRect(fullRect, currentBg());
|
p.fillRect(fullRect, currentBg());
|
||||||
|
@ -1280,7 +1300,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
|
||||||
|
|
||||||
const auto tagBase = QPoint(
|
const auto tagBase = QPoint(
|
||||||
_searchTagsLeft,
|
_searchTagsLeft,
|
||||||
searchInChatOffset() + st::dialogsSearchTagBottom);
|
searchTagsOffset() + st::dialogsSearchTagBottom / 2);
|
||||||
const auto tagPoint = local - tagBase;
|
const auto tagPoint = local - tagBase;
|
||||||
const auto inTags = _searchTags
|
const auto inTags = _searchTags
|
||||||
&& QRect(
|
&& QRect(
|
||||||
|
@ -2464,11 +2484,7 @@ void InnerWidget::applySearchState(SearchState state) {
|
||||||
const auto ignoreInChat = (state.tab == ChatSearchTab::MyMessages)
|
const auto ignoreInChat = (state.tab == ChatSearchTab::MyMessages)
|
||||||
|| (state.tab == ChatSearchTab::PublicPosts);
|
|| (state.tab == ChatSearchTab::PublicPosts);
|
||||||
const auto sublist = ignoreInChat ? nullptr : state.inChat.sublist();
|
const auto sublist = ignoreInChat ? nullptr : state.inChat.sublist();
|
||||||
const auto peer = ignoreInChat
|
const auto peer = ignoreInChat ? nullptr : state.inChat.peer();
|
||||||
? nullptr
|
|
||||||
: sublist
|
|
||||||
? session().user().get()
|
|
||||||
: state.inChat.peer();
|
|
||||||
if (const auto migrateFrom = peer ? peer->migrateFrom() : nullptr) {
|
if (const auto migrateFrom = peer ? peer->migrateFrom() : nullptr) {
|
||||||
_searchInMigrated = peer->owner().history(migrateFrom);
|
_searchInMigrated = peer->owner().history(migrateFrom);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2481,14 +2497,9 @@ void InnerWidget::applySearchState(SearchState state) {
|
||||||
reactions->myTagsValue(sublist),
|
reactions->myTagsValue(sublist),
|
||||||
state.tags);
|
state.tags);
|
||||||
|
|
||||||
_searchTags->selectedChanges(
|
|
||||||
) | rpl::start_with_next([=](std::vector<Data::ReactionId> &&list) {
|
|
||||||
_searchState.tags = std::move(list);
|
|
||||||
}, _searchTags->lifetime());
|
|
||||||
|
|
||||||
_searchTags->repaintRequests() | rpl::start_with_next([=] {
|
_searchTags->repaintRequests() | rpl::start_with_next([=] {
|
||||||
const auto height = _searchTags->height();
|
const auto height = _searchTags->height();
|
||||||
update(0, searchInChatOffset(), width(), height);
|
update(0, searchTagsOffset(), width(), height);
|
||||||
}, _searchTags->lifetime());
|
}, _searchTags->lifetime());
|
||||||
|
|
||||||
_searchTags->menuRequests(
|
_searchTags->menuRequests(
|
||||||
|
|
|
@ -334,6 +334,7 @@ private:
|
||||||
[[nodiscard]] int filteredIndex(int y) const;
|
[[nodiscard]] int filteredIndex(int y) const;
|
||||||
[[nodiscard]] int filteredHeight(int till = -1) const;
|
[[nodiscard]] int filteredHeight(int till = -1) const;
|
||||||
[[nodiscard]] int peerSearchOffset() const;
|
[[nodiscard]] int peerSearchOffset() const;
|
||||||
|
[[nodiscard]] int searchTagsOffset() const;
|
||||||
[[nodiscard]] int searchInChatOffset() const;
|
[[nodiscard]] int searchInChatOffset() const;
|
||||||
[[nodiscard]] int searchedOffset() const;
|
[[nodiscard]] int searchedOffset() const;
|
||||||
[[nodiscard]] int searchInChatSkip() const;
|
[[nodiscard]] int searchInChatSkip() const;
|
||||||
|
@ -349,6 +350,9 @@ private:
|
||||||
Painter &p,
|
Painter &p,
|
||||||
not_null<const PeerSearchResult*> result,
|
not_null<const PeerSearchResult*> result,
|
||||||
const Ui::PaintContext &context);
|
const Ui::PaintContext &context);
|
||||||
|
void paintSearchTags(
|
||||||
|
Painter &p,
|
||||||
|
const Ui::PaintContext &context) const;
|
||||||
void paintSearchInChat(
|
void paintSearchInChat(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
const Ui::PaintContext &context) const;
|
const Ui::PaintContext &context) const;
|
||||||
|
|
|
@ -93,7 +93,7 @@ PeerData *Key::peer() const {
|
||||||
ChatSearchTab SearchState::defaultTabForMe() const {
|
ChatSearchTab SearchState::defaultTabForMe() const {
|
||||||
return inChat.topic()
|
return inChat.topic()
|
||||||
? ChatSearchTab::ThisTopic
|
? ChatSearchTab::ThisTopic
|
||||||
: inChat.history()
|
: (inChat.history() || inChat.sublist())
|
||||||
? ChatSearchTab::ThisPeer
|
? ChatSearchTab::ThisPeer
|
||||||
: ChatSearchTab::MyMessages;
|
: ChatSearchTab::MyMessages;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1282,7 +1282,8 @@ void Widget::updateSearchTabs() {
|
||||||
&& !_searchingHashtag)) {
|
&& !_searchingHashtag)) {
|
||||||
_searchState.tab = _searchState.inChat.topic()
|
_searchState.tab = _searchState.inChat.topic()
|
||||||
? ChatSearchTab::ThisTopic
|
? ChatSearchTab::ThisTopic
|
||||||
: _searchState.inChat.owningHistory()
|
: (_searchState.inChat.owningHistory()
|
||||||
|
|| _searchState.inChat.sublist())
|
||||||
? ChatSearchTab::ThisPeer
|
? ChatSearchTab::ThisPeer
|
||||||
: ChatSearchTab::MyMessages;
|
: ChatSearchTab::MyMessages;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue