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
|
|
|
|
2019-09-13 06:06:02 +00:00
|
|
|
#include <QtCore/QTimer>
|
|
|
|
|
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
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
namespace Window {
|
|
|
|
class SessionNavigation;
|
|
|
|
} // namespace Window
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
2018-09-09 17:38:08 +00:00
|
|
|
|
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
|
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
constexpr auto kMaxBioLength = 70;
|
|
|
|
|
2017-08-14 12:53:49 +00:00
|
|
|
enum class PeerFloodType {
|
|
|
|
Send,
|
|
|
|
InviteGroup,
|
|
|
|
InviteChannel,
|
|
|
|
};
|
2019-07-24 11:45:24 +00:00
|
|
|
|
2020-06-17 09:36:25 +00:00
|
|
|
[[nodiscard]] style::InputField CreateBioFieldStyle();
|
2019-07-24 11:45:24 +00:00
|
|
|
|
2020-06-17 09:36:25 +00:00
|
|
|
[[nodiscard]] QString PeerFloodErrorText(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
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
|
|
|
|
2019-09-18 11:19:05 +00:00
|
|
|
class AddContactBox : public Ui::BoxContent {
|
2014-05-30 08:53:19 +00:00
|
|
|
public:
|
2019-07-24 11:45:24 +00:00
|
|
|
AddContactBox(QWidget*, not_null<Main::Session*> session);
|
2019-07-24 11:13:51 +00:00
|
|
|
AddContactBox(
|
|
|
|
QWidget*,
|
2019-07-24 11:45:24 +00:00
|
|
|
not_null<Main::Session*> session,
|
2019-07-24 11:13:51 +00:00
|
|
|
QString fname,
|
|
|
|
QString lname,
|
|
|
|
QString phone);
|
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
|
|
|
|
2019-07-24 11:45:24 +00:00
|
|
|
const not_null<Main::Session*> _session;
|
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
|
|
|
|
2019-11-27 08:02:56 +00:00
|
|
|
class GroupInfoBox : public Ui::BoxContent {
|
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*,
|
2019-07-25 18:55:11 +00:00
|
|
|
not_null<Window::SessionNavigation*> navigation,
|
2019-05-24 11:14:02 +00:00
|
|
|
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-07-25 18:55:11 +00:00
|
|
|
const not_null<Window::SessionNavigation*> _navigation;
|
2019-11-27 08:02:56 +00:00
|
|
|
MTP::Sender _api;
|
2019-07-24 11:13:51 +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
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
class SetupChannelBox final
|
2019-09-18 11:19:05 +00:00
|
|
|
: public Ui::BoxContent
|
2019-09-16 11:14:06 +00:00
|
|
|
, private base::Subscriber {
|
2015-10-11 08:37:24 +00:00
|
|
|
public:
|
2019-07-24 11:13:51 +00:00
|
|
|
SetupChannelBox(
|
|
|
|
QWidget*,
|
2019-07-25 18:55:11 +00:00
|
|
|
not_null<Window::SessionNavigation*> navigation,
|
2019-07-24 11:13:51 +00:00
|
|
|
not_null<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
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
void updateDone(const MTPBool &result);
|
|
|
|
void updateFail(const RPCError &error);
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
void checkDone(const MTPBool &result);
|
|
|
|
void checkFail(const RPCError &error);
|
|
|
|
void firstCheckFail(const RPCError &error);
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2016-03-04 16:47:48 +00:00
|
|
|
void updateMaxHeight();
|
|
|
|
|
2016-08-12 15:22:11 +00:00
|
|
|
void showRevokePublicLinkBoxForEdit();
|
|
|
|
|
2019-07-25 18:55:11 +00:00
|
|
|
const not_null<Window::SessionNavigation*> _navigation;
|
2019-07-24 11:13:51 +00:00
|
|
|
const not_null<ChannelData*> _channel;
|
2020-06-11 16:09:46 +00:00
|
|
|
MTP::Sender _api;
|
2019-07-24 11:13:51 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
class EditNameBox : public Ui::BoxContent {
|
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);
|
2020-06-11 16:09:46 +00:00
|
|
|
void saveSelfFail(const RPCError &error);
|
2015-10-06 19:49:23 +00:00
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
const not_null<UserData*> _user;
|
|
|
|
MTP::Sender _api;
|
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
|
|
|
};
|
|
|
|
|
2020-06-11 16:09:46 +00:00
|
|
|
class RevokePublicLinkBox final
|
2019-09-18 11:19:05 +00:00
|
|
|
: public Ui::BoxContent
|
2019-09-16 11:14:06 +00:00
|
|
|
, private base::Subscriber {
|
2016-08-12 15:22:11 +00:00
|
|
|
public:
|
2019-07-24 11:13:51 +00:00
|
|
|
RevokePublicLinkBox(
|
|
|
|
QWidget*,
|
2019-07-24 11:45:24 +00:00
|
|
|
not_null<Main::Session*> session,
|
2019-07-24 11:13:51 +00:00
|
|
|
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:
|
2019-07-24 11:45:24 +00:00
|
|
|
const not_null<Main::Session*> _session;
|
2019-07-24 11:13:51 +00:00
|
|
|
|
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
|
|
|
};
|