mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Fixed display of chats filters strip from forward box in search mode.
This commit is contained in:
parent
a41e9bf67e
commit
4a327ba584
3 changed files with 33 additions and 7 deletions
|
@ -206,7 +206,9 @@ void PeerListBox::keyPressEvent(QKeyEvent *e) {
|
||||||
content()->selectSkipPage(height(), 1);
|
content()->selectSkipPage(height(), 1);
|
||||||
} else if (e->key() == Qt::Key_PageUp) {
|
} else if (e->key() == Qt::Key_PageUp) {
|
||||||
content()->selectSkipPage(height(), -1);
|
content()->selectSkipPage(height(), -1);
|
||||||
} else if (e->key() == Qt::Key_Escape && _select && !_select->entity()->getQuery().isEmpty()) {
|
} else if (e->key() == Qt::Key_Escape
|
||||||
|
&& _select
|
||||||
|
&& !_select->entity()->getQuery().isEmpty()) {
|
||||||
_select->entity()->clearQuery();
|
_select->entity()->clearQuery();
|
||||||
} else {
|
} else {
|
||||||
BoxContent::keyPressEvent(e);
|
BoxContent::keyPressEvent(e);
|
||||||
|
@ -215,7 +217,16 @@ void PeerListBox::keyPressEvent(QKeyEvent *e) {
|
||||||
|
|
||||||
void PeerListBox::searchQueryChanged(const QString &query) {
|
void PeerListBox::searchQueryChanged(const QString &query) {
|
||||||
scrollToY(0);
|
scrollToY(0);
|
||||||
content()->searchQueryChanged(query);
|
const auto isEmpty = content()->searchQueryChanged(query);
|
||||||
|
if (_specialTabsMode.enabled) {
|
||||||
|
_specialTabsMode.searchIsActive = !isEmpty;
|
||||||
|
if (_specialTabsMode.searchIsActive) {
|
||||||
|
_specialTabsMode.topSkip = _addedTopScrollSkip;
|
||||||
|
setAddedTopScrollSkip(0);
|
||||||
|
} else {
|
||||||
|
setAddedTopScrollSkip(_specialTabsMode.topSkip);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListBox::resizeEvent(QResizeEvent *e) {
|
void PeerListBox::resizeEvent(QResizeEvent *e) {
|
||||||
|
@ -547,8 +558,13 @@ rpl::producer<int> PeerListBox::multiSelectHeightValue() const {
|
||||||
return _select ? _select->heightValue() : rpl::single(0);
|
return _select ? _select->heightValue() : rpl::single(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListBox::setIgnoreHiddenRowsOnSearch(bool value) {
|
void PeerListBox::setSpecialTabMode(bool value) {
|
||||||
content()->setIgnoreHiddenRowsOnSearch(value);
|
content()->setIgnoreHiddenRowsOnSearch(value);
|
||||||
|
if (value) {
|
||||||
|
_specialTabsMode.enabled = true;
|
||||||
|
} else {
|
||||||
|
_specialTabsMode = {};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PeerListRow::PeerListRow(not_null<PeerData*> peer)
|
PeerListRow::PeerListRow(not_null<PeerData*> peer)
|
||||||
|
@ -2060,7 +2076,7 @@ void PeerListContent::checkScrollForPreload() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerListContent::searchQueryChanged(QString query) {
|
PeerListContent::IsEmpty PeerListContent::searchQueryChanged(QString query) {
|
||||||
const auto searchWordsList = TextUtilities::PrepareSearchWords(query);
|
const auto searchWordsList = TextUtilities::PrepareSearchWords(query);
|
||||||
const auto normalizedQuery = searchWordsList.join(' ');
|
const auto normalizedQuery = searchWordsList.join(' ');
|
||||||
if (_ignoreHiddenRowsOnSearch && !normalizedQuery.isEmpty()) {
|
if (_ignoreHiddenRowsOnSearch && !normalizedQuery.isEmpty()) {
|
||||||
|
@ -2117,6 +2133,7 @@ void PeerListContent::searchQueryChanged(QString query) {
|
||||||
}
|
}
|
||||||
refreshRows();
|
refreshRows();
|
||||||
}
|
}
|
||||||
|
return _normalizedSearchQuery.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PeerListState> PeerListContent::saveState() const {
|
std::unique_ptr<PeerListState> PeerListContent::saveState() const {
|
||||||
|
|
|
@ -652,7 +652,8 @@ public:
|
||||||
[[nodiscard]] bool hasPressed() const;
|
[[nodiscard]] bool hasPressed() const;
|
||||||
void clearSelection();
|
void clearSelection();
|
||||||
|
|
||||||
void searchQueryChanged(QString query);
|
using IsEmpty = bool;
|
||||||
|
IsEmpty searchQueryChanged(QString query);
|
||||||
bool submitted();
|
bool submitted();
|
||||||
|
|
||||||
PeerListRowId updateFromParentDrag(QPoint globalPosition);
|
PeerListRowId updateFromParentDrag(QPoint globalPosition);
|
||||||
|
@ -1107,7 +1108,7 @@ public:
|
||||||
[[nodiscard]] std::vector<not_null<PeerData*>> collectSelectedRows();
|
[[nodiscard]] std::vector<not_null<PeerData*>> collectSelectedRows();
|
||||||
[[nodiscard]] rpl::producer<int> multiSelectHeightValue() const;
|
[[nodiscard]] rpl::producer<int> multiSelectHeightValue() const;
|
||||||
|
|
||||||
void setIgnoreHiddenRowsOnSearch(bool value);
|
void setSpecialTabMode(bool value);
|
||||||
|
|
||||||
void peerListSetTitle(rpl::producer<QString> title) override {
|
void peerListSetTitle(rpl::producer<QString> title) override {
|
||||||
setTitle(std::move(title));
|
setTitle(std::move(title));
|
||||||
|
@ -1174,4 +1175,11 @@ private:
|
||||||
bool _scrollBottomFixed = false;
|
bool _scrollBottomFixed = false;
|
||||||
int _addedTopScrollSkip = 0;
|
int _addedTopScrollSkip = 0;
|
||||||
|
|
||||||
|
struct SpecialTabsMode final {
|
||||||
|
bool enabled = false;
|
||||||
|
bool searchIsActive = false;
|
||||||
|
int topSkip = 0;
|
||||||
|
};
|
||||||
|
SpecialTabsMode _specialTabsMode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -2053,7 +2053,7 @@ QPointer<Ui::BoxContent> ShowForwardMessagesBox(
|
||||||
auto controller = std::make_unique<Controller>(session);
|
auto controller = std::make_unique<Controller>(session);
|
||||||
const auto controllerRaw = controller.get();
|
const auto controllerRaw = controller.get();
|
||||||
auto init = [=](not_null<PeerListBox*> box) {
|
auto init = [=](not_null<PeerListBox*> box) {
|
||||||
box->setIgnoreHiddenRowsOnSearch(true);
|
box->setSpecialTabMode(true);
|
||||||
auto applyFilter = [=](FilterId id) {
|
auto applyFilter = [=](FilterId id) {
|
||||||
box->scrollToY(0);
|
box->scrollToY(0);
|
||||||
auto &filters = session->data().chatsFilters();
|
auto &filters = session->data().chatsFilters();
|
||||||
|
@ -2114,6 +2114,7 @@ QPointer<Ui::BoxContent> ShowForwardMessagesBox(
|
||||||
box,
|
box,
|
||||||
session,
|
session,
|
||||||
std::move(applyFilter));
|
std::move(applyFilter));
|
||||||
|
chatsFilters->lower();
|
||||||
chatsFilters->heightValue() | rpl::start_with_next([box](int h) {
|
chatsFilters->heightValue() | rpl::start_with_next([box](int h) {
|
||||||
box->setAddedTopScrollSkip(h);
|
box->setAddedTopScrollSkip(h);
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
|
|
Loading…
Add table
Reference in a new issue