many various fixes, intro and login slightly redesigned

This commit is contained in:
John Preston 2014-11-26 19:45:52 +03:00
parent 7efb5df35c
commit fc04717d96
21 changed files with 263 additions and 158 deletions

View file

@ -17,7 +17,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
*/
direction: "LTR";
lng_maintitle: "Telegram D";
lng_maintitle: "Telegram Desktop";
lng_menu_contacts: "Contacts";
lng_menu_settings: "Settings";
@ -89,14 +89,12 @@ lng_server_error: "Internal server error.";
lng_flood_error: "Too much tries. Please try again later.";
lng_deleted: "Unknown";
lng_intro1: "Welcome to an official [b]desktop[/b] client
of [b]Telegram[/b] mobile messenger.";
lng_intro2: "Visit [a href=\"https://telegram.org/\"]telegram.org[/a] to learn more.";
lng_start_msgs: "Start Messaging";
lng_intro: "Welcome to the official [a href=\"https://telegram.org/\"]Telegram[/a] desktop app.
It's [b]fast[/b] and [b]secure[/b].";
lng_start_msgs: "START MESSAGING";
lng_intro_back: "Back";
lng_intro_next: "Next";
lng_intro_finish: "Finish";
lng_intro_next: "NEXT";
lng_intro_finish: "SIGN UP";
lng_phone_ph: "Your phone number";
lng_phone_title: "Your Phone";
@ -112,7 +110,7 @@ lng_country_none: "Country not found";
lng_country_select: "Select Country";
lng_code_ph: "Your code";
lng_code_desc: "We have sent you an SMS with activation
lng_code_desc: "We have sent you a message with activation
code to your phone. Please enter it below.";
lng_code_call: "Telegram will dial your number in %1:%2";
lng_code_calling: "Requesting a call from Telegram..";
@ -126,6 +124,8 @@ lng_bad_chat_title: "Please enter new chat title.";
lng_bad_photo: "Bad image selected.";
lng_signup_title: "Information and photo";
lng_signup_desc: "Please enter your name and
upload a photo.";
lng_signup_firstname: "First Name";
lng_signup_lastname: "Last Name";

View file

