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-05-30 09:31:40 +00:00
|
|
|
#include "mtproto/sender.h"
|
2018-04-26 16:14:21 +00:00
|
|
|
#include "ui/rp_widget.h"
|
2019-04-02 09:13:30 +00:00
|
|
|
#include "ui/effects/animations.h"
|
2018-06-03 13:30:40 +00:00
|
|
|
#include "window/window_lock_widgets.h"
|
2018-08-03 21:48:00 +00:00
|
|
|
#include "core/core_cloud_password.h"
|
2020-06-25 14:17:37 +00:00
|
|
|
#include "media/player/media_player_float.h"
|
2017-05-30 09:31:40 +00:00
|
|
|
|
2019-07-24 08:46:23 +00:00
|
|
|
namespace Main {
|
|
|
|
class Account;
|
|
|
|
} // namespace Main
|
|
|
|
|
2016-10-26 10:06:00 +00:00
|
|
|
namespace Ui {
|
|
|
|
class IconButton;
|
2016-11-11 13:46:04 +00:00
|
|
|
class RoundButton;
|
2016-11-24 19:28:23 +00:00
|
|
|
class LinkButton;
|
|
|
|
class FlatLabel;
|
2016-10-26 10:06:00 +00:00
|
|
|
template <typename Widget>
|
2017-09-30 18:26:45 +00:00
|
|
|
class FadeWrap;
|
2016-10-26 10:06:00 +00:00
|
|
|
} // namespace Ui
|
|
|
|
|
2018-05-07 17:44:33 +00:00
|
|
|
namespace Window {
|
2019-02-10 16:29:55 +00:00
|
|
|
class ConnectionState;
|
2021-02-21 03:51:30 +00:00
|
|
|
class Controller;
|
2018-05-07 17:44:33 +00:00
|
|
|
} // namespace Window
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
namespace Intro {
|
2019-11-26 11:10:44 +00:00
|
|
|
namespace details {
|
2016-11-24 19:28:23 +00:00
|
|
|
|
2019-11-26 11:10:44 +00:00
|
|
|
enum class CallStatus {
|
|
|
|
Waiting,
|
|
|
|
Calling,
|
|
|
|
Called,
|
|
|
|
Disabled,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Data {
|
2021-02-21 03:51:30 +00:00
|
|
|
// Required for the UserpicButton.
|
|
|
|
const not_null<Window::Controller*> controller;
|
|
|
|
|
2019-11-26 11:10:44 +00:00
|
|
|
QString country;
|
|
|
|
QString phone;
|
|
|
|
QByteArray phoneHash;
|
|
|
|
|
|
|
|
CallStatus callStatus = CallStatus::Disabled;
|
|
|
|
int callTimeout = 0;
|
|
|
|
|
|
|
|
int codeLength = 5;
|
|
|
|
bool codeByTelegram = false;
|
|
|
|
|
|
|
|
Core::CloudPasswordCheckRequest pwdRequest;
|
|
|
|
bool hasRecovery = false;
|
|
|
|
QString pwdHint;
|
|
|
|
bool pwdNotEmptyPassport = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2019-11-26 11:10:44 +00:00
|
|
|
Window::TermsLock termsLock;
|
|
|
|
|
2021-05-25 13:27:23 +00:00
|
|
|
rpl::event_stream<> updated;
|
2019-11-26 11:10:44 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-06-23 14:55:08 +00:00
|
|
|
enum class StackAction {
|
2019-11-26 11:10:44 +00:00
|
|
|
Back,
|
|
|
|
Forward,
|
|
|
|
Replace,
|
|
|
|
};
|
|
|
|
|
2020-06-23 14:55:08 +00:00
|
|
|
enum class Animate {
|
|
|
|
Back,
|
|
|
|
Forward,
|
|
|
|
};
|
|
|
|
|
2019-11-26 11:10:44 +00:00
|
|
|
class Step;
|
|
|
|
|
|
|
|
} // namespace details
|
|
|
|
|
2020-06-23 14:55:08 +00:00
|
|
|
enum class EnterPoint : uchar {
|
|
|
|
Start,
|
|
|
|
Phone,
|
|
|
|
Qr,
|
|
|
|
};
|
|
|
|
|
2020-06-25 14:17:37 +00:00
|
|
|
class Widget
|
|
|
|
: public Ui::RpWidget
|
|
|
|
, private Media::Player::FloatDelegate
|
2021-05-25 14:12:10 +00:00
|
|
|
, private Media::Player::FloatSectionDelegate {
|
2014-05-30 08:53:19 +00:00
|
|
|
public:
|
2020-06-23 14:55:08 +00:00
|
|
|
Widget(
|
|
|
|
QWidget *parent,
|
2021-02-21 03:51:30 +00:00
|
|
|
not_null<Window::Controller*> controller,
|
2020-06-23 14:55:08 +00:00
|
|
|
not_null<Main::Account*> account,
|
|
|
|
EnterPoint point);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-05 11:01:08 +00:00
|
|
|
void showAnimated(const QPixmap &bgAnimCache, bool back = false);
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
void setInnerFocus();
|
2016-03-14 16:59:18 +00:00
|
|
|
|
2021-02-03 01:58:27 +00:00
|
|
|
[[nodiscard]] rpl::producer<> showSettingsRequested() const;
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
~Widget();
|
2016-11-05 08:36:24 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
private:
|
2017-05-30 13:54:05 +00:00
|
|
|
void refreshLang();
|
2016-12-05 11:01:08 +00:00
|
|
|
void animationCallback();
|
2017-05-30 09:31:40 +00:00
|
|
|
void createLanguageLink();
|
2019-11-26 11:10:44 +00:00
|
|
|
void checkUpdateStatus();
|
|
|
|
void setupNextButton();
|
2020-03-29 10:06:10 +00:00
|
|
|
void handleUpdates(const MTPUpdates &updates);
|
|
|
|
void handleUpdate(const MTPUpdate &update);
|
2020-06-23 14:55:08 +00:00
|
|
|
void backRequested();
|
2016-11-24 19:28:23 +00:00
|
|
|
|
2016-11-05 08:36:24 +00:00
|
|
|
void updateControlsGeometry();
|
2019-11-26 11:10:44 +00:00
|
|
|
[[nodiscard]] not_null<details::Data*> getData() {
|
2016-11-24 19:28:23 +00:00
|
|
|
return &_data;
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
void fixOrder();
|
|
|
|
void showControls();
|
|
|
|
void hideControls();
|
2014-12-19 21:20:30 +00:00
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
void showResetButton();
|
|
|
|
void resetAccount();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-06-01 07:00:18 +00:00
|
|
|
void showTerms();
|
2018-06-04 15:35:11 +00:00
|
|
|
void acceptTerms(Fn<void()> callback);
|
2018-05-30 15:08:12 +00:00
|
|
|
void hideAndDestroy(object_ptr<Ui::FadeWrap<Ui::RpWidget>> widget);
|
|
|
|
|
2019-11-26 11:10:44 +00:00
|
|
|
[[nodiscard]] details::Step *getStep(int skip = 0) const {
|
|
|
|
Expects(skip >= 0);
|
|
|
|
Expects(skip < _stepHistory.size());
|
|
|
|
|
|
|
|
return _stepHistory[_stepHistory.size() - skip - 1];
|
2016-03-14 16:59:18 +00:00
|
|
|
}
|
2020-06-23 14:55:08 +00:00
|
|
|
void historyMove(details::StackAction action, details::Animate animate);
|
|
|
|
void moveToStep(
|
|
|
|
details::Step *step,
|
|
|
|
details::StackAction action,
|
|
|
|
details::Animate animate);
|
2019-11-26 11:10:44 +00:00
|
|
|
void appendStep(details::Step *step);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-05-30 09:31:40 +00:00
|
|
|
void getNearestDC();
|
2018-06-04 15:35:11 +00:00
|
|
|
void showTerms(Fn<void()> callback);
|
2017-05-30 09:31:40 +00:00
|
|
|
|
2020-06-25 14:17:37 +00:00
|
|
|
// FloatDelegate
|
|
|
|
[[nodiscard]] auto floatPlayerDelegate()
|
|
|
|
-> not_null<Media::Player::FloatDelegate*>;
|
|
|
|
[[nodiscard]] auto floatPlayerSectionDelegate()
|
|
|
|
-> not_null<Media::Player::FloatSectionDelegate*>;
|
|
|
|
not_null<Ui::RpWidget*> floatPlayerWidget() override;
|
|
|
|
not_null<Media::Player::FloatSectionDelegate*> floatPlayerGetSection(
|
|
|
|
Window::Column column) override;
|
|
|
|
void floatPlayerEnumerateSections(Fn<void(
|
|
|
|
not_null<Media::Player::FloatSectionDelegate*> widget,
|
|
|
|
Window::Column widgetColumn)> callback) override;
|
|
|
|
bool floatPlayerIsVisible(not_null<HistoryItem*> item) override;
|
2021-06-15 23:06:22 +00:00
|
|
|
void floatPlayerDoubleClickEvent(
|
|
|
|
not_null<const HistoryItem*> item) override;
|
2020-06-25 14:17:37 +00:00
|
|
|
|
|
|
|
// FloatSectionDelegate
|
|
|
|
QRect floatPlayerAvailableRect() override;
|
|
|
|
bool floatPlayerHandleWheelEvent(QEvent *e) override;
|
|
|
|
|
2019-11-27 08:02:56 +00:00
|
|
|
const not_null<Main::Account*> _account;
|
|
|
|
std::optional<MTP::Sender> _api;
|
2020-06-26 11:28:06 +00:00
|
|
|
mtpRequestId _nearestDcRequestId = 0;
|
2019-07-24 08:46:23 +00:00
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _a_show;
|
2017-05-30 09:31:40 +00:00
|
|
|
bool _showBack = false;
|
|
|
|
QPixmap _cacheUnder, _cacheOver;
|
|
|
|
|
2019-11-26 11:10:44 +00:00
|
|
|
std::vector<details::Step*> _stepHistory;
|
2019-12-31 08:56:41 +00:00
|
|
|
rpl::lifetime _stepLifetime;
|
2016-04-14 19:24:42 +00:00
|
|
|
|
2019-11-26 11:10:44 +00:00
|
|
|
details::Data _data;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2019-04-02 09:13:30 +00:00
|
|
|
Ui::Animations::Simple _coverShownAnimation;
|
2016-11-24 19:28:23 +00:00
|
|
|
int _nextTopFrom = 0;
|
|
|
|
int _controlsTopFrom = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<Ui::FadeWrap<Ui::IconButton>> _back;
|
|
|
|
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _update = { nullptr };
|
|
|
|
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _settings;
|
2014-11-26 16:45:52 +00:00
|
|
|
|
2019-11-26 11:39:54 +00:00
|
|
|
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _next;
|
2017-09-30 18:26:45 +00:00
|
|
|
object_ptr<Ui::FadeWrap<Ui::LinkButton>> _changeLanguage = { nullptr };
|
|
|
|
object_ptr<Ui::FadeWrap<Ui::RoundButton>> _resetAccount = { nullptr };
|
2018-05-30 15:08:12 +00:00
|
|
|
object_ptr<Ui::FadeWrap<Ui::FlatLabel>> _terms = { nullptr };
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2019-02-10 16:29:55 +00:00
|
|
|
std::unique_ptr<Window::ConnectionState> _connecting;
|
2018-05-07 17:44:33 +00:00
|
|
|
|
2019-11-26 14:27:09 +00:00
|
|
|
bool _nextShown = true;
|
2019-11-26 11:10:44 +00:00
|
|
|
Ui::Animations::Simple _nextShownAnimation;
|
|
|
|
|
2016-11-24 19:28:23 +00:00
|
|
|
mtpRequestId _resetRequest = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
};
|
2016-11-24 19:28:23 +00:00
|
|
|
|
|
|
|
} // namespace Intro
|