From d3ed14ebb7ffe94debe29fb64659e3e0168a08b2 Mon Sep 17 00:00:00 2001 From: Weslly Date: Wed, 3 May 2017 21:26:08 -0300 Subject: [PATCH] Display TOTP code split in halfs --- src/gui/TotpDialog.cpp | 7 +++++-- tests/gui/TestGui.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/TotpDialog.cpp b/src/gui/TotpDialog.cpp index 521ddbafe..058210870 100644 --- a/src/gui/TotpDialog.cpp +++ b/src/gui/TotpDialog.cpp @@ -67,7 +67,7 @@ void TotpDialog::copyToClipboard() void TotpDialog::updateProgressBar() { if (uCounter < 100) { - m_ui->progressBar->setValue(100 - uCounter); + m_ui->progressBar->setValue(static_cast(100 - uCounter)); m_ui->progressBar->update(); uCounter++; } else { @@ -85,7 +85,10 @@ void TotpDialog::updateSeconds() void TotpDialog::updateTotp() { - m_ui->totpLabel->setText(m_entry->totp()); + QString totpCode = m_entry->totp(); + QString firstHalf = totpCode.left(totpCode.size()/2); + QString secondHalf = totpCode.right(totpCode.size()/2); + m_ui->totpLabel->setText(firstHalf + " " + secondHalf); } double TotpDialog::resetCounter() diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index 5a4142660..b1cc02462 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -489,7 +489,7 @@ void TestGui::testTotp() TotpDialog* totpDialog = m_dbWidget->findChild("TotpDialog"); QLabel* totpLabel = totpDialog->findChild("totpLabel"); - QCOMPARE(totpLabel->text(), entry->totp()); + QCOMPARE(totpLabel->text().replace(" ", ""), entry->totp()); } void TestGui::testSearch()