From 71f34f4e31fbc15a8c75fa634e48727c417cef80 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 15 May 2025 18:19:49 +0300 Subject: [PATCH] Added ability to jump from code to phone input in intro with Space. --- Telegram/SourceFiles/intro/intro_phone.cpp | 3 +++ Telegram/SourceFiles/ui/widgets/fields/special_fields.cpp | 8 ++++++++ Telegram/SourceFiles/ui/widgets/fields/special_fields.h | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/Telegram/SourceFiles/intro/intro_phone.cpp b/Telegram/SourceFiles/intro/intro_phone.cpp index ae74136c8c..261c533112 100644 --- a/Telegram/SourceFiles/intro/intro_phone.cpp +++ b/Telegram/SourceFiles/intro/intro_phone.cpp @@ -80,6 +80,9 @@ PhoneWidget::PhoneWidget( ) | rpl::start_with_next([=](const QString &added) { _phone->addedToNumber(added); }, _phone->lifetime()); + _code->spacePressed() | rpl::start_with_next([=] { + submit(); + }, _code->lifetime()); connect(_phone, &Ui::PhonePartInput::changed, [=] { phoneChanged(); }); connect(_code, &Ui::CountryCodeInput::changed, [=] { phoneChanged(); }); diff --git a/Telegram/SourceFiles/ui/widgets/fields/special_fields.cpp b/Telegram/SourceFiles/ui/widgets/fields/special_fields.cpp index 0b7487caf1..b4afeb536c 100644 --- a/Telegram/SourceFiles/ui/widgets/fields/special_fields.cpp +++ b/Telegram/SourceFiles/ui/widgets/fields/special_fields.cpp @@ -50,6 +50,14 @@ void CountryCodeInput::codeSelected(const QString &code) { changed(); } +void CountryCodeInput::keyPressEvent(QKeyEvent *e) { + if (e->key() == Qt::Key_Space) { + _spacePressed.fire({}); + } else { + MaskedInputField::keyPressEvent(e); + } +} + void CountryCodeInput::correctValue( const QString &was, int wasCursor, diff --git a/Telegram/SourceFiles/ui/widgets/fields/special_fields.h b/Telegram/SourceFiles/ui/widgets/fields/special_fields.h index 6c000f8012..bb37f6eb3b 100644 --- a/Telegram/SourceFiles/ui/widgets/fields/special_fields.h +++ b/Telegram/SourceFiles/ui/widgets/fields/special_fields.h @@ -23,10 +23,14 @@ public: [[nodiscard]] rpl::producer codeChanged() const { return _codeChanged.events(); } + [[nodiscard]] rpl::producer<> spacePressed() const { + return _spacePressed.events(); + } void codeSelected(const QString &code); protected: + void keyPressEvent(QKeyEvent *e) override; void correctValue( const QString &was, int wasCursor, @@ -37,6 +41,7 @@ private: bool _nosignal = false; rpl::event_stream _addedToNumber; rpl::event_stream _codeChanged; + rpl::event_stream<> _spacePressed; };