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"
|
2018-11-04 07:32:26 +00:00
|
|
|
#include "base/timer.h"
|
2022-03-06 09:40:51 +00:00
|
|
|
#include "history/view/history_view_schedule_box.h"
|
2022-02-02 21:58:21 +00:00
|
|
|
#include "ui/chat/forward_options_box.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
|
|
|
|
2022-12-02 11:07:12 +00:00
|
|
|
class History;
|
|
|
|
|
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 {
|
2022-02-23 06:59:51 +00:00
|
|
|
class SessionController;
|
2019-07-25 18:55:11 +00:00
|
|
|
} // 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
|
|
|
|
|
2022-02-02 21:58:21 +00:00
|
|
|
namespace Data {
|
|
|
|
enum class ForwardOptions;
|
2022-11-01 11:17:13 +00:00
|
|
|
class Thread;
|
2022-02-02 21:58:21 +00:00
|
|
|
} // namespace Data
|
|
|
|
|
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;
|
2022-02-02 21:58:21 +00:00
|
|
|
class PopupMenu;
|
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(
|
2022-02-23 06:59:51 +00:00
|
|
|
not_null<Window::SessionController*> controller,
|
2019-07-25 18:55:11 +00:00
|
|
|
const QString &hash);
|
2022-02-23 07:37:59 +00:00
|
|
|
void FastShareMessage(
|
|
|
|
not_null<Window::SessionController*> controller,
|
|
|
|
not_null<HistoryItem*> item);
|
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(
|
2022-11-01 11:17:13 +00:00
|
|
|
std::vector<not_null<Data::Thread*>>&&,
|
2019-07-26 16:06:22 +00:00
|
|
|
TextWithTags&&,
|
2022-02-02 21:58:21 +00:00
|
|
|
Api::SendOptions,
|
2022-12-02 11:07:12 +00:00
|
|
|
Data::ForwardOptions)>;
|
2022-11-01 11:17:13 +00:00
|
|
|
using FilterCallback = Fn<bool(not_null<Data::Thread*>)>;
|
2019-07-25 18:55:11 +00:00
|
|
|
|
2022-12-02 11:07:12 +00:00
|
|
|
[[nodiscard]] static SubmitCallback DefaultForwardCallback(
|
|
|
|
std::shared_ptr<Ui::Show> show,
|
|
|
|
not_null<History*> history,
|
|
|
|
MessageIdsList msgIds);
|
|
|
|
|
2021-03-10 16:38:15 +00:00
|
|
|
struct Descriptor {
|
|
|
|
not_null<Main::Session*> session;
|
|
|
|
CopyCallback copyCallback;
|
|
|
|
SubmitCallback submitCallback;
|
|
|
|
FilterCallback filterCallback;
|
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;
|
2022-03-14 10:39:50 +00:00
|
|
|
const style::InputField *stLabel = nullptr;
|
2022-02-02 21:58:21 +00:00
|
|
|
struct {
|
|
|
|
int messagesCount = 0;
|
|
|
|
bool show = false;
|
|
|
|
bool hasCaptions = false;
|
|
|
|
} forwardOptions;
|
2022-03-06 09:40:51 +00:00
|
|
|
HistoryView::ScheduleBoxStyleArgs scheduleBoxStyle;
|
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();
|
2023-04-22 18:26:09 +00:00
|
|
|
void submitWhenOnline();
|
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();
|
|
|
|
|
2022-11-01 11:17:13 +00:00
|
|
|
void addPeerToMultiSelect(not_null<Data::Thread*> thread);
|
|
|
|
void innerSelectedChanged(not_null<Data::Thread*> thread, 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
|
|
|
|
2022-02-02 21:58:21 +00:00
|
|
|
void showMenu(not_null<Ui::RpWidget*> parent);
|
|
|
|
|
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
|
|
|
|
2022-02-02 21:58:21 +00:00
|
|
|
base::unique_qptr<Ui::PopupMenu> _menu;
|
|
|
|
Ui::ForwardOptions _forwardOptions;
|
|
|
|
|
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
|
|
|
};
|