2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
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;
|
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:
|
2017-03-17 18:44:55 +00:00
|
|
|
ConfirmBox(QWidget*, const QString &text, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
|
|
|
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
|
|
|
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
|
|
|
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const QString &cancelText, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
|
|
|
ConfirmBox(QWidget*, const QString &text, const QString &confirmText, const style::RoundButton &confirmStyle, const QString &cancelText, base::lambda_once<void()> confirmedCallback = base::lambda_once<void()>(), base::lambda_once<void()> cancelledCallback = base::lambda_once<void()>());
|
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
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
void closeHook() override;
|
2014-05-30 08:53:19 +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 {
|
|
|
|
};
|
2017-02-26 11:32:13 +00:00
|
|
|
ConfirmBox(const InformBoxTag &, const QString &text, const QString &doneText, base::lambda<void()> closedCallback);
|
2017-03-17 18:44:55 +00:00
|
|
|
base::lambda_once<void()> generateInformCallback(base::lambda<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);
|
2016-12-13 17:07:56 +00:00
|
|
|
void textUpdated();
|
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
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Text _text;
|
2016-12-13 17:07:56 +00:00
|
|
|
int _textWidth = 0;
|
|
|
|
int _textHeight = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-12-05 13:44:27 +00:00
|
|
|
void updateHover();
|
|
|
|
|
|
|
|
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;
|
2017-03-17 18:44:55 +00:00
|
|
|
base::lambda_once<void()> _confirmedCallback;
|
|
|
|
base::lambda_once<void()> _cancelledCallback;
|
2016-08-12 15:22:11 +00:00
|
|
|
|
2015-10-03 10:09:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class InformBox : public ConfirmBox {
|
|
|
|
public:
|
2017-02-26 11:32:13 +00:00
|
|
|
InformBox(QWidget*, const QString &text, base::lambda<void()> closedCallback = base::lambda<void()>());
|
|
|
|
InformBox(QWidget*, const QString &text, const QString &doneText, base::lambda<void()> closedCallback = base::lambda<void()>());
|
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:
|
2016-12-13 17:07:56 +00:00
|
|
|
MaxInviteBox(QWidget*, const QString &link);
|
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);
|
|
|
|
|
|
|
|
Text _text;
|
|
|
|
int32 _textWidth, _textHeight;
|
|
|
|
|
|
|
|
QString _link;
|
|
|
|
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 ConvertToSupergroupBox : public BoxContent, public RPCSender {
|
2016-03-04 22:04:15 +00:00
|
|
|
public:
|
2016-12-13 17:07:56 +00:00
|
|
|
ConvertToSupergroupBox(QWidget*, ChatData *chat);
|
2016-03-04 22:04:15 +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;
|
2016-03-04 22:04:15 +00:00
|
|
|
|
|
|
|
private:
|
2016-12-13 17:07:56 +00:00
|
|
|
void convertToSupergroup();
|
2016-03-04 22:04:15 +00:00
|
|
|
void convertDone(const MTPUpdates &updates);
|
|
|
|
bool convertFail(const RPCError &error);
|
|
|
|
|
|
|
|
ChatData *_chat;
|
|
|
|
Text _text, _note;
|
|
|
|
int32 _textWidth, _textHeight;
|
|
|
|
|
2016-03-10 10:15:21 +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:
|
2016-12-13 17:07:56 +00:00
|
|
|
PinMessageBox(QWidget*, ChannelData *channel, 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);
|
|
|
|
|
|
|
|
ChannelData *_channel;
|
|
|
|
MsgId _msgId;
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _text;
|
|
|
|
object_ptr<Ui::Checkbox> _notify;
|
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:
|
2016-12-31 15:19:22 +00:00
|
|
|
DeleteMessagesBox(QWidget*, HistoryItem *item, bool suggestModerateActions);
|
|
|
|
DeleteMessagesBox(QWidget*, const SelectedItemSet &selected);
|
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:
|
2016-12-13 17:07:56 +00:00
|
|
|
void deleteAndClear();
|
|
|
|
|
2016-12-31 15:19:22 +00:00
|
|
|
QVector<FullMsgId> _ids;
|
|
|
|
bool _singleItem = false;
|
|
|
|
UserData *_moderateFrom = nullptr;
|
|
|
|
ChannelData *_moderateInChannel = nullptr;
|
2016-03-10 15:42:01 +00:00
|
|
|
|
2016-12-31 15:19:22 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _text = { nullptr };
|
|
|
|
object_ptr<Ui::Checkbox> _forEveryone = { nullptr };
|
|
|
|
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
|
|
|
|
|
|
|
};
|
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:
|
2016-12-13 17:07:56 +00:00
|
|
|
ConfirmInviteBox(QWidget*, const QString &title, const MTPChatPhoto &photo, int count, const QVector<UserData*> &participants);
|
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:
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _title;
|
|
|
|
object_ptr<Ui::FlatLabel> _status;
|
2016-07-08 16:59:46 +00:00
|
|
|
ImagePtr _photo;
|
2016-12-29 09:03:51 +00:00
|
|
|
EmptyUserpic _photoEmpty;
|
2016-07-08 16:59:46 +00:00
|
|
|
QVector<UserData*> _participants;
|
|
|
|
|
|
|
|
int _userWidth = 0;
|
|
|
|
|
|
|
|
};
|