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
|
|
|
|
|
2023-11-15 00:52:41 +00:00
|
|
|
#include "ui/layers/box_content.h"
|
2021-10-18 00:46:24 +00:00
|
|
|
#include "base/timer.h"
|
2017-07-18 15:15:02 +00:00
|
|
|
#include "mtproto/sender.h"
|
2019-09-13 06:06:02 +00:00
|
|
|
|
2017-08-14 12:53:49 +00:00
|
|
|
class PeerListBox;
|
2023-01-13 13:59:15 +00:00
|
|
|
struct RequestPeerQuery;
|
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
|
|
|
|
|
2017-08-14 12:53:49 +00:00
|
|
|
enum class PeerFloodType {
|
|
|
|
Send,
|
|
|
|
InviteGroup,
|
|
|
|
InviteChannel,
|
|
|
|
};
|
2019-07-24 11:45:24 +00:00
|
|
|
|
2021-12-26 16:29:25 +00:00
|
|
|
[[nodiscard]] TextWithEntities PeerFloodErrorText(
|
2020-06-17 09:36:25 +00:00
|
|
|
not_null<Main::Session*> session,
|
|
|
|
PeerFloodType type);
|
2018-12-28 11:42:58 +00:00
|
|
|
void ShowAddParticipantsError(
|
|
|
|
const QString &error,
|
|
|
|
not_null<PeerData*> chat,
|
2023-03-10 14:43:20 +00:00
|
|
|
const std::vector<not_null<UserData*>> &users,
|
|
|
|
std::shared_ptr<Ui::Show> show = nullptr);
|
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,
|
2022-09-20 09:35:47 +00:00
|
|
|
Forum,
|
2019-05-24 11:14:02 +00:00
|
|
|
};
|
|
|
|
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);
|
2023-01-13 13:59:15 +00:00
|
|
|
GroupInfoBox(
|
|
|
|
QWidget*,
|
|
|
|
not_null<Window::SessionNavigation*> navigation,
|
|
|
|
not_null<UserData*> bot,
|
|
|
|
RequestPeerQuery query,
|
|
|
|
Fn<void(not_null<PeerData*>)> done);
|
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);
|
2021-10-18 00:46:24 +00:00
|
|
|
void createGroup(
|
2023-01-13 13:59:15 +00:00
|
|
|
QPointer<Ui::BoxContent> selectUsersBox,
|
2021-10-18 00:46:24 +00:00
|
|
|
const QString &title,
|
|
|
|
const std::vector<not_null<PeerData*>> &users);
|
2018-05-31 12:20:28 +00:00
|
|
|
void submitName();
|
|
|
|
void submit();
|
2021-01-14 13:13:43 +00:00
|
|
|
void checkInviteLink();
|
|
|
|
void channelReady();
|
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
|
|
|
|
2024-01-30 15:51:37 +00:00
|
|
|
[[nodiscard]] TimeId ttlPeriod() const;
|
|
|
|
|
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;
|
2023-01-13 13:59:15 +00:00
|
|
|
bool _mustBePublic = false;
|
|
|
|
UserData *_canAddBot = nullptr;
|
|
|
|
Fn<void(not_null<PeerData*>)> _done;
|
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;
|
2021-01-14 13:13:43 +00:00
|
|
|
bool _creatingInviteLink = false;
|
2016-11-19 14:47:28 +00:00
|
|
|
ChannelData *_createdChannel = nullptr;
|
2022-11-30 10:06:17 +00:00
|
|
|
TimeId _ttlPeriod = 0;
|
2024-01-30 15:51:37 +00:00
|
|
|
bool _ttlPeriodOverridden = false;
|
2015-10-11 08:37:24 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2021-07-15 11:12:38 +00:00
|
|
|
class SetupChannelBox final : public Ui::BoxContent {
|
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,
|
2023-01-13 13:59:15 +00:00
|
|
|
bool mustBePublic,
|
|
|
|
Fn<void(not_null<PeerData*>)> done);
|
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,
|
|
|
|
};
|
2021-11-27 21:49:17 +00:00
|
|
|
enum class UsernameResult {
|
|
|
|
Ok,
|
|
|
|
Invalid,
|
|
|
|
Occupied,
|
|
|
|
ChatsTooMuch,
|
|
|
|
NA,
|
|
|
|
Unknown,
|
|
|
|
};
|
|
|
|
[[nodiscard]] UsernameResult parseError(const QString &error);
|
|
|
|
|
2017-03-18 21:06:10 +00:00
|
|
|
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
|
|
|
|
2021-11-27 21:49:17 +00:00
|
|
|
void updateFail(UsernameResult result);
|
2015-10-11 08:37:24 +00:00
|
|
|
|
2023-01-13 13:59:15 +00:00
|
|
|
void mustBePublicFailed();
|
2021-11-27 21:49:17 +00:00
|
|
|
void checkFail(UsernameResult result);
|
|
|
|
void firstCheckFail(UsernameResult result);
|
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
|
|
|
|
2021-10-12 12:50:18 +00:00
|
|
|
bool _creatingInviteLink = false;
|
2023-01-13 13:59:15 +00:00
|
|
|
bool _mustBePublic = false;
|
|
|
|
Fn<void(not_null<PeerData*>)> _done;
|
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;
|
|
|
|
|
2021-10-18 00:46:24 +00:00
|
|
|
base::Timer _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();
|
2021-10-18 00:46:24 +00:00
|
|
|
void saveSelfFail(const QString &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
|
|
|
};
|