/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "boxes/abstract_box.h" #include "base/timer.h" #include "history/view/history_view_schedule_box.h" #include "ui/chat/forward_options_box.h" #include "ui/effects/animations.h" #include "ui/effects/round_checkbox.h" #include "mtproto/sender.h" namespace style { struct MultiSelect; struct InputField; struct PeerList; } // namespace style namespace SendMenu { enum class Type; } // namespace SendMenu namespace Window { class SessionController; } // namespace Window namespace Api { struct SendOptions; } // namespace Api namespace Main { class Session; } // namespace Main namespace Dialogs { class Row; class IndexedList; } // namespace Dialogs namespace Data { enum class ForwardOptions; } // namespace Data namespace Ui { class MultiSelect; class InputField; struct ScrollToRequest; template class SlideWrap; class PopupMenu; } // namespace Ui QString AppendShareGameScoreUrl( not_null session, const QString &url, const FullMsgId &fullId); void ShareGameScoreByHash( not_null controller, const QString &hash); void FastShareMessage( not_null controller, not_null item); class ShareBox final : public Ui::BoxContent { public: using CopyCallback = Fn; using SubmitCallback = Fn>&&, TextWithTags&&, Api::SendOptions, Data::ForwardOptions option)>; using FilterCallback = Fn; struct Descriptor { not_null session; CopyCallback copyCallback; SubmitCallback submitCallback; FilterCallback filterCallback; object_ptr bottomWidget = { nullptr }; rpl::producer copyLinkText; const style::MultiSelect *stMultiSelect = nullptr; const style::InputField *stComment = nullptr; const style::PeerList *st = nullptr; const style::InputField *stLabel = nullptr; struct { int messagesCount = 0; bool show = false; bool hasCaptions = false; } forwardOptions; HistoryView::ScheduleBoxStyleArgs scheduleBoxStyle; }; ShareBox(QWidget*, Descriptor &&descriptor); protected: void prepare() override; void setInnerFocus() override; void resizeEvent(QResizeEvent *e) override; void keyPressEvent(QKeyEvent *e) override; private: void prepareCommentField(); void scrollAnimationCallback(); void submit(Api::SendOptions options); void submitSilent(); void submitScheduled(); void copyLink(); bool searchByUsername(bool useCache = false); SendMenu::Type sendMenuType() const; void scrollTo(Ui::ScrollToRequest request); void needSearchByUsername(); void applyFilterUpdate(const QString &query); void selectedChanged(); void createButtons(); int getTopScrollSkip() const; int getBottomScrollSkip() const; int contentHeight() const; void updateScrollSkips(); void addPeerToMultiSelect(PeerData *peer, bool skipAnimation = false); void innerSelectedChanged(PeerData *peer, bool checked); void peopleDone( const MTPcontacts_Found &result, mtpRequestId requestId); void peopleFail(const MTP::Error &error, mtpRequestId requestId); void showMenu(not_null parent); Descriptor _descriptor; MTP::Sender _api; std::shared_ptr _show; object_ptr _select; object_ptr> _comment; object_ptr _bottomWidget; base::unique_qptr _menu; Ui::ForwardOptions _forwardOptions; class Inner; QPointer _inner; bool _hasSelected = false; rpl::variable _copyLinkText; base::Timer _searchTimer; QString _peopleQuery; bool _peopleFull = false; mtpRequestId _peopleRequest = 0; using PeopleCache = QMap; PeopleCache _peopleCache; using PeopleQueries = QMap; PeopleQueries _peopleQueries; Ui::Animations::Simple _scrollAnimation; };