@ -306,20 +306,18 @@ labelDefFlat: flatLabel {
align: align(left);
}
introSkip: 20px;
introBtnTop: 288px;
introSkip: 45px;
introFinishSkip: 15px;
introHeaderFont: font(28px);
introPhotoSize: 98px;
introHeaderFont: font(24px);
introHeaderSkip: 14px;
introFont: font(17px);
introVersionFont: introFont;
introVersionColor: #9b9b9b;
introVersionSkip: 10px;
intro2Skip: 60px;
intro1Skip: 14px;
introIconSkip: 54px;
introFont: font(16px);
introColor: black;
introLabel: flatLabel(labelDefFlat) {
font: introFont;
align: align(center);
}
introPointsTop: -30px; // intro steps bottom points
@ -350,31 +348,28 @@ introHideFunc: transition(easeInCirc);
introShowFunc: transition(easeOutCirc);
introAlphaHideFunc: transition(easeOutCirc);
introAlphaShowFunc: transition(easeInCirc);
introTextSize: size(400px, 97px);
introTitleFont: font(24px);
introDescFont: font(18px);
introTextTop: 22px;
introTextSize: size(400px, 93px);
introCallSkip: 15px;
btnIntroSep: 12px;
btnIntroNext: flatButton(btnDefNext, btnDefBig) {
width: 144px;
}
btnIntroBack: flatButton(btnIntroNext, btnDefBack) {
}
textTop: 16px;
overTextTop: 16px;
downTextTop: 17px;
font: font(17px);
overFont: font(17px);
btnIntroStart: flatButton(btnIntroNext) {
width: 300px;
}
btnIntroFinish: flatButton(btnIntroNext) {
width: 240px;
}
boxShadow: sprite(240px, 21px, 9px, 9px);
introCountry: countryInput {
width: 300px;
height: 41px;
top: 24px;
top: 33px;
bgColor: #f2f2f2;
ptrSize: size(15px, 8px);
textMrg: margins(16px, 5px, 16px, 15px);
@ -397,13 +392,14 @@ inpIntroCode: flatInput(inpDefGray) {
textMrg: margins(12px, 5px, 12px, 6px);
width: 106px;
height: 41px;
align: align(center);
phPos: point(0px, 0px);
phAlign: align(center);
phShift: 0px;
}
inpIntroName: flatInput(inpIntroPhone) {
width: 240px;
width: 192px;
}
introSelectDelta: 30px;
@ -465,8 +461,6 @@ countriesBackShowFunc: transition(linear);
countriesAlphaHideFunc: transition(easeOutCirc);
countriesAlphaShowFunc: transition(easeInCirc);
introBtnTop: 244px;
introErrWidth: 450px;
introErrDuration: 200;
introErrFunc: transition(linear);
@ -478,6 +472,7 @@ introErrFont: font(16px);
introErrLabel: flatLabel(labelDefFlat) {
font: introErrFont;
align: align(center);
}
setWidth: 356px;
@ -506,15 +501,17 @@ setScroll: flatScroll(scrollDef) {
topsh: 0px;
}
setClose: iconedButton(btnDefIconed) {
icon: sprite(245px, 221px, 43px, 43px);
icon: sprite(245px, 221px, 40px, 40px);
iconPos: point(0px, 0px);
downIcon: sprite(245px, 221px, 43px, 43px);
downIcon: sprite(245px, 221px, 40px, 40px);
downIconPos: point(0px, 0px);
opacity: 0.71;
width: 43px;
height: 43px;
}
setClosePos: point(18px, 18px);
setClosePos: point(32px, 32px);
setPhotoImg: sprite(0px, 220px, 120px, 120px);
setOverPhotoImg: sprite(122px, 220px, 120px, 120px);
setPhotoDuration: 150;
@ -844,6 +841,12 @@ dlgActiveTextStyle: textStyle(defaultTextStyle) {
lnkDownColor: dlgActiveColor;
lnkOverFlags: font(fsize);
}
introLabelTextStyle: textStyle(defaultTextStyle) {
lineHeight: 30px;
}
introErrLabelTextStyle: textStyle(defaultTextStyle) {
lineHeight: 27px;
}
mediaMaxWidth: 250px;
mediaFont: font(fsize);

View file

@ -89,6 +89,8 @@ Application::Application(int &argc, char **argv) : PsApplication(argc, argv),
serverName(psServerPrefix() + cGUIDStr()), closing(false),
updateRequestId(0), updateReply(0), updateThread(0), updateDownloader(0) {
DEBUG_LOG(("Application Info: creation.."));
QByteArray d(QDir((cPlatform() == dbipWindows ? cExeDir() : cWorkingDir()).toLower()).absolutePath().toUtf8());
char h[33] = { 0 };
hashMd5Hex(d.constData(), d.size(), h);
@ -138,9 +140,11 @@ Application::Application(int &argc, char **argv) : PsApplication(argc, argv),
anim::startManager();
historyInit();
DEBUG_LOG(("Application Info: inited.."));
window = new Window();
psInstallEventFilter();
psInstallEventFilter();
connect(&socket, SIGNAL(connected()), this, SLOT(socketConnected()));
connect(&socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
@ -158,7 +162,7 @@ Application::Application(int &argc, char **argv) : PsApplication(argc, argv),
connect(&killDownloadSessionsTimer, SIGNAL(timeout()), this, SLOT(killDownloadSessions()));
if (cManyInstance()) {
if (cManyInstance()) {
startApp();
} else {
DEBUG_LOG(("Application Info: connecting local socket to %1..").arg(serverName));
@ -620,8 +624,11 @@ void Application::socketError(QLocalSocket::LocalSocketError e) {
}
void Application::startApp() {
DEBUG_LOG(("Application Info: starting app.."));
Local::ReadMapState state = Local::readMap(QByteArray());
DEBUG_LOG(("Application Info: local map read.."));
App::readUserConfig();
if (!Local::oldKey().created()) {
Local::createOldKey();
@ -632,10 +639,12 @@ void Application::startApp() {
App::writeUserConfig();
cSetNeedConfigResave(false);
}
DEBUG_LOG(("Application Info: user config read.."));
window->createWinId();
window->init();
DEBUG_LOG(("Application Info: window created.."));
readSupportTemplates();
MTP::start();
@ -643,9 +652,13 @@ void Application::startApp() {
MTP::setStateChangedHandler(mtpStateChanged);
MTP::setSessionResetHandler(mtpSessionReset);
DEBUG_LOG(("Application Info: MTP started.."));
initImageLinkManager();
App::initMedia();
DEBUG_LOG(("Application Info: showing."));
if (MTP::authedId()) {
window->setupMain(false);
} else {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 KiB

After

Width:  |  Height:  |  Size: 98 KiB

View file

@ -45,10 +45,24 @@ namespace {
}
IntroWidget::IntroWidget(Window *window) : QWidget(window),
cacheForHideInd(0), cacheForShowInd(0), wnd(window), steps(new IntroSteps(this)),
phone(0), code(0), signup(0), current(0), moving(0), visibilityChanging(0), _callTimeout(60) {
cacheForHideInd(0),
cacheForShowInd(0),
wnd(window),
steps(new IntroSteps(this)),
phone(0),
code(0),
signup(0),
current(0),
moving(0),
visibilityChanging(0),
_callTimeout(60),
_back(this, st::setClose),
_backFrom(0), _backTo(0) {
setGeometry(QRect(0, st::titleHeight, wnd->width(), wnd->height() - st::titleHeight));
connect(&_back, SIGNAL(clicked()), this, SLOT(onIntroBack()));
_back.hide();
countryForReg = psCurrentCountry();
MTP::send(MTPhelp_GetNearestDc(), rpcDone(gotNearestDC));
@ -56,11 +70,14 @@ IntroWidget::IntroWidget(Window *window) : QWidget(window),
stages[0] = steps;
memset(stages + 1, 0, sizeof(QWidget*) * 3);
_back.raise();
connect(window, SIGNAL(resized(const QSize &)), this, SLOT(onParentResize(const QSize &)));
show();
setFocus();
_back.move(st::setClosePos.x(), st::setClosePos.y());
}
void IntroWidget::onParentResize(const QSize &newSize) {
@ -88,6 +105,7 @@ bool IntroWidget::createNext() {
case 2: stages[current + 1] = signup = new IntroSignup(this); break;
}
}
_back.raise();
return true;
}
@ -101,6 +119,14 @@ void IntroWidget::prepareMove() {
cAlphaShow = anim::fvalue(0, 1);
anim::start(this);
_backTo = stages[current + moving]->hasBack() ? 1 : 0;
_backFrom = stages[current]->hasBack() ? 1 : 0;
animStep(0);
if (_backFrom > 0 || _backTo > 0) {
_back.show();
} else {
_back.hide();
}
stages[current]->deactivate();
stages[current + moving]->hide();
}
@ -138,6 +164,12 @@ void IntroWidget::animShow(const QPixmap &bgAnimCache, bool back) {
anim::stop(this);
stages[current]->show();
if (stages[current]->hasBack()) {
_back.setOpacity(1);
_back.show();
} else {
_back.hide();
}
_animCache = myGrab(this, rect());
visibilityChanging = 1;
@ -148,6 +180,7 @@ void IntroWidget::animShow(const QPixmap &bgAnimCache, bool back) {
stages[current]->deactivate();
stages[current]->hide();
_back.hide();
anim::start(this);
show();
}
@ -170,6 +203,10 @@ bool IntroWidget::animStep(float64 ms) {
setFocus();
stages[current]->show();
stages[current]->activate();
if (stages[current]->hasBack()) {
_back.setOpacity(1);
_back.show();
}
} else {
a_bgCoord.update(dt1, st::introHideFunc);
a_bgAlpha.update(dt1, st::introAlphaHideFunc);
@ -187,11 +224,19 @@ bool IntroWidget::animStep(float64 ms) {
moving = 0;
setFocus();
stages[current]->activate();
if (!stages[current]->hasBack()) {
_back.hide();
}
} else {
xCoordShow.update(dt2, st::introShowFunc);
cAlphaShow.update(dt2, st::introAlphaShowFunc);
xCoordHide.update(dt1, st::introHideFunc);
cAlphaHide.update(dt1, st::introAlphaHideFunc);
if (_backFrom != _backTo) {
_back.setOpacity((_backFrom > _backTo) ? cAlphaHide.current() : cAlphaShow.current());
} else {
_back.setOpacity(1);
}
}
update();
return res;

View file

@ -104,6 +104,9 @@ private:
QString _firstname, _lastname;
IconedButton _back;
float64 _backFrom, _backTo;
};
class IntroStage : public QWidget {
@ -116,6 +119,9 @@ public:
virtual void deactivate() = 0; // deactivate and hide
virtual void onNext() = 0;
virtual void onBack() = 0;
virtual bool hasBack() const {
return false;
}
protected:

View file

@ -69,14 +69,12 @@ void CodeInput::correctValue(QKeyEvent *e, const QString &was) {
IntroCode::IntroCode(IntroWidget *parent) : IntroStage(parent), errorAlpha(0),
next(this, lang(lng_intro_next), st::btnIntroNext),
back(this, lang(lng_intro_back), st::btnIntroBack),
code(this, st::inpIntroCode, lang(lng_code_ph)), waitTillCall(intro()->getCallTimeout()) {
setVisible(false);
setGeometry(parent->innerRect());
connect(&next, SIGNAL(stateChanged(int, ButtonStateChangeSource)), parent, SLOT(onDoneStateChanged(int, ButtonStateChangeSource)));
connect(&next, SIGNAL(clicked()), this, SLOT(onSubmitCode()));
connect(&back, SIGNAL(clicked()), parent, SLOT(onIntroBack()));
connect(&code, SIGNAL(changed()), this, SLOT(onInputChange()));
connect(&callTimer, SIGNAL(timeout()), this, SLOT(onSendCall()));
connect(&checkRequest, SIGNAL(timeout()), this, SLOT(onCheckRequest()));
@ -91,9 +89,9 @@ void IntroCode::paintEvent(QPaintEvent *e) {
}
if (trivial || e->rect().intersects(textRect)) {
p.setFont(st::introHeaderFont->f);
p.drawText(textRect, intro()->getPhone(), style::al_topleft);
p.drawText(textRect, intro()->getPhone(), style::al_top);
p.setFont(st::introFont->f);
p.drawText(textRect, lang(lng_code_desc), style::al_bottomleft);
p.drawText(textRect, lang(lng_code_desc), style::al_bottom);
}
QString callText = lang(lng_code_calling);
if (waitTillCall >= 3600) {
@ -103,7 +101,7 @@ void IntroCode::paintEvent(QPaintEvent *e) {
} else if (waitTillCall < 0) {
callText = lang(lng_code_called);
}
p.drawText(QRect(textRect.left(), code.y() + code.height() + st::introSkip, st::introTextSize.width(), st::introErrHeight), callText, style::al_left);
p.drawText(QRect(textRect.left(), code.y() + code.height() + st::introCallSkip, st::introTextSize.width(), st::introErrHeight), callText, style::al_center);
if (animating() || error.length()) {
p.setOpacity(errorAlpha.current());
p.setFont(st::introErrFont->f);
@ -113,14 +111,11 @@ void IntroCode::paintEvent(QPaintEvent *e) {
}
void IntroCode::resizeEvent(QResizeEvent *e) {
int sumBack = st::btnIntroNext.width + st::btnIntroBack.width + st::btnIntroSep;
if (e->oldSize().width() != width()) {
int sumNext = st::btnIntroNext.width - st::btnIntroBack.width - st::btnIntroSep;
back.move((width() - sumBack) / 2, st::introBtnTop);
next.move((width() - sumNext) / 2, st::introBtnTop);
code.move((width() - sumBack) / 2, st::introTextSize.height() + 24);
next.move((width() - next.width()) / 2, st::introBtnTop);
code.move((width() - code.width()) / 2, st::introTextTop + st::introTextSize.height() + st::introCountry.top);
}
textRect = QRect((width() - sumBack) / 2, 0, st::introTextSize.width(), st::introTextSize.height());
textRect = QRect((width() - st::introTextSize.width()) / 2, st::introTextTop, st::introTextSize.width(), st::introTextSize.height());
}
void IntroCode::showError(const QString &err) {

View file

@ -56,6 +56,10 @@ public:
void onNext();
void onBack();
bool hasBack() const {
return true;
}
void codeSubmitDone(const MTPauth_Authorization &result);
bool codeSubmitFail(const RPCError &error);
@ -75,7 +79,7 @@ private:
QString error;
anim::fvalue errorAlpha;
FlatButton next, back;
FlatButton next;
QRect textRect;

View file

@ -42,10 +42,10 @@ namespace {
IntroPhone::IntroPhone(IntroWidget *parent) : IntroStage(parent),
errorAlpha(0), changed(false),
next(this, lang(lng_intro_next), st::btnIntroStart),
next(this, lang(lng_intro_next), st::btnIntroNext),
country(this, st::introCountry),
phone(this, st::inpIntroPhone, lang(lng_phone_ph)), code(this, st::inpIntroCountryCode),
_signup(this, lang(lng_phone_notreg).replace(qsl("{signup}"), textcmdStartLink(1)).replace(qsl("{/signup}"), textcmdStopLink()), st::introErrLabel),
_signup(this, lang(lng_phone_notreg).replace(qsl("{signup}"), textcmdStartLink(1)).replace(qsl("{/signup}"), textcmdStopLink()), st::introErrLabel, st::introErrLabelTextStyle),
_showSignup(false) {
setVisible(false);
setGeometry(parent->innerRect());
@ -82,15 +82,16 @@ void IntroPhone::paintEvent(QPaintEvent *e) {
}
if (trivial || e->rect().intersects(textRect)) {
p.setFont(st::introHeaderFont->f);
p.drawText(textRect, lang(lng_phone_title), style::al_topleft);
p.drawText(textRect, lang(lng_phone_title), style::al_top);
p.setFont(st::introFont->f);
p.drawText(textRect, lang(lng_phone_desc), style::al_bottomleft);
p.drawText(textRect, lang(lng_phone_desc), style::al_bottom);
}
if (animating() || error.length()) {
int32 errorY = _showSignup ? ((phone.y() + phone.height() + next.y() - st::introErrFont->height) / 2) : (next.y() + next.height() + st::introErrTop);
p.setOpacity(errorAlpha.current());
p.setFont(st::introErrFont->f);
p.setPen(st::introErrColor->p);
p.drawText(textRect.x(), next.y() + next.height() + st::introErrTop + st::introErrFont->ascent, error);
p.drawText(QRect(textRect.x(), errorY, textRect.width(), st::introErrFont->height), error, style::al_top);
if (_signup.isHidden() && _showSignup) {
p.drawPixmap(_signup.x(), _signup.y(), _signupCache);
@ -101,13 +102,13 @@ void IntroPhone::paintEvent(QPaintEvent *e) {
void IntroPhone::resizeEvent(QResizeEvent *e) {
if (e->oldSize().width() != width()) {
next.move((width() - next.width()) / 2, st::introBtnTop);
country.move((width() - country.width()) / 2, st::introTextSize.height() + st::introCountry.top);
country.move((width() - country.width()) / 2, st::introTextTop + st::introTextSize.height() + st::introCountry.top);
int phoneTop = country.y() + country.height() + st::introPhoneTop;
phone.move((width() + country.width()) / 2 - st::inpIntroPhone.width, phoneTop);
phone.move((width() - country.width()) / 2 + country.width() - st::inpIntroPhone.width, phoneTop);
code.move((width() - country.width()) / 2, phoneTop);
}
_signup.move((width() - next.width()) / 2, next.y() + next.height() + st::introErrTop * 2 + st::introErrFont->height);
textRect = QRect((width() - next.width()) / 2, 0, st::introTextSize.width(), st::introTextSize.height());
_signup.move((width() - _signup.width()) / 2, next.y() + next.height() + st::introErrTop - ((st::introErrLabelTextStyle.lineHeight - st::introErrFont->height) / 2));
textRect = QRect((width() - st::introTextSize.width()) / 2, st::introTextTop, st::introTextSize.width(), st::introTextSize.height());
}
void IntroPhone::showError(const QString &err, bool signUp) {

View file

@ -29,7 +29,7 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
IntroSignup::IntroSignup(IntroWidget *parent) : IntroStage(parent),
errorAlpha(0), a_photo(0),
next(this, lang(lng_intro_finish), st::btnIntroFinish),
next(this, lang(lng_intro_finish), st::btnIntroNext),
first(this, st::inpIntroName, lang(lng_signup_firstname)),
last(this, st::inpIntroName, lang(lng_signup_lastname)) {
setVisible(false);
@ -42,7 +42,7 @@ IntroSignup::IntroSignup(IntroWidget *parent) : IntroStage(parent),
}
void IntroSignup::mouseMoveEvent(QMouseEvent *e) {
bool photoOver = QRect(_phLeft, _phTop, st::setPhotoSize, st::setPhotoSize).contains(e->pos());
bool photoOver = QRect(_phLeft, _phTop, st::introPhotoSize, st::introPhotoSize).contains(e->pos());
if (photoOver != _photoOver) {
_photoOver = photoOver;
if (_photoSmall.isNull()) {
@ -57,7 +57,7 @@ void IntroSignup::mouseMoveEvent(QMouseEvent *e) {
void IntroSignup::mousePressEvent(QMouseEvent *e) {
mouseMoveEvent(e);
if (QRect(_phLeft, _phTop, st::setPhotoSize, st::setPhotoSize).contains(e->pos())) {
if (QRect(_phLeft, _phTop, st::introPhotoSize, st::introPhotoSize).contains(e->pos())) {
QStringList imgExtensions(cImgExtensions());
QString filter(qsl("Image files (*") + imgExtensions.join(qsl(" *")) + qsl(");;All files (*.*)"));
@ -94,8 +94,10 @@ void IntroSignup::paintEvent(QPaintEvent *e) {
p.setClipRect(e->rect());
}
if (trivial || e->rect().intersects(textRect)) {
p.setFont(st::introTitleFont->f);
p.drawText(textRect, lang(lng_signup_title), QTextOption(Qt::AlignHCenter | Qt::AlignTop));
p.setFont(st::introHeaderFont->f);
p.drawText(textRect, lang(lng_signup_title), style::al_top);
p.setFont(st::introFont->f);
p.drawText(textRect, lang(lng_signup_desc), style::al_bottom);
}
if (animating() || error.length()) {
p.setOpacity(errorAlpha.current());
@ -111,11 +113,17 @@ void IntroSignup::paintEvent(QPaintEvent *e) {
if (_photoSmall.isNull()) {
if (a_photo.current() < 1) {
p.drawPixmap(QPoint(_phLeft, _phTop), App::sprite(), st::setPhotoImg);
QRect pix(st::setPhotoImg);
pix.moveTo(pix.x() + (pix.width() - st::introPhotoSize) / 2, pix.y() + (pix.height() - st::introPhotoSize) / 2);
pix.setSize(QSize(st::introPhotoSize, st::introPhotoSize));
p.drawPixmap(QPoint(_phLeft, _phTop), App::sprite(), pix);
}
if (a_photo.current() > 0) {
QRect pix(st::setOverPhotoImg);
pix.moveTo(pix.x() + (pix.width() - st::introPhotoSize) / 2, pix.y() + (pix.height() - st::introPhotoSize) / 2);
pix.setSize(QSize(st::introPhotoSize, st::introPhotoSize));
p.setOpacity(a_photo.current());
p.drawPixmap(QPoint(_phLeft, _phTop), App::sprite(), st::setOverPhotoImg);
p.drawPixmap(QPoint(_phLeft, _phTop), App::sprite(), pix);
p.setOpacity(1);
}
} else {
@ -124,18 +132,14 @@ void IntroSignup::paintEvent(QPaintEvent *e) {
}
void IntroSignup::resizeEvent(QResizeEvent *e) {
textRect = QRect((width() - st::introTextSize.width()) / 2, 0, st::introTextSize.width(), st::introTextSize.height());
_phLeft = (width() - st::setPhotoImg.pxWidth()) / 2;
_phTop = st::introHeaderFont->height + st::introFinishSkip;
_phLeft = (width() - next.width()) / 2;
_phTop = st::introTextTop + st::introTextSize.height() + st::introCountry.top;
if (e->oldSize().width() != width()) {
int sumNext = st::btnIntroNext.width - st::btnIntroBack.width - st::btnIntroSep;
next.move((width() - sumNext) / 2, st::introSize.height() - st::btnIntroNext.height);
}
if (e->oldSize().width() != width()) {
next.move((width() - next.width()) / 2, st::introSize.height() - st::btnIntroNext.height);
first.move((width() - first.width()) / 2, _phTop + st::setPhotoImg.pxHeight() + st::introFinishSkip);
last.move((width() - last.width()) / 2, first.y() + first.height() + st::introFinishSkip);
next.move((width() - next.width()) / 2, st::introBtnTop);
first.move((width() - next.width()) / 2 + next.width() - first.width(), _phTop);
last.move((width() - next.width()) / 2 + next.width() - last.width(), first.y() + st::introCountry.height + st::introCountry.ptrSize.height() + st::introPhoneTop);
}
textRect = QRect((width() - st::introTextSize.width()) / 2, st::introTextTop, st::introTextSize.width(), st::introTextSize.height());
}
void IntroSignup::showError(const QString &err) {
@ -204,7 +208,7 @@ void IntroSignup::onCheckRequest() {
void IntroSignup::onPhotoReady(const QImage &img) {
_photoBig = img;
_photoSmall = QPixmap::fromImage(img.scaled(st::setPhotoSize, st::setPhotoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
_photoSmall = QPixmap::fromImage(img.scaled(st::introPhotoSize, st::introPhotoSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
App::wnd()->hideLayer();
}

View file

@ -25,9 +25,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com
#include "intro/intro.h"
IntroSteps::IntroSteps(IntroWidget *parent) : IntroStage(parent),
_intro1(this, lang(lng_intro1), st::introLabel),
_intro2(this, lang(lng_intro2), st::introLabel),
_next(this, lang(lng_start_msgs), st::btnIntroStart) {
_intro(this, lang(lng_intro), st::introLabel, st::introLabelTextStyle),
_next(this, lang(lng_start_msgs), st::btnIntroNext) {
_headerWidth = st::introHeaderFont->m.width(lang(lng_maintitle));
@ -46,21 +45,19 @@ void IntroSteps::paintEvent(QPaintEvent *e) {
if (!trivial) {
p.setClipRect(e->rect());
}
int32 hy = _intro1.y() - st::introHeaderFont->height - st::introHeaderSkip + st::introHeaderFont->ascent;
int32 hy = _intro.y() - st::introHeaderFont->height - st::introHeaderSkip + st::introHeaderFont->ascent;
p.setFont(st::introHeaderFont->f);
p.drawText(_next.x(), hy, lang(lng_maintitle));
p.setPen(st::introColor->p);
p.setFont(st::introVersionFont->f);
p.setPen(st::introVersionColor->p);
p.drawText(_next.x() + _headerWidth + st::introVersionSkip, hy, qsl("alpha ") + QString::fromWCharArray(AppVersionStr));
p.drawText((width() - _headerWidth) / 2, hy, lang(lng_maintitle));
p.drawPixmap(QPoint((width() - st::aboutIcon.pxWidth()) / 2, hy - st::introIconSkip - st::aboutIcon.pxHeight()), App::sprite(), st::aboutIcon);
}
void IntroSteps::resizeEvent(QResizeEvent *e) {
if (e->oldSize().width() != width()) {
_next.move((width() - st::btnIntroStart.width) / 2, st::introBtnTop);
_intro2.move(_next.x(), _next.y() - _intro2.height() - st::intro2Skip);
_intro1.move(_next.x(), _intro2.y() - _intro1.height() - st::intro1Skip);
_next.move((width() - _next.width()) / 2, st::introBtnTop);
_intro.move((width() - _intro.width()) / 2, _next.y() - _intro.height() - st::introSkip);
}
}

View file

@ -36,7 +36,7 @@ public:
private:
FlatLabel _intro1, _intro2;
FlatLabel _intro;
FlatButton _next;
int32 _headerWidth;

View file

@ -48,6 +48,9 @@ namespace {
typedef QList<DelayedRequest> DelayedRequestsList;
DelayedRequestsList delayedRequests;
typedef QMap<mtpRequestId, int32> RequestsDelays;
RequestsDelays requestsDelays;
typedef QSet<mtpRequestId> BadGuestDCRequests;
BadGuestDCRequests badGuestDCRequests;
@ -138,7 +141,8 @@ namespace {
bool onErrorDefault(mtpRequestId requestId, const RPCError &error) {
const QString &err(error.type());
bool badGuestDC = (error.code() == 400) && (err == qsl("FILE_ID_INVALID"));
int32 code = error.code();
bool badGuestDC = (code == 400) && (err == qsl("FILE_ID_INVALID"));
QRegularExpressionMatch m;
if ((m = QRegularExpression("^(FILE|PHONE|NETWORK|USER)_MIGRATE_(\\d+)$").match(err)).hasMatch()) {
if (!requestId) return false;
@ -183,10 +187,20 @@ namespace {
_mtp_internal::registerRequest(requestId, (dc < 0) ? -newdc : newdc);
_mtp_internal::getSession(newdc)->sendPrepared(req);
return true;
} else if ((m = QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err)).hasMatch()) {
} else if (code < 0 || code >= 500 || (m = QRegularExpression("^FLOOD_WAIT_(\\d+)$").match(err)).hasMatch()) {
if (!requestId) return false;
int32 secs = m.captured(1).toInt();
int32 secs = 1;
if (code < 0 || code >= 500) {
RequestsDelays::iterator i = requestsDelays.find(requestId);
if (i != requestsDelays.cend()) {
secs = (i.value() > 60) ? i.value() : (i.value() *= 2);
} else {
requestsDelays.insert(requestId, secs);
}
} else {
secs = m.captured(1).toInt();
}
uint64 sendAt = getms(true) + secs * 1000 + 10;
DelayedRequestsList::iterator i = delayedRequests.begin(), e = delayedRequests.end();
for (; i != e; ++i) {
@ -198,7 +212,7 @@ namespace {
if (resender) resender->checkDelayed();
return true;
} else if (error.code() == 401 || (badGuestDC && badGuestDCRequests.constFind(requestId) == badGuestDCRequests.cend())) {
} else if (code == 401 || (badGuestDC && badGuestDCRequests.constFind(requestId) == badGuestDCRequests.cend())) {
int32 dc = 0;
{
QMutexLocker locker(&requestByDCLock);
@ -246,7 +260,8 @@ namespace {
}
if (!dc) return false;
_mtp_internal::getSession(dc < 0 ? (-dc) : dc)->sendPreparedWithInit(req);
req->needsLayer = true;
_mtp_internal::getSession(dc < 0 ? (-dc) : dc)->sendPrepared(req);
return true;
} else if (err == qsl("MSG_WAIT_FAILED")) {
mtpRequest req;
@ -281,7 +296,8 @@ namespace {
if (!dc) return false;
if (!req->after) {
_mtp_internal::getSession(dc < 0 ? (-dc) : dc)->sendPreparedWithInit(req);
req->needsLayer = true;
_mtp_internal::getSession(dc < 0 ? (-dc) : dc)->sendPrepared(req);
} else {
int32 newdc = abs(dc) % _mtp_internal::dcShift;
DCAuthWaiters &waiters(authWaiters[newdc]);
@ -304,6 +320,8 @@ namespace {
if (i != e) {
delayedRequests.insert(i, DelayedRequest(requestId, i->second));
}
if (resender) resender->checkDelayed();
}
}
return true;
@ -341,6 +359,8 @@ namespace _mtp_internal {
}
void unregisterRequest(mtpRequestId requestId) {
requestsDelays.remove(requestId);
{
QWriteLocker locker(&requestMapLock);
requestMap.remove(requestId);
@ -554,7 +574,7 @@ namespace _mtp_internal {
}
req = j.value();
}
_mtp_internal::getSession(dc < 0 ? (-dc) : dc)->sendPrepared(req, 0, false);
_mtp_internal::getSession(dc < 0 ? (-dc) : dc)->sendPrepared(req);
}
if (!delayedRequests.isEmpty()) {
@ -655,6 +675,7 @@ namespace MTP {
void cancel(mtpRequestId requestId) {
mtpMsgId msgId = 0;
requestsDelays.remove(requestId);
{
QWriteLocker locker(&requestMapLock);
RequestMap::iterator i = requestMap.find(requestId);

View file

@ -446,6 +446,7 @@ void mtpUpdateDcOptions(const QVector<MTPDcOption> &options) {
MTProtoConfigLoader::MTProtoConfigLoader() : _enumCurrent(0), _enumRequest(0) {
connect(&_enumDCTimer, SIGNAL(timeout()), this, SLOT(enumDC()));
connect(this, SIGNAL(killCurrentSession(qint32,qint32)), this, SLOT(onKillCurrentSession(qint32,qint32)), Qt::QueuedConnection);
}
void MTProtoConfigLoader::load() {
@ -457,10 +458,24 @@ void MTProtoConfigLoader::load() {
_enumDCTimer.start(MTPEnumDCTimeout);
}
void MTProtoConfigLoader::onKillCurrentSession(qint32 request, qint32 current) {
if (request == _enumRequest && current == _enumCurrent) {
if (_enumRequest) {
MTP::cancel(_enumRequest);
_enumRequest = 0;
}
if (_enumCurrent) {
MTP::killSession(MTP::cfg + _enumCurrent);
_enumCurrent = 0;
}
}
}
void MTProtoConfigLoader::done() {
_enumDCTimer.stop();
if (_enumRequest) MTP::cancel(_enumRequest);
if (_enumCurrent) MTP::killSession(MTP::cfg + _enumCurrent);
if (_enumRequest || _enumCurrent) {
emit killCurrentSession(_enumRequest, _enumCurrent);
}
emit loaded();
}

View file

@ -83,10 +83,12 @@ public:
public slots:
void enumDC();
void onKillCurrentSession(qint32 request, qint32 session);
signals:
void loaded();
void killCurrentSession(qint32 request, qint32 session);
private:

View file

@ -23,13 +23,18 @@ public:
RPCError(const MTPrpcError &error) : _code(error.c_rpc_error().verror_code.v) {
const string &msg(error.c_rpc_error().verror_message.c_string().v);
const QString &text(QString::fromUtf8(msg.c_str(), msg.length()));
QRegularExpressionMatch m = QRegularExpression("^([A-Z0-9_]+)(: .*)?$", reMultiline).match(text);
if (m.hasMatch()) {
_type = m.captured(1);
_description = m.captured(2).mid(2);
if (_code < 0 || _code >= 500) {
_type = "INTERNAL_SERVER_ERROR";
_description = text;
} else {
_type = "CLIENT_BAD_RPC_ERROR";
_description = "Bad rpc error received, text = '" + text + "'";
QRegularExpressionMatch m = QRegularExpression("^([A-Z0-9_]+)(: .*)?$", reMultiline).match(text);
if (m.hasMatch()) {
_type = m.captured(1);
_description = m.captured(2).mid(2);
} else {
_type = "CLIENT_BAD_RPC_ERROR";
_description = "Bad rpc error received, text = '" + text + "'";
}
}
}

View file

@ -399,11 +399,6 @@ void MTProtoSession::sendPrepared(const mtpRequest &request, uint64 msCanWait, b
sendAnything(msCanWait);
}
void MTProtoSession::sendPreparedWithInit(const mtpRequest &request, uint64 msCanWait) {
request->needsLayer = true;
sendPrepared(request, msCanWait, false);
}
QReadWriteLock *MTProtoSession::keyMutex() const {
return dc->keyMutex();
}

View file

@ -242,7 +242,6 @@ public:
QString transport() const;
void sendPrepared(const mtpRequest &request, uint64 msCanWait = 0, bool newRequest = true); // nulls msgId and seqNo in request, if newRequest = true
void sendPreparedWithInit(const mtpRequest &request, uint64 msCanWait = 0);
signals:

View file

@ -1047,8 +1047,8 @@ void PsMainWindow::psInitSize() {
TWindowPos pos(cWindowPos());
if (cDebug()) { // temp while design
pos.w = 800;
pos.h = 600;
pos.w = 879;
pos.h = 689;
}
QRect avail(QDesktopWidget().availableGeometry());
bool maximized = false;

View file

@ -1,45 +1,45 @@
<RCC>
<qresource prefix="/gui">
<file>art/fonts/OpenSans-Regular.ttf</file>
<file>art/fonts/OpenSans-Bold.ttf</file>
<file>art/fonts/OpenSans-Semibold.ttf</file>
<file>art/newmsg.wav</file>
<file>art/bg.png</file>
<file>art/bg_125x.png</file>
<file>art/bg_150x.png</file>
<file>art/bg_200x.png</file>
<file>art/sprite.png</file>
<file>art/sprite_125x.png</file>
<file>art/sprite_150x.png</file>
<file>art/sprite_200x.png</file>
<file>art/emoji.png</file>
<file>art/emoji_125x.png</file>
<file>art/emoji_150x.png</file>
<file>art/emoji_200x.png</file>
<file>art/blank.gif</file>
<file>art/icon256.png</file>
<file>art/iconbig256.png</file>
<file>art/fonts/DejaVuSans.ttf</file>
<file>art/osxtray.png</file>
</qresource>
<qresource prefix="/ava">
<file>art/chatcolor1.png</file>
<file>art/chatcolor2.png</file>
<file>art/chatcolor3.png</file>
<file>art/chatcolor4.png</file>
<file>art/usercolor1.png</file>
<file>art/usercolor2.png</file>
<file>art/usercolor3.png</file>
<file>art/usercolor4.png</file>
<file>art/usercolor5.png</file>
<file>art/usercolor6.png</file>
<file>art/usercolor7.png</file>
<file>art/usercolor8.png</file>
</qresource>
<qresource prefix="/qt-project.org">
<file>qmime/freedesktop.org.xml</file>
</qresource>
<qresource prefix="/qt">
<file alias="etc/qt.conf">etc/qt_win.conf</file>
</qresource>
<qresource prefix="/gui">
<file>art/fonts/OpenSans-Regular.ttf</file>
<file>art/fonts/OpenSans-Bold.ttf</file>
<file>art/fonts/OpenSans-Semibold.ttf</file>
<file>art/newmsg.wav</file>
<file>art/bg.png</file>
<file>art/bg_125x.png</file>
<file>art/bg_150x.png</file>
<file>art/bg_200x.png</file>
<file>art/sprite.png</file>
<file>art/sprite_125x.png</file>
<file>art/sprite_150x.png</file>
<file>art/sprite_200x.png</file>
<file>art/emoji.png</file>
<file>art/emoji_125x.png</file>
<file>art/emoji_150x.png</file>
<file>art/emoji_200x.png</file>
<file>art/blank.gif</file>
<file>art/icon256.png</file>
<file>art/iconbig256.png</file>
<file>art/fonts/DejaVuSans.ttf</file>
<file>art/osxtray.png</file>
</qresource>
<qresource prefix="/ava">
<file>art/chatcolor1.png</file>
<file>art/chatcolor2.png</file>
<file>art/chatcolor3.png</file>
<file>art/chatcolor4.png</file>
<file>art/usercolor1.png</file>
<file>art/usercolor2.png</file>
<file>art/usercolor3.png</file>
<file>art/usercolor4.png</file>
<file>art/usercolor5.png</file>
<file>art/usercolor6.png</file>
<file>art/usercolor7.png</file>
<file>art/usercolor8.png</file>
</qresource>
<qresource prefix="/qt-project.org">
<file>qmime/freedesktop.org.xml</file>
</qresource>
<qresource prefix="/qt">
<file alias="etc/qt.conf">etc/qt_win.conf</file>
</qresource>
</RCC>