2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2014-12-01 10:47:38 +00:00
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
2015-10-03 13:16:42 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2016-04-14 19:24:42 +00:00
|
|
|
#include "mtproto/rpc_sender.h"
|
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
class IntroStep;
|
2016-04-14 19:24:42 +00:00
|
|
|
class IntroWidget : public TWidget, public RPCSender {
|
2014-05-30 08:53:19 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
IntroWidget(QWidget *window);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
void paintEvent(QPaintEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
2016-02-08 14:54:55 +00:00
|
|
|
|
|
|
|
void updateAdaptiveLayout();
|
2014-12-12 16:27:03 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
void animShow(const QPixmap &bgAnimCache, bool back = false);
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_show(float64 ms, bool timer);
|
|
|
|
void stop_show();
|
2016-02-08 14:54:55 +00:00
|
|
|
|
2015-12-08 12:33:37 +00:00
|
|
|
void step_stage(float64 ms, bool timer);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QRect innerRect() const;
|
|
|
|
QString currentCountry() const;
|
|
|
|
|
2016-03-15 19:38:30 +00:00
|
|
|
enum CallStatusType {
|
|
|
|
CallWaiting,
|
|
|
|
CallCalling,
|
|
|
|
CallCalled,
|
|
|
|
CallDisabled,
|
|
|
|
};
|
|
|
|
struct CallStatus {
|
|
|
|
CallStatusType type;
|
|
|
|
int timeout;
|
|
|
|
};
|
2014-05-30 08:53:19 +00:00
|
|
|
void setPhone(const QString &phone, const QString &phone_hash, bool registered);
|
|
|
|
void setCode(const QString &code);
|
2016-03-15 19:38:30 +00:00
|
|
|
void setCallStatus(const CallStatus &status);
|
2015-04-02 10:33:19 +00:00
|
|
|
void setPwdSalt(const QByteArray &salt);
|
|
|
|
void setHasRecovery(bool hasRecovery);
|
|
|
|
void setPwdHint(const QString &hint);
|
2015-08-31 14:27:20 +00:00
|
|
|
void setCodeByTelegram(bool byTelegram);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
const QString &getPhone() const;
|
|
|
|
const QString &getPhoneHash() const;
|
|
|
|
const QString &getCode() const;
|
2016-03-15 19:38:30 +00:00
|
|
|
const CallStatus &getCallStatus() const;
|
2015-04-02 10:33:19 +00:00
|
|
|
const QByteArray &getPwdSalt() const;
|
|
|
|
bool getHasRecovery() const;
|
|
|
|
const QString &getPwdHint() const;
|
2015-08-31 14:27:20 +00:00
|
|
|
bool codeByTelegram() const;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
void finish(const MTPUser &user, const QImage &photo = QImage());
|
|
|
|
|
2016-04-19 08:57:55 +00:00
|
|
|
void rpcClear() override;
|
2014-12-19 21:20:30 +00:00
|
|
|
void langChangeTo(int32 langId);
|
2014-08-01 11:09:46 +00:00
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
void nextStep(IntroStep *step) {
|
|
|
|
pushStep(step, MoveForward);
|
|
|
|
}
|
|
|
|
void replaceStep(IntroStep *step) {
|
|
|
|
pushStep(step, MoveReplace);
|
|
|
|
}
|
|
|
|
|
|
|
|
~IntroWidget() override;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
void onStepSubmit();
|
|
|
|
void onBack();
|
2014-05-30 08:53:19 +00:00
|
|
|
void onParentResize(const QSize &newSize);
|
2014-12-19 21:20:30 +00:00
|
|
|
void onChangeLang();
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
void countryChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
QPixmap grabStep(int skip = 0);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-04-14 19:24:42 +00:00
|
|
|
int _langChangeTo = 0;
|
2014-12-19 21:20:30 +00:00
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
Animation _a_stage;
|
|
|
|
QPixmap _cacheHide, _cacheShow;
|
2016-04-14 19:24:42 +00:00
|
|
|
int _cacheHideIndex = 0;
|
|
|
|
int _cacheShowIndex = 0;
|
2015-10-17 14:52:26 +00:00
|
|
|
anim::ivalue a_coordHide, a_coordShow;
|
|
|
|
anim::fvalue a_opacityHide, a_opacityShow;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2015-10-17 14:52:26 +00:00
|
|
|
Animation _a_show;
|
|
|
|
QPixmap _cacheUnder, _cacheOver;
|
|
|
|
anim::ivalue a_coordUnder, a_coordOver;
|
|
|
|
anim::fvalue a_shadow;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
QVector<IntroStep*> _stepHistory;
|
|
|
|
IntroStep *step(int skip = 0) {
|
|
|
|
t_assert(_stepHistory.size() + skip > 0);
|
|
|
|
return _stepHistory.at(_stepHistory.size() - skip - 1);
|
|
|
|
}
|
|
|
|
enum MoveType {
|
|
|
|
MoveBack,
|
|
|
|
MoveForward,
|
|
|
|
MoveReplace,
|
|
|
|
};
|
|
|
|
void historyMove(MoveType type);
|
|
|
|
void pushStep(IntroStep *step, MoveType type);
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-04-14 19:24:42 +00:00
|
|
|
void gotNearestDC(const MTPNearestDc &dc);
|
|
|
|
|
|
|
|
QString _countryForReg;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
QString _phone, _phone_hash;
|
2016-04-14 19:24:42 +00:00
|
|
|
CallStatus _callStatus = { CallDisabled, 0 };
|
|
|
|
bool _registered = false;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
QString _code;
|
|
|
|
|
2015-04-02 10:33:19 +00:00
|
|
|
QByteArray _pwdSalt;
|
2016-04-14 19:24:42 +00:00
|
|
|
bool _hasRecovery = false;
|
|
|
|
bool _codeByTelegram = false;
|
2015-04-02 10:33:19 +00:00
|
|
|
QString _pwdHint;
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
QString _firstname, _lastname;
|
|
|
|
|
2014-11-26 16:45:52 +00:00
|
|
|
IconedButton _back;
|
2016-04-14 19:24:42 +00:00
|
|
|
float64 _backFrom = 0.;
|
|
|
|
float64 _backTo = 0.;
|
2014-11-26 16:45:52 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
};
|
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
class IntroStep : public TWidget, public RPCSender {
|
2014-05-30 08:53:19 +00:00
|
|
|
public:
|
|
|
|
|
2016-03-14 16:59:18 +00:00
|
|
|
IntroStep(IntroWidget *parent) : TWidget(parent) {
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2014-11-26 16:45:52 +00:00
|
|
|
virtual bool hasBack() const {
|
|
|
|
return false;
|
|
|
|
}
|
2016-03-14 16:59:18 +00:00
|
|
|
virtual void activate() {
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
virtual void cancelled() {
|
|
|
|
}
|
|
|
|
virtual void finished() {
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
virtual void onSubmit() = 0;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
protected:
|
2016-02-08 14:54:55 +00:00
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
IntroWidget *intro() {
|
2016-03-16 11:54:37 +00:00
|
|
|
IntroWidget *result = qobject_cast<IntroWidget*>(parentWidget());
|
|
|
|
t_assert(result != nullptr);
|
|
|
|
return result;
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|