2019-09-16 11:14:06 +00: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/widgets/input_fields.h"
|
|
|
|
|
|
|
|
namespace Ui {
|
|
|
|
|
|
|
|
class CountryCodeInput : public MaskedInputField {
|
|
|
|
public:
|
|
|
|
CountryCodeInput(QWidget *parent, const style::InputField &st);
|
|
|
|
|
|
|
|
void startErasing(QKeyEvent *e);
|
|
|
|
|
2021-03-29 14:56:26 +00:00
|
|
|
[[nodiscard]] rpl::producer<QString> addedToNumber() const {
|
|
|
|
return _addedToNumber.events();
|
|
|
|
}
|
|
|
|
[[nodiscard]] rpl::producer<QString> codeChanged() const {
|
|
|
|
return _codeChanged.events();
|
|
|
|
}
|
|
|
|
|
|
|
|
void codeSelected(const QString &code);
|
2019-09-16 11:14:06 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void correctValue(
|
|
|
|
const QString &was,
|
|
|
|
int wasCursor,
|
|
|
|
QString &now,
|
|
|
|
int &nowCursor) override;
|
|
|
|
|
|
|
|
private:
|
2021-03-29 14:56:26 +00:00
|
|
|
bool _nosignal = false;
|
|
|
|
rpl::event_stream<QString> _addedToNumber;
|
|
|
|
rpl::event_stream<QString> _codeChanged;
|
2019-09-16 11:14:06 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class PhonePartInput : public MaskedInputField {
|
|
|
|
public:
|
2021-11-28 08:25:25 +00:00
|
|
|
using GroupsCallback = Fn<QVector<int>(const QString &)>;
|
|
|
|
|
|
|
|
PhonePartInput(
|
|
|
|
QWidget *parent,
|
|
|
|
const style::InputField &st,
|
|
|
|
GroupsCallback groupsCallback);
|
2019-09-16 11:14:06 +00:00
|
|
|
|
2021-03-29 14:56:26 +00:00
|
|
|
[[nodiscard]] auto frontBackspaceEvent() const
|
|
|
|
-> rpl::producer<not_null<QKeyEvent*>> {
|
|
|
|
return _frontBackspaceEvent.events();
|
|
|
|
}
|
2019-09-16 11:14:06 +00:00
|
|
|
|
2021-03-29 14:56:26 +00:00
|
|
|
void addedToNumber(const QString &added);
|
|
|
|
void chooseCode(const QString &code);
|
2019-09-16 11:14:06 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void keyPressEvent(QKeyEvent *e) override;
|
|
|
|
|
|
|
|
void correctValue(
|
|
|
|
const QString &was,
|
|
|
|
int wasCursor,
|
|
|
|
QString &now,
|
|
|
|
int &nowCursor) override;
|
|
|
|
void paintAdditionalPlaceholder(Painter &p) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QVector<int> _pattern;
|
|
|
|
QString _additionalPlaceholder;
|
2021-03-29 14:56:26 +00:00
|
|
|
rpl::event_stream<not_null<QKeyEvent*>> _frontBackspaceEvent;
|
2021-11-28 08:25:25 +00:00
|
|
|
GroupsCallback _groupsCallback;
|
2019-09-16 11:14:06 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class UsernameInput : public MaskedInputField {
|
|
|
|
public:
|
|
|
|
UsernameInput(
|
|
|
|
QWidget *parent,
|
|
|
|
const style::InputField &st,
|
|
|
|
rpl::producer<QString> placeholder,
|
|
|
|
const QString &val,
|
2020-06-17 09:36:25 +00:00
|
|
|
const QString &linkPlaceholder);
|
2019-09-16 11:14:06 +00:00
|
|
|
|
|
|
|
void setLinkPlaceholder(const QString &placeholder);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void correctValue(
|
|
|
|
const QString &was,
|
|
|
|
int wasCursor,
|
|
|
|
QString &now,
|
|
|
|
int &nowCursor) override;
|
|
|
|
void paintAdditionalPlaceholder(Painter &p) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString _linkPlaceholder;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class PhoneInput : public MaskedInputField {
|
|
|
|
public:
|
2021-11-28 08:25:25 +00:00
|
|
|
using GroupsCallback = Fn<QVector<int>(const QString &)>;
|
|
|
|
|
2019-09-16 11:14:06 +00:00
|
|
|
PhoneInput(
|
|
|
|
QWidget *parent,
|
|
|
|
const style::InputField &st,
|
|
|
|
rpl::producer<QString> placeholder,
|
|
|
|
const QString &defaultValue,
|
2021-11-28 08:25:25 +00:00
|
|
|
QString value,
|
|
|
|
GroupsCallback groupsCallback);
|
2019-09-16 11:14:06 +00:00
|
|
|
|
|
|
|
void clearText();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void focusInEvent(QFocusEvent *e) override;
|
|
|
|
|
|
|
|
void correctValue(
|
|
|
|
const QString &was,
|
|
|
|
int wasCursor,
|
|
|
|
QString &now,
|
|
|
|
int &nowCursor) override;
|
|
|
|
void paintAdditionalPlaceholder(Painter &p) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QString _defaultValue;
|
|
|
|
QVector<int> _pattern;
|
|
|
|
QString _additionalPlaceholder;
|
|
|
|
|
2021-11-28 08:25:25 +00:00
|
|
|
GroupsCallback _groupsCallback;
|
|
|
|
|
2019-09-16 11:14:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Ui
|