2014-05-30 12:53:19 +04:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 12:53:19 +04:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2023-11-15 03:52:41 +03:00
|
|
|
#include "ui/layers/box_content.h"
|
2021-10-18 03:46:24 +03:00
|
|
|
#include "base/timer.h"
|
2017-07-18 18:15:02 +03:00
|
|
|
#include "mtproto/sender.h"
|
2019-09-13 09:06:02 +03:00
|
|
|
|
2017-08-14 15:53:49 +03:00
|
|
|
class PeerListBox;
|
2023-01-13 17:59:15 +04:00
|
|
|
struct RequestPeerQuery;
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2019-07-25 20:55:11 +02:00
|
|
|
namespace Window {
|
|
|
|
class SessionNavigation;
|
|
|
|
} // namespace Window
|
|
|
|
|
2019-07-24 13:45:24 +02:00
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
2018-09-09 20:38:08 +03:00
|
|
|
|
2016-10-28 12:20:24 +03:00
|
|
|
namespace Ui {
|
2016-11-16 13:44:06 +03:00
|
|
|
class FlatLabel;
|
2016-11-15 14:56:49 +03:00
|
|
|
class InputField;
|
|
|
|
class PhoneInput;
|
|
|
|
class UsernameInput;
|
2016-10-28 12:20:24 +03:00
|
|
|
class Checkbox;
|
2017-03-19 00:06:10 +03:00
|
|
|
template <typename Enum>
|
|
|
|
class RadioenumGroup;
|
|
|
|
template <typename Enum>
|
|
|
|
class Radioenum;
|
2016-11-11 16:46:04 +03:00
|
|
|
class LinkButton;
|
2017-11-13 16:02:53 +04:00
|
|
|
class UserpicButton;
|
2024-04-01 17:54:44 +04:00
|
|
|
class Show;
|
2016-10-28 12:20:24 +03:00
|
|
|
} // namespace Ui
|
|
|
|
|
2017-08-14 15:53:49 +03:00
|
|
|
enum class PeerFloodType {
|
|
|
|
Send,
|
|
|
|
InviteGroup,
|
|
|
|
InviteChannel,
|
|
|
|
};
|
2019-07-24 13:45:24 +02:00
|
|
|
|
2024-04-01 22:39:29 +04:00
|
|
|
struct ForbiddenInvites;
|
|
|
|
|
2021-12-26 19:29:25 +03:00
|
|
|
[[nodiscard]] TextWithEntities PeerFloodErrorText(
|
2020-06-17 13:36:25 +04:00
|
|
|
not_null<Main::Session*> session,
|
|
|
|
PeerFloodType type);
|
2018-12-28 15:42:58 +04:00
|
|
|
void ShowAddParticipantsError(
|
2024-04-01 17:54:44 +04:00
|
|
|
std::shared_ptr<Ui::Show> show,
|
2018-12-28 15:42:58 +04:00
|
|
|
const QString &error,
|
|
|
|
not_null<PeerData*> chat,
|
2024-04-01 22:39:29 +04:00
|
|
|
const ForbiddenInvites &forbidden);
|
|
|
|
void ShowAddParticipantsError(
|
|
|
|
std::shared_ptr<Ui::Show> show,
|
|
|
|
const QString &error,
|
|
|
|
not_null<PeerData*> chat,
|
|
|
|
not_null<UserData*> user);
|
2017-08-14 15:53:49 +03:00
|
|
|
|
2019-09-18 14:19:05 +03:00
|
|
|
class AddContactBox : public Ui::BoxContent {
|
2014-05-30 12:53:19 +04:00
|
|
|
public:
|
2019-07-24 13:45:24 +02:00
|
|
|
AddContactBox(QWidget*, not_null<Main::Session*> session);
|
2019-07-24 13:13:51 +02:00
|
|
|
AddContactBox(
|
|
|
|
QWidget*,
|
2019-07-24 13:45:24 +02:00
|
|
|
not_null<Main::Session*> session,
|
2019-07-24 13:13:51 +02:00
|
|
|
QString fname,
|
|
|
|
QString lname,
|
|
|
|
QString phone);
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2015-04-02 13:33:19 +03:00
|
|
|
protected:
|
2016-12-13 20:07:56 +03:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-16 19:53:10 +03:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
void setInnerFocus() override;
|
|
|
|
|
2015-04-02 13:33:19 +03:00
|
|
|
private:
|
2018-05-31 15:20:28 +03:00
|
|
|
void submit();
|
|
|
|
void retry();
|
|
|
|
void save();
|
2016-12-13 20:07:56 +03:00
|
|
|
void updateButtons();
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2019-07-24 13:45:24 +02:00
|
|
|
const not_null<Main::Session*> _session;
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
object_ptr<Ui::InputField> _first;
|
|
|
|
object_ptr<Ui::InputField> _last;
|
|
|
|
object_ptr<Ui::PhoneInput> _phone;
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
bool _retrying = false;
|
|
|
|
bool _invertOrder = false;
|
2015-09-23 20:43:08 +03:00
|
|
|
|
2016-05-31 22:27:11 +03:00
|
|
|
uint64 _contactId = 0;
|
2014-05-30 12:53:19 +04:00
|
|
|
|
2016-05-31 22:27:11 +03:00
|
|
|
mtpRequestId _addRequest = 0;
|
2014-05-30 12:53:19 +04:00
|
|
|
QString _sentName;
|
2016-12-13 20:07:56 +03:00
|
|
|
|
2014-05-30 12:53:19 +04:00
|
|
|
};
|
2015-09-21 23:57:42 +03:00
|
|
|
|
2019-11-27 11:02:56 +03:00
|
|
|
class GroupInfoBox : public Ui::BoxContent {
|
2015-10-11 10:37:24 +02:00
|
|
|
public:
|
2019-05-24 13:14:02 +02:00
|
|
|
enum class Type {
|
|
|
|
Group,
|
|
|
|
Channel,
|
|
|
|
Megagroup,
|
2022-09-20 13:35:47 +04:00
|
|
|
Forum,
|
2019-05-24 13:14:02 +02:00
|
|
|
};
|
|
|
|
GroupInfoBox(
|
|
|
|
QWidget*,
|
2019-07-25 20:55:11 +02:00
|
|
|
not_null<Window::SessionNavigation*> navigation,
|
2019-05-24 13:14:02 +02:00
|
|
|
Type type,
|
|
|
|
const QString &title = QString(),
|
|
|
|
Fn<void(not_null<ChannelData*>)> channelDone = nullptr);
|
2023-01-13 17:59:15 +04:00
|
|
|
GroupInfoBox(
|
|
|
|
QWidget*,
|
|
|
|
not_null<Window::SessionNavigation*> navigation,
|
|
|
|
not_null<UserData*> bot,
|
|
|
|
RequestPeerQuery query,
|
|
|
|
Fn<void(not_null<PeerData*>)> done);
|
2016-12-13 20:07:56 +03:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void prepare() override;
|
|
|
|
void setInnerFocus() override;
|
|
|
|
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2015-10-11 10:37:24 +02:00
|
|
|
|
|
|
|
private:
|
2017-08-14 15:53:49 +03:00
|
|
|
void createChannel(const QString &title, const QString &description);
|
2021-10-18 03:46:24 +03:00
|
|
|
void createGroup(
|
2023-01-13 17:59:15 +04:00
|
|
|
QPointer<Ui::BoxContent> selectUsersBox,
|
2021-10-18 03:46:24 +03:00
|
|
|
const QString &title,
|
|
|
|
const std::vector<not_null<PeerData*>> &users);
|
2018-05-31 15:20:28 +03:00
|
|
|
void submitName();
|
|
|
|
void submit();
|
2021-01-14 17:13:43 +04:00
|
|
|
void checkInviteLink();
|
|
|
|
void channelReady();
|
2016-12-13 20:07:56 +03:00
|
|
|
|
2018-05-31 15:20:28 +03:00
|
|
|
void descriptionResized();
|
2015-10-11 10:37:24 +02:00
|
|
|
void updateMaxHeight();
|
2016-12-13 20:07:56 +03:00
|
|
|
|
2024-01-30 18:51:37 +03:00
|
|
|
[[nodiscard]] TimeId ttlPeriod() const;
|
|
|
|
|
2019-07-25 20:55:11 +02:00
|
|
|
const not_null<Window::SessionNavigation*> _navigation;
|
2019-11-27 11:02:56 +03:00
|
|
|
MTP::Sender _api;
|
2019-07-24 13:13:51 +02:00
|
|
|
|
2019-05-24 13:14:02 +02:00
|
|
|
Type _type = Type::Group;
|
|
|
|
QString _initialTitle;
|
2023-01-13 17:59:15 +04:00
|
|
|
bool _mustBePublic = false;
|
|
|
|
UserData *_canAddBot = nullptr;
|
|
|
|
Fn<void(not_null<PeerData*>)> _done;
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2017-11-13 16:02:53 +04:00
|
|
|
object_ptr<Ui::UserpicButton> _photo = { nullptr };
|
|
|
|
object_ptr<Ui::InputField> _title = { nullptr };
|
2018-05-20 20:42:30 +03:00
|
|
|
object_ptr<Ui::InputField> _description = { nullptr };
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2017-08-14 15:53:49 +03:00
|
|
|
// group / channel creation
|
2016-11-19 17:47:28 +03:00
|
|
|
mtpRequestId _creationRequestId = 0;
|
2021-01-14 17:13:43 +04:00
|
|
|
bool _creatingInviteLink = false;
|
2016-11-19 17:47:28 +03:00
|
|
|
ChannelData *_createdChannel = nullptr;
|
2022-11-30 13:06:17 +03:00
|
|
|
TimeId _ttlPeriod = 0;
|
2024-01-30 18:51:37 +03:00
|
|
|
bool _ttlPeriodOverridden = false;
|
2015-10-11 10:37:24 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-07-15 14:12:38 +03:00
|
|
|
class SetupChannelBox final : public Ui::BoxContent {
|
2015-10-11 10:37:24 +02:00
|
|
|
public:
|
2019-07-24 13:13:51 +02:00
|
|
|
SetupChannelBox(
|
|
|
|
QWidget*,
|
2019-07-25 20:55:11 +02:00
|
|
|
not_null<Window::SessionNavigation*> navigation,
|
2019-07-24 13:13:51 +02:00
|
|
|
not_null<ChannelData*> channel,
|
2023-01-13 17:59:15 +04:00
|
|
|
bool mustBePublic,
|
|
|
|
Fn<void(not_null<PeerData*>)> done);
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
void setInnerFocus() override;
|
2015-10-11 10:37:24 +02:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 20:07:56 +03:00
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-16 19:53:10 +03: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 14:24:37 +03:00
|
|
|
void leaveEventHook(QEvent *e) override;
|
2015-10-11 10:37:24 +02:00
|
|
|
|
|
|
|
private:
|
2017-03-19 00:06:10 +03:00
|
|
|
enum class Privacy {
|
|
|
|
Public,
|
|
|
|
Private,
|
|
|
|
};
|
2021-11-28 00:49:17 +03:00
|
|
|
enum class UsernameResult {
|
|
|
|
Ok,
|
|
|
|
Invalid,
|
|
|
|
Occupied,
|
|
|
|
ChatsTooMuch,
|
|
|
|
NA,
|
|
|
|
Unknown,
|
|
|
|
};
|
|
|
|
[[nodiscard]] UsernameResult parseError(const QString &error);
|
|
|
|
|
2017-03-19 00:06:10 +03:00
|
|
|
void privacyChanged(Privacy value);
|
2015-10-11 10:37:24 +02:00
|
|
|
void updateSelected(const QPoint &cursorGlobalPosition);
|
2018-05-31 15:20:28 +03:00
|
|
|
void handleChange();
|
|
|
|
void check();
|
|
|
|
void save();
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2021-11-28 00:49:17 +03:00
|
|
|
void updateFail(UsernameResult result);
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2023-01-13 17:59:15 +04:00
|
|
|
void mustBePublicFailed();
|
2021-11-28 00:49:17 +03:00
|
|
|
void checkFail(UsernameResult result);
|
|
|
|
void firstCheckFail(UsernameResult result);
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2016-03-04 18:47:48 +02:00
|
|
|
void updateMaxHeight();
|
|
|
|
|
2016-08-12 18:22:11 +03:00
|
|
|
void showRevokePublicLinkBoxForEdit();
|
|
|
|
|
2019-07-25 20:55:11 +02:00
|
|
|
const not_null<Window::SessionNavigation*> _navigation;
|
2019-07-24 13:13:51 +02:00
|
|
|
const not_null<ChannelData*> _channel;
|
2020-06-11 20:09:46 +04:00
|
|
|
MTP::Sender _api;
|
2019-07-24 13:13:51 +02:00
|
|
|
|
2021-10-12 16:50:18 +04:00
|
|
|
bool _creatingInviteLink = false;
|
2023-01-13 17:59:15 +04:00
|
|
|
bool _mustBePublic = false;
|
|
|
|
Fn<void(not_null<PeerData*>)> _done;
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2017-03-19 00:06:10 +03:00
|
|
|
std::shared_ptr<Ui::RadioenumGroup<Privacy>> _privacyGroup;
|
|
|
|
object_ptr<Ui::Radioenum<Privacy>> _public;
|
|
|
|
object_ptr<Ui::Radioenum<Privacy>> _private;
|
2015-10-11 10:37:24 +02:00
|
|
|
int32 _aboutPublicWidth, _aboutPublicHeight;
|
2019-06-12 15:26:04 +02:00
|
|
|
Ui::Text::String _aboutPublic, _aboutPrivate;
|
2016-10-28 12:20:24 +03:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
object_ptr<Ui::UsernameInput> _link;
|
2016-10-28 12:20:24 +03:00
|
|
|
|
2015-10-11 10:37:24 +02:00
|
|
|
QRect _invitationLink;
|
2016-12-13 20:07:56 +03:00
|
|
|
bool _linkOver = false;
|
2016-08-12 18:22:11 +03:00
|
|
|
bool _tooMuchUsernames = false;
|
2015-10-11 10:37:24 +02:00
|
|
|
|
2016-08-12 18:22:11 +03:00
|
|
|
mtpRequestId _saveRequestId = 0;
|
|
|
|
mtpRequestId _checkRequestId = 0;
|
2015-10-11 10:37:24 +02:00
|
|
|
QString _sentUsername, _checkUsername, _errorText, _goodText;
|
|
|
|
|
2021-10-18 03:46:24 +03:00
|
|
|
base::Timer _checkTimer;
|
2016-08-16 19:53:10 +03:00
|
|
|
|
2015-10-11 10:37:24 +02:00
|
|
|
};
|
|
|
|
|
2020-06-11 20:09:46 +04:00
|
|
|
class EditNameBox : public Ui::BoxContent {
|
2015-10-06 22:49:23 +03:00
|
|
|
public:
|
2017-12-02 16:04:22 +04:00
|
|
|
EditNameBox(QWidget*, not_null<UserData*> user);
|
2015-10-06 22:49:23 +03:00
|
|
|
|
|
|
|
protected:
|
2016-12-13 20:07:56 +03:00
|
|
|
void setInnerFocus() override;
|
|
|
|
void prepare() override;
|
|
|
|
|
2016-08-16 19:53:10 +03:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2015-10-06 22:49:23 +03:00
|
|
|
|
|
|
|
private:
|
2017-12-02 16:04:22 +04:00
|
|
|
void submit();
|
|
|
|
void save();
|
2021-10-18 03:46:24 +03:00
|
|
|
void saveSelfFail(const QString &error);
|
2015-10-06 22:49:23 +03:00
|
|
|
|
2020-06-11 20:09:46 +04:00
|
|
|
const not_null<UserData*> _user;
|
|
|
|
MTP::Sender _api;
|
2015-10-06 22:49:23 +03:00
|
|
|
|
2016-12-13 20:07:56 +03:00
|
|
|
object_ptr<Ui::InputField> _first;
|
|
|
|
object_ptr<Ui::InputField> _last;
|
2015-10-06 22:49:23 +03:00
|
|
|
|
2016-11-03 13:58:10 +03:00
|
|
|
bool _invertOrder = false;
|
2015-10-06 22:49:23 +03:00
|
|
|
|
2016-11-03 13:58:10 +03:00
|
|
|
mtpRequestId _requestId = 0;
|
2015-10-06 22:49:23 +03:00
|
|
|
QString _sentName;
|
2016-08-16 19:53:10 +03:00
|
|
|
|
2015-10-06 22:49:23 +03:00
|
|
|
};
|