Modernise Account C++ code a bit

master
Johan Ouwerkerk 2019-09-25 14:15:04 +02:00
parent 4cff5519ed
commit 8b03fe5123
2 changed files with 11 additions and 11 deletions

View File

@ -42,7 +42,7 @@ Account::Account(const QUuid &id, const std::function<qint64(void)>& clock, QObj
m_clock(clock) m_clock(clock)
{ {
m_totpTimer.setSingleShot(true); m_totpTimer.setSingleShot(true);
connect(&m_totpTimer, SIGNAL(timeout()), SLOT(generate())); connect(&m_totpTimer, &QTimer::timeout, this, &Account::generate);
} }
QUuid Account::id() const QUuid Account::id() const
@ -59,7 +59,7 @@ void Account::setName(const QString &name)
{ {
if (m_name != name) { if (m_name != name) {
m_name = name; m_name = name;
emit nameChanged(); Q_EMIT nameChanged();
} }
} }
@ -73,7 +73,7 @@ void Account::setType(Account::Type type)
if (m_type != type) { if (m_type != type) {
m_type = type; m_type = type;
// qDebug() << "setting type" << type; // qDebug() << "setting type" << type;
emit typeChanged(); Q_EMIT typeChanged();
generate(); generate();
} }
} }
@ -87,7 +87,7 @@ void Account::setSecret(const QString &secret)
{ {
if (m_secret != secret) { if (m_secret != secret) {
m_secret = secret; m_secret = secret;
emit secretChanged(); Q_EMIT secretChanged();
generate(); generate();
} }
} }
@ -101,7 +101,7 @@ void Account::setCounter(quint64 counter)
{ {
if (m_counter != counter) { if (m_counter != counter) {
m_counter = counter; m_counter = counter;
emit counterChanged(); Q_EMIT counterChanged();
generate(); generate();
} }
} }
@ -115,7 +115,7 @@ void Account::setTimeStep(int timeStep)
{ {
if (m_timeStep != timeStep) { if (m_timeStep != timeStep) {
m_timeStep = timeStep; m_timeStep = timeStep;
emit timeStepChanged(); Q_EMIT timeStepChanged();
generate(); generate();
} }
} }
@ -129,7 +129,7 @@ void Account::setPinLength(int pinLength)
{ {
if (m_pinLength != pinLength) { if (m_pinLength != pinLength) {
m_pinLength = pinLength; m_pinLength = pinLength;
emit pinLengthChanged(); Q_EMIT pinLengthChanged();
generate(); generate();
} }
} }
@ -154,7 +154,7 @@ void Account::next()
{ {
m_counter++; m_counter++;
// qDebug() << "emitting changed"; // qDebug() << "emitting changed";
emit counterChanged(); Q_EMIT counterChanged();
generate(); generate();
} }
@ -193,7 +193,7 @@ void Account::generate()
m_otp = QLatin1String(code); m_otp = QLatin1String(code);
// qDebug() << "Generating secret" << m_name << m_secret << m_counter << m_pinLength << m_otp << m_timeStep; // qDebug() << "Generating secret" << m_name << m_secret << m_counter << m_pinLength << m_otp << m_timeStep;
emit otpChanged(); Q_EMIT otpChanged();
if (m_type == TypeTOTP) { if (m_type == TypeTOTP) {

View File

@ -70,7 +70,7 @@ public:
Q_INVOKABLE qint64 msecsToNext() const; Q_INVOKABLE qint64 msecsToNext() const;
signals: Q_SIGNALS:
void nameChanged(); void nameChanged();
void typeChanged(); void typeChanged();
void secretChanged(); void secretChanged();
@ -79,7 +79,7 @@ signals:
void pinLengthChanged(); void pinLengthChanged();
void otpChanged(); void otpChanged();
public slots: public Q_SLOTS:
void generate(); void generate();
void next(); void next();