init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
111
Telegram/SourceFiles/passport/passport_panel.cpp
Normal file
111
Telegram/SourceFiles/passport/passport_panel.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
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"
|
||||
#include "ui/widgets/separate_panel.h"
|
||||
#include "ui/widgets/labels.h"
|
||||
#include "ui/wrap/padding_wrap.h"
|
||||
#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)
|
||||
, _widget(std::make_unique<Ui::SeparatePanel>(Ui::SeparatePanelArgs{
|
||||
.onAllSpaces = true,
|
||||
})) {
|
||||
_widget->setTitle(tr::lng_passport_title());
|
||||
_widget->setInnerSize(st::passportPanelSize);
|
||||
|
||||
_widget->closeRequests(
|
||||
) | rpl::on_next([=] {
|
||||
_controller->cancelAuth();
|
||||
}, _widget->lifetime());
|
||||
|
||||
_widget->closeEvents(
|
||||
) | rpl::on_next([=] {
|
||||
_controller->cancelAuthSure();
|
||||
}, _widget->lifetime());
|
||||
}
|
||||
|
||||
rpl::producer<> Panel::backRequests() const {
|
||||
return _widget->backRequests();
|
||||
}
|
||||
|
||||
void Panel::setBackAllowed(bool allowed) {
|
||||
_widget->setBackAllowed(allowed);
|
||||
}
|
||||
|
||||
not_null<Ui::RpWidget*> Panel::widget() const {
|
||||
return _widget.get();
|
||||
}
|
||||
|
||||
int Panel::hideAndDestroyGetDuration() {
|
||||
return _widget->hideGetDuration();
|
||||
}
|
||||
|
||||
void Panel::showAskPassword() {
|
||||
_widget->showInner(
|
||||
base::make_unique_q<PanelAskPassword>(_widget.get(), _controller));
|
||||
setBackAllowed(false);
|
||||
}
|
||||
|
||||
void Panel::showNoPassword() {
|
||||
_widget->showInner(
|
||||
base::make_unique_q<PanelNoPassword>(_widget.get(), _controller));
|
||||
setBackAllowed(false);
|
||||
}
|
||||
|
||||
void Panel::showCriticalError(const QString &error) {
|
||||
auto container = base::make_unique_q<Ui::PaddingWrap<Ui::FlatLabel>>(
|
||||
_widget.get(),
|
||||
object_ptr<Ui::FlatLabel>(
|
||||
_widget.get(),
|
||||
error,
|
||||
st::passportErrorLabel),
|
||||
style::margins(0, st::passportPanelSize.height() / 3, 0, 0));
|
||||
container->widthValue(
|
||||
) | rpl::on_next([label = container->entity()](int width) {
|
||||
label->resize(width, label->height());
|
||||
}, container->lifetime());
|
||||
|
||||
_widget->showInner(std::move(container));
|
||||
setBackAllowed(false);
|
||||
}
|
||||
|
||||
void Panel::showForm() {
|
||||
_widget->showInner(
|
||||
base::make_unique_q<PanelForm>(_widget.get(), _controller));
|
||||
setBackAllowed(false);
|
||||
}
|
||||
|
||||
void Panel::showEditValue(object_ptr<Ui::RpWidget> from) {
|
||||
_widget->showInner(base::unique_qptr<Ui::RpWidget>(from.data()));
|
||||
}
|
||||
|
||||
void Panel::showBox(
|
||||
object_ptr<Ui::BoxContent> box,
|
||||
Ui::LayerOptions options,
|
||||
anim::type animated) {
|
||||
_widget->showBox(std::move(box), options, animated);
|
||||
_widget->showAndActivate();
|
||||
}
|
||||
|
||||
void Panel::showToast(const QString &text) {
|
||||
_widget->showToast({ text });
|
||||
}
|
||||
|
||||
Panel::~Panel() = default;
|
||||
|
||||
} // namespace Passport
|
||||
Reference in New Issue
Block a user