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"
|
2017-07-18 15:15:02 +00:00
|
|
|
#include "mtproto/sender.h"
|
2017-09-30 18:26:45 +00:00
|
|
|
#include "styles/style_widgets.h"
|
2016-08-12 15:22:11 +00:00
|
|
|
|
|
|
|
class ConfirmBox;
|
2017-08-14 12:53:49 +00:00
|
|
|
class PeerListBox;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-09-09 17:38:08 +00:00
|
|
|
constexpr auto kMaxBioLength = 70;
|
|
|
|
|
|
|
|
style::InputField CreateBioFieldStyle();
|
|
|
|
|
2016-10-28 09:20:24 +00:00
|
|
|
namespace Ui {
|
2016-11-16 10:44:06 +00:00
|
|
|
class FlatLabel;
|
2016-11-15 11:56:49 +00:00
|
|
|
class InputField;
|
|
|
|
class PhoneInput;
|
|
|
|
class UsernameInput;
|
2016-10-28 09:20:24 +00:00
|
|
|
class Checkbox;
|
2017-03-18 21:06:10 +00:00
|
|
|
template <typename Enum>
|
|
|
|
class RadioenumGroup;
|
|
|
|
template <typename Enum>
|
|
|
|
class Radioenum;
|
2016-11-11 13:46:04 +00:00
|
|
|
class LinkButton;
|
2017-11-13 12:02:53 +00:00
|
|
|
class UserpicButton;
|
2016-10-28 09:20:24 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2017-08-14 12:53:49 +00:00
|
|
|
enum class PeerFloodType {
|
|
|
|
Send,
|
|
|
|
InviteGroup,
|
|
|
|
InviteChannel,
|
|
|
|
};
|
|
|
|
QString PeerFloodErrorText(PeerFloodType type);
|
2018-12-28 11:42:58 +00:00
|
|
|
void ShowAddParticipantsError(
|
|
|
|
const QString &error,
|
|
|
|
not_null<PeerData*> chat,
|
|
|
|
const std::vector<not_null<UserData*>> &users);
|
2017-08-14 12:53:49 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class AddContactBox : public BoxContent, public RPCSender {
|
2014-05-30 08:53:19 +00:00
|
|
|
public:
|
2016-12-13 17:07:56 +00:00
|
|
|
AddContactBox(QWidget*, QString fname = QString(), QString lname = QString(), QString phone = QString());
|
|
|
|
AddContactBox(QWidget*, UserData *user);
|
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 paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
void setInnerFocus() override;
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
private:
|
2018-05-31 12:20:28 +00:00
|
|
|
void submit();
|
|
|
|
void retry();
|
|
|
|
void save();
|
2016-12-13 17:07:56 +00:00
|
|
|
void updateButtons();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onImportDone(const MTPcontacts_ImportedContacts &res);
|
|
|
|
|
|
|
|
void onSaveUserDone(const MTPcontacts_ImportedContacts &res);
|
2015-10-11 08:37:24 +00:00
|
|
|
bool onSaveUserFail(const RPCError &e);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
UserData *_user = nullptr;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::InputField> _first;
|
|
|
|
object_ptr<Ui::InputField> _last;
|
|
|
|
object_ptr<Ui::PhoneInput> _phone;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
bool _retrying = false;
|
|
|
|
bool _invertOrder = false;
|
2015-09-23 17:43:08 +00:00
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
uint64 _contactId = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-05-31 19:27:11 +00:00
|
|
|
mtpRequestId _addRequest = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
QString _sentName;
|
2016-12-13 17:07:56 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
2015-09-21 20:57:42 +00:00
|
|
|
|
2017-08-14 12:53:49 +00:00
|
|
|
class GroupInfoBox : public BoxContent, private MTP::Sender {
|
2015-10-11 08:37:24 +00:00
|
|
|
public:
|
2019-05-24 11:14:02 +00:00
|
|
|
enum class Type {
|
|
|
|
Group,
|
|
|
|
Channel,
|
|
|
|
Megagroup,
|
|
|
|
};
|
|
|
|
GroupInfoBox(
|
|
|
|
QWidget*,
|
|
|
|
Type type,
|
|
|
|
const QString &title = QString(),
|
|
|
|
Fn<void(not_null<ChannelData*>)> channelDone = nullptr);
|
2016-12-13 17:07:56 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
private:
|
2017-08-14 12:53:49 +00:00
|
|
|
void createChannel(const QString &title, const QString &description);
|
2017-08-17 08:31:24 +00:00
|
|
|
void createGroup(not_null<PeerListBox*> selectUsersBox, const QString &title, const std::vector<not_null<PeerData*>> &users);
|
2018-05-31 12:20:28 +00:00
|
|
|
void submitName();
|
|
|
|
void submit();
|
2016-12-13 17:07:56 +00:00
|
|
|
|
2018-05-31 12:20:28 +00:00
|
|
|
void descriptionResized();
|
2015-10-11 08:37:24 +00:00
|
|
|
void updateMaxHeight();
|
2016-12-13 17:07:56 +00:00
|
|
|
|
2019-05-24 11:14:02 +00:00
|
|
|
Type _type = Type::Group;
|
|
|
|
QString _initialTitle;
|
|
|
|
Fn<void(not_null<ChannelData*>)> _channelDone;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2017-11-13 12:02:53 +00:00
|
|
|
object_ptr<Ui::UserpicButton> _photo = { nullptr };
|
|
|
|
object_ptr<Ui::InputField> _title = { nullptr };
|
2018-05-20 17:42:30 +00:00
|
|
|
object_ptr<Ui::InputField> _description = { nullptr };
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2017-08-14 12:53:49 +00:00
|
|
|
// group / channel creation
|
2016-11-19 14:47:28 +00:00
|
|
|
mtpRequestId _creationRequestId = 0;
|
|
|
|
ChannelData *_createdChannel = nullptr;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class SetupChannelBox : public BoxContent, public RPCSender {
|
2015-10-11 08:37:24 +00:00
|
|
|
public:
|
2016-12-13 17:07:56 +00:00
|
|
|
SetupChannelBox(QWidget*, ChannelData *channel, bool existing = false);
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
void setInnerFocus() override;
|
2015-10-11 08:37:24 +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 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-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
private:
|
2017-03-18 21:06:10 +00:00
|
|
|
enum class Privacy {
|
|
|
|
Public,
|
|
|
|
Private,
|
|
|
|
};
|
|
|
|
void privacyChanged(Privacy value);
|
2015-10-11 08:37:24 +00:00
|
|
|
void updateSelected(const QPoint &cursorGlobalPosition);
|
2018-05-31 12:20:28 +00:00
|
|
|
void handleChange();
|
|
|
|
void check();
|
|
|
|
void save();
|
2015-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
void onUpdateDone(const MTPBool &result);
|
|
|
|
bool onUpdateFail(const RPCError &error);
|
|
|
|
|
|
|
|
void onCheckDone(const MTPBool &result);
|
|
|
|
bool onCheckFail(const RPCError &error);
|
|
|
|
bool onFirstCheckFail(const RPCError &error);
|
|
|
|
|
2016-03-04 16:47:48 +00:00
|
|
|
void updateMaxHeight();
|
|
|
|
|
2016-08-12 15:22:11 +00:00
|
|
|
void showRevokePublicLinkBoxForEdit();
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
ChannelData *_channel = nullptr;
|
|
|
|
bool _existing = false;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2017-03-18 21:06:10 +00:00
|
|
|
std::shared_ptr<Ui::RadioenumGroup<Privacy>> _privacyGroup;
|
|
|
|
object_ptr<Ui::Radioenum<Privacy>> _public;
|
|
|
|
object_ptr<Ui::Radioenum<Privacy>> _private;
|
2015-10-11 08:37:24 +00:00
|
|
|
int32 _aboutPublicWidth, _aboutPublicHeight;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _aboutPublic, _aboutPrivate;
|
2016-10-28 09:20:24 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::UsernameInput> _link;
|
2016-10-28 09:20:24 +00:00
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
QRect _invitationLink;
|
2016-12-13 17:07:56 +00:00
|
|
|
bool _linkOver = false;
|
2016-08-12 15:22:11 +00:00
|
|
|
bool _tooMuchUsernames = false;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2016-08-12 15:22:11 +00:00
|
|
|
mtpRequestId _saveRequestId = 0;
|
|
|
|
mtpRequestId _checkRequestId = 0;
|
2015-10-11 08:37:24 +00:00
|
|
|
QString _sentUsername, _checkUsername, _errorText, _goodText;
|
|
|
|
|
|
|
|
QTimer _checkTimer;
|
2016-08-16 16:53:10 +00:00
|
|
|
|
2015-10-11 08:37:24 +00:00
|
|
|
};
|
|
|
|
|
2017-12-02 12:04:22 +00:00
|
|
|
class EditNameBox : public BoxContent, public RPCSender {
|
2015-10-06 19:49:23 +00:00
|
|
|
public:
|
2017-12-02 12:04:22 +00:00
|
|
|
EditNameBox(QWidget*, not_null<UserData*> user);
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void setInnerFocus() override;
|
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-16 16:53:10 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
|
|
|
private:
|
2017-12-02 12:04:22 +00:00
|
|
|
void submit();
|
|
|
|
void save();
|
|
|
|
void saveSelfDone(const MTPUser &user);
|
|
|
|
bool saveSelfFail(const RPCError &error);
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2017-12-02 12:04:22 +00:00
|
|
|
not_null<UserData*> _user;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::InputField> _first;
|
|
|
|
object_ptr<Ui::InputField> _last;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-11-03 10:58:10 +00:00
|
|
|
bool _invertOrder = false;
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2016-11-03 10:58:10 +00:00
|
|
|
mtpRequestId _requestId = 0;
|
2015-10-06 19:49:23 +00:00
|
|
|
QString _sentName;
|
2016-08-16 16:53:10 +00:00
|
|
|
|
2015-10-06 19:49:23 +00:00
|
|
|
};
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
class RevokePublicLinkBox : public BoxContent, public RPCSender {
|
2016-08-12 15:22:11 +00:00
|
|
|
public:
|
2018-06-04 15:35:11 +00:00
|
|
|
RevokePublicLinkBox(QWidget*, Fn<void()> revokeCallback);
|
2016-08-12 15:22:11 +00:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 17:07:56 +00:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-12 15:22:11 +00:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
2016-12-13 17:07:56 +00:00
|
|
|
object_ptr<Ui::FlatLabel> _aboutRevoke;
|
2016-08-12 15:22:11 +00:00
|
|
|
|
2017-07-03 13:57:46 +00:00
|
|
|
class Inner;
|
|
|
|
QPointer<Inner> _inner;
|
|
|
|
|
|
|
|
int _innerTop = 0;
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void()> _revokeCallback;
|
2016-08-12 15:22:11 +00:00
|
|
|
|
2015-09-21 20:57:42 +00:00
|
|
|
};
|