mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Single entry point to search in chat.
This commit is contained in:
parent
2c75fe033c
commit
f8e76f1b84
6 changed files with 23 additions and 39 deletions
|
@ -1481,9 +1481,7 @@ void Widget::showMainMenu() {
|
|||
controller()->widget()->showMainMenu();
|
||||
}
|
||||
|
||||
void Widget::searchMessages(
|
||||
const QString &query,
|
||||
Key inChat) {
|
||||
void Widget::searchMessages(const QString &query, Key inChat) {
|
||||
if (_childList) {
|
||||
const auto forum = controller()->shownForum().current();
|
||||
const auto topic = inChat.topic();
|
||||
|
@ -1494,18 +1492,27 @@ void Widget::searchMessages(
|
|||
}
|
||||
hideChildList();
|
||||
}
|
||||
if (_openedFolder) {
|
||||
controller()->closeFolder();
|
||||
}
|
||||
|
||||
const auto inChatChanged = [&] {
|
||||
const auto inPeer = inChat.peer();
|
||||
const auto inTopic = inChat.topic();
|
||||
if (!inTopic && _openedForum && inPeer == _openedForum->channel()) {
|
||||
if (!inTopic
|
||||
&& _openedForum
|
||||
&& inPeer == _openedForum->channel()
|
||||
&& _subsectionTopBar
|
||||
&& _subsectionTopBar->searchMode()) {
|
||||
return false;
|
||||
} else if ((inTopic || (inPeer && !inPeer->isForum()))
|
||||
&& (inChat == _searchInChat)) {
|
||||
return false;
|
||||
} else if (const auto inPeer = inChat.peer()) {
|
||||
if (inPeer->migrateTo() == _searchInChat.peer()
|
||||
&& !_searchInChat.topic()) {
|
||||
return false;
|
||||
if (const auto to = inPeer->migrateTo()) {
|
||||
if (to == _searchInChat.peer() && !_searchInChat.topic()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -2130,18 +2137,7 @@ void Widget::closeChildList(anim::type animated) {
|
|||
}
|
||||
|
||||
void Widget::searchInChat(Key chat) {
|
||||
if (_openedForum && !chat.peer()->forum()) {
|
||||
controller()->closeForum();
|
||||
}
|
||||
if (_openedFolder) {
|
||||
if (_childList && _childList->setSearchInChat(chat)) {
|
||||
return;
|
||||
}
|
||||
controller()->closeFolder();
|
||||
}
|
||||
cancelSearch();
|
||||
setSearchInChat(chat);
|
||||
applyFilterUpdate(true);
|
||||
searchMessages(QString(), chat);
|
||||
}
|
||||
|
||||
bool Widget::setSearchInChat(Key chat, PeerData *from) {
|
||||
|
|
|
@ -4536,12 +4536,8 @@ bool HistoryWidget::updateCmdStartShown() {
|
|||
}
|
||||
|
||||
void HistoryWidget::searchInChat() {
|
||||
if (!_history) {
|
||||
return;
|
||||
} else if (controller()->isPrimary()) {
|
||||
if (_history) {
|
||||
controller()->content()->searchInChat(_history);
|
||||
} else {
|
||||
searchInChatEmbedded();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2598,12 +2598,8 @@ void RepliesWidget::setupShortcuts() {
|
|||
}
|
||||
|
||||
void RepliesWidget::searchInTopic() {
|
||||
if (!_topic) {
|
||||
return;
|
||||
} else if (controller()->isPrimary()) {
|
||||
if (_topic) {
|
||||
controller()->content()->searchInChat(_topic);
|
||||
} else {
|
||||
// #TODO forum window
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1318,6 +1318,10 @@ bool TopBarWidget::searchSetFocus() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TopBarWidget::searchMode() const {
|
||||
return _searchMode;
|
||||
}
|
||||
|
||||
bool TopBarWidget::searchHasFocus() const {
|
||||
return _searchMode && _searchField->hasFocus();
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ public:
|
|||
void searchEnableJumpToDate(bool enable);
|
||||
void searchEnableChooseFromUser(bool enable, bool visible);
|
||||
bool searchSetFocus();
|
||||
[[nodiscard]] bool searchMode() const;
|
||||
[[nodiscard]] bool searchHasFocus() const;
|
||||
[[nodiscard]] rpl::producer<> searchCancelled() const;
|
||||
[[nodiscard]] rpl::producer<> searchSubmitted() const;
|
||||
|
|
|
@ -2652,16 +2652,7 @@ int MainWidget::backgroundFromY() const {
|
|||
}
|
||||
|
||||
void MainWidget::searchInChat(Dialogs::Key chat) {
|
||||
// #TODO windows
|
||||
if (!_dialogs) {
|
||||
return;
|
||||
}
|
||||
_dialogs->searchInChat(chat);
|
||||
if (isOneColumn()) {
|
||||
_controller->clearSectionStack();
|
||||
} else {
|
||||
_dialogs->setInnerFocus();
|
||||
}
|
||||
searchMessages(QString(), chat);
|
||||
}
|
||||
|
||||
bool MainWidget::contentOverlapped(const QRect &globalRect) {
|
||||
|
|
Loading…
Add table
Reference in a new issue