Start showing folder chats list.

This commit is contained in:
John Preston 2019-04-16 22:06:15 +04:00
parent 0c0d6bc411
commit 927735dff2
3 changed files with 25 additions and 9 deletions

View File

@ -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<Dialogs::IndexedList*> 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();

View File

@ -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<Dialogs::IndexedList*> shownDialogs() const;
void checkReorderPinnedStart(QPoint localPosition);
int shownPinnedCount() const;
@ -288,6 +289,7 @@ private:
std::optional<QPoint> _lastMousePosition;
Qt::MouseButton _pressButton = Qt::LeftButton;
Dialogs::IndexedList *_folderChatsList = nullptr;
std::unique_ptr<ImportantSwitch> _importantSwitch;
bool _importantSwitchSelected = false;
bool _importantSwitchPressed = false;

View File

@ -513,6 +513,9 @@ void DialogsWidget::animationCallback() {
}
void DialogsWidget::onCancel() {
if (_inner->cancelFolder()) {
return;
}
if (!onCancelSearch() || (!_searchInChat && !App::main()->selectingPeer())) {
emit cancelled();
}