Removed Ui::show from CountryInput.

This commit is contained in:
23rd 2022-06-09 04:50:00 +03:00
parent f0e1498a41
commit 4add87e7a9
4 changed files with 25 additions and 6 deletions

View file

@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/boxes/confirm_box.h" #include "ui/boxes/confirm_box.h"
#include "boxes/phone_banned_box.h" #include "boxes/phone_banned_box.h"
#include "core/application.h" #include "core/application.h"
#include "window/window_session_controller.h"
#include "countries/countries_instance.h" // Countries::Groups #include "countries/countries_instance.h" // Countries::Groups
namespace Intro { namespace Intro {
@ -43,7 +44,10 @@ PhoneWidget::PhoneWidget(
not_null<Main::Account*> account, not_null<Main::Account*> account,
not_null<Data*> data) not_null<Data*> data)
: Step(parent, account, data) : Step(parent, account, data)
, _country(this, st::introCountry) , _country(
this,
std::make_shared<Window::Show>(getData()->controller),
st::introCountry)
, _code(this, st::introCountryCode) , _code(this, st::introCountryCode)
, _phone( , _phone(
this, this,

View file

@ -7,7 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/ */
#pragma once #pragma once
#include "boxes/abstract_box.h" #include "ui/layers/box_content.h"
#include "styles/style_widgets.h" #include "styles/style_widgets.h"
namespace Countries { namespace Countries {

View file

@ -13,12 +13,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/effects/ripple_animation.h" #include "ui/effects/ripple_animation.h"
#include "ui/boxes/country_select_box.h" #include "ui/boxes/country_select_box.h"
#include "countries/countries_instance.h" #include "countries/countries_instance.h"
#include "window/window_session_controller.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
#include "styles/style_boxes.h" #include "styles/style_boxes.h"
#include "styles/style_intro.h" #include "styles/style_intro.h"
CountryInput::CountryInput(QWidget *parent, const style::InputField &st) CountryInput::CountryInput(
QWidget *parent,
std::shared_ptr<Window::Show> show,
const style::InputField &st)
: RpWidget(parent) : RpWidget(parent)
, _show(show)
, _st(st) , _st(st)
, _text(tr::lng_country_code(tr::now)) { , _text(tr::lng_country_code(tr::now)) {
resize(_st.width, _st.heightMin); resize(_st.width, _st.heightMin);
@ -112,7 +117,9 @@ void CountryInput::mouseMoveEvent(QMouseEvent *e) {
void CountryInput::mousePressEvent(QMouseEvent *e) { void CountryInput::mousePressEvent(QMouseEvent *e) {
mouseMoveEvent(e); mouseMoveEvent(e);
if (_active) { if (_active) {
const auto box = Ui::show(Box<Ui::CountrySelectBox>()); auto object = Box<Ui::CountrySelectBox>();
const auto box = Ui::MakeWeak(object.data());
_show->showBox(std::move(object), Ui::LayerOption::CloseOther);
box->entryChosen( box->entryChosen(
) | rpl::start_with_next([=]( ) | rpl::start_with_next([=](
const Ui::CountrySelectBox::Entry &entry) { const Ui::CountrySelectBox::Entry &entry) {
@ -153,7 +160,7 @@ void CountryInput::leaveEventHook(QEvent *e) {
} }
void CountryInput::onChooseCode(const QString &code) { void CountryInput::onChooseCode(const QString &code) {
Ui::hideLayer(); _show->hideLayer();
_chosenIso = QString(); _chosenIso = QString();
if (code.length()) { if (code.length()) {
const auto &byCode = Countries::Instance().byCode(); const auto &byCode = Countries::Instance().byCode();

View file

@ -18,6 +18,10 @@ namespace Countries {
struct Info; struct Info;
} // namespace Countries } // namespace Countries
namespace Window {
class Show;
} // namespace Window
namespace Ui { namespace Ui {
class MultiSelect; class MultiSelect;
class RippleAnimation; class RippleAnimation;
@ -26,7 +30,10 @@ class RippleAnimation;
class CountryInput : public Ui::RpWidget { class CountryInput : public Ui::RpWidget {
public: public:
CountryInput(QWidget *parent, const style::InputField &st); CountryInput(
QWidget *parent,
std::shared_ptr<Window::Show> show,
const style::InputField &st);
[[nodiscard]] QString iso() const { [[nodiscard]] QString iso() const {
return _chosenIso; return _chosenIso;
@ -48,6 +55,7 @@ private:
void chooseCountry(not_null<const Countries::Info*> info, int codeIndex); void chooseCountry(not_null<const Countries::Info*> info, int codeIndex);
void setText(const QString &newText); void setText(const QString &newText);
const std::shared_ptr<Window::Show> _show;
const style::InputField &_st; const style::InputField &_st;
bool _active = false; bool _active = false;
QString _text; QString _text;