2017-08-01 12:01:42 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-08-01 12:01:42 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "window/section_widget.h"
|
|
|
|
#include "ui/widgets/scroll_area.h"
|
2018-02-14 19:38:01 +00:00
|
|
|
#include "dialogs/dialogs_key.h"
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
class DialogsInner;
|
|
|
|
|
|
|
|
namespace Dialogs {
|
2018-01-04 17:15:04 +00:00
|
|
|
struct RowDescriptor;
|
2017-08-01 12:01:42 +00:00
|
|
|
class Row;
|
|
|
|
class FakeRow;
|
|
|
|
class IndexedList;
|
2018-01-13 12:45:11 +00:00
|
|
|
class Key;
|
2017-08-01 12:01:42 +00:00
|
|
|
} // namespace Dialogs
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class IconButton;
|
|
|
|
class PopupMenu;
|
|
|
|
class DropdownMenu;
|
|
|
|
class FlatButton;
|
|
|
|
class FlatInput;
|
|
|
|
class CrossButton;
|
|
|
|
template <typename Widget>
|
2017-09-30 18:26:45 +00:00
|
|
|
class FadeWrapScaled;
|
2017-08-01 12:01:42 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Window {
|
|
|
|
class Controller;
|
2018-05-07 17:44:33 +00:00
|
|
|
class ConnectingWidget;
|
2017-08-01 12:01:42 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
|
|
|
enum DialogsSearchRequestType {
|
|
|
|
DialogsSearchFromStart,
|
|
|
|
DialogsSearchFromOffset,
|
|
|
|
DialogsSearchPeerFromStart,
|
|
|
|
DialogsSearchPeerFromOffset,
|
|
|
|
DialogsSearchMigratedFromStart,
|
|
|
|
DialogsSearchMigratedFromOffset,
|
|
|
|
};
|
|
|
|
|
|
|
|
class DialogsWidget : public Window::AbstractSectionWidget, public RPCSender {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-08-17 08:31:24 +00:00
|
|
|
DialogsWidget(QWidget *parent, not_null<Window::Controller*> controller);
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
void updateDragInScroll(bool inScroll);
|
|
|
|
|
2018-01-22 17:39:20 +00:00
|
|
|
void searchInChat(Dialogs::Key chat);
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
void loadDialogs();
|
|
|
|
void loadPinnedDialogs();
|
2018-01-05 15:57:18 +00:00
|
|
|
void createDialog(Dialogs::Key key);
|
|
|
|
void removeDialog(Dialogs::Key key);
|
2018-01-22 17:39:20 +00:00
|
|
|
void repaintDialogRow(Dialogs::Mode list, not_null<Dialogs::Row*> row);
|
|
|
|
void repaintDialogRow(not_null<History*> history, MsgId messageId);
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
void dialogsToUp();
|
|
|
|
|
|
|
|
void startWidthAnimation();
|
|
|
|
void stopWidthAnimation();
|
|
|
|
|
|
|
|
bool hasTopBarShadow() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
void showAnimated(Window::SlideDirection direction, const Window::SectionSlideParams ¶ms);
|
|
|
|
void showFast();
|
|
|
|
|
|
|
|
void destroyData();
|
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
Dialogs::RowDescriptor chatListEntryBefore(
|
|
|
|
const Dialogs::RowDescriptor &which) const;
|
|
|
|
Dialogs::RowDescriptor chatListEntryAfter(
|
|
|
|
const Dialogs::RowDescriptor &which) const;
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2018-01-04 17:15:04 +00:00
|
|
|
void scrollToPeer(not_null<History*> history, MsgId msgId);
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
Dialogs::IndexedList *contactsList();
|
|
|
|
Dialogs::IndexedList *dialogsList();
|
|
|
|
Dialogs::IndexedList *contactsNoDialogsList();
|
|
|
|
|
2018-02-14 19:38:01 +00:00
|
|
|
void searchMessages(const QString &query, Dialogs::Key inChat = {});
|
2017-08-01 12:01:42 +00:00
|
|
|
void onSearchMore();
|
|
|
|
|
|
|
|
// Float player interface.
|
2017-09-16 16:53:41 +00:00
|
|
|
bool wheelEventFromFloatPlayer(QEvent *e) override;
|
|
|
|
QRect rectForFloatPlayer() const override;
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
void notify_historyMuteUpdated(History *history);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void cancelled();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onDraggingScrollDelta(int delta);
|
|
|
|
|
|
|
|
void onCancel();
|
|
|
|
void onListScroll();
|
|
|
|
void activate();
|
|
|
|
void onFilterUpdate(bool force = false);
|
|
|
|
bool onCancelSearch();
|
2018-02-14 19:38:01 +00:00
|
|
|
void onCancelSearchInChat();
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
void onFilterCursorMoved(int from = -1, int to = -1);
|
|
|
|
void onCompleteHashtag(QString tag);
|
|
|
|
|
|
|
|
void onDialogMoved(int movedFrom, int movedTo);
|
|
|
|
bool onSearchMessages(bool searchCache = false);
|
|
|
|
void onNeedSearchMessages();
|
|
|
|
|
|
|
|
void onChooseByDrag();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void onDraggingScrollTimer();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e) override;
|
|
|
|
void dragMoveEvent(QDragMoveEvent *e) override;
|
|
|
|
void dragLeaveEvent(QDragLeaveEvent *e) override;
|
|
|
|
void dropEvent(QDropEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void animationCallback();
|
2018-01-03 18:00:11 +00:00
|
|
|
void dialogsReceived(
|
|
|
|
const MTPmessages_Dialogs &result,
|
|
|
|
mtpRequestId requestId);
|
|
|
|
void pinnedDialogsReceived(
|
|
|
|
const MTPmessages_PeerDialogs &result,
|
|
|
|
mtpRequestId requestId);
|
2018-01-22 10:58:11 +00:00
|
|
|
void searchReceived(
|
|
|
|
DialogsSearchRequestType type,
|
|
|
|
const MTPmessages_Messages &result,
|
|
|
|
mtpRequestId requestId);
|
|
|
|
void peerSearchReceived(
|
|
|
|
const MTPcontacts_Found &result,
|
|
|
|
mtpRequestId requestId);
|
2018-01-03 18:00:11 +00:00
|
|
|
void updateDialogsOffset(
|
|
|
|
const QVector<MTPDialog> &dialogs,
|
|
|
|
const QVector<MTPMessage> &messages);
|
|
|
|
void applyReceivedDialogs(
|
|
|
|
const QVector<MTPDialog> &dialogs,
|
|
|
|
const QVector<MTPMessage> &messages);
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2018-05-07 17:44:33 +00:00
|
|
|
void setupConnectingWidget();
|
2018-03-08 13:15:56 +00:00
|
|
|
bool searchForPeersRequired(const QString &query) const;
|
2018-02-14 19:38:01 +00:00
|
|
|
void setSearchInChat(Dialogs::Key chat, UserData *from = nullptr);
|
2018-02-21 21:17:36 +00:00
|
|
|
void showJumpToDate();
|
2017-08-01 12:01:42 +00:00
|
|
|
void showSearchFrom();
|
|
|
|
void showMainMenu();
|
2017-08-01 15:55:51 +00:00
|
|
|
void clearSearchCache();
|
2017-08-01 12:01:42 +00:00
|
|
|
void updateLockUnlockVisibility();
|
|
|
|
void updateJumpToDateVisibility(bool fast = false);
|
2017-08-01 15:55:51 +00:00
|
|
|
void updateSearchFromVisibility(bool fast = false);
|
2017-08-01 12:01:42 +00:00
|
|
|
void updateControlsGeometry();
|
|
|
|
void updateForwardBar();
|
2018-04-26 16:14:21 +00:00
|
|
|
void checkUpdateStatus();
|
|
|
|
|
2017-08-01 12:01:42 +00:00
|
|
|
bool dialogsFailed(const RPCError &error, mtpRequestId req);
|
|
|
|
bool searchFailed(DialogsSearchRequestType type, const RPCError &error, mtpRequestId req);
|
|
|
|
bool peopleFailed(const RPCError &error, mtpRequestId req);
|
|
|
|
|
|
|
|
bool _dragInScroll = false;
|
|
|
|
bool _dragForward = false;
|
|
|
|
QTimer _chooseByDragTimer;
|
|
|
|
|
|
|
|
bool _dialogsFull = false;
|
|
|
|
int32 _dialogsOffsetDate = 0;
|
|
|
|
MsgId _dialogsOffsetId = 0;
|
|
|
|
PeerData *_dialogsOffsetPeer = nullptr;
|
|
|
|
mtpRequestId _dialogsRequestId = 0;
|
|
|
|
mtpRequestId _pinnedDialogsRequestId = 0;
|
|
|
|
bool _pinnedDialogsReceived = false;
|
|
|
|
|
|
|
|
object_ptr<Ui::IconButton> _forwardCancel = { nullptr };
|
|
|
|
object_ptr<Ui::IconButton> _mainMenuToggle;
|
|
|
|
object_ptr<Ui::FlatInput> _filter;
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _chooseFromUser;
|
|
|
|
object_ptr<Ui::FadeWrapScaled<Ui::IconButton>> _jumpToDate;
|
2017-08-01 12:01:42 +00:00
|
|
|
object_ptr<Ui::CrossButton> _cancelSearch;
|
|
|
|
object_ptr<Ui::IconButton> _lockUnlock;
|
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
|
|
|
QPointer<DialogsInner> _inner;
|
|
|
|
class UpdateButton;
|
|
|
|
object_ptr<UpdateButton> _updateTelegram = { nullptr };
|
2018-05-07 17:44:33 +00:00
|
|
|
base::unique_qptr<Window::ConnectingWidget> _connecting;
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
Animation _a_show;
|
|
|
|
Window::SlideDirection _showDirection;
|
|
|
|
QPixmap _cacheUnder, _cacheOver;
|
|
|
|
|
2018-02-14 19:38:01 +00:00
|
|
|
Dialogs::Key _searchInChat;
|
|
|
|
History *_searchInMigrated = nullptr;
|
2017-08-01 15:55:51 +00:00
|
|
|
UserData *_searchFromUser = nullptr;
|
2017-08-06 17:32:05 +00:00
|
|
|
QString _lastFilterText;
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
QTimer _searchTimer;
|
|
|
|
|
|
|
|
QString _peerSearchQuery;
|
|
|
|
bool _peerSearchFull = false;
|
|
|
|
mtpRequestId _peerSearchRequest = 0;
|
|
|
|
|
|
|
|
QString _searchQuery;
|
2017-08-01 15:55:51 +00:00
|
|
|
UserData *_searchQueryFrom = nullptr;
|
2017-08-01 12:01:42 +00:00
|
|
|
bool _searchFull = false;
|
|
|
|
bool _searchFullMigrated = false;
|
|
|
|
mtpRequestId _searchRequest = 0;
|
|
|
|
|
|
|
|
using SearchCache = QMap<QString, MTPmessages_Messages>;
|
|
|
|
SearchCache _searchCache;
|
|
|
|
|
|
|
|
using SearchQueries = QMap<mtpRequestId, QString>;
|
|
|
|
SearchQueries _searchQueries;
|
|
|
|
|
|
|
|
using PeerSearchCache = QMap<QString, MTPcontacts_Found>;
|
|
|
|
PeerSearchCache _peerSearchCache;
|
|
|
|
|
|
|
|
using PeerSearchQueries = QMap<mtpRequestId, QString>;
|
|
|
|
PeerSearchQueries _peerSearchQueries;
|
|
|
|
|
|
|
|
QPixmap _widthAnimationCache;
|
|
|
|
|
|
|
|
object_ptr<QTimer> _draggingScrollTimer = { nullptr };
|
|
|
|
int _draggingScrollDelta = 0;
|
|
|
|
|
|
|
|
};
|