diff --git a/Telegram/PrepareWin.bat b/Telegram/PrepareWin.bat index d028326573..126ddf6e4d 100644 --- a/Telegram/PrepareWin.bat +++ b/Telegram/PrepareWin.bat @@ -1,8 +1,8 @@ @echo OFF -set "AppVersionStrSmall=0.6.14" -set "AppVersionStr=0.6.14" -set "AppVersionStrFull=0.6.14.0" +set "AppVersionStrSmall=0.6.15" +set "AppVersionStr=0.6.15" +set "AppVersionStrFull=0.6.15.0" echo. echo Preparing version %AppVersionStr%.. diff --git a/Telegram/Resources/lang.txt b/Telegram/Resources/lang.txt index bb2f2a515c..3d9f9fe2be 100644 --- a/Telegram/Resources/lang.txt +++ b/Telegram/Resources/lang.txt @@ -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"; diff --git a/Telegram/Resources/style.txt b/Telegram/Resources/style.txt index f2e857ed6e..b420e092a7 100644 --- a/Telegram/Resources/style.txt +++ b/Telegram/Resources/style.txt @@ -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); diff --git a/Telegram/SourceFiles/application.cpp b/Telegram/SourceFiles/application.cpp index a487f61fe7..365a0a59ca 100644 --- a/Telegram/SourceFiles/application.cpp +++ b/Telegram/SourceFiles/application.cpp @@ -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 { diff --git a/Telegram/SourceFiles/art/sprite.png b/Telegram/SourceFiles/art/sprite.png index b712de59cf..b4a293083f 100644 Binary files a/Telegram/SourceFiles/art/sprite.png and b/Telegram/SourceFiles/art/sprite.png differ diff --git a/Telegram/SourceFiles/art/sprite_200x.png b/Telegram/SourceFiles/art/sprite_200x.png index 7ef8f79a6d..87968e1d65 100644 Binary files a/Telegram/SourceFiles/art/sprite_200x.png and b/Telegram/SourceFiles/art/sprite_200x.png differ diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index efcbab8110..b2d5e6411b 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -17,8 +17,8 @@ Copyright (c) 2014 John Preston, https://tdesktop.com */ #pragma once -static const int32 AppVersion = 6014; -static const wchar_t *AppVersionStr = L"0.6.14"; +static const int32 AppVersion = 6015; +static const wchar_t *AppVersionStr = L"0.6.15"; static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; static const wchar_t *AppName = L"Telegram Desktop"; diff --git a/Telegram/SourceFiles/intro/intro.cpp b/Telegram/SourceFiles/intro/intro.cpp index 89551e99a3..6a489cac2d 100644 --- a/Telegram/SourceFiles/intro/intro.cpp +++ b/Telegram/SourceFiles/intro/intro.cpp @@ -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; diff --git a/Telegram/SourceFiles/intro/intro.h b/Telegram/SourceFiles/intro/intro.h index 508770def8..78c66ba2b2 100644 --- a/Telegram/SourceFiles/intro/intro.h +++ b/Telegram/SourceFiles/intro/intro.h @@ -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: diff --git a/Telegram/SourceFiles/intro/introcode.cpp b/Telegram/SourceFiles/intro/introcode.cpp index 63f2eb6136..e8b46b7a6a 100644 --- a/Telegram/SourceFiles/intro/introcode.cpp +++ b/Telegram/SourceFiles/intro/introcode.cpp @@ -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) { diff --git a/Telegram/SourceFiles/intro/introcode.h b/Telegram/SourceFiles/intro/introcode.h index 71acfcafbe..a216c2384c 100644 --- a/Telegram/SourceFiles/intro/introcode.h +++ b/Telegram/SourceFiles/intro/introcode.h @@ -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; diff --git a/Telegram/SourceFiles/intro/introphone.cpp b/Telegram/SourceFiles/intro/introphone.cpp index a42facefae..448f439e1a 100644 --- a/Telegram/SourceFiles/intro/introphone.cpp +++ b/Telegram/SourceFiles/intro/introphone.cpp @@ -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) { diff --git a/Telegram/SourceFiles/intro/introsignup.cpp b/Telegram/SourceFiles/intro/introsignup.cpp index a036b814d5..5662a70116 100644 --- a/Telegram/SourceFiles/intro/introsignup.cpp +++ b/Telegram/SourceFiles/intro/introsignup.cpp @@ -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(); } diff --git a/Telegram/SourceFiles/intro/introsteps.cpp b/Telegram/SourceFiles/intro/introsteps.cpp index 49f0bf883a..e8476e14f5 100644 --- a/Telegram/SourceFiles/intro/introsteps.cpp +++ b/Telegram/SourceFiles/intro/introsteps.cpp @@ -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); } } diff --git a/Telegram/SourceFiles/intro/introsteps.h b/Telegram/SourceFiles/intro/introsteps.h index 02a0850fdd..b7ee876b8b 100644 --- a/Telegram/SourceFiles/intro/introsteps.h +++ b/Telegram/SourceFiles/intro/introsteps.h @@ -36,7 +36,7 @@ public: private: - FlatLabel _intro1, _intro2; + FlatLabel _intro; FlatButton _next; int32 _headerWidth; diff --git a/Telegram/SourceFiles/mtproto/mtp.cpp b/Telegram/SourceFiles/mtproto/mtp.cpp index c598ecdafd..825f285f2e 100644 --- a/Telegram/SourceFiles/mtproto/mtp.cpp +++ b/Telegram/SourceFiles/mtproto/mtp.cpp @@ -48,6 +48,9 @@ namespace { typedef QList DelayedRequestsList; DelayedRequestsList delayedRequests; + typedef QMap RequestsDelays; + RequestsDelays requestsDelays; + typedef QSet 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); diff --git a/Telegram/SourceFiles/mtproto/mtpDC.cpp b/Telegram/SourceFiles/mtproto/mtpDC.cpp index 91f654010b..6902f0919a 100644 --- a/Telegram/SourceFiles/mtproto/mtpDC.cpp +++ b/Telegram/SourceFiles/mtproto/mtpDC.cpp @@ -446,6 +446,7 @@ void mtpUpdateDcOptions(const QVector &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(); } diff --git a/Telegram/SourceFiles/mtproto/mtpDC.h b/Telegram/SourceFiles/mtproto/mtpDC.h index 0082578f2a..455f8ed96e 100644 --- a/Telegram/SourceFiles/mtproto/mtpDC.h +++ b/Telegram/SourceFiles/mtproto/mtpDC.h @@ -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: diff --git a/Telegram/SourceFiles/mtproto/mtpRPC.h b/Telegram/SourceFiles/mtproto/mtpRPC.h index 86a712946e..3adeec0f91 100644 --- a/Telegram/SourceFiles/mtproto/mtpRPC.h +++ b/Telegram/SourceFiles/mtproto/mtpRPC.h @@ -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 + "'"; + } } } diff --git a/Telegram/SourceFiles/mtproto/mtpSession.cpp b/Telegram/SourceFiles/mtproto/mtpSession.cpp index 6fcdf38f46..9fd04a2096 100644 --- a/Telegram/SourceFiles/mtproto/mtpSession.cpp +++ b/Telegram/SourceFiles/mtproto/mtpSession.cpp @@ -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(); } diff --git a/Telegram/SourceFiles/mtproto/mtpSession.h b/Telegram/SourceFiles/mtproto/mtpSession.h index f9f16a947a..12ec869e1d 100644 --- a/Telegram/SourceFiles/mtproto/mtpSession.h +++ b/Telegram/SourceFiles/mtproto/mtpSession.h @@ -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: diff --git a/Telegram/SourceFiles/pspecific_wnd.cpp b/Telegram/SourceFiles/pspecific_wnd.cpp index cdfc3857e1..6912b252e1 100644 --- a/Telegram/SourceFiles/pspecific_wnd.cpp +++ b/Telegram/SourceFiles/pspecific_wnd.cpp @@ -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; diff --git a/Telegram/SourceFiles/telegram.qrc b/Telegram/SourceFiles/telegram.qrc index 5762dc7d85..099a40a271 100644 --- a/Telegram/SourceFiles/telegram.qrc +++ b/Telegram/SourceFiles/telegram.qrc @@ -1,45 +1,45 @@ - - art/fonts/OpenSans-Regular.ttf - art/fonts/OpenSans-Bold.ttf - art/fonts/OpenSans-Semibold.ttf - art/newmsg.wav - art/bg.png - art/bg_125x.png - art/bg_150x.png - art/bg_200x.png - art/sprite.png - art/sprite_125x.png - art/sprite_150x.png - art/sprite_200x.png - art/emoji.png - art/emoji_125x.png - art/emoji_150x.png - art/emoji_200x.png - art/blank.gif - art/icon256.png - art/iconbig256.png - art/fonts/DejaVuSans.ttf - art/osxtray.png - - - art/chatcolor1.png - art/chatcolor2.png - art/chatcolor3.png - art/chatcolor4.png - art/usercolor1.png - art/usercolor2.png - art/usercolor3.png - art/usercolor4.png - art/usercolor5.png - art/usercolor6.png - art/usercolor7.png - art/usercolor8.png - - - qmime/freedesktop.org.xml - - - etc/qt_win.conf - + + art/fonts/OpenSans-Regular.ttf + art/fonts/OpenSans-Bold.ttf + art/fonts/OpenSans-Semibold.ttf + art/newmsg.wav + art/bg.png + art/bg_125x.png + art/bg_150x.png + art/bg_200x.png + art/sprite.png + art/sprite_125x.png + art/sprite_150x.png + art/sprite_200x.png + art/emoji.png + art/emoji_125x.png + art/emoji_150x.png + art/emoji_200x.png + art/blank.gif + art/icon256.png + art/iconbig256.png + art/fonts/DejaVuSans.ttf + art/osxtray.png + + + art/chatcolor1.png + art/chatcolor2.png + art/chatcolor3.png + art/chatcolor4.png + art/usercolor1.png + art/usercolor2.png + art/usercolor3.png + art/usercolor4.png + art/usercolor5.png + art/usercolor6.png + art/usercolor7.png + art/usercolor8.png + + + qmime/freedesktop.org.xml + + + etc/qt_win.conf + diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist index 4614b7acb4..c5acc4123e 100644 --- a/Telegram/Telegram.plist +++ b/Telegram/Telegram.plist @@ -11,7 +11,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.6.14 + 0.6.15 CFBundleSignature ???? NOTE diff --git a/Telegram/Telegram.rc b/Telegram/Telegram.rc index e69798d0fb..d5ec8e1363 100644 Binary files a/Telegram/Telegram.rc and b/Telegram/Telegram.rc differ diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj index 3064ab7bf9..1c90f9f05a 100644 --- a/Telegram/Telegram.xcodeproj/project.pbxproj +++ b/Telegram/Telegram.xcodeproj/project.pbxproj @@ -1531,7 +1531,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.6.14; + CURRENT_PROJECT_VERSION = 0.6.15; DEBUG_INFORMATION_FORMAT = dwarf; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -1549,7 +1549,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 0.6.14; + CURRENT_PROJECT_VERSION = 0.6.15; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_OPTIMIZATION_LEVEL = fast; GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h; @@ -1575,10 +1575,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.6.14; + CURRENT_PROJECT_VERSION = 0.6.15; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 0.6; - DYLIB_CURRENT_VERSION = 0.6.14; + DYLIB_CURRENT_VERSION = 0.6.15; ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; @@ -1718,10 +1718,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.6.14; + CURRENT_PROJECT_VERSION = 0.6.15; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 0.6; - DYLIB_CURRENT_VERSION = 0.6.14; + DYLIB_CURRENT_VERSION = 0.6.15; ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; diff --git a/Telegram/Version.sh b/Telegram/Version.sh index 321467d325..a4fbb4618f 100755 --- a/Telegram/Version.sh +++ b/Telegram/Version.sh @@ -1,2 +1,2 @@ -echo 6014 0.6.14 +echo 6015 0.6.15