mirror of
https://git.sr.ht/~thestr4ng3r/chiaki
synced 2025-08-21 14:03:11 -07:00
Support multiple PIN Entries
This commit is contained in:
parent
31fb11fd43
commit
d668423775
10 changed files with 81 additions and 13 deletions
|
@ -36,7 +36,7 @@ class LoginPINDialog : public QDialog
|
|||
void UpdateButtons();
|
||||
|
||||
public:
|
||||
explicit LoginPINDialog(QWidget *parent = nullptr);
|
||||
explicit LoginPINDialog(bool incorrect, QWidget *parent = nullptr);
|
||||
|
||||
QString GetPIN() { return pin; }
|
||||
};
|
||||
|
|
|
@ -105,7 +105,7 @@ class StreamSession : public QObject
|
|||
signals:
|
||||
void CurrentImageUpdated();
|
||||
void SessionQuit(ChiakiQuitReason reason, const QString &reason_str);
|
||||
void LoginPINRequested();
|
||||
void LoginPINRequested(bool incorrect);
|
||||
|
||||
private slots:
|
||||
void UpdateGamepads();
|
||||
|
|
|
@ -47,7 +47,7 @@ class StreamWindow: public QMainWindow
|
|||
|
||||
private slots:
|
||||
void SessionQuit(ChiakiQuitReason reason, const QString &reason_str);
|
||||
void LoginPINRequested();
|
||||
void LoginPINRequested(bool incorrect);
|
||||
void ToggleFullscreen();
|
||||
};
|
||||
|
||||
|
|
|
@ -23,16 +23,22 @@
|
|||
#include <QPushButton>
|
||||
#include <QRegularExpression>
|
||||
#include <QRegularExpressionValidator>
|
||||
#include <QLabel>
|
||||
|
||||
#define PIN_LENGTH 4
|
||||
|
||||
static const QRegularExpression pin_re(QString("[0-9]").repeated(PIN_LENGTH));
|
||||
|
||||
LoginPINDialog::LoginPINDialog(QWidget *parent) : QDialog(parent)
|
||||
LoginPINDialog::LoginPINDialog(bool incorrect, QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
setWindowTitle(tr("Console Login PIN"));
|
||||
|
||||
auto layout = new QVBoxLayout(this);
|
||||
setLayout(layout);
|
||||
|
||||
if(incorrect)
|
||||
layout->addWidget(new QLabel(tr("Entered PIN was incorrect!"), this));
|
||||
|
||||
pin_edit = new QLineEdit(this);
|
||||
pin_edit->setPlaceholderText(tr("Login PIN"));
|
||||
pin_edit->setValidator(new QRegularExpressionValidator(pin_re, pin_edit));
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <QAudioOutput>
|
||||
|
||||
#include <cstring>
|
||||
#include <chiaki/session.h>
|
||||
|
||||
StreamSessionConnectInfo::StreamSessionConnectInfo()
|
||||
{
|
||||
|
@ -332,7 +333,7 @@ void StreamSession::Event(ChiakiEvent *event)
|
|||
emit SessionQuit(event->quit.reason, event->quit.reason_str ? QString::fromUtf8(event->quit.reason_str) : QString());
|
||||
break;
|
||||
case CHIAKI_EVENT_LOGIN_PIN_REQUEST:
|
||||
emit LoginPINRequested();
|
||||
emit LoginPINRequested(event->login_pin_request.pin_incorrect);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,9 +104,9 @@ void StreamWindow::SessionQuit(ChiakiQuitReason reason, const QString &reason_st
|
|||
close();
|
||||
}
|
||||
|
||||
void StreamWindow::LoginPINRequested()
|
||||
void StreamWindow::LoginPINRequested(bool incorrect)
|
||||
{
|
||||
auto dialog = new LoginPINDialog(this);
|
||||
auto dialog = new LoginPINDialog(incorrect, this);
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
connect(dialog, &QDialog::finished, this, [this, dialog](int result) {
|
||||
grabKeyboard();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue