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 "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<Main::Account*> account,
not_null<Data*> data)
: Step(parent, account, data)
, _country(this, st::introCountry)
, _country(
this,
std::make_shared<Window::Show>(getData()->controller),
st::introCountry)
, _code(this, st::introCountryCode)
, _phone(
this,

View File

@ -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 {

View File

@ -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<Window::Show> 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<Ui::CountrySelectBox>());
auto object = Box<Ui::CountrySelectBox>();
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();

View File

@ -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<Window::Show> show,
const style::InputField &st);
[[nodiscard]] QString iso() const {
return _chosenIso;
@ -48,6 +55,7 @@ private:
void chooseCountry(not_null<const Countries::Info*> info, int codeIndex);
void setText(const QString &newText);
const std::shared_ptr<Window::Show> _show;
const style::InputField &_st;
bool _active = false;
QString _text;