17#include <QProgressBar>
24constexpr int kRefreshIntervalMs = 1000;
26constexpr int kProgressHeight = 18;
28constexpr int kProgressWidth = 52;
33 bool monospace, QWidget *parent)
34 : QWidget(parent),
m_settings(std::move(settings)) {
36 const QString buttonStyle =
37 "QPushButton { border-style: none; background: transparent; padding: 0; "
38 "margin: 0; icon-size: 16px; color: inherit; }";
40 auto *layout =
new QHBoxLayout(
this);
41 layout->setContentsMargins(0, 0, 0, 0);
42 layout->setSpacing(4);
53 m_codeLabel->setObjectName(QStringLiteral(
"OTP code"));
54 m_codeLabel->setTextInteractionFlags(Qt::TextSelectableByMouse);
56 m_codeLabel->setStyleSheet(
"QLabel { font-family: monospace; }");
62 m_progress->setObjectName(QStringLiteral(
"otpCountdown"));
68 m_progress->setToolTip(tr(
"Seconds until the OTP code changes"));
73 auto *timer =
new QTimer(
this);
74 timer->setInterval(kRefreshIntervalMs);
75 connect(timer, &QTimer::timeout,
this,
static auto counter(const Settings &settings, quint64 unixTime) -> quint64
Time-step counter for a point in time.
static auto currentUnixTime() -> quint64
Current wall-clock time.
static auto generate(const Settings &settings, quint64 unixTime) -> QString
Generate the code for a given point in time.
static auto secondsRemaining(const Settings &settings, quint64 unixTime) -> uint
Seconds until the code for unixTime expires.
Validated TOTP parameters. Only Totp::parse() produces one.
uint step
Period in seconds, 1..MAX_STEP.