2014-05-30 08:53:19 +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.
|
2014-05-30 08:53:19 +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
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/abstract_box.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-10-28 09:20:24 +00:00
|
|
|
namespace Ui {
|
|
|
|
class Checkbox;
|
2016-11-16 10:44:06 +00:00
|
|
|
class FlatLabel;
|
2017-12-05 08:43:18 +00:00
|
|
|
class EmptyUserpic;
|
2016-10-28 09:20:24 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2015-10-03 10:09:09 +00:00
|
|
|
class InformBox;
|
2016-12-13 17:07:56 +00:00
|
|
|
class ConfirmBox : public BoxContent, public ClickHandlerHost {
|
2014-05-30 08:53:19 +00:00
|
|
|
public:
|
2018-06-04 15:35:11 +00:00
|
|
|
ConfirmBox(QWidget*, const QString &text, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
|
|
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
|
|
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
|
|
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const QString &cancelText, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
|
|
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, const QString &cancelText, FnMut<void()> confirmedCallback = FnMut<void()>(), FnMut<void()> cancelledCallback = FnMut<void()>());
|
|
|
|
ConfirmBox(QWidget*, const TextWithEntities &text, const QString &confirmText, FnMut<void()> confirmedCallback = nullptr, FnMut<void()> cancelledCallback = nullptr);
|
2016-08-16 16:53:10 +00:00
|
|
|
|
2014-12-05 13:44:27 +00:00
|
|
|
void updateLink();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
// If strict cancel is set the cancelledCallback is only called if the cancel button was pressed.
|
|
|
|
void setStrictCancel(bool strictCancel) {
|
|
|
|
_strictCancel = strictCancel;
|
2016-08-12 15:22:11 +00:00
|
|
|
}
|
|
|
|
|
2018-05-30 15:08:12 +00:00
|
|
|
void setMaxLineCount(int count);
|
|
|
|
|
2016-03-29 17:17:00 +00:00
|
|
|
// ClickHandlerHost interface
|
2016-08-16 16:53:10 +00:00
|
|
|
void clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) override;
|
|
|
|
void clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) override;
|
2016-03-29 17:17:00 +00:00
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
2017-02-11 11:24:37 +00:00
|
|
|
void leaveEventHook(QEvent *e) override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-13 17:07:56 +00:00
|
|
|
struct InformBoxTag {
|
|
|
|
};
|
2018-06-04 15:35:11 +00:00
|
|
|
ConfirmBox(const InformBoxTag &, const QString &text, const QString &doneText, Fn<void()> closedCallback);
|
|
|
|
ConfirmBox(const InformBoxTag &, const TextWithEntities &text, const QString &doneText, Fn<void()> closedCallback);
|
|
|
|
FnMut<void()> generateInformCallback(Fn<void()> closedCallback);
|
2015-10-03 10:09:09 +00:00
|
|
|
friend class InformBox;
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
void confirmed();
|
2014-12-05 13:44:27 +00:00
|
|
|
void init(const QString &text);
|
2018-04-18 15:42:02 +00:00
|
|
|
void init(const TextWithEntities &text);
|
2016-12-13 17:07:56 +00:00
|
|
|
void textUpdated();
|
2018-05-30 15:08:12 +00:00
|
|
|
void updateHover();
|
2014-12-05 13:44:27 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
QString _confirmText;
|
|
|
|
QString _cancelText;
|
|
|
|
const style::RoundButton &_confirmStyle;
|
|
|
|
bool _informative = false;
|
2014-12-05 13:44:27 +00:00
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _text;
|
2016-12-13 17:07:56 +00:00
|
|
|
int _textWidth = 0;
|
|
|
|
int _textHeight = 0;
|
2018-05-30 15:08:12 +00:00
|
|
|
int _maxLineCount = 16;
|
2014-12-05 13:44:27 +00:00
|
|
|
|
|
|
|
QPoint _lastMousePos;
|
2015-10-03 10:09:09 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
bool _confirmed = false;
|
|
|
|
bool _cancelled = false;
|
|
|
|
bool _strictCancel = false;
|
2018-06-04 15:35:11 +00:00
|
|
|
FnMut<void()> _confirmedCallback;
|
|
|
|
FnMut<void()> _cancelledCallback;
|
2016-08-12 15:22:11 +00:00
|
|
|
|
2015-10-03 10:09:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class InformBox : public ConfirmBox {
|
|
|
|
public:
|
2018-06-04 15:35:11 +00:00
|
|
|
InformBox(QWidget*, const QString &text, Fn<void()> closedCallback = nullptr);
|
|
|
|
InformBox(QWidget*, const QString &text, const QString &doneText, Fn<void()> closedCallback = nullptr);
|
|
|
|
InformBox(QWidget*, const TextWithEntities &text, Fn<void()> closedCallback = nullptr);
|
2018-06-04 18:18:52 +00:00
|
|
|
InformBox(QWidget*, const TextWithEntities &text, const QString &doneText, Fn<void()> closedCallback = nullptr);
|
2016-08-16 16:53:10 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
2015-09-10 11:20:28 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class MaxInviteBox : public BoxContent {
|
2015-09-23 17:43:08 +00:00
|
|
|
public:
|
2017-08-17 08:31:24 +00:00
|
|
|
MaxInviteBox(QWidget*, not_null<ChannelData*> channel);
|
2016-03-04 22:04:15 +00:00
|
|
|
|
2015-09-23 17:43:08 +00:00
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *e) override;
|
|
|
|
void mousePressEvent(QMouseEvent *e) override;
|
2017-02-11 11:24:37 +00:00
|
|
|
void leaveEventHook(QEvent *e) override;
|
2015-09-23 17:43:08 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void updateSelected(const QPoint &cursorGlobalPosition);
|
|
|
|
|
2017-08-17 08:31:24 +00:00
|
|
|
not_null<ChannelData*> _channel;
|
2017-07-14 12:28:08 +00:00
|
|
|
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _text;
|
2015-09-23 17:43:08 +00:00
|
|
|
int32 _textWidth, _textHeight;
|
|
|
|
|
|
|
|
QRect _invitationLink;
|
2016-12-07 13:32:25 +00:00
|
|
|
bool _linkOver = false;
|
2015-09-23 17:43:08 +00:00
|
|
|
|
|
|
|
QPoint _lastMousePos;
|
|
|
|
|
|
|
|
};
|
2016-03-04 22:04:15 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class PinMessageBox : public BoxContent, public RPCSender {
|
2016-03-10 10:15:21 +00:00
|
|
|
public:
|
2018-10-31 11:29:14 +00:00
|
|
|
PinMessageBox(QWidget*, not_null<PeerData*> peer, MsgId msgId);
|
2016-03-10 10:15:21 +00:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2017-01-02 17:11:49 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2016-03-10 10:15:21 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-13 17:07:56 +00:00
|
|
|
void pinMessage();
|
2016-03-10 10:15:21 +00:00
|
|
|
void pinDone(const MTPUpdates &updates);
|
|
|
|
bool pinFail(const RPCError &error);
|
|
|
|
|
2018-10-31 11:29:14 +00:00
|
|
|
not_null<PeerData*> _peer;
|
2016-03-10 10:15:21 +00:00
|
|
|
MsgId _msgId;
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _text;
|
2017-11-21 13:23:56 +00:00
|
|
|
object_ptr<Ui::Checkbox> _notify = { nullptr };
|
2016-03-10 10:15:21 +00:00
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
mtpRequestId _requestId = 0;
|
2016-03-10 10:15:21 +00:00
|
|
|
|
2016-03-10 15:42:01 +00:00
|
|
|
};
|
|
|
|
|
2016-12-31 15:19:22 +00:00
|
|
|
class DeleteMessagesBox : public BoxContent, public RPCSender {
|
2016-03-10 15:42:01 +00:00
|
|
|
public:
|
2017-11-24 16:28:14 +00:00
|
|
|
DeleteMessagesBox(
|
|
|
|
QWidget*,
|
|
|
|
not_null<HistoryItem*> item,
|
|
|
|
bool suggestModerateActions);
|
2017-12-06 10:13:38 +00:00
|
|
|
DeleteMessagesBox(QWidget*, MessageIdsList &&selected);
|
2019-03-21 13:48:40 +00:00
|
|
|
DeleteMessagesBox(QWidget*, not_null<PeerData*> peer, bool justClear);
|
2016-03-10 15:42:01 +00:00
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
void setDeleteConfirmedCallback(Fn<void()> callback) {
|
2018-01-26 15:40:11 +00:00
|
|
|
_deleteConfirmedCallback = std::move(callback);
|
|
|
|
}
|
|
|
|
|
2016-03-10 15:42:01 +00:00
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2017-01-02 17:11:49 +00:00
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2016-03-10 15:42:01 +00:00
|
|
|
|
|
|
|
private:
|
2019-03-21 12:49:27 +00:00
|
|
|
struct RevokeConfig {
|
|
|
|
QString checkbox;
|
|
|
|
TextWithEntities description;
|
|
|
|
};
|
2016-12-13 17:07:56 +00:00
|
|
|
void deleteAndClear();
|
2019-03-20 13:02:02 +00:00
|
|
|
PeerData *checkFromSinglePeer() const;
|
2019-03-21 12:49:27 +00:00
|
|
|
std::optional<RevokeConfig> revokeText(not_null<PeerData*> peer) const;
|
2016-12-13 17:07:56 +00:00
|
|
|
|
2019-03-21 13:48:40 +00:00
|
|
|
PeerData * const _wipeHistoryPeer = nullptr;
|
|
|
|
const bool _wipeHistoryJustClear = false;
|
2017-12-06 10:13:38 +00:00
|
|
|
const MessageIdsList _ids;
|
2016-12-31 15:19:22 +00:00
|
|
|
UserData *_moderateFrom = nullptr;
|
|
|
|
ChannelData *_moderateInChannel = nullptr;
|
2017-06-04 11:09:29 +00:00
|
|
|
bool _moderateBan = false;
|
|
|
|
bool _moderateDeleteAll = false;
|
2016-03-10 15:42:01 +00:00
|
|
|
|
2016-12-31 15:19:22 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _text = { nullptr };
|
2019-03-20 13:02:02 +00:00
|
|
|
object_ptr<Ui::Checkbox> _revoke = { nullptr };
|
2016-12-31 15:19:22 +00:00
|
|
|
object_ptr<Ui::Checkbox> _banUser = { nullptr };
|
|
|
|
object_ptr<Ui::Checkbox> _reportSpam = { nullptr };
|
|
|
|
object_ptr<Ui::Checkbox> _deleteAll = { nullptr };
|
2016-06-20 15:40:36 +00:00
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void()> _deleteConfirmedCallback;
|
2018-01-26 15:40:11 +00:00
|
|
|
|
2016-06-20 15:40:36 +00:00
|
|
|
};
|
2016-07-08 16:59:46 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class ConfirmInviteBox : public BoxContent, public RPCSender {
|
2016-07-08 16:59:46 +00:00
|
|
|
public:
|
2018-11-26 11:55:02 +00:00
|
|
|
ConfirmInviteBox(
|
|
|
|
QWidget*,
|
|
|
|
const MTPDchatInvite &data,
|
|
|
|
Fn<void()> submit);
|
2017-12-05 08:43:18 +00:00
|
|
|
~ConfirmInviteBox();
|
2016-07-08 16:59:46 +00:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-07-08 16:59:46 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
2018-11-26 11:55:02 +00:00
|
|
|
static std::vector<not_null<UserData*>> GetParticipants(
|
|
|
|
const MTPDchatInvite &data);
|
|
|
|
|
|
|
|
Fn<void()> _submit;
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _title;
|
|
|
|
object_ptr<Ui::FlatLabel> _status;
|
2019-03-22 14:19:43 +00:00
|
|
|
Image *_photo = nullptr;
|
2017-12-05 08:43:18 +00:00
|
|
|
std::unique_ptr<Ui::EmptyUserpic> _photoEmpty;
|
2018-11-26 11:55:02 +00:00
|
|
|
std::vector<not_null<UserData*>> _participants;
|
2018-10-24 13:40:37 +00:00
|
|
|
bool _isChannel = false;
|
2016-07-08 16:59:46 +00:00
|
|
|
|
|
|
|
int _userWidth = 0;
|
|
|
|
|
|
|
|
};
|
2018-12-05 08:07:17 +00:00
|
|
|
|
|
|
|
class ConfirmDontWarnBox : public BoxContent {
|
|
|
|
public:
|
|
|
|
ConfirmDontWarnBox(
|
|
|
|
QWidget*,
|
|
|
|
const QString &text,
|
|
|
|
const QString &checkbox,
|
|
|
|
const QString &confirm,
|
|
|
|
FnMut<void(bool)> callback);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
not_null<Ui::RpWidget*> setupContent(
|
|
|
|
const QString &text,
|
|
|
|
const QString &checkbox,
|
|
|
|
FnMut<void(bool)> callback);
|
|
|
|
|
|
|
|
QString _confirm;
|
|
|
|
FnMut<void()> _callback;
|
|
|
|
not_null<Ui::RpWidget*> _content;
|
|
|
|
|
|
|
|
};
|