mirror of https://github.com/Nheko-Reborn/nheko
parent
488cc5e73b
commit
2088053d26
@ -1,13 +0,0 @@ |
||||
import QtQuick 2.3 |
||||
import QtQuick.Controls 1.2 |
||||
|
||||
Item { |
||||
DeviceVerification { |
||||
id: deviceVerification |
||||
} |
||||
|
||||
Button { |
||||
text: "Test DeviceVerification" |
||||
onClicked: deviceVerification.show() |
||||
} |
||||
} |
@ -0,0 +1,36 @@ |
||||
#include "DeviceVerificationFlow.h" |
||||
|
||||
#include <QTimer> |
||||
|
||||
static constexpr int TIMEOUT = 2 * 60 * 1000; // 2 minutes
|
||||
|
||||
DeviceVerificationFlow::DeviceVerificationFlow(QObject *) |
||||
{ |
||||
timeout = new QTimer(this); |
||||
timeout->setSingleShot(true); |
||||
connect(timeout, &QTimer::timeout, this, [this]() { |
||||
emit timedout(); |
||||
this->deleteLater(); |
||||
}); |
||||
timeout->start(TIMEOUT); |
||||
} |
||||
|
||||
//! accepts a verification and starts the verification flow
|
||||
void |
||||
DeviceVerificationFlow::acceptVerificationRequest() |
||||
{ |
||||
emit verificationRequestAccepted(rand() % 2 ? Emoji : Decimal); |
||||
} |
||||
//! cancels a verification flow
|
||||
void |
||||
DeviceVerificationFlow::cancelVerification() |
||||
{ |
||||
this->deleteLater(); |
||||
} |
||||
//! Completes the verification flow
|
||||
void |
||||
DeviceVerificationFlow::acceptDevice() |
||||
{ |
||||
emit deviceVerified(); |
||||
this->deleteLater(); |
||||
} |
@ -0,0 +1,38 @@ |
||||
#pragma once |
||||
|
||||
#include <QObject> |
||||
|
||||
class QTimer; |
||||
|
||||
class DeviceVerificationFlow : public QObject |
||||
{ |
||||
Q_OBJECT |
||||
// Q_CLASSINFO("RegisterEnumClassesUnscoped", "false")
|
||||
|
||||
public: |
||||
enum Method |
||||
{ |
||||
Decimal, |
||||
Emoji |
||||
}; |
||||
Q_ENUM(Method) |
||||
|
||||
DeviceVerificationFlow(QObject *parent = nullptr); |
||||
|
||||
public slots: |
||||
//! accepts a verification and starts the verification flow
|
||||
void acceptVerificationRequest(); |
||||
//! cancels a verification flow
|
||||
void cancelVerification(); |
||||
//! Completes the verification flow
|
||||
void acceptDevice(); |
||||
|
||||
signals: |
||||
void verificationRequestAccepted(Method method); |
||||
void deviceVerified(); |
||||
void timedout(); |
||||
void verificationCanceled(); |
||||
|
||||
private: |
||||
QTimer *timeout = nullptr; |
||||
}; |
Loading…
Reference in new issue