mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-07-29 00:39:55 +00:00
Add phone format and validation in payments.
This commit is contained in:
@@ -30,8 +30,7 @@ constexpr auto kMaxPhoneCodeLength = 4;
|
||||
CountryCodeInput::CountryCodeInput(
|
||||
QWidget *parent,
|
||||
const style::InputField &st)
|
||||
: MaskedInputField(parent, st)
|
||||
, _nosignal(false) {
|
||||
: MaskedInputField(parent, st) {
|
||||
}
|
||||
|
||||
void CountryCodeInput::startErasing(QKeyEvent *e) {
|
||||
@@ -91,14 +90,15 @@ void CountryCodeInput::correctValue(
|
||||
setCorrectedText(now, nowCursor, newText, newPos);
|
||||
|
||||
if (!_nosignal && was != newText) {
|
||||
codeChanged(newText.mid(1));
|
||||
_codeChanged.fire(newText.mid(1));
|
||||
}
|
||||
if (!addToNumber.isEmpty()) {
|
||||
addedToNumber(addToNumber);
|
||||
_addedToNumber.fire_copy(addToNumber);
|
||||
}
|
||||
}
|
||||
|
||||
PhonePartInput::PhonePartInput(QWidget *parent, const style::InputField &st) : MaskedInputField(parent, st/*, tr::lng_phone_ph(tr::now)*/) {
|
||||
PhonePartInput::PhonePartInput(QWidget *parent, const style::InputField &st)
|
||||
: MaskedInputField(parent, st/*, tr::lng_phone_ph(tr::now)*/) {
|
||||
}
|
||||
|
||||
void PhonePartInput::paintAdditionalPlaceholder(Painter &p) {
|
||||
@@ -119,8 +119,8 @@ void PhonePartInput::paintAdditionalPlaceholder(Painter &p) {
|
||||
}
|
||||
|
||||
void PhonePartInput::keyPressEvent(QKeyEvent *e) {
|
||||
if (e->key() == Qt::Key_Backspace && getLastText().isEmpty()) {
|
||||
voidBackspace(e);
|
||||
if (e->key() == Qt::Key_Backspace && cursorPosition() == 0) {
|
||||
_frontBackspaceEvent.fire_copy(e);
|
||||
} else {
|
||||
MaskedInputField::keyPressEvent(e);
|
||||
}
|
||||
@@ -204,7 +204,7 @@ void PhonePartInput::addedToNumber(const QString &added) {
|
||||
startPlaceholderAnimation();
|
||||
}
|
||||
|
||||
void PhonePartInput::onChooseCode(const QString &code) {
|
||||
void PhonePartInput::chooseCode(const QString &code) {
|
||||
_pattern = phoneNumberParse(code);
|
||||
if (!_pattern.isEmpty() && _pattern.at(0) == code.size()) {
|
||||
_pattern.pop_front();
|
||||
|
||||
Reference in New Issue
Block a user