tdesktop/Telegram/SourceFiles/passport/passport_panel_details_row.h

92 lines
1.9 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 "ui/rp_widget.h"
#include "ui/wrap/padding_wrap.h"
#include "ui/widgets/labels.h"
#include "boxes/abstract_box.h"
namespace Ui {
class InputField;
2018-04-10 11:26:21 +00:00
class FlatLabel;
template <typename Widget>
class SlideWrap;
} // namespace Ui
namespace Passport {
2018-04-10 11:26:21 +00:00
class PanelController;
enum class PanelDetailsType {
Text,
Country,
Date,
Gender,
};
class PanelLabel : public Ui::PaddingWrap<Ui::FlatLabel> {
public:
using PaddingWrap::PaddingWrap;
int naturalWidth() const override;
protected:
void resizeEvent(QResizeEvent *e) override;
private:
2018-04-12 10:20:54 +00:00
object_ptr<BoxContentDivider> _background
= object_ptr<BoxContentDivider>(this);
};
class PanelDetailsRow : public Ui::RpWidget {
public:
2018-04-10 11:26:21 +00:00
using Type = PanelDetailsType;
PanelDetailsRow(
QWidget *parent,
2018-04-10 11:26:21 +00:00
const QString &label);
static object_ptr<PanelDetailsRow> Create(
QWidget *parent,
Type type,
not_null<PanelController*> controller,
const QString &label,
2018-04-10 11:26:21 +00:00
const QString &value,
const QString &error);
2018-04-10 11:26:21 +00:00
virtual bool setFocusFast();
virtual rpl::producer<QString> value() const = 0;
virtual QString valueCurrent() const = 0;
void showError(const QString &error);
void hideError();
void finishAnimating();
protected:
int resizeGetHeight(int newWidth) override;
void paintEvent(QPaintEvent *e) override;
private:
2018-04-10 11:26:21 +00:00
virtual int resizeInner(int left, int top, int width) = 0;
virtual void showInnerError() = 0;
virtual void finishInnerAnimating() = 0;
void startErrorAnimation(bool shown);
QString _label;
2018-04-10 11:26:21 +00:00
object_ptr<Ui::SlideWrap<Ui::FlatLabel>> _error = { nullptr };
bool _errorShown = false;
bool _errorHideSubscription = false;
2018-04-10 11:26:21 +00:00
Animation _errorAnimation;
};
} // namespace Passport