mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
chore: modify about box
This commit is contained in:
parent
e3ebb30518
commit
9aa8f30e2b
4 changed files with 31 additions and 109 deletions
|
@ -25,17 +25,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include <QtGui/QGuiApplication>
|
#include <QtGui/QGuiApplication>
|
||||||
#include <QtGui/QClipboard>
|
#include <QtGui/QClipboard>
|
||||||
|
|
||||||
|
#include "window/window_session_controller.h"
|
||||||
|
#include "window/window_session_controller_link_info.h"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> Text1() {
|
rpl::producer<TextWithEntities> Text() {
|
||||||
return tr::lng_about_text1(
|
|
||||||
lt_api_link,
|
|
||||||
tr::lng_about_text1_api(
|
|
||||||
) | Ui::Text::ToLink("https://core.telegram.org/api"),
|
|
||||||
Ui::Text::WithEntities);
|
|
||||||
}
|
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> Text2() {
|
|
||||||
return tr::lng_about_text2(
|
return tr::lng_about_text2(
|
||||||
lt_gpl_link,
|
lt_gpl_link,
|
||||||
rpl::single(Ui::Text::Link(
|
rpl::single(Ui::Text::Link(
|
||||||
|
@ -48,34 +44,33 @@ rpl::producer<TextWithEntities> Text2() {
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
rpl::producer<TextWithEntities> Text3() {
|
|
||||||
return tr::lng_about_text3(
|
|
||||||
lt_faq_link,
|
|
||||||
tr::lng_about_text3_faq() | Ui::Text::ToLink(telegramFaqLink()),
|
|
||||||
Ui::Text::WithEntities);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
AboutBox::AboutBox(QWidget *parent)
|
AboutBox::AboutBox(QWidget *parent, not_null<Window::SessionController*> controller)
|
||||||
: _version(this, tr::lng_about_version(tr::now, lt_version, currentVersionText()), st::aboutVersionLink)
|
: _version(this, tr::lng_about_version(tr::now, lt_version, currentVersionText()), st::aboutVersionLink)
|
||||||
, _text1(this, Text1(), st::aboutLabel)
|
, _text(this, Text(), st::aboutLabel)
|
||||||
, _text2(this, Text2(), st::aboutLabel)
|
, _controller(controller) {
|
||||||
, _text3(this, Text3(), st::aboutLabel) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutBox::prepare() {
|
void AboutBox::prepare() {
|
||||||
setTitle(rpl::single(u"AyuGram Desktop"_q));
|
setTitle(rpl::single(u"AyuGram Desktop"_q));
|
||||||
|
|
||||||
addButton(tr::lng_close(), [this] { closeBox(); });
|
addButton(tr::lng_close(), [this] { closeBox(); });
|
||||||
|
addLeftButton(
|
||||||
|
rpl::single(QString("@ayugramchat")),
|
||||||
|
[=]
|
||||||
|
{
|
||||||
|
_controller->showPeerByLink(Window::PeerByLinkInfo{
|
||||||
|
.usernameOrId = QString("ayugramchat"),
|
||||||
|
});
|
||||||
|
closeBox();
|
||||||
|
});
|
||||||
|
|
||||||
_text1->setLinksTrusted();
|
_text->setLinksTrusted();
|
||||||
_text2->setLinksTrusted();
|
|
||||||
_text3->setLinksTrusted();
|
|
||||||
|
|
||||||
_version->setClickedCallback([this] { showVersionHistory(); });
|
_version->setClickedCallback([this] { showVersionHistory(); });
|
||||||
|
|
||||||
setDimensions(st::aboutWidth, st::aboutTextTop + _text1->height() + st::aboutSkip + _text2->height() + st::aboutSkip + _text3->height());
|
setDimensions(st::aboutWidth, st::aboutTextTop + _text->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutBox::resizeEvent(QResizeEvent *e) {
|
void AboutBox::resizeEvent(QResizeEvent *e) {
|
||||||
|
@ -85,42 +80,12 @@ void AboutBox::resizeEvent(QResizeEvent *e) {
|
||||||
- st::boxPadding.left()
|
- st::boxPadding.left()
|
||||||
- st::boxPadding.right();
|
- st::boxPadding.right();
|
||||||
_version->moveToLeft(st::boxPadding.left(), st::aboutVersionTop);
|
_version->moveToLeft(st::boxPadding.left(), st::aboutVersionTop);
|
||||||
_text1->resizeToWidth(available);
|
_text->resizeToWidth(available);
|
||||||
_text1->moveToLeft(st::boxPadding.left(), st::aboutTextTop);
|
_text->moveToLeft(st::boxPadding.left(), st::aboutTextTop);
|
||||||
_text2->resizeToWidth(available);
|
|
||||||
_text2->moveToLeft(st::boxPadding.left(), _text1->y() + _text1->height() + st::aboutSkip);
|
|
||||||
_text3->resizeToWidth(available);
|
|
||||||
_text3->moveToLeft(st::boxPadding.left(), _text2->y() + _text2->height() + st::aboutSkip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutBox::showVersionHistory() {
|
void AboutBox::showVersionHistory() {
|
||||||
if (cRealAlphaVersion()) {
|
File::OpenUrl(Core::App().changelogLink());
|
||||||
auto url = u"https://tdesktop.com/"_q;
|
|
||||||
if (Platform::IsWindows32Bit()) {
|
|
||||||
url += u"win/%1.zip"_q;
|
|
||||||
} else if (Platform::IsWindows64Bit()) {
|
|
||||||
url += u"win64/%1.zip"_q;
|
|
||||||
} else if (Platform::IsWindowsARM64()) {
|
|
||||||
url += u"winarm/%1.zip"_q;
|
|
||||||
} else if (Platform::IsMac()) {
|
|
||||||
url += u"mac/%1.zip"_q;
|
|
||||||
} else if (Platform::IsLinux()) {
|
|
||||||
url += u"linux/%1.tar.xz"_q;
|
|
||||||
} else {
|
|
||||||
Unexpected("Platform value.");
|
|
||||||
}
|
|
||||||
url = url.arg(u"talpha%1_%2"_q.arg(cRealAlphaVersion()).arg(Core::countAlphaVersionSignature(cRealAlphaVersion())));
|
|
||||||
|
|
||||||
QGuiApplication::clipboard()->setText(url);
|
|
||||||
|
|
||||||
getDelegate()->show(
|
|
||||||
Ui::MakeInformBox(
|
|
||||||
"The link to the current private alpha "
|
|
||||||
"version of Telegram Desktop was copied to the clipboard."),
|
|
||||||
Ui::LayerOption::CloseOther);
|
|
||||||
} else {
|
|
||||||
File::OpenUrl(Core::App().changelogLink());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AboutBox::keyPressEvent(QKeyEvent *e) {
|
void AboutBox::keyPressEvent(QKeyEvent *e) {
|
||||||
|
@ -131,23 +96,6 @@ void AboutBox::keyPressEvent(QKeyEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString telegramFaqLink() {
|
|
||||||
const auto result = u"https://telegram.org/faq"_q;
|
|
||||||
const auto langpacked = [&](const char *language) {
|
|
||||||
return result + '/' + language;
|
|
||||||
};
|
|
||||||
const auto current = Lang::Id();
|
|
||||||
for (const auto language : { "de", "es", "it", "ko" }) {
|
|
||||||
if (current.startsWith(QLatin1String(language))) {
|
|
||||||
return langpacked(language);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (current.startsWith(u"pt-br"_q)) {
|
|
||||||
return langpacked("br");
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString currentVersionText() {
|
QString currentVersionText() {
|
||||||
auto result = QString::fromLatin1(AppVersionStr);
|
auto result = QString::fromLatin1(AppVersionStr);
|
||||||
if (cAlphaVersion()) {
|
if (cAlphaVersion()) {
|
||||||
|
|
|
@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "ui/layers/box_content.h"
|
#include "ui/layers/box_content.h"
|
||||||
|
|
||||||
|
namespace Window {
|
||||||
|
class SessionController;
|
||||||
|
}
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class LinkButton;
|
class LinkButton;
|
||||||
class FlatLabel;
|
class FlatLabel;
|
||||||
|
@ -16,7 +20,7 @@ class FlatLabel;
|
||||||
|
|
||||||
class AboutBox : public Ui::BoxContent {
|
class AboutBox : public Ui::BoxContent {
|
||||||
public:
|
public:
|
||||||
AboutBox(QWidget*);
|
AboutBox(QWidget*, not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -28,9 +32,8 @@ private:
|
||||||
void showVersionHistory();
|
void showVersionHistory();
|
||||||
|
|
||||||
object_ptr<Ui::LinkButton> _version;
|
object_ptr<Ui::LinkButton> _version;
|
||||||
object_ptr<Ui::FlatLabel> _text1;
|
object_ptr<Ui::FlatLabel> _text;
|
||||||
object_ptr<Ui::FlatLabel> _text2;
|
not_null<Window::SessionController*> _controller;
|
||||||
object_ptr<Ui::FlatLabel> _text3;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1111,36 +1111,7 @@ bool Application::openInternalUrl(const QString &url, QVariant context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Application::changelogLink() const {
|
QString Application::changelogLink() const {
|
||||||
const auto base = u"https://desktop.telegram.org/changelog"_q;
|
return u"https://github.com/AyuGram/AyuGramDesktop/releases"_q;
|
||||||
const auto languages = {
|
|
||||||
"id",
|
|
||||||
"de",
|
|
||||||
"fr",
|
|
||||||
"nl",
|
|
||||||
"pl",
|
|
||||||
"tr",
|
|
||||||
"uk",
|
|
||||||
"fa",
|
|
||||||
"ru",
|
|
||||||
"ms",
|
|
||||||
"es",
|
|
||||||
"it",
|
|
||||||
"uz",
|
|
||||||
"pt-br",
|
|
||||||
"be",
|
|
||||||
"ar",
|
|
||||||
"ko",
|
|
||||||
};
|
|
||||||
const auto current = _langpack->id().replace("-raw", "");
|
|
||||||
if (current.isEmpty()) {
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
for (const auto language : languages) {
|
|
||||||
if (current == language || current.split(u'-')[0] == language) {
|
|
||||||
return base + "?setln=" + language;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return base;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Application::openCustomUrl(
|
bool Application::openCustomUrl(
|
||||||
|
|
|
@ -476,7 +476,7 @@ MainMenu::MainMenu(
|
||||||
_version->setLink(
|
_version->setLink(
|
||||||
2,
|
2,
|
||||||
std::make_shared<LambdaClickHandler>([=] {
|
std::make_shared<LambdaClickHandler>([=] {
|
||||||
controller->show(Box<AboutBox>());
|
controller->show(Box<AboutBox>(controller));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
|
|
Loading…
Add table
Reference in a new issue