-
Notifications
You must be signed in to change notification settings - Fork 5k
/
passport_panel_edit_scans.h
152 lines (127 loc) · 3.87 KB
/
passport_panel_edit_scans.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*
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"
#include "ui/effects/animations.h"
#include "base/object_ptr.h"
namespace Ui {
class BoxContentDivider;
class VerticalLayout;
class SettingsButton;
class FlatLabel;
template <typename Widget>
class SlideWrap;
} // namespace Ui
namespace Passport {
enum class FileType;
class PanelController;
class ScanButton;
struct ScanInfo;
enum class ReadScanError {
FileTooLarge,
CantReadImage,
BadImageSize,
Unknown,
};
struct ScanListData {
std::vector<ScanInfo> files;
QString errorMissing;
};
class EditScans : public Ui::RpWidget {
public:
EditScans(
QWidget *parent,
not_null<PanelController*> controller,
const QString &header,
const QString &error,
ScanListData &&scans,
std::optional<ScanListData> &&translations);
EditScans(
QWidget *parent,
not_null<PanelController*> controller,
const QString &header,
const QString &error,
std::map<FileType, ScanInfo> &&specialFiles,
std::optional<ScanListData> &&translations);
std::optional<int> validateGetErrorTop();
void scanFieldsChanged(bool changed);
static void ChooseScan(
QPointer<QWidget> parent,
FileType type,
Fn<void(QByteArray&&)> doneCallback,
Fn<void(ReadScanError)> errorCallback);
~EditScans();
private:
struct SpecialScan;
struct List {
List(not_null<PanelController*> controller, ScanListData &&data);
List(
not_null<PanelController*> controller,
std::optional<ScanListData> &&data = std::nullopt);
bool uploadedSomeMore() const;
bool uploadMoreRequired() const;
Ui::SlideWrap<ScanButton> *nonDeletedErrorRow() const;
rpl::producer<QString> uploadButtonText() const;
void toggleError(bool shown);
void hideError();
void errorAnimationCallback();
void updateScan(ScanInfo &&info, int width);
void pushScan(const ScanInfo &info);
not_null<PanelController*> controller;
std::vector<ScanInfo> files;
std::optional<int> initialCount;
QString errorMissing;
QPointer<Ui::SlideWrap<Ui::BoxContentDivider>> divider;
QPointer<Ui::SlideWrap<Ui::FlatLabel>> header;
QPointer<Ui::SlideWrap<Ui::FlatLabel>> uploadMoreError;
QPointer<Ui::VerticalLayout> wrap;
std::vector<base::unique_qptr<Ui::SlideWrap<ScanButton>>> rows;
QPointer<Ui::SettingsButton> upload;
rpl::event_stream<rpl::producer<QString>> uploadTexts;
bool errorShown = false;
Ui::Animations::Simple errorAnimation;
};
List &list(FileType type);
const List &list(FileType type) const;
void setupScans(const QString &header);
void setupList(
not_null<Ui::VerticalLayout*> container,
FileType type,
const QString &header);
void setupSpecialScans(
const QString &header,
std::map<FileType, ScanInfo> &&files);
void init();
void chooseScan(FileType type);
void updateScan(ScanInfo &&info);
void updateSpecialScan(ScanInfo &&info);
void createSpecialScanRow(
SpecialScan &scan,
const ScanInfo &info,
bool requiresBothSides);
base::unique_qptr<Ui::SlideWrap<ScanButton>> createScan(
not_null<Ui::VerticalLayout*> parent,
const ScanInfo &info,
const QString &name);
SpecialScan &findSpecialScan(FileType type);
void updateErrorLabels();
bool somethingChanged() const;
void toggleSpecialScanError(FileType type, bool shown);
void hideSpecialScanError(FileType type);
void specialScanErrorAnimationCallback(FileType type);
void specialScanChanged(FileType type, bool changed);
not_null<PanelController*> _controller;
QString _error;
object_ptr<Ui::VerticalLayout> _content;
QPointer<Ui::SlideWrap<Ui::FlatLabel>> _commonError;
bool _scanFieldsChanged = false;
bool _specialScanChanged = false;
List _scansList;
std::map<FileType, SpecialScan> _specialScans;
List _translationsList;
};
} // namespace Passport