2018-03-31 05:45:40 +04: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
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "ui/rp_widget.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
class InputField;
|
|
|
|
class ScrollArea;
|
|
|
|
class FadeShadow;
|
|
|
|
class PlainShadow;
|
|
|
|
class RoundButton;
|
|
|
|
} // namespace Ui
|
|
|
|
|
|
|
|
namespace Passport {
|
|
|
|
|
|
|
|
class PanelController;
|
|
|
|
struct ValueMap;
|
|
|
|
struct ScanInfo;
|
2018-04-04 23:26:40 +04:00
|
|
|
class EditScans;
|
2018-04-05 21:01:22 +04:00
|
|
|
class PanelDetailsRow;
|
2018-04-10 15:26:21 +04:00
|
|
|
enum class PanelDetailsType;
|
2018-03-31 05:45:40 +04:00
|
|
|
|
2018-04-12 19:45:04 +04:00
|
|
|
struct EditDocumentScheme {
|
|
|
|
enum class ValueClass {
|
|
|
|
Fields,
|
|
|
|
Scans,
|
|
|
|
};
|
|
|
|
struct Row {
|
|
|
|
ValueClass valueClass = ValueClass::Fields;
|
|
|
|
PanelDetailsType inputType = PanelDetailsType();
|
|
|
|
QString key;
|
|
|
|
QString label;
|
|
|
|
base::lambda<bool(const QString &value)> validate;
|
|
|
|
base::lambda<QString(const QString &value)> format;
|
2018-04-13 15:15:07 +04:00
|
|
|
int lengthLimit = 0;
|
2018-04-12 19:45:04 +04:00
|
|
|
};
|
|
|
|
std::vector<Row> rows;
|
|
|
|
QString rowsHeader;
|
|
|
|
QString scansHeader;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-04-05 21:01:22 +04:00
|
|
|
class PanelEditDocument : public Ui::RpWidget {
|
2018-03-31 05:45:40 +04:00
|
|
|
public:
|
2018-04-12 19:45:04 +04:00
|
|
|
using Scheme = EditDocumentScheme;
|
2018-04-05 21:01:22 +04:00
|
|
|
|
|
|
|
PanelEditDocument(
|
2018-03-31 05:45:40 +04:00
|
|
|
QWidget *parent,
|
|
|
|
not_null<PanelController*> controller,
|
2018-04-05 21:01:22 +04:00
|
|
|
Scheme scheme,
|
2018-03-31 05:45:40 +04:00
|
|
|
const ValueMap &data,
|
2018-04-03 22:24:31 +04:00
|
|
|
const ValueMap &scanData,
|
2018-04-10 23:00:52 +04:00
|
|
|
std::vector<ScanInfo> &&files,
|
|
|
|
std::unique_ptr<ScanInfo> &&selfie);
|
2018-04-05 21:01:22 +04:00
|
|
|
PanelEditDocument(
|
|
|
|
QWidget *parent,
|
|
|
|
not_null<PanelController*> controller,
|
|
|
|
Scheme scheme,
|
|
|
|
const ValueMap &data);
|
2018-03-31 05:45:40 +04:00
|
|
|
|
2018-04-09 21:56:07 +04:00
|
|
|
bool hasUnsavedChanges() const;
|
|
|
|
|
2018-03-31 05:45:40 +04:00
|
|
|
protected:
|
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
|
|
|
|
|
|
|
private:
|
2018-04-09 21:56:07 +04:00
|
|
|
struct Result;
|
2018-04-04 23:26:40 +04:00
|
|
|
void setupControls(
|
|
|
|
const ValueMap &data,
|
2018-04-05 21:01:22 +04:00
|
|
|
const ValueMap *scanData,
|
2018-04-10 23:00:52 +04:00
|
|
|
std::vector<ScanInfo> &&files,
|
|
|
|
std::unique_ptr<ScanInfo> &&selfie);
|
2018-04-03 22:24:31 +04:00
|
|
|
not_null<Ui::RpWidget*> setupContent(
|
|
|
|
const ValueMap &data,
|
2018-04-05 21:01:22 +04:00
|
|
|
const ValueMap *scanData,
|
2018-04-10 23:00:52 +04:00
|
|
|
std::vector<ScanInfo> &&files,
|
|
|
|
std::unique_ptr<ScanInfo> &&selfie);
|
2018-03-31 05:45:40 +04:00
|
|
|
void updateControlsGeometry();
|
|
|
|
|
2018-04-09 21:56:07 +04:00
|
|
|
Result collect() const;
|
2018-04-13 14:10:09 +04:00
|
|
|
bool validate();
|
2018-03-31 05:45:40 +04:00
|
|
|
void save();
|
|
|
|
|
|
|
|
not_null<PanelController*> _controller;
|
2018-04-05 21:01:22 +04:00
|
|
|
Scheme _scheme;
|
2018-03-31 05:45:40 +04:00
|
|
|
|
|
|
|
object_ptr<Ui::ScrollArea> _scroll;
|
|
|
|
object_ptr<Ui::FadeShadow> _topShadow;
|
|
|
|
object_ptr<Ui::PlainShadow> _bottomShadow;
|
|
|
|
|
2018-04-04 23:26:40 +04:00
|
|
|
QPointer<EditScans> _editScans;
|
2018-04-06 22:47:29 +04:00
|
|
|
std::map<int, QPointer<PanelDetailsRow>> _details;
|
2018-03-31 05:45:40 +04:00
|
|
|
|
|
|
|
object_ptr<Ui::RoundButton> _done;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-04-10 11:51:19 +04:00
|
|
|
object_ptr<BoxContent> RequestIdentityType(
|
|
|
|
base::lambda<void(int index)> submit,
|
|
|
|
std::vector<QString> labels);
|
|
|
|
object_ptr<BoxContent> RequestAddressType(
|
|
|
|
base::lambda<void(int index)> submit,
|
|
|
|
std::vector<QString> labels);
|
|
|
|
|
2018-03-31 05:45:40 +04:00
|
|
|
} // namespace Passport
|