mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-04 00:25:17 +00:00
links preview done
This commit is contained in:
@@ -107,7 +107,7 @@ void IntroWidget::onParentResize(const QSize &newSize) {
|
||||
|
||||
void IntroWidget::onIntroBack() {
|
||||
if (!current) return;
|
||||
moving = -1;
|
||||
moving = (current == 4) ? -2 : -1;
|
||||
prepareMove();
|
||||
}
|
||||
|
||||
@@ -125,11 +125,13 @@ bool IntroWidget::createNext() {
|
||||
case 1: stages[current + 1] = code = new IntroCode(this); break;
|
||||
case 2:
|
||||
if (_pwdSalt.isEmpty()) {
|
||||
if (signup) delete signup;
|
||||
stages[current + 1] = signup = new IntroSignup(this);
|
||||
} else {
|
||||
stages[current + 1] = pwdcheck = new IntroPwdCheck(this);
|
||||
}
|
||||
break;
|
||||
case 3: stages[current + 1] = signup = new IntroSignup(this); break;
|
||||
}
|
||||
}
|
||||
_back.raise();
|
||||
@@ -138,11 +140,14 @@ bool IntroWidget::createNext() {
|
||||
|
||||
void IntroWidget::prepareMove() {
|
||||
if (cacheForHide.isNull() || cacheForHideInd != current) makeHideCache();
|
||||
|
||||
stages[current + moving]->prepareShow();
|
||||
if (cacheForShow.isNull() || cacheForShowInd != current + moving) makeShowCache();
|
||||
|
||||
xCoordHide = anim::ivalue(0, -moving * st::introSlideShift);
|
||||
int32 m = (moving > 0) ? 1 : -1;
|
||||
xCoordHide = anim::ivalue(0, -m * st::introSlideShift);
|
||||
cAlphaHide = anim::fvalue(1, 0);
|
||||
xCoordShow = anim::ivalue(moving * st::introSlideShift, 0);
|
||||
xCoordShow = anim::ivalue(m * st::introSlideShift, 0);
|
||||
cAlphaShow = anim::fvalue(0, 1);
|
||||
anim::start(this);
|
||||
|
||||
@@ -315,7 +320,7 @@ void IntroWidget::setPwdSalt(const QByteArray &salt) {
|
||||
_pwdSalt = salt;
|
||||
delete signup;
|
||||
delete pwdcheck;
|
||||
stages[3] = 0;
|
||||
stages[3] = stages[4] = 0;
|
||||
signup = 0;
|
||||
pwdcheck = 0;
|
||||
}
|
||||
|
@@ -104,7 +104,7 @@ private:
|
||||
IntroCode *code;
|
||||
IntroSignup *signup;
|
||||
IntroPwdCheck *pwdcheck;
|
||||
IntroStage *stages[4];
|
||||
IntroStage *stages[5];
|
||||
int current, moving, visibilityChanging;
|
||||
|
||||
QString _phone, _phone_hash;
|
||||
@@ -131,6 +131,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void activate() = 0; // show and activate
|
||||
virtual void prepareShow() {
|
||||
}
|
||||
virtual void deactivate() = 0; // deactivate and hide
|
||||
virtual void onNext() = 0;
|
||||
virtual void onBack() = 0;
|
||||
|
@@ -158,6 +158,14 @@ void IntroCode::activate() {
|
||||
code.setFocus();
|
||||
}
|
||||
|
||||
void IntroCode::prepareShow() {
|
||||
code.setText(QString());
|
||||
if (sentRequest) {
|
||||
MTP::cancel(sentRequest);
|
||||
sentRequest = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void IntroCode::deactivate() {
|
||||
callTimer.stop();
|
||||
hide();
|
||||
@@ -222,8 +230,7 @@ bool IntroCode::codeSubmitFail(const RPCError &error) {
|
||||
checkRequest.start(1000);
|
||||
sentRequest = MTP::send(MTPaccount_GetPassword(), rpcDone(&IntroCode::gotPassword), rpcFail(&IntroCode::codeSubmitFail));
|
||||
return true;
|
||||
}
|
||||
if (QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err).hasMatch()) {
|
||||
} else if (error.type().startsWith(qsl("FLOOD_WAIT_"))) {
|
||||
showError(lang(lng_flood_error));
|
||||
code.setFocus();
|
||||
return true;
|
||||
|
@@ -52,6 +52,7 @@ public:
|
||||
bool animStep(float64 ms);
|
||||
|
||||
void activate();
|
||||
void prepareShow();
|
||||
void deactivate();
|
||||
void onNext();
|
||||
void onBack();
|
||||
|
@@ -266,8 +266,7 @@ bool IntroPhone::phoneSubmitFail(const RPCError &error) {
|
||||
showError(lang(lng_bad_phone));
|
||||
enableAll(true);
|
||||
return true;
|
||||
}
|
||||
if (QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err).hasMatch()) {
|
||||
} else if (error.type().startsWith(qsl("FLOOD_WAIT_"))) {
|
||||
showError(lang(lng_flood_error));
|
||||
enableAll(true);
|
||||
return true;
|
||||
|
@@ -36,7 +36,9 @@ _hint(parent->getPwdHint()),
|
||||
_pwdField(this, st::inpIntroPassword, lang(lng_signin_password)),
|
||||
_codeField(this, st::inpIntroPassword, lang(lng_signin_code)),
|
||||
_toRecover(this, lang(lng_signin_recover)),
|
||||
_toPassword(this, lang(lng_signin_try_password)) {
|
||||
_toPassword(this, lang(lng_signin_try_password)),
|
||||
_reset(this, lang(lng_signin_reset_account), st::btnRedLink),
|
||||
sentRequest(0) {
|
||||
setVisible(false);
|
||||
setGeometry(parent->innerRect());
|
||||
|
||||
@@ -46,6 +48,7 @@ _toPassword(this, lang(lng_signin_try_password)) {
|
||||
connect(&_toPassword, SIGNAL(clicked()), this, SLOT(onToPassword()));
|
||||
connect(&_pwdField, SIGNAL(changed()), this, SLOT(onInputChange()));
|
||||
connect(&_codeField, SIGNAL(changed()), this, SLOT(onInputChange()));
|
||||
connect(&_reset, SIGNAL(clicked()), this, SLOT(onReset()));
|
||||
|
||||
_pwdField.setEchoMode(QLineEdit::Password);
|
||||
|
||||
@@ -54,7 +57,8 @@ _toPassword(this, lang(lng_signin_try_password)) {
|
||||
}
|
||||
_codeField.hide();
|
||||
_toPassword.hide();
|
||||
_toRecover.setVisible(_hasRecovery);
|
||||
_toRecover.show();
|
||||
_reset.hide();
|
||||
|
||||
setMouseTracking(true);
|
||||
}
|
||||
@@ -98,6 +102,7 @@ void IntroPwdCheck::resizeEvent(QResizeEvent *e) {
|
||||
_codeField.move((width() - _codeField.width()) / 2, st::introTextTop + st::introTextSize.height() + st::introCountry.top);
|
||||
_toRecover.move(_next.x() + (_pwdField.width() - _toRecover.width()) / 2, _next.y() + _next.height() + st::introFinishSkip);
|
||||
_toPassword.move(_next.x() + (_pwdField.width() - _toPassword.width()) / 2, _next.y() + _next.height() + st::introFinishSkip);
|
||||
_reset.move((width() - _reset.width()) / 2, _toRecover.y() + _toRecover.height() + st::introFinishSkip);
|
||||
}
|
||||
textRect = QRect((width() - st::introTextSize.width()) / 2, st::introTextTop, st::introTextSize.width(), st::introTextSize.height());
|
||||
}
|
||||
@@ -168,6 +173,7 @@ void IntroPwdCheck::onCheckRequest() {
|
||||
}
|
||||
|
||||
void IntroPwdCheck::pwdSubmitDone(bool recover, const MTPauth_Authorization &result) {
|
||||
sentRequest = 0;
|
||||
stopCheck();
|
||||
if (recover) {
|
||||
cSetPasswordRecovered(true);
|
||||
@@ -183,6 +189,7 @@ void IntroPwdCheck::pwdSubmitDone(bool recover, const MTPauth_Authorization &res
|
||||
}
|
||||
|
||||
bool IntroPwdCheck::pwdSubmitFail(const RPCError &error) {
|
||||
sentRequest = 0;
|
||||
stopCheck();
|
||||
_pwdField.setDisabled(false);
|
||||
_codeField.setDisabled(false);
|
||||
@@ -193,10 +200,9 @@ bool IntroPwdCheck::pwdSubmitFail(const RPCError &error) {
|
||||
return true;
|
||||
} else if (err == "PASSWORD_EMPTY") {
|
||||
intro()->onIntroBack();
|
||||
}
|
||||
if (QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err).hasMatch()) {
|
||||
} else if (err.startsWith(qsl("FLOOD_WAIT_"))) {
|
||||
showError(lang(lng_flood_error));
|
||||
_pwdField.setFocus();
|
||||
_pwdField.notaBene();
|
||||
return true;
|
||||
}
|
||||
if (cDebug()) { // internal server error
|
||||
@@ -209,6 +215,7 @@ bool IntroPwdCheck::pwdSubmitFail(const RPCError &error) {
|
||||
}
|
||||
|
||||
bool IntroPwdCheck::codeSubmitFail(const RPCError &error) {
|
||||
sentRequest = 0;
|
||||
stopCheck();
|
||||
_pwdField.setDisabled(false);
|
||||
_codeField.setDisabled(false);
|
||||
@@ -225,10 +232,9 @@ bool IntroPwdCheck::codeSubmitFail(const RPCError &error) {
|
||||
return true;
|
||||
} else if (err == "CODE_INVALID") {
|
||||
showError(lang(lng_signin_wrong_code));
|
||||
_pwdField.notaBene();
|
||||
_codeField.notaBene();
|
||||
return true;
|
||||
}
|
||||
if (QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err).hasMatch()) {
|
||||
} else if (err.startsWith(qsl("FLOOD_WAIT_"))) {
|
||||
showError(lang(lng_flood_error));
|
||||
_codeField.notaBene();
|
||||
return true;
|
||||
@@ -260,34 +266,80 @@ bool IntroPwdCheck::recoverStartFail(const RPCError &error) {
|
||||
}
|
||||
|
||||
void IntroPwdCheck::onToRecover() {
|
||||
showError("");
|
||||
_toRecover.hide();
|
||||
_toPassword.show();
|
||||
_pwdField.hide();
|
||||
_pwdField.setText(QString());
|
||||
_codeField.show();
|
||||
_codeField.setFocus();
|
||||
if (_emailPattern.isEmpty()) {
|
||||
MTP::send(MTPauth_RequestPasswordRecovery(), rpcDone(&IntroPwdCheck::recoverStarted), rpcFail(&IntroPwdCheck::recoverStartFail));
|
||||
if (_hasRecovery) {
|
||||
if (sentRequest) {
|
||||
MTP::cancel(sentRequest);
|
||||
sentRequest = 0;
|
||||
}
|
||||
showError("");
|
||||
_toRecover.hide();
|
||||
_toPassword.show();
|
||||
_pwdField.hide();
|
||||
_pwdField.setText(QString());
|
||||
_codeField.show();
|
||||
_codeField.setFocus();
|
||||
if (_emailPattern.isEmpty()) {
|
||||
MTP::send(MTPauth_RequestPasswordRecovery(), rpcDone(&IntroPwdCheck::recoverStarted), rpcFail(&IntroPwdCheck::recoverStartFail));
|
||||
}
|
||||
update();
|
||||
} else {
|
||||
ConfirmBox *box = new ConfirmBox(lang(lng_signin_no_email_forgot), true);
|
||||
App::wnd()->showLayer(box);
|
||||
connect(box, SIGNAL(destroyed(QObject*)), this, SLOT(onToReset()));
|
||||
}
|
||||
update();
|
||||
}
|
||||
|
||||
void IntroPwdCheck::onToPassword() {
|
||||
ConfirmBox *box = new ConfirmBox(lang(lng_signin_no_email_forgot), true);
|
||||
App::wnd()->showLayer(box);
|
||||
connect(box, SIGNAL(destroyed(QObject*)), this, SLOT(onToReset()));
|
||||
}
|
||||
|
||||
void IntroPwdCheck::onToReset() {
|
||||
if (sentRequest) {
|
||||
MTP::cancel(sentRequest);
|
||||
sentRequest = 0;
|
||||
}
|
||||
_toRecover.show();
|
||||
_toPassword.hide();
|
||||
_pwdField.show();
|
||||
_codeField.hide();
|
||||
_codeField.setText(QString());
|
||||
_pwdField.setFocus();
|
||||
_reset.show();
|
||||
update();
|
||||
}
|
||||
|
||||
void IntroPwdCheck::onReset() {
|
||||
if (sentRequest) return;
|
||||
ConfirmBox *box = new ConfirmBox(lang(lng_sigin_sure_reset), lang(lng_sigin_reset), QString(), st::btnRedDone);
|
||||
connect(box, SIGNAL(confirmed()), this, SLOT(onResetSure()));
|
||||
App::wnd()->showLayer(box);
|
||||
}
|
||||
|
||||
void IntroPwdCheck::onResetSure() {
|
||||
if (sentRequest) return;
|
||||
sentRequest = MTP::send(MTPaccount_DeleteAccount(MTP_string("Forgot password")), rpcDone(&IntroPwdCheck::deleteDone), rpcFail(&IntroPwdCheck::deleteFail));
|
||||
}
|
||||
|
||||
bool IntroPwdCheck::deleteFail(const RPCError &error) {
|
||||
if (mtpIsFlood(error)) return false;
|
||||
sentRequest = 0;
|
||||
showError(lang(lng_server_error));
|
||||
return true;
|
||||
}
|
||||
|
||||
void IntroPwdCheck::deleteDone(const MTPBool &v) {
|
||||
App::wnd()->hideLayer();
|
||||
intro()->onIntroNext();
|
||||
}
|
||||
|
||||
void IntroPwdCheck::onInputChange() {
|
||||
showError("");
|
||||
}
|
||||
|
||||
void IntroPwdCheck::onSubmitPwd(bool force) {
|
||||
if (sentRequest) return;
|
||||
if (_pwdField.isHidden()) {
|
||||
if (!force && !_codeField.isEnabled()) return;
|
||||
QString code = _codeField.text().trimmed();
|
||||
|
@@ -53,12 +53,18 @@ public slots:
|
||||
void onToPassword();
|
||||
void onInputChange();
|
||||
void onCheckRequest();
|
||||
void onToReset();
|
||||
void onReset();
|
||||
void onResetSure();
|
||||
|
||||
private:
|
||||
|
||||
void showError(const QString &err);
|
||||
void stopCheck();
|
||||
|
||||
void deleteDone(const MTPBool &result);
|
||||
bool deleteFail(const RPCError &error);
|
||||
|
||||
QString error;
|
||||
anim::fvalue errorAlpha;
|
||||
|
||||
@@ -71,7 +77,7 @@ private:
|
||||
QString _hint, _emailPattern;
|
||||
|
||||
FlatInput _pwdField, _codeField;
|
||||
LinkButton _toRecover, _toPassword;
|
||||
LinkButton _toRecover, _toPassword, _reset;
|
||||
mtpRequestId sentRequest;
|
||||
|
||||
Text _hintText;
|
||||
|
@@ -239,8 +239,7 @@ bool IntroSignup::nameSubmitFail(const RPCError &error) {
|
||||
showError(lang(lng_bad_name));
|
||||
last.setFocus();
|
||||
return true;
|
||||
}
|
||||
if (QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err).hasMatch()) {
|
||||
} else if (error.type().startsWith(qsl("FLOOD_WAIT_"))) {
|
||||
showError(lang(lng_flood_error));
|
||||
last.setFocus();
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user