2018-03-31 01:45:40 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#include "passport/passport_panel.h"
|
|
|
|
|
|
|
|
#include "passport/passport_panel_controller.h"
|
|
|
|
#include "passport/passport_panel_form.h"
|
|
|
|
#include "passport/passport_panel_password.h"
|
2018-06-02 09:59:19 +00:00
|
|
|
#include "ui/widgets/separate_panel.h"
|
2018-03-31 01:45:40 +00:00
|
|
|
#include "ui/widgets/labels.h"
|
2018-04-15 15:06:53 +00:00
|
|
|
#include "ui/wrap/padding_wrap.h"
|
2018-03-31 01:45:40 +00:00
|
|
|
#include "lang/lang_keys.h"
|
|
|
|
#include "styles/style_passport.h"
|
|
|
|
#include "styles/style_widgets.h"
|
|
|
|
#include "styles/style_calls.h"
|
|
|
|
|
|
|
|
namespace Passport {
|
|
|
|
|
|
|
|
Panel::Panel(not_null<PanelController*> controller)
|
|
|
|
: _controller(controller)
|
2018-06-02 09:59:19 +00:00
|
|
|
, _widget(std::make_unique<Ui::SeparatePanel>()) {
|
|
|
|
_widget->setTitle(Lang::Viewer(lng_passport_title));
|
|
|
|
_widget->setInnerSize(st::passportPanelSize);
|
|
|
|
|
2018-06-02 14:29:21 +00:00
|
|
|
_widget->closeRequests(
|
2018-06-02 09:59:19 +00:00
|
|
|
) | rpl::start_with_next([=] {
|
2018-04-13 18:14:14 +00:00
|
|
|
_controller->cancelAuth();
|
2018-06-02 09:59:19 +00:00
|
|
|
}, _widget->lifetime());
|
2018-06-02 14:29:21 +00:00
|
|
|
|
|
|
|
_widget->closeEvents(
|
|
|
|
) | rpl::start_with_next([=] {
|
|
|
|
_controller->cancelAuthSure();
|
|
|
|
}, _widget->lifetime());
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
rpl::producer<> Panel::backRequests() const {
|
2018-06-02 09:59:19 +00:00
|
|
|
return _widget->backRequests();
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::setBackAllowed(bool allowed) {
|
2018-06-02 09:59:19 +00:00
|
|
|
_widget->setBackAllowed(allowed);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
2018-06-02 09:59:19 +00:00
|
|
|
not_null<Ui::RpWidget*> Panel::widget() const {
|
|
|
|
return _widget.get();
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
2018-04-13 18:14:14 +00:00
|
|
|
int Panel::hideAndDestroyGetDuration() {
|
2018-06-02 14:29:21 +00:00
|
|
|
return _widget->hideGetDuration();
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::showAskPassword() {
|
2018-06-02 09:59:19 +00:00
|
|
|
_widget->showInner(
|
|
|
|
base::make_unique_q<PanelAskPassword>(_widget.get(), _controller));
|
2018-04-06 16:23:09 +00:00
|
|
|
setBackAllowed(false);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::showNoPassword() {
|
2018-06-02 09:59:19 +00:00
|
|
|
_widget->showInner(
|
|
|
|
base::make_unique_q<PanelNoPassword>(_widget.get(), _controller));
|
2018-04-06 16:23:09 +00:00
|
|
|
setBackAllowed(false);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
2018-04-15 15:06:53 +00:00
|
|
|
void Panel::showCriticalError(const QString &error) {
|
|
|
|
auto container = base::make_unique_q<Ui::PaddingWrap<Ui::FlatLabel>>(
|
2018-06-02 09:59:19 +00:00
|
|
|
_widget.get(),
|
2018-04-15 15:06:53 +00:00
|
|
|
object_ptr<Ui::FlatLabel>(
|
2018-06-02 09:59:19 +00:00
|
|
|
_widget.get(),
|
2018-04-15 15:06:53 +00:00
|
|
|
error,
|
|
|
|
Ui::FlatLabel::InitType::Simple,
|
|
|
|
st::passportErrorLabel),
|
2018-06-02 09:59:19 +00:00
|
|
|
style::margins(0, st::passportPanelSize.height() / 3, 0, 0));
|
2018-04-15 15:06:53 +00:00
|
|
|
container->widthValue(
|
|
|
|
) | rpl::start_with_next([label = container->entity()](int width) {
|
|
|
|
label->resize(width, label->height());
|
|
|
|
}, container->lifetime());
|
2018-06-02 09:59:19 +00:00
|
|
|
|
|
|
|
_widget->showInner(std::move(container));
|
2018-04-15 15:06:53 +00:00
|
|
|
setBackAllowed(false);
|
|
|
|
}
|
|
|
|
|
2018-03-31 01:45:40 +00:00
|
|
|
void Panel::showForm() {
|
2018-06-02 09:59:19 +00:00
|
|
|
_widget->showInner(
|
|
|
|
base::make_unique_q<PanelForm>(_widget.get(), _controller));
|
2018-04-06 16:23:09 +00:00
|
|
|
setBackAllowed(false);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Panel::showEditValue(object_ptr<Ui::RpWidget> from) {
|
2018-06-02 09:59:19 +00:00
|
|
|
_widget->showInner(base::unique_qptr<Ui::RpWidget>(from.data()));
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
2018-04-16 17:02:40 +00:00
|
|
|
void Panel::showBox(
|
|
|
|
object_ptr<BoxContent> box,
|
|
|
|
LayerOptions options,
|
|
|
|
anim::type animated) {
|
2018-06-02 09:59:19 +00:00
|
|
|
_widget->showBox(std::move(box), options, animated);
|
2018-07-10 20:15:54 +00:00
|
|
|
_widget->showAndActivate();
|
2018-04-06 16:23:09 +00:00
|
|
|
}
|
|
|
|
|
2018-06-02 09:59:19 +00:00
|
|
|
void Panel::showToast(const QString &text) {
|
|
|
|
_widget->showToast(text);
|
2018-03-31 01:45:40 +00:00
|
|
|
}
|
|
|
|
|
2018-06-02 09:59:19 +00:00
|
|
|
Panel::~Panel() = default;
|
2018-03-31 01:45:40 +00:00
|
|
|
|
|
|
|
} // namespace Passport
|