diff --git a/Telegram/SourceFiles/intro/intro_phone.cpp b/Telegram/SourceFiles/intro/intro_phone.cpp index 8627972b01..53dee06f38 100644 --- a/Telegram/SourceFiles/intro/intro_phone.cpp +++ b/Telegram/SourceFiles/intro/intro_phone.cpp @@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/boxes/confirm_box.h" #include "boxes/phone_banned_box.h" #include "core/application.h" +#include "window/window_session_controller.h" #include "countries/countries_instance.h" // Countries::Groups namespace Intro { @@ -43,7 +44,10 @@ PhoneWidget::PhoneWidget( not_null account, not_null data) : Step(parent, account, data) -, _country(this, st::introCountry) +, _country( + this, + std::make_shared(getData()->controller), + st::introCountry) , _code(this, st::introCountryCode) , _phone( this, diff --git a/Telegram/SourceFiles/ui/boxes/country_select_box.h b/Telegram/SourceFiles/ui/boxes/country_select_box.h index c36a6c74f7..507e478e9b 100644 --- a/Telegram/SourceFiles/ui/boxes/country_select_box.h +++ b/Telegram/SourceFiles/ui/boxes/country_select_box.h @@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once -#include "boxes/abstract_box.h" +#include "ui/layers/box_content.h" #include "styles/style_widgets.h" namespace Countries { diff --git a/Telegram/SourceFiles/ui/countryinput.cpp b/Telegram/SourceFiles/ui/countryinput.cpp index 67d5aabf5d..9b0b7baf3d 100644 --- a/Telegram/SourceFiles/ui/countryinput.cpp +++ b/Telegram/SourceFiles/ui/countryinput.cpp @@ -13,12 +13,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/effects/ripple_animation.h" #include "ui/boxes/country_select_box.h" #include "countries/countries_instance.h" +#include "window/window_session_controller.h" #include "styles/style_layers.h" #include "styles/style_boxes.h" #include "styles/style_intro.h" -CountryInput::CountryInput(QWidget *parent, const style::InputField &st) +CountryInput::CountryInput( + QWidget *parent, + std::shared_ptr show, + const style::InputField &st) : RpWidget(parent) +, _show(show) , _st(st) , _text(tr::lng_country_code(tr::now)) { resize(_st.width, _st.heightMin); @@ -112,7 +117,9 @@ void CountryInput::mouseMoveEvent(QMouseEvent *e) { void CountryInput::mousePressEvent(QMouseEvent *e) { mouseMoveEvent(e); if (_active) { - const auto box = Ui::show(Box()); + auto object = Box(); + const auto box = Ui::MakeWeak(object.data()); + _show->showBox(std::move(object), Ui::LayerOption::CloseOther); box->entryChosen( ) | rpl::start_with_next([=]( const Ui::CountrySelectBox::Entry &entry) { @@ -153,7 +160,7 @@ void CountryInput::leaveEventHook(QEvent *e) { } void CountryInput::onChooseCode(const QString &code) { - Ui::hideLayer(); + _show->hideLayer(); _chosenIso = QString(); if (code.length()) { const auto &byCode = Countries::Instance().byCode(); diff --git a/Telegram/SourceFiles/ui/countryinput.h b/Telegram/SourceFiles/ui/countryinput.h index a6828e8f2e..c8130b8f49 100644 --- a/Telegram/SourceFiles/ui/countryinput.h +++ b/Telegram/SourceFiles/ui/countryinput.h @@ -18,6 +18,10 @@ namespace Countries { struct Info; } // namespace Countries +namespace Window { +class Show; +} // namespace Window + namespace Ui { class MultiSelect; class RippleAnimation; @@ -26,7 +30,10 @@ class RippleAnimation; class CountryInput : public Ui::RpWidget { public: - CountryInput(QWidget *parent, const style::InputField &st); + CountryInput( + QWidget *parent, + std::shared_ptr show, + const style::InputField &st); [[nodiscard]] QString iso() const { return _chosenIso; @@ -48,6 +55,7 @@ private: void chooseCountry(not_null info, int codeIndex); void setText(const QString &newText); + const std::shared_ptr _show; const style::InputField &_st; bool _active = false; QString _text;