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
|
|
|
|
|
2019-08-06 14:43:26 +00:00
|
|
|
#include "dialogs/dialogs_key.h"
|
2017-08-01 12:01:42 +00:00
|
|
|
#include "window/section_widget.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2017-08-01 12:01:42 +00:00
|
|
|
#include "ui/widgets/scroll_area.h"
|
2019-04-05 08:28:07 +00:00
|
|
|
#include "ui/special_buttons.h"
|
2019-08-06 14:43:26 +00:00
|
|
|
#include "api/api_single_message_search.h"
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2019-04-24 14:12:35 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
class TopBarWidget;
|
|
|
|
} // namespace HistoryView
|
|
|
|
|
2017-08-01 12:01:42 +00:00
|
|
|
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 {
|
2019-06-06 10:21:40 +00:00
|
|
|
class SessionController;
|
2019-02-10 16:29:55 +00:00
|
|
|
class ConnectionState;
|
2017-08-01 12:01:42 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
2019-04-24 10:15:10 +00:00
|
|
|
namespace Dialogs {
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
enum class Mode;
|
2019-04-24 10:15:10 +00:00
|
|
|
struct RowDescriptor;
|
|
|
|
class Row;
|
|
|
|
class FakeRow;
|
|
|
|
class Key;
|
|
|
|
struct ChosenRow;
|
|
|
|
class InnerWidget;
|
|
|
|
enum class SearchRequestType;
|
|
|
|
|
|
|
|
class Widget : public Window::AbstractSectionWidget, public RPCSender {
|
2017-08-01 12:01:42 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2019-06-06 10:21:40 +00:00
|
|
|
Widget(QWidget *parent, not_null<Window::SessionController*> controller);
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
void updateDragInScroll(bool inScroll);
|
|
|
|
|
2019-04-24 10:15:10 +00:00
|
|
|
void searchInChat(Key chat);
|
2019-04-24 14:12:35 +00:00
|
|
|
void setInnerFocus();
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2019-04-24 10:15:10 +00:00
|
|
|
void refreshDialog(Key key);
|
|
|
|
void removeDialog(Key key);
|
|
|
|
void repaintDialogRow(Mode list, not_null<Row*> row);
|
|
|
|
void repaintDialogRow(RowDescriptor row);
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2019-04-05 08:28:07 +00:00
|
|
|
void jumpToTop();
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
void startWidthAnimation();
|
|
|
|
void stopWidthAnimation();
|
|
|
|
|
|
|
|
bool hasTopBarShadow() const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
void showAnimated(Window::SlideDirection direction, const Window::SectionSlideParams ¶ms);
|
|
|
|
void showFast();
|
|
|
|
|
2019-04-24 10:15:10 +00:00
|
|
|
void scrollToEntry(const RowDescriptor &entry);
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2019-04-24 10:15:10 +00:00
|
|
|
void searchMessages(const QString &query, 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);
|
|
|
|
|
2019-04-24 10:15:10 +00:00
|
|
|
~Widget();
|
2019-02-11 12:55:54 +00:00
|
|
|
|
2017-08-01 12:01:42 +00:00
|
|
|
signals:
|
|
|
|
void cancelled();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onDraggingScrollDelta(int delta);
|
|
|
|
|
|
|
|
void onListScroll();
|
|
|
|
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:
|
2019-04-24 10:15:10 +00:00
|
|
|
enum class ShowAnimation {
|
|
|
|
External,
|
|
|
|
Internal,
|
|
|
|
};
|
|
|
|
|
2017-08-01 12:01:42 +00:00
|
|
|
void animationCallback();
|
2018-01-22 10:58:11 +00:00
|
|
|
void searchReceived(
|
2019-04-24 10:15:10 +00:00
|
|
|
SearchRequestType type,
|
2018-01-22 10:58:11 +00:00
|
|
|
const MTPmessages_Messages &result,
|
|
|
|
mtpRequestId requestId);
|
|
|
|
void peerSearchReceived(
|
|
|
|
const MTPcontacts_Found &result,
|
|
|
|
mtpRequestId requestId);
|
2019-05-01 12:09:16 +00:00
|
|
|
void escape();
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2018-12-30 08:40:25 +00:00
|
|
|
void setupSupportMode();
|
2018-05-07 17:44:33 +00:00
|
|
|
void setupConnectingWidget();
|
2018-03-08 13:15:56 +00:00
|
|
|
bool searchForPeersRequired(const QString &query) const;
|
2019-04-24 10:15:10 +00:00
|
|
|
void setSearchInChat(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();
|
2019-04-24 10:15:10 +00:00
|
|
|
void updateControlsVisibility(bool fast = false);
|
2017-08-01 12:01:42 +00:00
|
|
|
void updateLockUnlockVisibility();
|
2019-04-24 10:15:10 +00:00
|
|
|
void updateLoadMoreChatsVisibility();
|
2017-08-01 12:01:42 +00:00
|
|
|
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();
|
2019-04-24 14:12:35 +00:00
|
|
|
void refreshFolderTopBar();
|
2017-08-01 12:01:42 +00:00
|
|
|
void updateForwardBar();
|
2018-04-26 16:14:21 +00:00
|
|
|
void checkUpdateStatus();
|
2019-04-24 10:15:10 +00:00
|
|
|
void changeOpenedFolder(Data::Folder *folder, anim::type animated);
|
|
|
|
QPixmap grabForFolderSlideAnimation();
|
|
|
|
void startSlideAnimation();
|
2018-04-26 16:14:21 +00:00
|
|
|
|
2019-06-17 13:29:07 +00:00
|
|
|
void fullSearchRefreshOn(rpl::producer<> events);
|
2018-12-29 08:11:54 +00:00
|
|
|
void applyFilterUpdate(bool force = false);
|
2019-04-16 16:28:41 +00:00
|
|
|
void refreshLoadMoreButton(bool mayBlock, bool isBlocked);
|
|
|
|
void loadMoreBlockedByDate();
|
2018-11-09 13:54:34 +00:00
|
|
|
|
2019-04-24 10:15:10 +00:00
|
|
|
bool searchFailed(SearchRequestType type, const RPCError &error, mtpRequestId req);
|
2017-08-01 12:01:42 +00:00
|
|
|
bool peopleFailed(const RPCError &error, mtpRequestId req);
|
|
|
|
|
2019-04-24 10:15:10 +00:00
|
|
|
void scrollToTop();
|
|
|
|
void setupScrollUpButton();
|
|
|
|
void updateScrollUpVisibility();
|
|
|
|
void startScrollUpButtonAnimation(bool shown);
|
|
|
|
void updateScrollUpPosition();
|
|
|
|
|
2017-08-01 12:01:42 +00:00
|
|
|
bool _dragInScroll = false;
|
|
|
|
bool _dragForward = false;
|
|
|
|
QTimer _chooseByDragTimer;
|
|
|
|
|
|
|
|
object_ptr<Ui::IconButton> _forwardCancel = { nullptr };
|
2019-04-24 10:15:10 +00:00
|
|
|
object_ptr<Ui::RpWidget> _searchControls;
|
2019-04-24 14:12:35 +00:00
|
|
|
object_ptr<HistoryView::TopBarWidget> _folderTopBar = { nullptr } ;
|
2017-08-01 12:01:42 +00:00
|
|
|
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;
|
2019-04-24 10:15:10 +00:00
|
|
|
QPointer<InnerWidget> _inner;
|
2018-11-09 13:54:34 +00:00
|
|
|
class BottomButton;
|
|
|
|
object_ptr<BottomButton> _updateTelegram = { nullptr };
|
|
|
|
object_ptr<BottomButton> _loadMoreChats = { nullptr };
|
2019-02-10 16:29:55 +00:00
|
|
|
std::unique_ptr<Window::ConnectionState> _connecting;
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _scrollToAnimation;
|
|
|
|
Ui::Animations::Simple _a_show;
|
2019-04-24 10:15:10 +00:00
|
|
|
Window::SlideDirection _showDirection = Window::SlideDirection();
|
2017-08-01 12:01:42 +00:00
|
|
|
QPixmap _cacheUnder, _cacheOver;
|
2019-04-24 10:15:10 +00:00
|
|
|
ShowAnimation _showAnimationType = ShowAnimation::External;
|
2017-08-01 12:01:42 +00:00
|
|
|
|
2019-04-05 08:28:07 +00:00
|
|
|
Ui::Animations::Simple _scrollToTopShown;
|
|
|
|
bool _scrollToTopIsShown = false;
|
|
|
|
object_ptr<Ui::HistoryDownButton> _scrollToTop;
|
|
|
|
|
2019-04-24 10:15:10 +00:00
|
|
|
Data::Folder *_openedFolder = nullptr;
|
|
|
|
Key _searchInChat;
|
2018-02-14 19:38:01 +00:00
|
|
|
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;
|
2019-05-20 19:04:24 +00:00
|
|
|
int32 _searchNextRate = 0;
|
2017-08-01 12:01:42 +00:00
|
|
|
bool _searchFull = false;
|
|
|
|
bool _searchFullMigrated = false;
|
|
|
|
mtpRequestId _searchRequest = 0;
|
|
|
|
|
2019-08-06 14:43:26 +00:00
|
|
|
QMap<QString, MTPmessages_Messages> _searchCache;
|
|
|
|
Api::SingleMessageSearch _singleMessageSearch;
|
|
|
|
QMap<mtpRequestId, QString> _searchQueries;
|
|
|
|
QMap<QString, MTPcontacts_Found> _peerSearchCache;
|
|
|
|
QMap<mtpRequestId, QString> _peerSearchQueries;
|
2017-08-01 12:01:42 +00:00
|
|
|
|
|
|
|
QPixmap _widthAnimationCache;
|
|
|
|
|
|
|
|
object_ptr<QTimer> _draggingScrollTimer = { nullptr };
|
|
|
|
int _draggingScrollDelta = 0;
|
|
|
|
|
|
|
|
};
|
2019-04-24 10:15:10 +00:00
|
|
|
|
|
|
|
} // namespace Dialogs
|