tdesktop/Telegram/SourceFiles/boxes/share_box.h

136 lines
3.1 KiB
C
Raw Normal View History

/*
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
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"
#include "mtproto/sender.h"
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
namespace Api {
struct SendOptions;
} // namespace Api
2019-07-25 18:55:11 +00:00
namespace Main {
class Session;
} // namespace Main
namespace Dialogs {
class Row;
class IndexedList;
} // namespace Dialogs
namespace Ui {
class MultiSelect;
2018-11-04 07:32:26 +00:00
class InputField;
struct ScrollToRequest;
template <typename Widget>
class SlideWrap;
} // 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);
class ShareBox final : public Ui::BoxContent {
public:
using CopyCallback = Fn<void()>;
2019-07-26 16:06:22 +00:00
using SubmitCallback = Fn<void(
std::vector<not_null<PeerData*>>&&,
2019-07-26 16:06:22 +00:00
TextWithTags&&,
Api::SendOptions)>;
using FilterCallback = Fn<bool(PeerData*)>;
2019-07-25 18:55:11 +00:00
2018-11-04 07:32:26 +00:00
ShareBox(
QWidget*,
2019-07-25 18:55:11 +00:00
not_null<Window::SessionNavigation*> navigation,
2018-11-04 07:32:26 +00:00
CopyCallback &&copyCallback,
SubmitCallback &&submitCallback,
FilterCallback &&filterCallback);
protected:
void prepare() override;
void setInnerFocus() override;
void resizeEvent(QResizeEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
private:
2018-11-04 07:32:26 +00:00
void prepareCommentField();
void scrollAnimationCallback();
void submit(Api::SendOptions options);
void submitSilent();
void submitScheduled();
2018-11-04 07:32:26 +00:00
void copyLink();
bool searchByUsername(bool useCache = false);
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();
void applyFilterUpdate(const QString &query);
2018-11-04 07:32:26 +00:00
void selectedChanged();
void createButtons();
int getTopScrollSkip() const;
2018-11-04 07:32:26 +00:00
int getBottomScrollSkip() const;
int contentHeight() const;
void updateScrollSkips();
void addPeerToMultiSelect(PeerData *peer, bool skipAnimation = false);
2018-11-04 07:32:26 +00:00
void innerSelectedChanged(PeerData *peer, bool checked);
void peopleDone(
const MTPcontacts_Found &result,
mtpRequestId requestId);
void peopleFail(const RPCError &error, mtpRequestId requestId);
2019-07-25 18:55:11 +00:00
const not_null<Window::SessionNavigation*> _navigation;
MTP::Sender _api;
2019-07-25 18:55:11 +00:00
CopyCallback _copyCallback;
SubmitCallback _submitCallback;
FilterCallback _filterCallback;
object_ptr<Ui::MultiSelect> _select;
2018-11-04 07:32:26 +00:00
object_ptr<Ui::SlideWrap<Ui::InputField>> _comment;
class Inner;
QPointer<Inner> _inner;
bool _hasSelected = false;
2018-11-04 07:32:26 +00:00
base::Timer _searchTimer;
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;
};