tdesktop/Telegram/SourceFiles/intro/intro.h

159 lines
3.7 KiB
C
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop version of Telegram messaging app, see https://telegram.org
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.
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
*/
#pragma once
class Window;
class IntroSteps;
class IntroPhone;
class IntroCode;
class IntroSignup;
class IntroPwdCheck;
class IntroStage;
class Text;
class IntroWidget final : public TWidget {
Q_OBJECT
public:
IntroWidget(Window *window);
void paintEvent(QPaintEvent *e);
void resizeEvent(QResizeEvent *e);
void mousePressEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e);
void updateAdaptiveLayout();
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();
2015-12-08 12:33:37 +00:00
void step_stage(float64 ms, bool timer);
QRect innerRect() const;
QString currentCountry() const;
void setPhone(const QString &phone, const QString &phone_hash, bool registered);
void setCode(const QString &code);
void setCallTimeout(int32 callTimeout);
void setPwdSalt(const QByteArray &salt);
void setHasRecovery(bool hasRecovery);
void setPwdHint(const QString &hint);
void setCodeByTelegram(bool byTelegram);
const QString &getPhone() const;
const QString &getPhoneHash() const;
const QString &getCode() const;
int32 getCallTimeout() const;
const QByteArray &getPwdSalt() const;
bool getHasRecovery() const;
const QString &getPwdHint() const;
bool codeByTelegram() const;
void finish(const MTPUser &user, const QImage &photo = QImage());
void rpcClear();
void langChangeTo(int32 langId);
~IntroWidget();
public slots:
void onIntroNext();
void onIntroBack();
void onDoneStateChanged(int oldState, ButtonStateChangeSource source);
void onParentResize(const QSize &newSize);
void onChangeLang();
signals:
void countryChanged();
private:
void makeHideCache(int stage = -1);
void makeShowCache(int stage = -1);
void prepareMove();
bool createNext();
int32 _langChangeTo;
2015-10-17 14:52:26 +00:00
Animation _a_stage;
QPixmap _cacheHide, _cacheShow;
int _cacheHideIndex, _cacheShowIndex;
anim::ivalue a_coordHide, a_coordShow;
anim::fvalue a_opacityHide, a_opacityShow;
2015-10-17 14:52:26 +00:00
Animation _a_show;
QPixmap _cacheUnder, _cacheOver;
anim::ivalue a_coordUnder, a_coordOver;
anim::fvalue a_shadow;
IntroSteps *steps;
IntroPhone *phone;
IntroCode *code;
IntroSignup *signup;
IntroPwdCheck *pwdcheck;
2015-04-04 20:01:34 +00:00
IntroStage *stages[5];
2015-10-17 14:52:26 +00:00
int current, moving;
QString _phone, _phone_hash;
int32 _callTimeout;
bool _registered;
QString _code;
QByteArray _pwdSalt;
bool _hasRecovery, _codeByTelegram;
QString _pwdHint;
QString _firstname, _lastname;
IconedButton _back;
float64 _backFrom, _backTo;
};
2015-10-17 14:52:26 +00:00
class IntroStage : public TWidget {
public:
2015-10-17 14:52:26 +00:00
IntroStage(IntroWidget *parent) : TWidget(parent) {
}
virtual void activate() = 0; // show and activate
2015-04-04 20:01:34 +00:00
virtual void prepareShow() {
}
virtual void deactivate() = 0; // deactivate and hide
virtual void onNext() = 0;
virtual void onBack() = 0;
virtual bool hasBack() const {
return false;
}
protected:
IntroWidget *intro() {
return qobject_cast<IntroWidget*>(parent());
}
};