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
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
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
Close stale issues and PRs / stale (push) Successful in 13s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
This commit is contained in:
61
Telegram/SourceFiles/intro/intro_code_input.h
Normal file
61
Telegram/SourceFiles/intro/intro_code_input.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
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"
|
||||
|
||||
namespace Ui {
|
||||
|
||||
class CodeDigit;
|
||||
class PopupMenu;
|
||||
|
||||
class CodeInput final : public Ui::RpWidget {
|
||||
public:
|
||||
CodeInput(QWidget *parent);
|
||||
|
||||
QAccessible::Role accessibilityRole() override {
|
||||
return QAccessible::EditableText;
|
||||
}
|
||||
QString accessibilityName() override;
|
||||
QString accessibilityValue() const override;
|
||||
|
||||
void setDigitsCountMax(int digitsCount);
|
||||
|
||||
void setCode(QString code);
|
||||
|
||||
void requestCode();
|
||||
[[nodiscard]] rpl::producer<QString> codeCollected() const;
|
||||
|
||||
void clear();
|
||||
void showError();
|
||||
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *e) override;
|
||||
void focusOutEvent(QFocusEvent *e) override;
|
||||
void paintEvent(QPaintEvent *e) override;
|
||||
void keyPressEvent(QKeyEvent *e) override;
|
||||
void contextMenuEvent(QContextMenuEvent *e) override;
|
||||
|
||||
private:
|
||||
[[nodiscard]] QString collectDigits() const;
|
||||
|
||||
void insertCodeAndSubmit(const QString &code);
|
||||
void unfocusAll(int except);
|
||||
void findEmptyAndPerform(const Fn<void(int)> &callback);
|
||||
|
||||
int _digitsCountMax = 0;
|
||||
std::vector<not_null<CodeDigit*>> _digits;
|
||||
int _currentIndex = 0;
|
||||
|
||||
base::unique_qptr<Ui::PopupMenu> _menu;
|
||||
|
||||
rpl::event_stream<QString> _codeCollected;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Ui
|
||||
Reference in New Issue
Block a user