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.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2014-12-01 10:47:38 +00:00
|
|
|
Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "lang.h"
|
|
|
|
#include "style.h"
|
|
|
|
|
|
|
|
#include "application.h"
|
|
|
|
|
|
|
|
#include "intro/introsteps.h"
|
|
|
|
#include "intro/intro.h"
|
|
|
|
|
2014-12-19 21:20:30 +00:00
|
|
|
#include "langloaderplain.h"
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
IntroSteps::IntroSteps(IntroWidget *parent) : IntroStage(parent),
|
2014-11-26 16:45:52 +00:00
|
|
|
_intro(this, lang(lng_intro), st::introLabel, st::introLabelTextStyle),
|
2014-12-19 22:03:50 +00:00
|
|
|
_changeLang(this, QString()),
|
|
|
|
_next(this, lang(lng_start_msgs), st::btnIntroNext) {
|
2014-12-19 21:20:30 +00:00
|
|
|
|
|
|
|
_changeLang.hide();
|
2014-12-20 21:33:08 +00:00
|
|
|
if (cLang() == languageDefault) {
|
2014-12-19 21:20:30 +00:00
|
|
|
int32 l = App::app()->languageId();
|
2014-12-20 21:33:08 +00:00
|
|
|
if (l != languageDefault) {
|
2014-12-19 21:20:30 +00:00
|
|
|
LangLoaderPlain loader(qsl(":/langs/lang_") + LanguageCodes[l] + qsl(".strings"), LangLoaderRequest(lng_switch_to_this));
|
|
|
|
QString text = loader.found().value(lng_switch_to_this);
|
|
|
|
if (!text.isEmpty()) {
|
|
|
|
_changeLang.setText(text);
|
|
|
|
parent->langChangeTo(l);
|
|
|
|
_changeLang.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_changeLang.setText(langOriginal(lng_switch_to_this));
|
2014-12-20 21:33:08 +00:00
|
|
|
parent->langChangeTo(languageDefault);
|
2014-12-19 21:20:30 +00:00
|
|
|
_changeLang.show();
|
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2014-12-19 21:20:30 +00:00
|
|
|
_headerWidth = st::introHeaderFont->m.width(qsl("Telegram Desktop"));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
setGeometry(parent->innerRect());
|
|
|
|
|
|
|
|
connect(&_next, SIGNAL(stateChanged(int, ButtonStateChangeSource)), parent, SLOT(onDoneStateChanged(int, ButtonStateChangeSource)));
|
|
|
|
connect(&_next, SIGNAL(clicked()), parent, SLOT(onIntroNext()));
|
|
|
|
|
2014-12-19 21:20:30 +00:00
|
|
|
connect(&_changeLang, SIGNAL(clicked()), parent, SLOT(onChangeLang()));
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
setMouseTracking(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntroSteps::paintEvent(QPaintEvent *e) {
|
|
|
|
bool trivial = (rect() == e->rect());
|
|
|
|
|
|
|
|
QPainter p(this);
|
|
|
|
if (!trivial) {
|
|
|
|
p.setClipRect(e->rect());
|
|
|
|
}
|
2014-11-26 16:45:52 +00:00
|
|
|
int32 hy = _intro.y() - st::introHeaderFont->height - st::introHeaderSkip + st::introHeaderFont->ascent;
|
2014-05-30 08:53:19 +00:00
|
|
|
|
|
|
|
p.setFont(st::introHeaderFont->f);
|
|
|
|
p.setPen(st::introColor->p);
|
2014-12-19 21:20:30 +00:00
|
|
|
p.drawText((width() - _headerWidth) / 2, hy, qsl("Telegram Desktop"));
|
2014-11-26 16:45:52 +00:00
|
|
|
|
|
|
|
p.drawPixmap(QPoint((width() - st::aboutIcon.pxWidth()) / 2, hy - st::introIconSkip - st::aboutIcon.pxHeight()), App::sprite(), st::aboutIcon);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void IntroSteps::resizeEvent(QResizeEvent *e) {
|
|
|
|
if (e->oldSize().width() != width()) {
|
2014-11-26 16:45:52 +00:00
|
|
|
_next.move((width() - _next.width()) / 2, st::introBtnTop);
|
|
|
|
_intro.move((width() - _intro.width()) / 2, _next.y() - _intro.height() - st::introSkip);
|
2014-12-19 21:20:30 +00:00
|
|
|
_changeLang.move((width() - _changeLang.width()) / 2, _next.y() + _next.height() + _changeLang.height());
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntroSteps::activate() {
|
|
|
|
show();
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntroSteps::deactivate() {
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntroSteps::onNext() {
|
|
|
|
intro()->onIntroNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
void IntroSteps::onBack() {
|
|
|
|
}
|