init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
144
Telegram/SourceFiles/ui/widgets/fields/special_fields.h
Normal file
144
Telegram/SourceFiles/ui/widgets/fields/special_fields.h
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
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/fields/masked_input_field.h"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
class CountryCodeInput : public MaskedInputField {
|
||||
public:
|
||||
CountryCodeInput(QWidget *parent, const style::InputField &st);
|
||||
|
||||
void startErasing(QKeyEvent *e);
|
||||
|
||||
[[nodiscard]] rpl::producer<QString> addedToNumber() const {
|
||||
return _addedToNumber.events();
|
||||
}
|
||||
[[nodiscard]] rpl::producer<QString> codeChanged() const {
|
||||
return _codeChanged.events();
|
||||
}
|
||||
[[nodiscard]] rpl::producer<> spacePressed() const {
|
||||
return _spacePressed.events();
|
||||
}
|
||||
|
||||
void codeSelected(const QString &code);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
void correctValue(
|
||||
const QString &was,
|
||||
int wasCursor,
|
||||
QString &now,
|
||||
int &nowCursor) override;
|
||||
|
||||
private:
|
||||
bool _nosignal = false;
|
||||
rpl::event_stream<QString> _addedToNumber;
|
||||
rpl::event_stream<QString> _codeChanged;
|
||||
rpl::event_stream<> _spacePressed;
|
||||
|
||||
};
|
||||
|
||||
class PhonePartInput : public MaskedInputField {
|
||||
public:
|
||||
using GroupsCallback = Fn<QVector<int>(const QString &)>;
|
||||
|
||||
PhonePartInput(
|
||||
QWidget *parent,
|
||||
const style::InputField &st,
|
||||
GroupsCallback groupsCallback);
|
||||
|
||||
[[nodiscard]] auto frontBackspaceEvent() const
|
||||
-> rpl::producer<not_null<QKeyEvent*>> {
|
||||
return _frontBackspaceEvent.events();
|
||||
}
|
||||
|
||||
void addedToNumber(const QString &added);
|
||||
void chooseCode(const QString &code);
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
|
||||
void correctValue(
|
||||
const QString &was,
|
||||
int wasCursor,
|
||||
QString &now,
|
||||
int &nowCursor) override;
|
||||
void paintAdditionalPlaceholder(QPainter &p) override;
|
||||
|
||||
private:
|
||||
void updatePattern(QVector<int> &&pattern);
|
||||
|
||||
QString _code;
|
||||
QString _lastDigits;
|
||||
QVector<int> _pattern;
|
||||
QString _additionalPlaceholder;
|
||||
rpl::event_stream<not_null<QKeyEvent*>> _frontBackspaceEvent;
|
||||
GroupsCallback _groupsCallback;
|
||||
|
||||
};
|
||||
|
||||
class UsernameInput : public MaskedInputField {
|
||||
public:
|
||||
UsernameInput(
|
||||
QWidget *parent,
|
||||
const style::InputField &st,
|
||||
rpl::producer<QString> placeholder,
|
||||
const QString &val,
|
||||
const QString &linkPlaceholder);
|
||||
|
||||
void setLinkPlaceholder(const QString &placeholder);
|
||||
|
||||
protected:
|
||||
void correctValue(
|
||||
const QString &was,
|
||||
int wasCursor,
|
||||
QString &now,
|
||||
int &nowCursor) override;
|
||||
void paintAdditionalPlaceholder(QPainter &p) override;
|
||||
|
||||
private:
|
||||
QString _linkPlaceholder;
|
||||
|
||||
};
|
||||
|
||||
class PhoneInput : public MaskedInputField {
|
||||
public:
|
||||
using GroupsCallback = Fn<QVector<int>(const QString &)>;
|
||||
|
||||
PhoneInput(
|
||||
QWidget *parent,
|
||||
const style::InputField &st,
|
||||
rpl::producer<QString> placeholder,
|
||||
const QString &defaultValue,
|
||||
QString value,
|
||||
GroupsCallback groupsCallback);
|
||||
|
||||
void clearText();
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *e) override;
|
||||
|
||||
void correctValue(
|
||||
const QString &was,
|
||||
int wasCursor,
|
||||
QString &now,
|
||||
int &nowCursor) override;
|
||||
void paintAdditionalPlaceholder(QPainter &p) override;
|
||||
|
||||
private:
|
||||
QString _defaultValue;
|
||||
QVector<int> _pattern;
|
||||
QString _additionalPlaceholder;
|
||||
|
||||
GroupsCallback _groupsCallback;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user