mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added Window::SessionController to ChangePhoneBox.
This commit is contained in:
parent
30681e2e58
commit
c6e1b14429
3 changed files with 38 additions and 28 deletions
|
@ -23,6 +23,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_user.h"
|
#include "data/data_user.h"
|
||||||
#include "mtproto/sender.h"
|
#include "mtproto/sender.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.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"
|
||||||
|
|
||||||
|
@ -67,7 +68,7 @@ void createErrorLabel(
|
||||||
|
|
||||||
class ChangePhoneBox::EnterPhone : public Ui::BoxContent {
|
class ChangePhoneBox::EnterPhone : public Ui::BoxContent {
|
||||||
public:
|
public:
|
||||||
EnterPhone(QWidget*, not_null<Main::Session*> session);
|
EnterPhone(QWidget*, not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
void setInnerFocus() override {
|
void setInnerFocus() override {
|
||||||
_phone->setFocusFast();
|
_phone->setFocusFast();
|
||||||
|
@ -85,7 +86,7 @@ private:
|
||||||
showError(QString());
|
showError(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
const not_null<Main::Session*> _session;
|
const not_null<Window::SessionController*> _controller;
|
||||||
MTP::Sender _api;
|
MTP::Sender _api;
|
||||||
|
|
||||||
object_ptr<Ui::PhoneInput> _phone = { nullptr };
|
object_ptr<Ui::PhoneInput> _phone = { nullptr };
|
||||||
|
@ -139,9 +140,9 @@ private:
|
||||||
|
|
||||||
ChangePhoneBox::EnterPhone::EnterPhone(
|
ChangePhoneBox::EnterPhone::EnterPhone(
|
||||||
QWidget*,
|
QWidget*,
|
||||||
not_null<Main::Session*> session)
|
not_null<Window::SessionController*> controller)
|
||||||
: _session(session)
|
: _controller(controller)
|
||||||
, _api(&session->mtp()) {
|
, _api(&controller->session().mtp()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangePhoneBox::EnterPhone::prepare() {
|
void ChangePhoneBox::EnterPhone::prepare() {
|
||||||
|
@ -152,7 +153,7 @@ void ChangePhoneBox::EnterPhone::prepare() {
|
||||||
this,
|
this,
|
||||||
st::defaultInputField,
|
st::defaultInputField,
|
||||||
tr::lng_change_phone_new_title(),
|
tr::lng_change_phone_new_title(),
|
||||||
Countries::ExtractPhoneCode(_session->user()->phone()),
|
Countries::ExtractPhoneCode(_controller->session().user()->phone()),
|
||||||
phoneValue);
|
phoneValue);
|
||||||
|
|
||||||
_phone->resize(st::boxWidth - 2 * st::boxPadding.left(), _phone->height());
|
_phone->resize(st::boxWidth - 2 * st::boxPadding.left(), _phone->height());
|
||||||
|
@ -213,9 +214,9 @@ void ChangePhoneBox::EnterPhone::sendPhoneDone(
|
||||||
callTimeout = data.vtimeout().value_or(60);
|
callTimeout = data.vtimeout().value_or(60);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ui::show(
|
_controller->show(
|
||||||
Box<EnterCode>(
|
Box<EnterCode>(
|
||||||
_session,
|
&_controller->session(),
|
||||||
phoneNumber,
|
phoneNumber,
|
||||||
phoneCodeHash,
|
phoneCodeHash,
|
||||||
codeLength,
|
codeLength,
|
||||||
|
@ -232,12 +233,14 @@ void ChangePhoneBox::EnterPhone::sendPhoneFail(const MTP::Error &error, const QS
|
||||||
} else if (error.type() == qstr("PHONE_NUMBER_BANNED")) {
|
} else if (error.type() == qstr("PHONE_NUMBER_BANNED")) {
|
||||||
ShowPhoneBannedError(phoneNumber);
|
ShowPhoneBannedError(phoneNumber);
|
||||||
} else if (error.type() == qstr("PHONE_NUMBER_OCCUPIED")) {
|
} else if (error.type() == qstr("PHONE_NUMBER_OCCUPIED")) {
|
||||||
Ui::show(Box<InformBox>(
|
_controller->show(
|
||||||
tr::lng_change_phone_occupied(
|
Box<InformBox>(
|
||||||
tr::now,
|
tr::lng_change_phone_occupied(
|
||||||
lt_phone,
|
tr::now,
|
||||||
Ui::FormatPhone(phoneNumber)),
|
lt_phone,
|
||||||
tr::lng_box_ok(tr::now)));
|
Ui::FormatPhone(phoneNumber)),
|
||||||
|
tr::lng_box_ok(tr::now)),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
} else {
|
} else {
|
||||||
showError(Lang::Hard::ServerError());
|
showError(Lang::Hard::ServerError());
|
||||||
}
|
}
|
||||||
|
@ -371,18 +374,25 @@ void ChangePhoneBox::EnterCode::sendCodeFail(const MTP::Error &error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangePhoneBox::ChangePhoneBox(QWidget*, not_null<Main::Session*> session)
|
ChangePhoneBox::ChangePhoneBox(
|
||||||
: _session(session) {
|
QWidget*,
|
||||||
|
not_null<Window::SessionController*> controller)
|
||||||
|
: _controller(controller) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangePhoneBox::prepare() {
|
void ChangePhoneBox::prepare() {
|
||||||
const auto session = _session;
|
|
||||||
|
|
||||||
setTitle(tr::lng_change_phone_title());
|
setTitle(tr::lng_change_phone_title());
|
||||||
addButton(tr::lng_change_phone_button(), [=] {
|
addButton(tr::lng_change_phone_button(), [=, controller = _controller] {
|
||||||
Ui::show(Box<ConfirmBox>(tr::lng_change_phone_warning(tr::now), [=] {
|
auto callback = [=] {
|
||||||
Ui::show(Box<EnterPhone>(session));
|
controller->show(
|
||||||
}));
|
Box<EnterPhone>(controller),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
|
};
|
||||||
|
controller->show(
|
||||||
|
Box<ConfirmBox>(
|
||||||
|
tr::lng_change_phone_warning(tr::now),
|
||||||
|
std::move(callback)),
|
||||||
|
Ui::LayerOption::CloseOther);
|
||||||
});
|
});
|
||||||
addButton(tr::lng_cancel(), [this] {
|
addButton(tr::lng_cancel(), [this] {
|
||||||
closeBox();
|
closeBox();
|
||||||
|
|
|
@ -9,13 +9,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "boxes/abstract_box.h"
|
#include "boxes/abstract_box.h"
|
||||||
|
|
||||||
namespace Main {
|
namespace Window {
|
||||||
class Session;
|
class SessionController;
|
||||||
} // namespace Main
|
} // namespace Window
|
||||||
|
|
||||||
class ChangePhoneBox : public Ui::BoxContent {
|
class ChangePhoneBox : public Ui::BoxContent {
|
||||||
public:
|
public:
|
||||||
ChangePhoneBox(QWidget*, not_null<Main::Session*> session);
|
ChangePhoneBox(QWidget*, not_null<Window::SessionController*> controller);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
@ -26,7 +26,7 @@ private:
|
||||||
class EnterPhone;
|
class EnterPhone;
|
||||||
class EnterCode;
|
class EnterCode;
|
||||||
|
|
||||||
const not_null<Main::Session*> _session;
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ void SetupRows(
|
||||||
tr::lng_settings_phone_label(),
|
tr::lng_settings_phone_label(),
|
||||||
Info::Profile::PhoneValue(self),
|
Info::Profile::PhoneValue(self),
|
||||||
tr::lng_profile_copy_phone(tr::now),
|
tr::lng_profile_copy_phone(tr::now),
|
||||||
[=] { controller->show(Box<ChangePhoneBox>(session)); },
|
[=] { controller->show(Box<ChangePhoneBox>(controller)); },
|
||||||
st::settingsInfoPhone);
|
st::settingsInfoPhone);
|
||||||
|
|
||||||
auto username = Info::Profile::UsernameValue(self);
|
auto username = Info::Profile::UsernameValue(self);
|
||||||
|
|
Loading…
Add table
Reference in a new issue