2014-05-30 08:53:19 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/about_box.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-04-13 08:27:10 +00:00
|
|
|
#include "lang/lang_keys.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
#include "mainwidget.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "mainwindow.h"
|
2017-04-06 14:38:10 +00:00
|
|
|
#include "boxes/confirm_box.h"
|
2016-11-11 13:46:04 +00:00
|
|
|
#include "ui/widgets/buttons.h"
|
2016-11-16 10:44:06 +00:00
|
|
|
#include "ui/widgets/labels.h"
|
2016-11-11 13:46:04 +00:00
|
|
|
#include "styles/style_boxes.h"
|
2017-02-28 10:51:00 +00:00
|
|
|
#include "platform/platform_file_utilities.h"
|
2017-12-11 08:56:43 +00:00
|
|
|
#include "core/click_handler_types.h"
|
2018-04-26 16:14:21 +00:00
|
|
|
#include "core/update_checker.h"
|
2015-12-03 18:16:34 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
AboutBox::AboutBox(QWidget *parent)
|
2018-11-14 07:55:12 +00:00
|
|
|
: _version(this, lng_about_version(lt_version, currentVersionText()), st::aboutVersionLink)
|
2016-12-23 13:21:01 +00:00
|
|
|
, _text1(this, lang(lng_about_text_1), Ui::FlatLabel::InitType::Rich, st::aboutLabel)
|
|
|
|
, _text2(this, lang(lng_about_text_2), Ui::FlatLabel::InitType::Rich, st::aboutLabel)
|
|
|
|
, _text3(this, st::aboutLabel) {
|
2016-12-13 17:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AboutBox::prepare() {
|
2017-05-30 15:21:05 +00:00
|
|
|
setTitle([] { return qsl("Telegram Desktop"); });
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2017-05-30 15:21:05 +00:00
|
|
|
addButton(langFactory(lng_close), [this] { closeBox(); });
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2018-06-22 19:46:20 +00:00
|
|
|
const auto linkFilter = [](const ClickHandlerPtr &link, auto button) {
|
2017-12-18 09:07:18 +00:00
|
|
|
if (const auto url = dynamic_cast<UrlClickHandler*>(link.get())) {
|
2018-07-09 18:13:48 +00:00
|
|
|
url->UrlClickHandler::onClick({ button });
|
2017-12-11 08:56:43 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
_text3->setRichText(lng_about_text_3(lt_faq_open, qsl("[a href=\"%1\"]").arg(telegramFaqLink()), lt_faq_close, qsl("[/a]")));
|
2018-06-22 19:46:20 +00:00
|
|
|
_text1->setClickHandlerFilter(linkFilter);
|
|
|
|
_text2->setClickHandlerFilter(linkFilter);
|
|
|
|
_text3->setClickHandlerFilter(linkFilter);
|
2016-12-13 17:07:56 +00:00
|
|
|
|
|
|
|
_version->setClickedCallback([this] { showVersionHistory(); });
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
setDimensions(st::aboutWidth, st::aboutTextTop + _text1->height() + st::aboutSkip + _text2->height() + st::aboutSkip + _text3->height());
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 21:02:10 +00:00
|
|
|
void AboutBox::resizeEvent(QResizeEvent *e) {
|
2016-12-13 17:07:56 +00:00
|
|
|
BoxContent::resizeEvent(e);
|
|
|
|
|
|
|
|
_version->moveToLeft(st::boxPadding.left(), st::aboutVersionTop);
|
|
|
|
_text1->moveToLeft(st::boxPadding.left(), st::aboutTextTop);
|
2016-11-11 13:46:04 +00:00
|
|
|
_text2->moveToLeft(st::boxPadding.left(), _text1->y() + _text1->height() + st::aboutSkip);
|
|
|
|
_text3->moveToLeft(st::boxPadding.left(), _text2->y() + _text2->height() + st::aboutSkip);
|
2015-10-12 21:02:10 +00:00
|
|
|
}
|
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
void AboutBox::showVersionHistory() {
|
2018-09-26 14:58:09 +00:00
|
|
|
if (cRealAlphaVersion()) {
|
2016-11-22 09:48:13 +00:00
|
|
|
auto url = qsl("https://tdesktop.com/");
|
2015-12-03 18:16:34 +00:00
|
|
|
switch (cPlatform()) {
|
|
|
|
case dbipWindows: url += qsl("win/%1.zip"); break;
|
|
|
|
case dbipMac: url += qsl("mac/%1.zip"); break;
|
|
|
|
case dbipMacOld: url += qsl("mac32/%1.zip"); break;
|
|
|
|
case dbipLinux32: url += qsl("linux32/%1.tar.xz"); break;
|
|
|
|
case dbipLinux64: url += qsl("linux/%1.tar.xz"); break;
|
|
|
|
}
|
2018-09-26 14:58:09 +00:00
|
|
|
url = url.arg(qsl("talpha%1_%2").arg(cRealAlphaVersion()).arg(Core::countAlphaVersionSignature(cRealAlphaVersion())));
|
2015-12-03 18:16:34 +00:00
|
|
|
|
2019-01-18 11:26:43 +00:00
|
|
|
QApplication::clipboard()->setText(url);
|
2015-12-03 18:16:34 +00:00
|
|
|
|
2018-09-26 14:58:09 +00:00
|
|
|
Ui::show(Box<InformBox>("The link to the current private alpha version of Telegram Desktop was copied to the clipboard."));
|
2015-12-03 18:16:34 +00:00
|
|
|
} else {
|
2017-01-11 18:31:31 +00:00
|
|
|
QDesktopServices::openUrl(qsl("https://desktop.telegram.org/changelog"));
|
2015-12-03 18:16:34 +00:00
|
|
|
}
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AboutBox::keyPressEvent(QKeyEvent *e) {
|
|
|
|
if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
|
2016-12-13 17:07:56 +00:00
|
|
|
closeBox();
|
2015-04-02 10:33:19 +00:00
|
|
|
} else {
|
2016-12-13 17:07:56 +00:00
|
|
|
BoxContent::keyPressEvent(e);
|
2014-05-30 08:53:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-12 21:02:10 +00:00
|
|
|
QString telegramFaqLink() {
|
2018-12-17 06:12:44 +00:00
|
|
|
const auto result = qsl("https://telegram.org/faq");
|
|
|
|
const auto langpacked = [&](const char *language) {
|
|
|
|
return result + '/' + language;
|
|
|
|
};
|
|
|
|
const auto current = Lang::Current().id();
|
|
|
|
for (const auto language : { "de", "es", "it", "ko" }) {
|
|
|
|
if (current.startsWith(QLatin1String(language))) {
|
|
|
|
return langpacked(language);
|
2015-10-12 21:02:10 +00:00
|
|
|
}
|
|
|
|
}
|
2018-12-17 06:12:44 +00:00
|
|
|
if (current.startsWith(qstr("pt-br"))) {
|
|
|
|
return langpacked("br");
|
|
|
|
}
|
2015-10-12 21:02:10 +00:00
|
|
|
return result;
|
2016-01-31 16:13:51 +00:00
|
|
|
}
|
2016-11-16 10:44:06 +00:00
|
|
|
|
|
|
|
QString currentVersionText() {
|
2018-11-08 05:50:18 +00:00
|
|
|
auto result = QString::fromLatin1(AppVersionStr);
|
2018-09-26 14:58:09 +00:00
|
|
|
if (cAlphaVersion()) {
|
|
|
|
result += qsl(" alpha %1").arg(cAlphaVersion() % 1000);
|
2018-09-26 18:08:11 +00:00
|
|
|
} else if (AppBetaVersion) {
|
|
|
|
result += " beta";
|
2016-11-16 10:44:06 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|