tdesktop/Telegram/SourceFiles/passport/passport_panel_controller.h

102 lines
2.2 KiB
C
Raw Normal View History

/*
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
*/
#pragma once
#include "passport/passport_form_view_controller.h"
#include "passport/passport_form_controller.h"
namespace Passport {
class FormController;
class Panel;
struct ScanInfo {
FileKey key;
QString status;
QImage thumb;
bool deleted = false;
};
class BoxPointer {
public:
BoxPointer(QPointer<BoxContent> value = nullptr);
BoxPointer(BoxPointer &&other);
BoxPointer &operator=(BoxPointer &&other);
~BoxPointer();
BoxContent *get() const;
operator BoxContent*() const;
explicit operator bool() const;
BoxContent *operator->() const;
private:
QPointer<BoxContent> _value;
};
class PanelController : public ViewController {
public:
PanelController(not_null<FormController*> form);
not_null<UserData*> bot() const;
2018-04-03 18:24:31 +00:00
QString privacyPolicyUrl() const;
void submitPassword(const QString &password);
rpl::producer<QString> passwordError() const;
QString passwordHint() const;
2018-04-03 18:24:31 +00:00
void uploadScan(QByteArray &&content);
void deleteScan(int fileIndex);
void restoreScan(int fileIndex);
rpl::producer<ScanInfo> scanUpdated() const;
QString defaultEmail() const;
QString defaultPhoneNumber() const;
void showAskPassword() override;
void showNoPassword() override;
void showPasswordUnconfirmed() override;
void fillRows(
base::lambda<void(
QString title,
QString description,
bool ready)> callback);
2018-04-03 18:24:31 +00:00
void editScope(int index) override;
void saveScope(ValueMap &&data, ValueMap &&filesData);
2018-04-06 16:23:09 +00:00
void showBox(object_ptr<BoxContent> box) override;
void cancelAuth();
rpl::lifetime &lifetime();
private:
void ensurePanelCreated();
void cancelValueEdit(int index);
std::vector<ScanInfo> valueFiles(const Value &value) const;
ScanInfo collectScanInfo(const EditFile &file) const;
QString getDefaultContactValue(Scope::Type type) const;
not_null<FormController*> _form;
2018-04-03 18:24:31 +00:00
std::vector<Scope> _scopes;
std::unique_ptr<Panel> _panel;
2018-04-03 18:24:31 +00:00
Scope *_editScope = nullptr;
int _editScopeFilesIndex = -1;
rpl::lifetime _lifetime;
};
} // namespace Passport