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.
|
|
|
|
|
2015-10-03 11:33:51 +00:00
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
2014-05-30 08:53:19 +00:00
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2016-02-08 10:56:18 +00:00
|
|
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
2014-05-30 08:53:19 +00:00
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
2016-11-08 14:43:10 +00:00
|
|
|
#include "boxes/aboutbox.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-11-08 14:43:10 +00:00
|
|
|
#include "lang.h"
|
2014-05-30 08:53:19 +00:00
|
|
|
#include "mainwidget.h"
|
2016-04-12 21:31:28 +00:00
|
|
|
#include "mainwindow.h"
|
2015-12-03 18:16:34 +00:00
|
|
|
#include "autoupdater.h"
|
|
|
|
#include "boxes/confirmbox.h"
|
|
|
|
#include "application.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"
|
2016-11-28 15:45:07 +00:00
|
|
|
#include "platform/platform_file_dialog.h"
|
2015-12-03 18:16:34 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
AboutBox::AboutBox(QWidget *parent)
|
|
|
|
: _version(this, lng_about_version(lt_version, QString::fromLatin1(AppVersionStr.c_str()) + (cAlphaVersion() ? " alpha" : "") + (cBetaVersion() ? qsl(" beta %1").arg(cBetaVersion()) : QString())), 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() {
|
|
|
|
setTitle(qsl("Telegram Desktop"));
|
2014-05-30 08:53:19 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
addButton(lang(lng_close), [this] { closeBox(); });
|
2014-05-30 08:53:19 +00:00
|
|
|
|
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]")));
|
|
|
|
|
|
|
|
_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() {
|
2015-12-03 18:16:34 +00:00
|
|
|
if (cRealBetaVersion()) {
|
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;
|
|
|
|
}
|
|
|
|
url = url.arg(qsl("tbeta%1_%2").arg(cRealBetaVersion()).arg(countBetaVersionSignature(cRealBetaVersion())));
|
|
|
|
|
2016-01-30 18:24:18 +00:00
|
|
|
Application::clipboard()->setText(url);
|
2015-12-03 18:16:34 +00:00
|
|
|
|
2016-12-13 17:07:56 +00:00
|
|
|
Ui::show(Box<InformBox>("The link to the current private beta version of Telegram Desktop was copied to the clipboard."));
|
2015-12-03 18:16:34 +00:00
|
|
|
} else {
|
|
|
|
QDesktopServices::openUrl(qsl("https://desktop.telegram.org/?_hash=changelog"));
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-20 18:34:20 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
|
2016-01-30 18:38:33 +00:00
|
|
|
QString _getCrashReportFile(const QMimeData *m) {
|
2016-05-27 10:57:11 +00:00
|
|
|
if (!m || m->urls().size() != 1 || !m->urls().at(0).isLocalFile()) return QString();
|
2016-01-30 18:38:33 +00:00
|
|
|
|
2016-11-28 15:45:07 +00:00
|
|
|
auto file = Platform::FileDialog::UrlToLocal(m->urls().at(0));
|
2016-01-30 18:38:33 +00:00
|
|
|
|
|
|
|
return file.endsWith(qstr(".telegramcrash"), Qt::CaseInsensitive) ? file : QString();
|
|
|
|
}
|
2016-03-20 18:34:20 +00:00
|
|
|
#endif // !TDESKTOP_DISABLE_CRASH_REPORTS
|
2016-01-30 18:38:33 +00:00
|
|
|
|
|
|
|
void AboutBox::dragEnterEvent(QDragEnterEvent *e) {
|
2016-03-20 18:34:20 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
|
2016-01-30 18:38:33 +00:00
|
|
|
if (!_getCrashReportFile(e->mimeData()).isEmpty()) {
|
|
|
|
e->setDropAction(Qt::CopyAction);
|
|
|
|
e->accept();
|
|
|
|
}
|
2016-10-18 07:56:38 +00:00
|
|
|
#endif // !TDESKTOP_DISABLE_CRASH_REPORTS
|
2016-01-30 18:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AboutBox::dropEvent(QDropEvent *e) {
|
2016-03-20 18:34:20 +00:00
|
|
|
#ifndef TDESKTOP_DISABLE_CRASH_REPORTS
|
2016-01-30 18:38:33 +00:00
|
|
|
if (!_getCrashReportFile(e->mimeData()).isEmpty()) {
|
|
|
|
e->acceptProposedAction();
|
2016-01-31 18:01:43 +00:00
|
|
|
showCrashReportWindow(_getCrashReportFile(e->mimeData()));
|
2016-01-30 18:38:33 +00:00
|
|
|
}
|
2016-03-20 18:34:20 +00:00
|
|
|
#endif // !TDESKTOP_DISABLE_CRASH_REPORTS
|
2016-01-30 18:38:33 +00:00
|
|
|
}
|
|
|
|
|
2015-10-12 21:02:10 +00:00
|
|
|
QString telegramFaqLink() {
|
|
|
|
QString result = qsl("https://telegram.org/faq");
|
|
|
|
if (cLang() > languageDefault && cLang() < languageCount) {
|
2016-04-07 10:03:10 +00:00
|
|
|
const char *code = LanguageCodes[cLang()].c_str();
|
2015-10-12 21:02:10 +00:00
|
|
|
if (qstr("de") == code || qstr("es") == code || qstr("it") == code || qstr("ko") == code) {
|
|
|
|
result += qsl("/") + code;
|
|
|
|
} else if (qstr("pt_BR") == code) {
|
|
|
|
result += qsl("/br");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
2016-01-31 16:13:51 +00:00
|
|
|
}
|
2016-11-16 10:44:06 +00:00
|
|
|
|
|
|
|
QString currentVersionText() {
|
|
|
|
auto result = QString::fromLatin1(AppVersionStr.c_str());
|
|
|
|
if (cAlphaVersion()) {
|
|
|
|
result += " alpha";
|
|
|
|
}
|
|
|
|
if (cBetaVersion()) {
|
|
|
|
result += qsl(" beta %1").arg(cBetaVersion() % 1000);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|