From 927735dff2112c8e5ab5d83d931198f15f8f4754 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 16 Apr 2019 22:06:15 +0400 Subject: [PATCH] Start showing folder chats list. --- .../dialogs/dialogs_inner_widget.cpp | 27 +++++++++++++------ .../dialogs/dialogs_inner_widget.h | 4 ++- .../SourceFiles/dialogs/dialogs_widget.cpp | 3 +++ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index f9ced180ed..5b70b4bb35 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -248,6 +248,16 @@ int DialogsInner::searchInChatSkip() const { return result; } +bool DialogsInner::cancelFolder() { + if (!_folderChatsList) { + return false; + } + clearSelection(); + _folderChatsList = nullptr; + refresh(); + return true; +} + void DialogsInner::paintEvent(QPaintEvent *e) { Painter p(this); @@ -1460,10 +1470,12 @@ void DialogsInner::updateSelectedRow(Dialogs::Key key) { } } -Dialogs::IndexedList *DialogsInner::shownDialogs() const { - return (Global::DialogsMode() == Dialogs::Mode::Important) - ? session().data().importantChatsList() - : session().data().chatsList(); +not_null DialogsInner::shownDialogs() const { + return _folderChatsList + ? _folderChatsList + : (Global::DialogsMode() == Dialogs::Mode::Important) + ? session().data().importantChatsList().get() + : session().data().chatsList().get(); } void DialogsInner::leaveEventHook(QEvent *e) { @@ -2461,10 +2473,9 @@ bool DialogsInner::chooseRow() { ? ShowAtUnreadMsgId : chosen.message.fullId.msg)); } else if (const auto folder = chosen.key.folder()) { - // #TODO archive - //_controller->showSection( - // HistoryFeed::Memento(feed, chosen.message), - // Window::SectionShow::Way::ClearStack); + clearSelection(); + _folderChatsList = folder->chatsList(); + refresh(); } if (openSearchResult && !session().supportMode()) { emit clearSearchQuery(); diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h index e576f49477..e581bcaf09 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.h @@ -54,6 +54,7 @@ public: void activate(); + bool cancelFolder(); void selectSkip(int32 direction); void selectSkipPage(int32 pixels, int32 direction); @@ -269,7 +270,7 @@ private: void clearSearchResults(bool clearPeerSearchResults = true); void updateSelectedRow(Dialogs::Key key = Dialogs::Key()); - Dialogs::IndexedList *shownDialogs() const; + not_null shownDialogs() const; void checkReorderPinnedStart(QPoint localPosition); int shownPinnedCount() const; @@ -288,6 +289,7 @@ private: std::optional _lastMousePosition; Qt::MouseButton _pressButton = Qt::LeftButton; + Dialogs::IndexedList *_folderChatsList = nullptr; std::unique_ptr _importantSwitch; bool _importantSwitchSelected = false; bool _importantSwitchPressed = false; diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 203ff7af2f..0aec645c18 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -513,6 +513,9 @@ void DialogsWidget::animationCallback() { } void DialogsWidget::onCancel() { + if (_inner->cancelFolder()) { + return; + } if (!onCancelSearch() || (!_searchInChat && !App::main()->selectingPeer())) { emit cancelled(); }