2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Show folder using slide animation.

This commit is contained in:
John Preston
2019-04-24 14:15:10 +04:00
parent 6dd8f32f66
commit f56df0e1d9
9 changed files with 720 additions and 601 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -7,18 +7,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
#include "dialogs/dialogs_widget.h"
#include "dialogs/dialogs_key.h"
#include "data/data_messages.h"
#include "ui/effects/animations.h"
#include "ui/rp_widget.h"
#include "base/flags.h"
namespace Dialogs {
class Row;
class FakeRow;
class IndexedList;
} // namespace Dialogs
class AuthSession;
namespace Ui {
class IconButton;
@@ -30,18 +25,44 @@ namespace Window {
class Controller;
} // namespace Window
class DialogsInner
namespace Dialogs {
class Row;
class FakeRow;
class IndexedList;
struct ChosenRow {
Key key;
Data::MessagePosition message;
bool filteredRow = false;
};
enum class SearchRequestType {
FromStart,
FromOffset,
PeerFromStart,
PeerFromOffset,
MigratedFromStart,
MigratedFromOffset,
};
enum class WidgetState {
Default,
Filtered,
};
class InnerWidget
: public Ui::RpWidget
, public RPCSender
, private base::Subscriber {
Q_OBJECT
public:
DialogsInner(QWidget *parent, not_null<Window::Controller*> controller);
InnerWidget(QWidget *parent, not_null<Window::Controller*> controller);
bool searchReceived(
const QVector<MTPMessage> &result,
DialogsSearchRequestType type,
SearchRequestType type,
int fullCount);
void peerSearchReceived(
const QString &query,
@@ -50,15 +71,14 @@ public:
void activate();
bool openFolder(not_null<Data::Folder*> folder);
bool cancelFolder();
void changeOpenedFolder(Data::Folder *folder);
void selectSkip(int32 direction);
void selectSkipPage(int32 pixels, int32 direction);
void refreshDialog(Dialogs::Key key);
void removeDialog(Dialogs::Key key);
void repaintDialogRow(Dialogs::Mode list, not_null<Dialogs::Row*> row);
void repaintDialogRow(Dialogs::RowDescriptor row);
void refreshDialog(Key key);
void removeDialog(Key key);
void repaintDialogRow(Mode list, not_null<Row*> row);
void repaintDialogRow(RowDescriptor row);
void dragLeft();
@@ -67,7 +87,7 @@ public:
bool chooseRow();
void scrollToEntry(const Dialogs::RowDescriptor &entry);
void scrollToEntry(const RowDescriptor &entry);
Data::Folder *shownFolder() const;
int32 lastSearchDate() const;
@@ -75,17 +95,13 @@ public:
MsgId lastSearchId() const;
MsgId lastSearchMigratedId() const;
enum class State {
Default,
Filtered,
};
State state() const;
WidgetState state() const;
bool waitingForSearch() const {
return _waitingForSearch;
}
bool hasFilteredResults() const;
void searchInChat(Dialogs::Key key, UserData *from);
void searchInChat(Key key, UserData *from);
void applyFilterUpdate(QString newFilter, bool force = false);
void onHashtagFilterUpdate(QStringRef newFilter);
@@ -97,9 +113,11 @@ public:
base::Observable<UserData*> searchFromUserChanged;
rpl::producer<ChosenRow> chosenRow() const;
void notify_historyMuteUpdated(History *history);
~DialogsInner();
~InnerWidget();
public slots:
void onParentGeometryChanged();
@@ -109,7 +127,6 @@ signals:
void mustScrollTo(int scrollToTop, int scrollToBottom);
void dialogMoved(int movedFrom, int movedTo);
void searchMessages();
void clearSearchQuery();
void cancelSearchInChat();
void completeHashtag(QString tag);
void refreshHashtags();
@@ -140,21 +157,16 @@ private:
NextOrOriginal,
};
struct ChosenRow {
Dialogs::Key key;
Data::MessagePosition message;
};
AuthSession &session() const;
void dialogRowReplaced(Dialogs::Row *oldRow, Dialogs::Row *newRow);
void dialogRowReplaced(Row *oldRow, Row *newRow);
bool switchImportantChats();
bool chooseHashtag();
ChosenRow computeChosenRow() const;
bool isSearchResultActive(
not_null<Dialogs::FakeRow*> result,
const Dialogs::RowDescriptor &entry) const;
not_null<FakeRow*> result,
const RowDescriptor &entry) const;
void clearMouseSelection(bool clearSelection = false);
void mousePressReleased(QPoint globalPosition, Qt::MouseButton button);
@@ -162,7 +174,7 @@ private:
void selectByMouse(QPoint globalPosition);
void loadPeerPhotos();
void setImportantSwitchPressed(bool pressed);
void setPressed(Dialogs::Row *pressed);
void setPressed(Row *pressed);
void setHashtagPressed(int pressed);
void setFilteredPressed(int pressed);
void setPeerSearchPressed(int pressed);
@@ -187,17 +199,15 @@ private:
bool hasHistoryInResults(not_null<History*> history) const;
void setupShortcuts();
Dialogs::RowDescriptor computeJump(
const Dialogs::RowDescriptor &to,
RowDescriptor computeJump(
const RowDescriptor &to,
JumpSkip skip);
bool jumpToDialogRow(Dialogs::RowDescriptor to);
bool jumpToDialogRow(RowDescriptor to);
Dialogs::RowDescriptor chatListEntryBefore(
const Dialogs::RowDescriptor &which) const;
Dialogs::RowDescriptor chatListEntryAfter(
const Dialogs::RowDescriptor &which) const;
Dialogs::RowDescriptor chatListEntryFirst() const;
Dialogs::RowDescriptor chatListEntryLast() const;
RowDescriptor chatListEntryBefore(const RowDescriptor &which) const;
RowDescriptor chatListEntryAfter(const RowDescriptor &which) const;
RowDescriptor chatListEntryFirst() const;
RowDescriptor chatListEntryLast() const;
void itemRemoved(not_null<const HistoryItem*> item);
enum class UpdateRowSection {
@@ -212,7 +222,7 @@ private:
void updateSearchResult(not_null<PeerData*> peer);
void updateDialogRow(
Dialogs::RowDescriptor row,
RowDescriptor row,
QRect updateRect = QRect(),
UpdateRowSections sections = UpdateRowSection::All);
void fillSupportSearchMenu(not_null<Ui::PopupMenu*> menu);
@@ -224,7 +234,6 @@ private:
int peerSearchOffset() const;
int searchedOffset() const;
int searchInChatSkip() const;
int openedFolderSkip() const;
void paintPeerSearchResult(
Painter &p,
@@ -232,7 +241,6 @@ private:
int fullWidth,
bool active,
bool selected) const;
void paintOpenedFolder(Painter &p) const;
void paintSearchInChat(Painter &p) const;
void paintSearchInPeer(
Painter &p,
@@ -259,9 +267,9 @@ private:
void clearSelection();
void clearSearchResults(bool clearPeerSearchResults = true);
void updateSelectedRow(Dialogs::Key key = Dialogs::Key());
void updateSelectedRow(Key key = Key());
not_null<Dialogs::IndexedList*> shownDialogs() const;
not_null<IndexedList*> shownDialogs() const;
void checkReorderPinnedStart(QPoint localPosition);
int shownPinnedCount() const;
@@ -269,13 +277,11 @@ private:
bool updateReorderPinned(QPoint localPosition);
void finishReorderPinned();
void stopReorderPinned();
int countPinnedIndex(Dialogs::Row *ofRow);
int countPinnedIndex(Row *ofRow);
void savePinnedOrder();
bool pinnedShiftAnimationCallback(crl::time now);
void handleChatMigration(not_null<ChatData*> chat);
bool changeOpenedFolder(Data::Folder *folder);
not_null<Window::Controller*> _controller;
bool _mouseSelection = false;
@@ -283,15 +289,14 @@ private:
Qt::MouseButton _pressButton = Qt::LeftButton;
Data::Folder *_openedFolder = nullptr;
Text _openedFolderText;
std::unique_ptr<ImportantSwitch> _importantSwitch;
bool _importantSwitchSelected = false;
bool _importantSwitchPressed = false;
Dialogs::Row *_selected = nullptr;
Dialogs::Row *_pressed = nullptr;
Row *_selected = nullptr;
Row *_pressed = nullptr;
Dialogs::Row *_dragging = nullptr;
Row *_dragging = nullptr;
int _draggingIndex = -1;
int _aboveIndex = -1;
QPoint _dragStart;
@@ -301,7 +306,7 @@ private:
};
std::vector<PinnedRow> _pinnedRows;
Ui::Animations::Basic _pinnedShiftAnimation;
base::flat_set<Dialogs::Key> _pinnedOnDragStart;
base::flat_set<Key> _pinnedOnDragStart;
// Remember the last currently dragged row top shift for updating area.
int _aboveTopShift = -1;
@@ -316,10 +321,10 @@ private:
bool _hashtagDeleteSelected = false;
bool _hashtagDeletePressed = false;
std::vector<not_null<Dialogs::Row*>> _filterResults;
std::vector<not_null<Row*>> _filterResults;
base::flat_map<
not_null<PeerData*>,
std::unique_ptr<Dialogs::Row>> _filterResultsGlobal;
std::unique_ptr<Row>> _filterResultsGlobal;
int _filteredSelected = -1;
int _filteredPressed = -1;
@@ -330,7 +335,7 @@ private:
int _peerSearchSelected = -1;
int _peerSearchPressed = -1;
std::vector<std::unique_ptr<Dialogs::FakeRow>> _searchResults;
std::vector<std::unique_ptr<FakeRow>> _searchResults;
int _searchedCount = 0;
int _searchedMigratedCount = 0;
int _searchedSelected = -1;
@@ -341,23 +346,25 @@ private:
MsgId _lastSearchId = 0;
MsgId _lastSearchMigratedId = 0;
State _state = State::Default;
WidgetState _state = WidgetState::Default;
object_ptr<Ui::LinkButton> _addContactLnk;
object_ptr<Ui::IconButton> _closeOpenedFolder;
object_ptr<Ui::IconButton> _cancelSearchInChat;
object_ptr<Ui::IconButton> _cancelSearchFromUser;
Dialogs::Key _searchInChat;
Key _searchInChat;
History *_searchInMigrated = nullptr;
UserData *_searchFromUser = nullptr;
Text _searchInChatText;
Text _searchFromUserText;
Dialogs::RowDescriptor _menuRow;
RowDescriptor _menuRow;
Fn<void()> _loadMoreCallback;
rpl::event_stream<> _listBottomReached;
rpl::event_stream<ChosenRow> _chosenRow;
base::unique_qptr<Ui::PopupMenu> _menu;
};
} // namespace Dialogs

File diff suppressed because it is too large Load Diff

View File

@@ -13,16 +13,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "dialogs/dialogs_key.h"
#include "ui/special_buttons.h"
class DialogsInner;
class AuthSession;
namespace Dialogs {
struct RowDescriptor;
class Row;
class FakeRow;
class Key;
} // namespace Dialogs
namespace Ui {
class IconButton;
class PopupMenu;
@@ -39,29 +31,30 @@ class Controller;
class ConnectionState;
} // namespace Window
enum DialogsSearchRequestType {
DialogsSearchFromStart,
DialogsSearchFromOffset,
DialogsSearchPeerFromStart,
DialogsSearchPeerFromOffset,
DialogsSearchMigratedFromStart,
DialogsSearchMigratedFromOffset,
};
namespace Dialogs {
class DialogsWidget : public Window::AbstractSectionWidget, public RPCSender {
struct RowDescriptor;
class Row;
class FakeRow;
class Key;
struct ChosenRow;
class InnerWidget;
enum class SearchRequestType;
class Widget : public Window::AbstractSectionWidget, public RPCSender {
Q_OBJECT
public:
DialogsWidget(QWidget *parent, not_null<Window::Controller*> controller);
Widget(QWidget *parent, not_null<Window::Controller*> controller);
void updateDragInScroll(bool inScroll);
void searchInChat(Dialogs::Key chat);
void searchInChat(Key chat);
void refreshDialog(Dialogs::Key key);
void removeDialog(Dialogs::Key key);
void repaintDialogRow(Dialogs::Mode list, not_null<Dialogs::Row*> row);
void repaintDialogRow(Dialogs::RowDescriptor row);
void refreshDialog(Key key);
void removeDialog(Key key);
void repaintDialogRow(Mode list, not_null<Row*> row);
void repaintDialogRow(RowDescriptor row);
void jumpToTop();
@@ -74,9 +67,9 @@ public:
void showAnimated(Window::SlideDirection direction, const Window::SectionSlideParams &params);
void showFast();
void scrollToEntry(const Dialogs::RowDescriptor &entry);
void scrollToEntry(const RowDescriptor &entry);
void searchMessages(const QString &query, Dialogs::Key inChat = {});
void searchMessages(const QString &query, Key inChat = {});
void onSearchMore();
// Float player interface.
@@ -85,7 +78,7 @@ public:
void notify_historyMuteUpdated(History *history);
~DialogsWidget();
~Widget();
signals:
void cancelled();
@@ -121,9 +114,14 @@ protected:
void paintEvent(QPaintEvent *e) override;
private:
enum class ShowAnimation {
External,
Internal,
};
void animationCallback();
void searchReceived(
DialogsSearchRequestType type,
SearchRequestType type,
const MTPmessages_Messages &result,
mtpRequestId requestId);
void peerSearchReceived(
@@ -133,59 +131,67 @@ private:
void setupSupportMode();
void setupConnectingWidget();
bool searchForPeersRequired(const QString &query) const;
void setSearchInChat(Dialogs::Key chat, UserData *from = nullptr);
void setSearchInChat(Key chat, UserData *from = nullptr);
void showJumpToDate();
void showSearchFrom();
void showMainMenu();
void clearSearchCache();
void updateControlsVisibility(bool fast = false);
void updateLockUnlockVisibility();
void updateLoadMoreChatsVisibility();
void updateJumpToDateVisibility(bool fast = false);
void updateSearchFromVisibility(bool fast = false);
void updateControlsGeometry();
void updateForwardBar();
void checkUpdateStatus();
void changeOpenedFolder(Data::Folder *folder, anim::type animated);
QPixmap grabForFolderSlideAnimation();
void startSlideAnimation();
void applyFilterUpdate(bool force = false);
void refreshLoadMoreButton(bool mayBlock, bool isBlocked);
void loadMoreBlockedByDate();
bool searchFailed(DialogsSearchRequestType type, const RPCError &error, mtpRequestId req);
bool searchFailed(SearchRequestType type, const RPCError &error, mtpRequestId req);
bool peopleFailed(const RPCError &error, mtpRequestId req);
bool _dragInScroll = false;
bool _dragForward = false;
QTimer _chooseByDragTimer;
object_ptr<Ui::IconButton> _forwardCancel = { nullptr };
object_ptr<Ui::IconButton> _mainMenuToggle;
object_ptr<Ui::FlatInput> _filter;
object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _chooseFromUser;
object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _jumpToDate;
object_ptr<Ui::CrossButton> _cancelSearch;
object_ptr<Ui::IconButton> _lockUnlock;
object_ptr<Ui::ScrollArea> _scroll;
QPointer<DialogsInner> _inner;
class BottomButton;
object_ptr<BottomButton> _updateTelegram = { nullptr };
object_ptr<BottomButton> _loadMoreChats = { nullptr };
std::unique_ptr<Window::ConnectionState> _connecting;
Ui::Animations::Simple _scrollToAnimation;
Ui::Animations::Simple _a_show;
Window::SlideDirection _showDirection;
QPixmap _cacheUnder, _cacheOver;
Ui::Animations::Simple _scrollToTopShown;
bool _scrollToTopIsShown = false;
object_ptr<Ui::HistoryDownButton> _scrollToTop;
void scrollToTop();
void setupScrollUpButton();
void updateScrollUpVisibility();
void startScrollUpButtonAnimation(bool shown);
void updateScrollUpPosition();
Dialogs::Key _searchInChat;
bool _dragInScroll = false;
bool _dragForward = false;
QTimer _chooseByDragTimer;
object_ptr<Ui::IconButton> _forwardCancel = { nullptr };
object_ptr<Ui::RpWidget> _searchControls;
object_ptr<Ui::IconButton> _mainMenuToggle;
object_ptr<Ui::FlatInput> _filter;
object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _chooseFromUser;
object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _jumpToDate;
object_ptr<Ui::CrossButton> _cancelSearch;
object_ptr<Ui::IconButton> _lockUnlock;
object_ptr<Ui::ScrollArea> _scroll;
QPointer<InnerWidget> _inner;
class BottomButton;
object_ptr<BottomButton> _updateTelegram = { nullptr };
object_ptr<BottomButton> _loadMoreChats = { nullptr };
std::unique_ptr<Window::ConnectionState> _connecting;
Ui::Animations::Simple _scrollToAnimation;
Ui::Animations::Simple _a_show;
Window::SlideDirection _showDirection = Window::SlideDirection();
QPixmap _cacheUnder, _cacheOver;
ShowAnimation _showAnimationType = ShowAnimation::External;
Ui::Animations::Simple _scrollToTopShown;
bool _scrollToTopIsShown = false;
object_ptr<Ui::HistoryDownButton> _scrollToTop;
Data::Folder *_openedFolder = nullptr;
Key _searchInChat;
History *_searchInMigrated = nullptr;
UserData *_searchFromUser = nullptr;
QString _lastFilterText;
@@ -220,3 +226,5 @@ private:
int _draggingScrollDelta = 0;
};
} // namespace Dialogs