mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fix recent hashtags in chats search.
This commit is contained in:
parent
174b627a78
commit
053c462dc0
2 changed files with 49 additions and 66 deletions
|
@ -512,8 +512,12 @@ int InnerWidget::pinnedOffset() const {
|
||||||
return dialogsOffset() + shownHeight(fixedOnTopCount());
|
return dialogsOffset() + shownHeight(fixedOnTopCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int InnerWidget::hashtagsOffset() const {
|
||||||
|
return searchInChatOffset() + searchInChatSkip();
|
||||||
|
}
|
||||||
|
|
||||||
int InnerWidget::filteredOffset() const {
|
int InnerWidget::filteredOffset() const {
|
||||||
return _hashtagResults.size() * st::mentionHeight;
|
return hashtagsOffset() + (_hashtagResults.size() * st::mentionHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::filteredIndex(int y) const {
|
int InnerWidget::filteredIndex(int y) const {
|
||||||
|
@ -539,8 +543,16 @@ int InnerWidget::peerSearchOffset() const {
|
||||||
+ st::searchedBarHeight;
|
+ st::searchedBarHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::searchTagsOffset() const {
|
int InnerWidget::searchInChatOffset() const {
|
||||||
auto result = peerSearchOffset() - st::searchedBarHeight;
|
return (_searchTags ? _searchTags->height() : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int InnerWidget::searchInChatSkip() const {
|
||||||
|
return _searchIn ? _searchIn->height() : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int InnerWidget::searchedOffset() const {
|
||||||
|
auto result = peerSearchOffset();
|
||||||
if (!_peerSearchResults.empty()) {
|
if (!_peerSearchResults.empty()) {
|
||||||
result += (_peerSearchResults.size() * st::dialogsRowHeight)
|
result += (_peerSearchResults.size() * st::dialogsRowHeight)
|
||||||
+ st::searchedBarHeight;
|
+ st::searchedBarHeight;
|
||||||
|
@ -548,20 +560,6 @@ int InnerWidget::searchTagsOffset() const {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int InnerWidget::searchInChatOffset() const {
|
|
||||||
return searchTagsOffset() + (_searchTags ? _searchTags->height() : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
int InnerWidget::searchedOffset() const {
|
|
||||||
return searchInChatOffset()
|
|
||||||
+ searchInChatSkip()
|
|
||||||
+ st::searchedBarHeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
int InnerWidget::searchInChatSkip() const {
|
|
||||||
return _searchIn ? _searchIn->height() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InnerWidget::changeOpenedFolder(Data::Folder *folder) {
|
void InnerWidget::changeOpenedFolder(Data::Folder *folder) {
|
||||||
Expects(!folder || !_savedSublists);
|
Expects(!folder || !_savedSublists);
|
||||||
|
|
||||||
|
@ -796,10 +794,26 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
p.fillRect(dialogsClip, currentBg());
|
p.fillRect(dialogsClip, currentBg());
|
||||||
}
|
}
|
||||||
} else if (_state == WidgetState::Filtered) {
|
} else if (_state == WidgetState::Filtered) {
|
||||||
[[maybe_unused]] auto top = 0;
|
if (_searchTags) {
|
||||||
|
paintSearchTags(p, {
|
||||||
|
.st = &st::forumTopicRow,
|
||||||
|
.currentBg = currentBg(),
|
||||||
|
.now = ms,
|
||||||
|
.width = fullWidth,
|
||||||
|
.paused = videoPaused,
|
||||||
|
});
|
||||||
|
p.translate(0, _searchTags->height());
|
||||||
|
}
|
||||||
|
if (_searchIn) {
|
||||||
|
p.translate(0, searchInChatSkip());
|
||||||
|
if (_searchResults.empty()) {
|
||||||
|
p.fillRect(0, 0, fullWidth, st::lineWidth, st::shadowFg);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!_hashtagResults.empty()) {
|
if (!_hashtagResults.empty()) {
|
||||||
auto from = floorclamp(r.y(), st::mentionHeight, 0, _hashtagResults.size());
|
const auto skip = hashtagsOffset();
|
||||||
auto to = ceilclamp(r.y() + r.height(), st::mentionHeight, 0, _hashtagResults.size());
|
auto from = floorclamp(r.y() - skip, st::mentionHeight, 0, _hashtagResults.size());
|
||||||
|
auto to = ceilclamp(r.y() + r.height() - skip, st::mentionHeight, 0, _hashtagResults.size());
|
||||||
p.translate(0, from * st::mentionHeight);
|
p.translate(0, from * st::mentionHeight);
|
||||||
if (from < _hashtagResults.size()) {
|
if (from < _hashtagResults.size()) {
|
||||||
const auto htagleft = st::defaultDialogRow.padding.left();
|
const auto htagleft = st::defaultDialogRow.padding.left();
|
||||||
|
@ -841,7 +855,9 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
p.drawText(htagleft + firstwidth, st::mentionTop + st::mentionFont->ascent, second);
|
p.drawText(htagleft + firstwidth, st::mentionTop + st::mentionFont->ascent, second);
|
||||||
}
|
}
|
||||||
p.translate(0, st::mentionHeight);
|
p.translate(0, st::mentionHeight);
|
||||||
top += st::mentionHeight;
|
}
|
||||||
|
if (to < _hashtagResults.size()) {
|
||||||
|
p.translate(0, (_hashtagResults.size() - to) * st::mentionHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -853,7 +869,6 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
int(_filterResults.size()));
|
int(_filterResults.size()));
|
||||||
const auto height = filteredHeight(from);
|
const auto height = filteredHeight(from);
|
||||||
p.translate(0, height);
|
p.translate(0, height);
|
||||||
top += height;
|
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
const auto selected = isPressed()
|
const auto selected = isPressed()
|
||||||
? (from == _filteredPressed)
|
? (from == _filteredPressed)
|
||||||
|
@ -861,7 +876,6 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
const auto row = _filterResults[from].row;
|
const auto row = _filterResults[from].row;
|
||||||
paintRow(row, selected, !activeEntry.fullId);
|
paintRow(row, selected, !activeEntry.fullId);
|
||||||
p.translate(0, row->height());
|
p.translate(0, row->height());
|
||||||
top += row->height();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,13 +885,11 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
p.setPen(st::searchedBarFg);
|
p.setPen(st::searchedBarFg);
|
||||||
p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), tr::lng_search_global_results(tr::now));
|
p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), tr::lng_search_global_results(tr::now));
|
||||||
p.translate(0, st::searchedBarHeight);
|
p.translate(0, st::searchedBarHeight);
|
||||||
top += st::searchedBarHeight;
|
|
||||||
|
|
||||||
auto skip = peerSearchOffset();
|
auto skip = peerSearchOffset();
|
||||||
auto from = floorclamp(r.y() - skip, st::dialogsRowHeight, 0, _peerSearchResults.size());
|
auto from = floorclamp(r.y() - skip, st::dialogsRowHeight, 0, _peerSearchResults.size());
|
||||||
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _peerSearchResults.size());
|
auto to = ceilclamp(r.y() + r.height() - skip, st::dialogsRowHeight, 0, _peerSearchResults.size());
|
||||||
p.translate(0, from * st::dialogsRowHeight);
|
p.translate(0, from * st::dialogsRowHeight);
|
||||||
top += from * st::dialogsRowHeight;
|
|
||||||
if (from < _peerSearchResults.size()) {
|
if (from < _peerSearchResults.size()) {
|
||||||
const auto activePeer = activeEntry.key.peer();
|
const auto activePeer = activeEntry.key.peer();
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
|
@ -900,34 +912,10 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
.paused = videoPaused,
|
.paused = videoPaused,
|
||||||
});
|
});
|
||||||
p.translate(0, st::dialogsRowHeight);
|
p.translate(0, st::dialogsRowHeight);
|
||||||
top += st::dialogsRowHeight;
|
|
||||||
}
|
}
|
||||||
}
|
if (to < _peerSearchResults.size()) {
|
||||||
}
|
p.translate(0, (_peerSearchResults.size() - to) * st::dialogsRowHeight);
|
||||||
|
}
|
||||||
if (_searchTags) {
|
|
||||||
paintSearchTags(p, {
|
|
||||||
.st = &st::forumTopicRow,
|
|
||||||
.currentBg = currentBg(),
|
|
||||||
.now = ms,
|
|
||||||
.width = fullWidth,
|
|
||||||
.paused = videoPaused,
|
|
||||||
});
|
|
||||||
p.translate(0, _searchTags->height());
|
|
||||||
top += _searchTags->height();
|
|
||||||
}
|
|
||||||
if (_searchIn) {
|
|
||||||
//paintSearchInChat(p, {
|
|
||||||
// .st = &st::forumTopicRow,
|
|
||||||
// .currentBg = currentBg(),
|
|
||||||
// .now = ms,
|
|
||||||
// .width = fullWidth,
|
|
||||||
// .paused = videoPaused,
|
|
||||||
//});
|
|
||||||
p.translate(0, searchInChatSkip());
|
|
||||||
top += searchInChatSkip();
|
|
||||||
if (_searchResults.empty()) {
|
|
||||||
p.fillRect(0, 0, fullWidth, st::lineWidth, st::shadowFg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,7 +928,6 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
p.setPen(st::searchedBarFg);
|
p.setPen(st::searchedBarFg);
|
||||||
p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), text);
|
p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), text);
|
||||||
p.translate(0, st::searchedBarHeight);
|
p.translate(0, st::searchedBarHeight);
|
||||||
top += st::searchedBarHeight;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto text = showUnreadInSearchResults
|
const auto text = showUnreadInSearchResults
|
||||||
|
@ -954,13 +941,11 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
p.setPen(st::searchedBarFg);
|
p.setPen(st::searchedBarFg);
|
||||||
p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), text);
|
p.drawTextLeft(st::searchedBarPosition.x(), st::searchedBarPosition.y(), width(), text);
|
||||||
p.translate(0, st::searchedBarHeight);
|
p.translate(0, st::searchedBarHeight);
|
||||||
top += st::searchedBarHeight;
|
|
||||||
|
|
||||||
auto skip = searchedOffset();
|
auto skip = searchedOffset();
|
||||||
auto from = floorclamp(r.y() - skip, _st->height, 0, _searchResults.size());
|
auto from = floorclamp(r.y() - skip, _st->height, 0, _searchResults.size());
|
||||||
auto to = ceilclamp(r.y() + r.height() - skip, _st->height, 0, _searchResults.size());
|
auto to = ceilclamp(r.y() + r.height() - skip, _st->height, 0, _searchResults.size());
|
||||||
p.translate(0, from * _st->height);
|
p.translate(0, from * _st->height);
|
||||||
top += from * _st->height;
|
|
||||||
if (from < _searchResults.size()) {
|
if (from < _searchResults.size()) {
|
||||||
for (; from < to; ++from) {
|
for (; from < to; ++from) {
|
||||||
const auto &result = _searchResults[from];
|
const auto &result = _searchResults[from];
|
||||||
|
@ -988,7 +973,6 @@ void InnerWidget::paintEvent(QPaintEvent *e) {
|
||||||
.displayUnreadInfo = showUnreadInSearchResults,
|
.displayUnreadInfo = showUnreadInSearchResults,
|
||||||
});
|
});
|
||||||
p.translate(0, _st->height);
|
p.translate(0, _st->height);
|
||||||
top += _st->height;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1363,7 +1347,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
|
||||||
|
|
||||||
const auto tagBase = QPoint(
|
const auto tagBase = QPoint(
|
||||||
_searchTagsLeft,
|
_searchTagsLeft,
|
||||||
searchTagsOffset() + st::dialogsSearchTagBottom / 2);
|
st::dialogsSearchTagBottom / 2);
|
||||||
const auto tagPoint = local - tagBase;
|
const auto tagPoint = local - tagBase;
|
||||||
const auto inTags = _searchTags
|
const auto inTags = _searchTags
|
||||||
&& QRect(
|
&& QRect(
|
||||||
|
@ -1414,7 +1398,7 @@ void InnerWidget::selectByMouse(QPoint globalPosition) {
|
||||||
_hashtagSelected = -1;
|
_hashtagSelected = -1;
|
||||||
_hashtagDeleteSelected = false;
|
_hashtagDeleteSelected = false;
|
||||||
} else {
|
} else {
|
||||||
auto skip = 0;
|
auto skip = hashtagsOffset();
|
||||||
auto hashtagSelected = (mouseY >= skip) ? ((mouseY - skip) / st::mentionHeight) : -1;
|
auto hashtagSelected = (mouseY >= skip) ? ((mouseY - skip) / st::mentionHeight) : -1;
|
||||||
if (hashtagSelected < 0 || hashtagSelected >= _hashtagResults.size()) {
|
if (hashtagSelected < 0 || hashtagSelected >= _hashtagResults.size()) {
|
||||||
hashtagSelected = -1;
|
hashtagSelected = -1;
|
||||||
|
@ -1547,8 +1531,9 @@ void InnerWidget::mousePressEvent(QMouseEvent *e) {
|
||||||
_dragStart = e->pos();
|
_dragStart = e->pos();
|
||||||
} else if (base::in_range(_hashtagPressed, 0, _hashtagResults.size()) && !_hashtagDeletePressed) {
|
} else if (base::in_range(_hashtagPressed, 0, _hashtagResults.size()) && !_hashtagDeletePressed) {
|
||||||
auto row = &_hashtagResults[_hashtagPressed]->row;
|
auto row = &_hashtagResults[_hashtagPressed]->row;
|
||||||
row->addRipple(e->pos(), QSize(width(), st::mentionHeight), [this, index = _hashtagPressed] {
|
const auto origin = e->pos() - QPoint(0, hashtagsOffset() + _hashtagPressed * st::mentionHeight);
|
||||||
update(0, index * st::mentionHeight, width(), st::mentionHeight);
|
row->addRipple(origin, QSize(width(), st::mentionHeight), [this, index = _hashtagPressed] {
|
||||||
|
update(0, hashtagsOffset() + index * st::mentionHeight, width(), st::mentionHeight);
|
||||||
});
|
});
|
||||||
} else if (base::in_range(_filteredPressed, 0, _filterResults.size())) {
|
} else if (base::in_range(_filteredPressed, 0, _filterResults.size())) {
|
||||||
const auto &result = _filterResults[_filteredPressed];
|
const auto &result = _filterResults[_filteredPressed];
|
||||||
|
@ -1989,9 +1974,7 @@ void InnerWidget::moveSearchIn() {
|
||||||
width(),
|
width(),
|
||||||
st::columnMinimalWidthLeft - _narrowWidth);
|
st::columnMinimalWidthLeft - _narrowWidth);
|
||||||
_searchIn->resizeToWidth(searchInWidth);
|
_searchIn->resizeToWidth(searchInWidth);
|
||||||
|
_searchIn->moveToLeft(0, searchInChatOffset());
|
||||||
const auto top = (_searchTags ? _searchTags->height() : 0);
|
|
||||||
_searchIn->moveToLeft(0, top);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void InnerWidget::dialogRowReplaced(
|
void InnerWidget::dialogRowReplaced(
|
||||||
|
@ -2318,7 +2301,7 @@ void InnerWidget::updateSelectedRow(Key key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (_hashtagSelected >= 0) {
|
} else if (_hashtagSelected >= 0) {
|
||||||
update(0, _hashtagSelected * st::mentionHeight, width(), st::mentionHeight);
|
update(0, hashtagsOffset() + _hashtagSelected * st::mentionHeight, width(), st::mentionHeight);
|
||||||
} else if (_filteredSelected >= 0) {
|
} else if (_filteredSelected >= 0) {
|
||||||
if (_filteredSelected < _filterResults.size()) {
|
if (_filteredSelected < _filterResults.size()) {
|
||||||
const auto &result = _filterResults[_filteredSelected];
|
const auto &result = _filterResults[_filteredSelected];
|
||||||
|
@ -2631,7 +2614,7 @@ void InnerWidget::applySearchState(SearchState state) {
|
||||||
|
|
||||||
_searchTags->repaintRequests() | rpl::start_with_next([=] {
|
_searchTags->repaintRequests() | rpl::start_with_next([=] {
|
||||||
const auto height = _searchTags->height();
|
const auto height = _searchTags->height();
|
||||||
update(0, searchTagsOffset(), width(), height);
|
update(0, 0, width(), height);
|
||||||
}, _searchTags->lifetime());
|
}, _searchTags->lifetime());
|
||||||
|
|
||||||
_searchTags->menuRequests(
|
_searchTags->menuRequests(
|
||||||
|
|
|
@ -343,10 +343,10 @@ 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;
|
||||||
|
[[nodiscard]] int hashtagsOffset() const;
|
||||||
|
|
||||||
void paintCollapsedRows(
|
void paintCollapsedRows(
|
||||||
Painter &p,
|
Painter &p,
|
||||||
|
|
Loading…
Add table
Reference in a new issue