/* 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 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 files; QString errorMissing; }; class EditScans : public Ui::RpWidget { public: EditScans( QWidget *parent, not_null controller, const QString &header, const QString &error, ScanListData &&scans, std::optional &&translations); EditScans( QWidget *parent, not_null controller, const QString &header, const QString &error, std::map &&specialFiles, std::optional &&translations); std::optional validateGetErrorTop(); void scanFieldsChanged(bool changed); static void ChooseScan( QPointer parent, FileType type, Fn doneCallback, Fn errorCallback); ~EditScans(); private: struct SpecialScan; struct List { List(not_null controller, ScanListData &&data); List( not_null controller, std::optional &&data = std::nullopt); bool uploadedSomeMore() const; bool uploadMoreRequired() const; Ui::SlideWrap *nonDeletedErrorRow() const; rpl::producer uploadButtonText() const; void toggleError(bool shown); void hideError(); void errorAnimationCallback(); void updateScan(ScanInfo &&info, int width); void pushScan(const ScanInfo &info); not_null controller; std::vector files; std::optional initialCount; QString errorMissing; QPointer> divider; QPointer> header; QPointer> uploadMoreError; QPointer wrap; std::vector>> rows; QPointer upload; rpl::event_stream> 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 container, FileType type, const QString &header); void setupSpecialScans( const QString &header, std::map &&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> createScan( not_null 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 _controller; QString _error; object_ptr _content; QPointer> _commonError; bool _scanFieldsChanged = false; bool _specialScanChanged = false; List _scansList; std::map _specialScans; List _translationsList; }; } // namespace Passport