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"
|
2021-10-18 21:36:55 +00:00
|
|
|
#include "ui/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"
|
2019-06-12 20:11:41 +00:00
|
|
|
#include "ui/text/text_utilities.h"
|
2019-09-17 16:13:12 +00:00
|
|
|
#include "base/platform/base_platform_info.h"
|
2022-12-22 14:03:47 +00:00
|
|
|
#include "core/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"
|
2021-02-04 16:42:32 +00:00
|
|
|
#include "core/application.h"
|
2019-09-18 11:19:05 +00:00
|
|
|
#include "styles/style_layers.h"
|
2019-06-12 20:11:41 +00:00
|
|
|
#include "styles/style_boxes.h"
|
|
|
|
|
2019-09-04 07:19:15 +00:00
|
|
|
#include <QtGui/QGuiApplication>
|
|
|
|
#include <QtGui/QClipboard>
|
|
|
|
|
2019-06-12 20:11:41 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
rpl::producer<TextWithEntities> Text1() {
|
2019-06-18 16:53:27 +00:00
|
|
|
return tr::lng_about_text1(
|
2019-06-12 20:11:41 +00:00
|
|
|
lt_api_link,
|
2019-06-18 16:53:27 +00:00
|
|
|
tr::lng_about_text1_api(
|
|
|
|
) | Ui::Text::ToLink("https://core.telegram.org/api"),
|
|
|
|
Ui::Text::WithEntities);
|
2019-06-12 20:11:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<TextWithEntities> Text2() {
|
2019-06-18 16:53:27 +00:00
|
|
|
return tr::lng_about_text2(
|
2019-06-12 20:11:41 +00:00
|
|
|
lt_gpl_link,
|
2019-06-23 14:43:21 +00:00
|
|
|
rpl::single(Ui::Text::Link(
|
|
|
|
"GNU GPL",
|
|
|
|
"https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE")),
|
2019-06-12 20:11:41 +00:00
|
|
|
lt_github_link,
|
2019-06-23 14:43:21 +00:00
|
|
|
rpl::single(Ui::Text::Link(
|
|
|
|
"GitHub",
|
|
|
|
"https://github.com/telegramdesktop/tdesktop")),
|
2019-06-18 16:53:27 +00:00
|
|
|
Ui::Text::WithEntities);
|
2019-06-12 20:11:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<TextWithEntities> Text3() {
|
2019-06-18 16:53:27 +00:00
|
|
|
return tr::lng_about_text3(
|
2019-06-12 20:11:41 +00:00
|
|
|
lt_faq_link,
|
2019-06-18 16:53:27 +00:00
|
|
|
tr::lng_about_text3_faq() | Ui::Text::ToLink(telegramFaqLink()),
|
|
|
|
Ui::Text::WithEntities);
|
2019-06-12 20:11:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
2015-12-03 18:16:34 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
AboutBox::AboutBox(QWidget *parent)
|
2019-06-19 16:39:25 +00:00
|
|
|
: _version(this, tr::lng_about_version(tr::now, lt_version, currentVersionText()), st::aboutVersionLink)
|
2019-06-12 20:11:41 +00:00
|
|
|
, _text1(this, Text1(), st::aboutLabel)
|
|
|
|
, _text2(this, Text2(), st::aboutLabel)
|
|
|
|
, _text3(this, Text3(), st::aboutLabel) {
|
2016-12-13 17:07:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AboutBox::prepare() {
|
2022-11-26 21:20:17 +00:00
|
|
|
setTitle(rpl::single(u"Telegram Desktop"_q));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2019-06-18 16:53:27 +00:00
|
|
|
addButton(tr::lng_close(), [this] { closeBox(); });
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2019-06-12 20:11:41 +00:00
|
|
|
_text1->setLinksTrusted();
|
|
|
|
_text2->setLinksTrusted();
|
|
|
|
_text3->setLinksTrusted();
|
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);
|
|
|
|
|
2021-12-18 14:10:30 +00:00
|
|
|
const auto available = width()
|
|
|
|
- st::boxPadding.left()
|
|
|
|
- st::boxPadding.right();
|
2016-12-13 17:07:56 +00:00
|
|
|
_version->moveToLeft(st::boxPadding.left(), st::aboutVersionTop);
|
2021-12-18 14:10:30 +00:00
|
|
|
_text1->resizeToWidth(available);
|
2016-12-13 17:07:56 +00:00
|
|
|
_text1->moveToLeft(st::boxPadding.left(), st::aboutTextTop);
|
2021-12-18 14:10:30 +00:00
|
|
|
_text2->resizeToWidth(available);
|
2016-11-11 13:46:04 +00:00
|
|
|
_text2->moveToLeft(st::boxPadding.left(), _text1->y() + _text1->height() + st::aboutSkip);
|
2021-12-18 14:10:30 +00:00
|
|
|
_text3->resizeToWidth(available);
|
2016-11-11 13:46:04 +00:00
|
|
|
_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()) {
|
2022-11-26 21:20:17 +00:00
|
|
|
auto url = u"https://tdesktop.com/"_q;
|
2021-01-28 15:30:47 +00:00
|
|
|
if (Platform::IsWindows32Bit()) {
|
2022-11-26 21:20:17 +00:00
|
|
|
url += u"win/%1.zip"_q;
|
2021-01-28 15:30:47 +00:00
|
|
|
} else if (Platform::IsWindows64Bit()) {
|
2022-11-26 21:20:17 +00:00
|
|
|
url += u"win64/%1.zip"_q;
|
2019-06-03 14:41:23 +00:00
|
|
|
} else if (Platform::IsMac()) {
|
2022-11-26 21:20:17 +00:00
|
|
|
url += u"mac/%1.zip"_q;
|
2021-08-11 02:27:26 +00:00
|
|
|
} else if (Platform::IsLinux()) {
|
2022-11-26 21:20:17 +00:00
|
|
|
url += u"linux/%1.tar.xz"_q;
|
2019-06-03 14:41:23 +00:00
|
|
|
} else {
|
|
|
|
Unexpected("Platform value.");
|
2015-12-03 18:16:34 +00:00
|
|
|
}
|
2022-11-26 21:20:17 +00:00
|
|
|
url = url.arg(u"talpha%1_%2"_q.arg(cRealAlphaVersion()).arg(Core::countAlphaVersionSignature(cRealAlphaVersion())));
|
2015-12-03 18:16:34 +00:00
|
|
|
|
2019-09-04 07:19:15 +00:00
|
|
|
QGuiApplication::clipboard()->setText(url);
|
2015-12-03 18:16:34 +00:00
|
|
|
|
2022-02-27 08:23:20 +00:00
|
|
|
getDelegate()->show(
|
|
|
|
Ui::MakeInformBox(
|
|
|
|
"The link to the current private alpha "
|
|
|
|
"version of Telegram Desktop was copied to the clipboard."),
|
|
|
|
Ui::LayerOption::CloseOther);
|
2015-12-03 18:16:34 +00:00
|
|
|
} else {
|
2022-12-22 14:03:47 +00:00
|
|
|
File::OpenUrl(Core::App().changelogLink());
|
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() {
|
2022-11-26 21:20:17 +00:00
|
|
|
const auto result = u"https://telegram.org/faq"_q;
|
2018-12-17 06:12:44 +00:00
|
|
|
const auto langpacked = [&](const char *language) {
|
|
|
|
return result + '/' + language;
|
|
|
|
};
|
2020-09-30 09:11:44 +00:00
|
|
|
const auto current = Lang::Id();
|
2018-12-17 06:12:44 +00:00
|
|
|
for (const auto language : { "de", "es", "it", "ko" }) {
|
|
|
|
if (current.startsWith(QLatin1String(language))) {
|
|
|
|
return langpacked(language);
|
2015-10-12 21:02:10 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-26 21:20:17 +00:00
|
|
|
if (current.startsWith(u"pt-br"_q)) {
|
2018-12-17 06:12:44 +00:00
|
|
|
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()) {
|
2022-11-26 21:20:17 +00:00
|
|
|
result += u" alpha %1"_q.arg(cAlphaVersion() % 1000);
|
2018-09-26 18:08:11 +00:00
|
|
|
} else if (AppBetaVersion) {
|
|
|
|
result += " beta";
|
2016-11-16 10:44:06 +00:00
|
|
|
}
|
2021-01-28 15:30:47 +00:00
|
|
|
if (Platform::IsWindows64Bit()) {
|
|
|
|
result += " x64";
|
|
|
|
}
|
2016-11-16 10:44:06 +00:00
|
|
|
return result;
|
|
|
|
}
|