2016-09-06 12:28:37 +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.
|
2016-09-06 12:28:37 +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
|
2016-09-06 12:28:37 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
|
|
|
#include "base/observer.h"
|
2018-11-04 07:32:26 +00:00
|
|
|
#include "base/timer.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2016-11-21 17:46:29 +00:00
|
|
|
#include "ui/effects/round_checkbox.h"
|
2020-06-11 16:09:46 +00:00
|
|
|
#include "mtproto/sender.h"
|
2016-09-06 12:28:37 +00:00
|
|
|
|
2021-03-10 17:36:21 +00:00
|
|
|
namespace style {
|
|
|
|
struct MultiSelect;
|
|
|
|
struct InputField;
|
|
|
|
struct PeerList;
|
|
|
|
} // namespace style
|
|
|
|
|
2020-08-10 12:22:54 +00:00
|
|
|
namespace SendMenu {
|
|
|
|
enum class Type;
|
|
|
|
} // namespace SendMenu
|
2019-08-28 16:46:47 +00:00
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
namespace Window {
|
|
|
|
class SessionNavigation;
|
|
|
|
} // namespace Window
|
|
|
|
|
2019-08-12 12:11:34 +00:00
|
|
|
namespace Api {
|
|
|
|
struct SendOptions;
|
|
|
|
} // namespace Api
|
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
2016-09-06 12:28:37 +00:00
|
|
|
namespace Dialogs {
|
|
|
|
class Row;
|
|
|
|
class IndexedList;
|
|
|
|
} // namespace Dialogs
|
|
|
|
|
2016-10-20 16:32:15 +00:00
|
|
|
namespace Ui {
|
2016-10-22 13:03:20 +00:00
|
|
|
class MultiSelect;
|
2018-11-04 07:32:26 +00:00
|
|
|
class InputField;
|
|
|
|
struct ScrollToRequest;
|
|
|
|
template <typename Widget>
|
|
|
|
class SlideWrap;
|
2016-10-20 16:32:15 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
QString AppendShareGameScoreUrl(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
const QString &url,
|
|
|
|
const FullMsgId &fullId);
|
|
|
|
void ShareGameScoreByHash(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
const QString &hash);
|
2016-09-07 09:04:57 +00:00
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
class ShareBox final : public Ui::BoxContent {
|
2016-09-06 12:28:37 +00:00
|
|
|
public:
|
2018-06-04 15:35:11 +00:00
|
|
|
using CopyCallback = Fn<void()>;
|
2019-07-26 16:06:22 +00:00
|
|
|
using SubmitCallback = Fn<void(
|
2019-09-13 06:06:02 +00:00
|
|
|
std::vector<not_null<PeerData*>>&&,
|
2019-07-26 16:06:22 +00:00
|
|
|
TextWithTags&&,
|
2019-08-12 12:11:34 +00:00
|
|
|
Api::SendOptions)>;
|
2018-06-04 15:35:11 +00:00
|
|
|
using FilterCallback = Fn<bool(PeerData*)>;
|
2019-07-25 18:55:11 +00:00
|
|
|
|
2021-03-10 16:38:15 +00:00
|
|
|
struct Descriptor {
|
|
|
|
not_null<Main::Session*> session;
|
|
|
|
CopyCallback copyCallback;
|
|
|
|
SubmitCallback submitCallback;
|
|
|
|
FilterCallback filterCallback;
|
|
|
|
Window::SessionNavigation *navigation = nullptr;
|
|
|
|
Fn<void(not_null<Ui::InputField*>)> initSpellchecker;
|
|
|
|
Fn<void(not_null<Ui::InputField*>)> initEditLink;
|
2021-03-10 17:06:34 +00:00
|
|
|
object_ptr<Ui::RpWidget> bottomWidget = { nullptr };
|
2021-03-12 18:22:19 +00:00
|
|
|
rpl::producer<QString> copyLinkText;
|
2021-03-10 17:36:21 +00:00
|
|
|
const style::MultiSelect *stMultiSelect = nullptr;
|
|
|
|
const style::InputField *stComment = nullptr;
|
|
|
|
const style::PeerList *st = nullptr;
|
2021-03-10 16:38:15 +00:00
|
|
|
};
|
|
|
|
ShareBox(QWidget*, Descriptor &&descriptor);
|
2016-09-06 12:28:37 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
2016-09-06 12:28:37 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
|
2016-09-06 12:28:37 +00:00
|
|
|
private:
|
2018-11-04 07:32:26 +00:00
|
|
|
void prepareCommentField();
|
2016-12-07 13:32:25 +00:00
|
|
|
void scrollAnimationCallback();
|
|
|
|
|
2019-08-12 12:11:34 +00:00
|
|
|
void submit(Api::SendOptions options);
|
|
|
|
void submitSilent();
|
|
|
|
void submitScheduled();
|
2018-11-04 07:32:26 +00:00
|
|
|
void copyLink();
|
|
|
|
bool searchByUsername(bool useCache = false);
|
|
|
|
|
2020-08-10 12:22:54 +00:00
|
|
|
SendMenu::Type sendMenuType() const;
|
2019-08-28 16:46:47 +00:00
|
|
|
|
2018-11-04 07:32:26 +00:00
|
|
|
void scrollTo(Ui::ScrollToRequest request);
|
|
|
|
void needSearchByUsername();
|
2018-12-29 08:11:54 +00:00
|
|
|
void applyFilterUpdate(const QString &query);
|
2018-11-04 07:32:26 +00:00
|
|
|
void selectedChanged();
|
2016-12-13 17:07:56 +00:00
|
|
|
void createButtons();
|
2016-10-22 13:03:20 +00:00
|
|
|
int getTopScrollSkip() const;
|
2018-11-04 07:32:26 +00:00
|
|
|
int getBottomScrollSkip() const;
|
|
|
|
int contentHeight() const;
|
2016-10-22 13:03:20 +00:00
|
|
|
void updateScrollSkips();
|
|
|
|
|
|
|
|
void addPeerToMultiSelect(PeerData *peer, bool skipAnimation = false);
|
2018-11-04 07:32:26 +00:00
|
|
|
void innerSelectedChanged(PeerData *peer, bool checked);
|
2016-09-06 12:28:37 +00:00
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
void peopleDone(
|
2018-01-22 10:58:11 +00:00
|
|
|
const MTPcontacts_Found &result,
|
|
|
|
mtpRequestId requestId);
|
2021-03-12 12:48:00 +00:00
|
|
|
void peopleFail(const MTP::Error &error, mtpRequestId requestId);
|
2016-09-06 12:28:37 +00:00
|
|
|
|
2021-03-10 16:38:15 +00:00
|
|
|
Descriptor _descriptor;
|
2020-06-11 16:09:46 +00:00
|
|
|
MTP::Sender _api;
|
2019-07-25 18:55:11 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::MultiSelect> _select;
|
2018-11-04 07:32:26 +00:00
|
|
|
object_ptr<Ui::SlideWrap<Ui::InputField>> _comment;
|
2021-03-10 17:06:34 +00:00
|
|
|
object_ptr<Ui::RpWidget> _bottomWidget;
|
2016-09-06 12:28:37 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class Inner;
|
|
|
|
QPointer<Inner> _inner;
|
2016-09-06 12:28:37 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
bool _hasSelected = false;
|
2021-03-12 18:22:19 +00:00
|
|
|
rpl::variable<QString> _copyLinkText;
|
2016-09-06 12:28:37 +00:00
|
|
|
|
2018-11-04 07:32:26 +00:00
|
|
|
base::Timer _searchTimer;
|
2016-09-06 12:28:37 +00:00
|
|
|
QString _peopleQuery;
|
|
|
|
bool _peopleFull = false;
|
|
|
|
mtpRequestId _peopleRequest = 0;
|
|
|
|
|
|
|
|
using PeopleCache = QMap<QString, MTPcontacts_Found>;
|
|
|
|
PeopleCache _peopleCache;
|
|
|
|
|
|
|
|
using PeopleQueries = QMap<mtpRequestId, QString>;
|
|
|
|
PeopleQueries _peopleQueries;
|
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _scrollAnimation;
|
2016-09-06 14:45:10 +00:00
|
|
|
|
2016-09-06 12:28:37 +00:00
|
|
|
};
|