From 383c48826834fc86e4949273994df71d16eebd82 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Tue, 4 Feb 2025 19:28:46 +0300 Subject: [PATCH] feat: simplify intro --- Telegram/CMakeLists.txt | 2 - Telegram/SourceFiles/intro/intro.style | 10 ++++- Telegram/SourceFiles/intro/intro_qr.h | 2 +- Telegram/SourceFiles/intro/intro_start.cpp | 42 ------------------- Telegram/SourceFiles/intro/intro_start.h | 34 --------------- Telegram/SourceFiles/intro/intro_widget.cpp | 13 +++--- Telegram/SourceFiles/intro/intro_widget.h | 3 +- .../SourceFiles/window/window_controller.cpp | 5 +-- 8 files changed, 20 insertions(+), 91 deletions(-) delete mode 100644 Telegram/SourceFiles/intro/intro_start.cpp delete mode 100644 Telegram/SourceFiles/intro/intro_start.h diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 266d8218a..92d2d0ff6 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -1168,8 +1168,6 @@ PRIVATE intro/intro_qr.h intro/intro_signup.cpp intro/intro_signup.h - intro/intro_start.cpp - intro/intro_start.h intro/intro_step.cpp intro/intro_step.h intro/intro_widget.cpp diff --git a/Telegram/SourceFiles/intro/intro.style b/Telegram/SourceFiles/intro/intro.style index c2ea8389c..888fd3d34 100644 --- a/Telegram/SourceFiles/intro/intro.style +++ b/Telegram/SourceFiles/intro/intro.style @@ -59,6 +59,14 @@ introDescription: FlatLabel(defaultFlatLabel) { lineHeight: 20px; } } +introFooter: FlatLabel(defaultFlatLabel) { + align: align(center); + textFg: introDescriptionFg; + style: TextStyle(defaultTextStyle) { + font: font(11px); + lineHeight: 24px; + } +} introDescriptionTop: 34px; introLink: defaultLinkButton; @@ -173,7 +181,7 @@ introQrPixel: 50px; // large enough introQrMaxSize: 180px; introQrBackgroundSkip: 12px; introQrBackgroundRadius: 8px; -introQrLabelsWidth: 292px; +introQrLabelsWidth: 300px; introQrTitleWidth: 320px; introQrTitle: FlatLabel(defaultFlatLabel) { textFg: introTitleFg; diff --git a/Telegram/SourceFiles/intro/intro_qr.h b/Telegram/SourceFiles/intro/intro_qr.h index 7cc166a4b..621b85539 100644 --- a/Telegram/SourceFiles/intro/intro_qr.h +++ b/Telegram/SourceFiles/intro/intro_qr.h @@ -28,7 +28,7 @@ public: rpl::producer nextButtonText() const override; bool hasBack() const override { - return true; + return false; } private: diff --git a/Telegram/SourceFiles/intro/intro_start.cpp b/Telegram/SourceFiles/intro/intro_start.cpp deleted file mode 100644 index a3184d85f..000000000 --- a/Telegram/SourceFiles/intro/intro_start.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#include "intro/intro_start.h" - -#include "lang/lang_keys.h" -#include "intro/intro_qr.h" -#include "intro/intro_phone.h" -#include "ui/widgets/buttons.h" -#include "ui/widgets/labels.h" -#include "main/main_account.h" -#include "main/main_app_config.h" - -namespace Intro { -namespace details { - -StartWidget::StartWidget( - QWidget *parent, - not_null account, - not_null data) -: Step(parent, account, data, true) { - setMouseTracking(true); - setTitleText(rpl::single(u"AyuGram Desktop"_q)); - setDescriptionText(tr::ayu_IntroAbout()); - show(); -} - -void StartWidget::submit() { - account().destroyStaleAuthorizationKeys(); - goNext(); -} - -rpl::producer StartWidget::nextButtonText() const { - return tr::lng_start_msgs(); -} - -} // namespace details -} // namespace Intro diff --git a/Telegram/SourceFiles/intro/intro_start.h b/Telegram/SourceFiles/intro/intro_start.h deleted file mode 100644 index 4b3f072cd..000000000 --- a/Telegram/SourceFiles/intro/intro_start.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -This file is part of Telegram Desktop, -the official desktop application for the Telegram messaging service. - -For license and copyright information please follow this link: -https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL -*/ -#pragma once - -#include "intro/intro_step.h" - -namespace Ui { -class FlatLabel; -class LinkButton; -class RoundButton; -} // namespace Ui - -namespace Intro { -namespace details { - -class StartWidget : public Step { -public: - StartWidget( - QWidget *parent, - not_null account, - not_null data); - - void submit() override; - rpl::producer nextButtonText() const override; - -}; - -} // namespace details -} // namespace Intro diff --git a/Telegram/SourceFiles/intro/intro_widget.cpp b/Telegram/SourceFiles/intro/intro_widget.cpp index 831641d8e..bea534984 100644 --- a/Telegram/SourceFiles/intro/intro_widget.cpp +++ b/Telegram/SourceFiles/intro/intro_widget.cpp @@ -7,7 +7,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "intro/intro_widget.h" -#include "intro/intro_start.h" #include "intro/intro_phone.h" #include "intro/intro_qr.h" #include "intro/intro_code.h" @@ -46,6 +45,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_layers.h" #include "styles/style_intro.h" #include "base/qt/qt_common_adapters.h" +#include "boxes/about_box.h" namespace Intro { namespace { @@ -87,6 +87,7 @@ Widget::Widget( , _next( this, object_ptr(this, nullptr, *_nextStyle)) +, _footer(this, st::introFooter) , _connecting(std::make_unique( this, account, @@ -102,10 +103,6 @@ Widget::Widget( }, lifetime()); switch (point) { - case EnterPoint::Start: - getNearestDC(); - appendStep(new StartWidget(this, _account, getData())); - break; case EnterPoint::Phone: appendStep(new PhoneWidget(this, _account, getData())); break; @@ -158,6 +155,8 @@ Widget::Widget( checkUpdateStatus(); }, lifetime()); } + + _footer->setText(QString("AyuGram Desktop v%1").arg(currentVersionText())); } rpl::producer<> Widget::showSettingsRequested() const { @@ -826,6 +825,8 @@ void Widget::updateControlsGeometry() { (width() - _terms->width()) / 2, height() - st::introTermsBottom - _terms->height()); } + + _footer->move((width() - _footer->width()) / 2, height() - _footer->height() - st::lineWidth * 6); } void Widget::keyPressEvent(QKeyEvent *e) { @@ -850,7 +851,7 @@ void Widget::backRequested() { Core::App().domain().activate(parent); } else { moveToStep( - Ui::CreateChild(this, _account, getData()), + Ui::CreateChild(this, _account, getData()), StackAction::Replace, Animate::Back); } diff --git a/Telegram/SourceFiles/intro/intro_widget.h b/Telegram/SourceFiles/intro/intro_widget.h index 8b804c623..fa4663921 100644 --- a/Telegram/SourceFiles/intro/intro_widget.h +++ b/Telegram/SourceFiles/intro/intro_widget.h @@ -82,7 +82,6 @@ class Step; } // namespace details enum class EnterPoint : uchar { - Start, Phone, Qr, }; @@ -198,6 +197,8 @@ private: object_ptr> _resetAccount = { nullptr }; object_ptr> _terms = { nullptr }; + object_ptr _footer; + std::unique_ptr _connecting; bool _nextShown = true; diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index fb47a4050..578a17310 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -375,10 +375,7 @@ void Controller::clearPasscodeLock() { } void Controller::setupIntro(QPixmap oldContentCache) { - const auto point = Core::App().domain().maybeLastOrSomeAuthedAccount() - ? Intro::EnterPoint::Qr - : Intro::EnterPoint::Start; - _widget.setupIntro(point, std::move(oldContentCache)); + _widget.setupIntro(Intro::EnterPoint::Qr, std::move(oldContentCache)); } void Controller::setupMain(