mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-29 05:29:23 +00:00
Added simple colorizing of query in found messages from compose search.
This commit is contained in:
parent
5c33a2bd5c
commit
2b93fe9a30
@ -54,7 +54,9 @@ using SearchRequest = Api::MessagesSearchMerged::Request;
|
||||
|
||||
class Row final : public PeerListRow {
|
||||
public:
|
||||
explicit Row(std::unique_ptr<Dialogs::FakeRow> fakeRow);
|
||||
explicit Row(
|
||||
std::unique_ptr<Dialogs::FakeRow> fakeRow,
|
||||
not_null<QString*> query);
|
||||
|
||||
[[nodiscard]] FullMsgId fullId() const;
|
||||
|
||||
@ -73,15 +75,17 @@ public:
|
||||
private:
|
||||
const std::unique_ptr<Dialogs::FakeRow> _fakeRow;
|
||||
|
||||
not_null<QString*> _query;
|
||||
int _outerWidth = 0;
|
||||
|
||||
};
|
||||
|
||||
Row::Row(std::unique_ptr<Dialogs::FakeRow> fakeRow)
|
||||
Row::Row(std::unique_ptr<Dialogs::FakeRow> fakeRow, not_null<QString*> query)
|
||||
: PeerListRow(
|
||||
fakeRow->searchInChat().history()->peer,
|
||||
fakeRow->item()->fullId().msg.bare)
|
||||
, _fakeRow(std::move(fakeRow)) {
|
||||
, _fakeRow(std::move(fakeRow))
|
||||
, _query(query) {
|
||||
}
|
||||
|
||||
FullMsgId Row::fullId() const {
|
||||
@ -116,9 +120,11 @@ void Row::elementsPaint(
|
||||
.st = &st::defaultDialogRow,
|
||||
.currentBg = st::dialogsBg,
|
||||
.now = crl::now(),
|
||||
.searchLowerText = QStringView(*_query),
|
||||
.width = outerWidth,
|
||||
.selected = selected,
|
||||
.paused = p.inactive(),
|
||||
.search = true,
|
||||
});
|
||||
}
|
||||
|
||||
@ -134,6 +140,7 @@ public:
|
||||
void loadMoreRows() override;
|
||||
|
||||
void addItems(const MessageIdsList &ids, bool clear);
|
||||
void setQuery(const QString &query);
|
||||
|
||||
[[nodiscard]] rpl::producer<FullMsgId> showItemRequests() const;
|
||||
[[nodiscard]] rpl::producer<> searchMoreRequests() const;
|
||||
@ -145,6 +152,8 @@ private:
|
||||
rpl::event_stream<> _searchMoreRequests;
|
||||
rpl::event_stream<> _resetScrollRequests;
|
||||
|
||||
QString _query;
|
||||
|
||||
};
|
||||
|
||||
ListController::ListController(not_null<History*> history)
|
||||
@ -201,7 +210,8 @@ void ListController::addItems(const MessageIdsList &ids, bool clear) {
|
||||
std::make_unique<Dialogs::FakeRow>(
|
||||
key,
|
||||
item,
|
||||
[=] { delegate()->peerListUpdateRow(*shared); }));
|
||||
[=] { delegate()->peerListUpdateRow(*shared); }),
|
||||
&_query);
|
||||
*shared = row.get();
|
||||
delegate()->peerListAppendRow(std::move(row));
|
||||
}
|
||||
@ -214,6 +224,10 @@ void ListController::addItems(const MessageIdsList &ids, bool clear) {
|
||||
}
|
||||
}
|
||||
|
||||
void ListController::setQuery(const QString &query) {
|
||||
_query = query;
|
||||
}
|
||||
|
||||
struct List {
|
||||
base::unique_qptr<Ui::RpWidget> container;
|
||||
std::unique_ptr<ListController> controller;
|
||||
@ -913,6 +927,9 @@ ComposeSearch::Inner::Inner(
|
||||
search.topMsgId = _topMsgId;
|
||||
_apiSearch.clear();
|
||||
_apiSearch.search(search);
|
||||
|
||||
_list.controller->addItems({}, true);
|
||||
_list.controller->setQuery(_apiSearch.request().query);
|
||||
}, _topBar->lifetime());
|
||||
|
||||
_topBar->queryChanges(
|
||||
|
Loading…
x
Reference in New Issue
Block a user