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; return result;
} }
bool DialogsInner::cancelFolder() {
if (!_folderChatsList) {
return false;
}
clearSelection();
_folderChatsList = nullptr;
refresh();
return true;
}
void DialogsInner::paintEvent(QPaintEvent *e) { void DialogsInner::paintEvent(QPaintEvent *e) {
Painter p(this); Painter p(this);
@ -1460,10 +1470,12 @@ void DialogsInner::updateSelectedRow(Dialogs::Key key) {
} }
} }
Dialogs::IndexedList *DialogsInner::shownDialogs() const { not_null<Dialogs::IndexedList*> DialogsInner::shownDialogs() const {
return (Global::DialogsMode() == Dialogs::Mode::Important) return _folderChatsList
? session().data().importantChatsList() ? _folderChatsList
: session().data().chatsList(); : (Global::DialogsMode() == Dialogs::Mode::Important)
? session().data().importantChatsList().get()
: session().data().chatsList().get();
} }
void DialogsInner::leaveEventHook(QEvent *e) { void DialogsInner::leaveEventHook(QEvent *e) {
@ -2461,10 +2473,9 @@ bool DialogsInner::chooseRow() {
? ShowAtUnreadMsgId ? ShowAtUnreadMsgId
: chosen.message.fullId.msg)); : chosen.message.fullId.msg));
} else if (const auto folder = chosen.key.folder()) { } else if (const auto folder = chosen.key.folder()) {
// #TODO archive clearSelection();
//_controller->showSection( _folderChatsList = folder->chatsList();
// HistoryFeed::Memento(feed, chosen.message), refresh();
// Window::SectionShow::Way::ClearStack);
} }
if (openSearchResult && !session().supportMode()) { if (openSearchResult && !session().supportMode()) {
emit clearSearchQuery(); emit clearSearchQuery();

View File

@ -54,6 +54,7 @@ public:
void activate(); void activate();
bool cancelFolder();
void selectSkip(int32 direction); void selectSkip(int32 direction);
void selectSkipPage(int32 pixels, int32 direction); void selectSkipPage(int32 pixels, int32 direction);
@ -269,7 +270,7 @@ private:
void clearSearchResults(bool clearPeerSearchResults = true); void clearSearchResults(bool clearPeerSearchResults = true);
void updateSelectedRow(Dialogs::Key key = Dialogs::Key()); void updateSelectedRow(Dialogs::Key key = Dialogs::Key());
Dialogs::IndexedList *shownDialogs() const; not_null<Dialogs::IndexedList*> shownDialogs() const;
void checkReorderPinnedStart(QPoint localPosition); void checkReorderPinnedStart(QPoint localPosition);
int shownPinnedCount() const; int shownPinnedCount() const;
@ -288,6 +289,7 @@ private:
std::optional<QPoint> _lastMousePosition; std::optional<QPoint> _lastMousePosition;
Qt::MouseButton _pressButton = Qt::LeftButton; Qt::MouseButton _pressButton = Qt::LeftButton;
Dialogs::IndexedList *_folderChatsList = nullptr;
std::unique_ptr<ImportantSwitch> _importantSwitch; std::unique_ptr<ImportantSwitch> _importantSwitch;
bool _importantSwitchSelected = false; bool _importantSwitchSelected = false;
bool _importantSwitchPressed = false; bool _importantSwitchPressed = false;

View File

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