2017-08-14 12:53:49 +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-14 12:53:49 +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-14 12:53:49 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-08-14 12:48:11 +00:00
|
|
|
#include "boxes/peer_list_box.h"
|
|
|
|
#include "base/flat_set.h"
|
2017-11-30 17:33:27 +00:00
|
|
|
#include "base/weak_ptr.h"
|
2017-08-14 12:53:49 +00:00
|
|
|
|
2017-08-15 09:41:53 +00:00
|
|
|
// Not used for now.
|
|
|
|
//
|
|
|
|
//class MembersAddButton : public Ui::RippleButton {
|
|
|
|
//public:
|
|
|
|
// MembersAddButton(QWidget *parent, const style::TwoIconButton &st);
|
|
|
|
//
|
|
|
|
//protected:
|
|
|
|
// void paintEvent(QPaintEvent *e) override;
|
|
|
|
//
|
|
|
|
// QImage prepareRippleMask() const override;
|
|
|
|
// QPoint prepareRippleStartPosition() const override;
|
|
|
|
//
|
|
|
|
//private:
|
|
|
|
// const style::TwoIconButton &_st;
|
|
|
|
//
|
|
|
|
//};
|
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
class History;
|
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
namespace Window {
|
2020-10-07 17:08:50 +00:00
|
|
|
class SessionController;
|
2019-07-25 18:55:11 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
2020-10-07 17:08:50 +00:00
|
|
|
[[nodiscard]] object_ptr<Ui::BoxContent> PrepareContactsBox(
|
|
|
|
not_null<Window::SessionController*> sessionController);
|
|
|
|
|
2017-08-14 12:53:49 +00:00
|
|
|
class PeerListRowWithLink : public PeerListRow {
|
|
|
|
public:
|
|
|
|
using PeerListRow::PeerListRow;
|
|
|
|
|
|
|
|
void setActionLink(const QString &action);
|
|
|
|
|
2017-10-10 20:39:44 +00:00
|
|
|
void lazyInitialize(const style::PeerListItem &st) override;
|
2017-08-14 12:53:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void refreshActionLink();
|
2021-10-13 12:37:38 +00:00
|
|
|
QSize rightActionSize() const override;
|
|
|
|
QMargins rightActionMargins() const override;
|
|
|
|
void rightActionPaint(
|
2017-11-07 17:53:00 +00:00
|
|
|
Painter &p,
|
|
|
|
int x,
|
|
|
|
int y,
|
|
|
|
int outerWidth,
|
|
|
|
bool selected,
|
|
|
|
bool actionSelected) override;
|
2017-08-14 12:53:49 +00:00
|
|
|
|
|
|
|
QString _action;
|
|
|
|
int _actionWidth = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-11-27 08:02:56 +00:00
|
|
|
class PeerListGlobalSearchController : public PeerListSearchController {
|
2017-08-14 12:53:49 +00:00
|
|
|
public:
|
2020-12-21 19:43:23 +00:00
|
|
|
explicit PeerListGlobalSearchController(not_null<Main::Session*> session);
|
2017-08-14 12:53:49 +00:00
|
|
|
|
|
|
|
void searchQuery(const QString &query) override;
|
|
|
|
bool isLoading() override;
|
|
|
|
bool loadMoreRows() override {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool searchInCache();
|
|
|
|
void searchOnServer();
|
|
|
|
void searchDone(const MTPcontacts_Found &result, mtpRequestId requestId);
|
|
|
|
|
2020-12-21 19:43:23 +00:00
|
|
|
const not_null<Main::Session*> _session;
|
2019-11-27 08:02:56 +00:00
|
|
|
MTP::Sender _api;
|
2017-08-14 12:53:49 +00:00
|
|
|
base::Timer _timer;
|
|
|
|
QString _query;
|
|
|
|
mtpRequestId _requestId = 0;
|
|
|
|
std::map<QString, MTPcontacts_Found> _cache;
|
|
|
|
std::map<mtpRequestId, QString> _queries;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-04-18 08:28:43 +00:00
|
|
|
class ChatsListBoxController : public PeerListController {
|
2017-08-14 12:53:49 +00:00
|
|
|
public:
|
|
|
|
class Row : public PeerListRow {
|
|
|
|
public:
|
2018-01-13 12:45:11 +00:00
|
|
|
Row(not_null<History*> history);
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<History*> history() const {
|
2017-08-14 12:53:49 +00:00
|
|
|
return _history;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<History*> _history;
|
2017-08-14 12:53:49 +00:00
|
|
|
|
|
|
|
};
|
2020-03-20 14:56:18 +00:00
|
|
|
|
2020-12-21 19:43:23 +00:00
|
|
|
ChatsListBoxController(not_null<Main::Session*> session);
|
2020-03-20 14:56:18 +00:00
|
|
|
ChatsListBoxController(
|
|
|
|
std::unique_ptr<PeerListSearchController> searchController);
|
|
|
|
|
|
|
|
void prepare() override final;
|
|
|
|
std::unique_ptr<PeerListRow> createSearchRow(not_null<PeerData*> peer) override final;
|
|
|
|
|
|
|
|
protected:
|
2017-08-17 08:31:24 +00:00
|
|
|
virtual std::unique_ptr<Row> createRow(not_null<History*> history) = 0;
|
2017-08-14 12:53:49 +00:00
|
|
|
virtual void prepareViewHook() = 0;
|
2017-08-17 08:31:24 +00:00
|
|
|
virtual void updateRowHook(not_null<Row*> row) {
|
2017-08-14 12:53:49 +00:00
|
|
|
}
|
2017-08-15 09:35:19 +00:00
|
|
|
virtual QString emptyBoxText() const;
|
2017-08-14 12:53:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void rebuildRows();
|
|
|
|
void checkForEmptyRows();
|
2017-08-17 08:31:24 +00:00
|
|
|
bool appendRow(not_null<History*> history);
|
2017-08-14 12:53:49 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2019-04-18 08:28:43 +00:00
|
|
|
class ContactsBoxController : public PeerListController {
|
2017-08-14 12:53:49 +00:00
|
|
|
public:
|
2020-12-21 19:43:23 +00:00
|
|
|
explicit ContactsBoxController(not_null<Main::Session*> session);
|
2019-01-13 13:28:05 +00:00
|
|
|
ContactsBoxController(
|
2020-12-21 19:43:23 +00:00
|
|
|
not_null<Main::Session*> session,
|
2019-07-25 18:55:11 +00:00
|
|
|
std::unique_ptr<PeerListSearchController> searchController);
|
2017-08-14 12:53:49 +00:00
|
|
|
|
2020-12-21 19:43:23 +00:00
|
|
|
[[nodiscard]] Main::Session &session() const override;
|
2017-08-14 12:53:49 +00:00
|
|
|
void prepare() override final;
|
2020-12-21 19:43:23 +00:00
|
|
|
[[nodiscard]] std::unique_ptr<PeerListRow> createSearchRow(
|
|
|
|
not_null<PeerData*> peer) override final;
|
2017-08-17 08:31:24 +00:00
|
|
|
void rowClicked(not_null<PeerListRow*> row) override;
|
2017-08-14 12:53:49 +00:00
|
|
|
|
|
|
|
protected:
|
2017-08-17 08:31:24 +00:00
|
|
|
virtual std::unique_ptr<PeerListRow> createRow(not_null<UserData*> user);
|
2017-08-14 12:53:49 +00:00
|
|
|
virtual void prepareViewHook() {
|
|
|
|
}
|
2017-08-17 08:31:24 +00:00
|
|
|
virtual void updateRowHook(not_null<PeerListRow*> row) {
|
2017-08-14 12:53:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
void rebuildRows();
|
|
|
|
void checkForEmptyRows();
|
2017-08-17 08:31:24 +00:00
|
|
|
bool appendRow(not_null<UserData*> user);
|
2017-08-14 12:53:49 +00:00
|
|
|
|
2020-12-21 19:43:23 +00:00
|
|
|
const not_null<Main::Session*> _session;
|
2019-07-25 18:55:11 +00:00
|
|
|
|
2017-08-14 12:53:49 +00:00
|
|
|
};
|
2017-08-14 12:48:11 +00:00
|
|
|
|
2018-11-30 05:45:22 +00:00
|
|
|
class AddBotToGroupBoxController
|
|
|
|
: public ChatsListBoxController
|
|
|
|
, public base::has_weak_ptr {
|
2017-08-15 09:35:19 +00:00
|
|
|
public:
|
2020-12-21 19:43:23 +00:00
|
|
|
static void Start(not_null<UserData*> bot);
|
2017-08-15 09:35:19 +00:00
|
|
|
|
2020-12-21 19:43:23 +00:00
|
|
|
explicit AddBotToGroupBoxController(not_null<UserData*> bot);
|
2017-08-15 09:35:19 +00:00
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
Main::Session &session() const override;
|
2017-08-17 08:31:24 +00:00
|
|
|
void rowClicked(not_null<PeerListRow*> row) override;
|
2017-08-15 09:35:19 +00:00
|
|
|
|
|
|
|
protected:
|
2017-08-17 08:31:24 +00:00
|
|
|
std::unique_ptr<Row> createRow(not_null<History*> history) override;
|
2017-08-15 09:35:19 +00:00
|
|
|
void prepareViewHook() override;
|
|
|
|
QString emptyBoxText() const override;
|
|
|
|
|
|
|
|
private:
|
2017-08-17 08:31:24 +00:00
|
|
|
static bool SharingBotGame(not_null<UserData*> bot);
|
2017-08-15 09:35:19 +00:00
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
bool needToCreateRow(not_null<PeerData*> peer) const;
|
2017-08-15 09:35:19 +00:00
|
|
|
bool sharingBotGame() const;
|
|
|
|
QString noResultsText() const;
|
|
|
|
QString descriptionText() const;
|
|
|
|
void updateLabels();
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
void shareBotGame(not_null<PeerData*> chat);
|
|
|
|
void addBotToGroup(not_null<PeerData*> chat);
|
2017-08-15 09:35:19 +00:00
|
|
|
|
2020-12-21 19:43:23 +00:00
|
|
|
const not_null<UserData*> _bot;
|
2017-08-15 09:35:19 +00:00
|
|
|
|
|
|
|
};
|
2017-11-07 13:13:41 +00:00
|
|
|
|
2018-11-30 05:45:22 +00:00
|
|
|
class ChooseRecipientBoxController
|
|
|
|
: public ChatsListBoxController
|
|
|
|
, public base::has_weak_ptr {
|
2017-11-07 13:13:41 +00:00
|
|
|
public:
|
|
|
|
ChooseRecipientBoxController(
|
2020-12-21 19:43:23 +00:00
|
|
|
not_null<Main::Session*> session,
|
2018-06-04 15:35:11 +00:00
|
|
|
FnMut<void(not_null<PeerData*>)> callback);
|
2017-11-07 13:13:41 +00:00
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
Main::Session &session() const override;
|
2017-11-07 13:13:41 +00:00
|
|
|
void rowClicked(not_null<PeerListRow*> row) override;
|
|
|
|
|
2017-12-05 14:07:01 +00:00
|
|
|
bool respectSavedMessagesChat() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-07 13:13:41 +00:00
|
|
|
protected:
|
|
|
|
void prepareViewHook() override;
|
2020-09-11 15:33:26 +00:00
|
|
|
std::unique_ptr<Row> createRow(not_null<History*> history) override;
|
2017-11-07 13:13:41 +00:00
|
|
|
|
2017-12-05 14:07:01 +00:00
|
|
|
private:
|
2020-12-21 19:43:23 +00:00
|
|
|
const not_null<Main::Session*> _session;
|
2018-06-04 15:35:11 +00:00
|
|
|
FnMut<void(not_null<PeerData*>)> _callback;
|
2017-11-07 13:13:41 +00:00
|
|
|
|
|
|
|
};
|