QtPass
2.0.0
Developer documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
otpcodewidget.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2
// SPDX-License-Identifier: GPL-3.0-or-later
8
#ifndef SRC_OTPCODEWIDGET_H_
9
#define SRC_OTPCODEWIDGET_H_
10
11
#include "
totp.h
"
12
13
#include <QWidget>
14
15
class
QLabel;
16
class
QProgressBar;
17
class
QPushButtonWithClipboard
;
18
34
class
OtpCodeWidget
:
public
QWidget {
35
Q_OBJECT
36
37
public
:
46
OtpCodeWidget
(
Totp::Settings
settings,
bool
withCopyButton,
bool
monospace,
47
QWidget *parent =
nullptr
);
48
56
void
refresh
(quint64 unixTime);
57
62
[[nodiscard]]
auto
code
()
const
-> QString;
63
68
[[nodiscard]]
auto
secondsRemaining
()
const
-> uint;
69
70
signals:
75
void
copyRequested
(
const
QString &text);
76
77
private
:
79
Totp::Settings
m_settings
;
82
QPushButtonWithClipboard
*
m_copyButton
{
nullptr
};
84
QLabel *
m_codeLabel
{
nullptr
};
86
QProgressBar *
m_progress
{
nullptr
};
88
QString
m_code
;
91
quint64
m_counter
{0};
93
uint
m_secondsRemaining
{0};
96
bool
m_hasCode
{
false
};
97
};
98
99
#endif
// SRC_OTPCODEWIDGET_H_
OtpCodeWidget::m_code
QString m_code
The code last rendered, ungrouped.
Definition
otpcodewidget.h:88
OtpCodeWidget::m_counter
quint64 m_counter
Time-step counter m_code was generated for; a tick only regenerates when the counter changes.
Definition
otpcodewidget.h:91
OtpCodeWidget::m_copyButton
QPushButtonWithClipboard * m_copyButton
Copy button, or nullptr when built without one; child widget whose text is kept equal to m_code.
Definition
otpcodewidget.h:82
OtpCodeWidget::refresh
void refresh(quint64 unixTime)
Recompute the code and countdown for an explicit point in time.
Definition
otpcodewidget.cpp:82
OtpCodeWidget::m_progress
QProgressBar * m_progress
Countdown bar from step down to 1 second; child widget.
Definition
otpcodewidget.h:86
OtpCodeWidget::OtpCodeWidget
OtpCodeWidget(Totp::Settings settings, bool withCopyButton, bool monospace, QWidget *parent=nullptr)
Build a live OTP code display and start its refresh timer.
Definition
otpcodewidget.cpp:32
OtpCodeWidget::m_codeLabel
QLabel * m_codeLabel
Shows the current code; child widget.
Definition
otpcodewidget.h:84
OtpCodeWidget::m_secondsRemaining
uint m_secondsRemaining
Seconds left on m_code as of the last refresh().
Definition
otpcodewidget.h:93
OtpCodeWidget::copyRequested
void copyRequested(const QString &text)
Emitted when the copy button is activated.
OtpCodeWidget::code
auto code() const -> QString
The current code, ungrouped, exactly as it is copied.
Definition
otpcodewidget.cpp:98
OtpCodeWidget::m_hasCode
bool m_hasCode
False until the first refresh(), which must generate a code regardless of m_counter.
Definition
otpcodewidget.h:96
OtpCodeWidget::secondsRemaining
auto secondsRemaining() const -> uint
Seconds left on the current code, as last rendered.
Definition
otpcodewidget.cpp:100
OtpCodeWidget::m_settings
Totp::Settings m_settings
Validated TOTP parameters for the entry; fixed at construction.
Definition
otpcodewidget.h:79
QPushButtonWithClipboard
QPushButton that stores a text payload and emits it when activated.
Definition
qpushbuttonwithclipboard.h:25
Totp::Settings
Validated TOTP parameters. Only Totp::parse() produces one.
Definition
totp.h:59
totp.h
RFC 6238 TOTP: otpauth URI parsing, code generation and canonical re-serialisation.
src
otpcodewidget.h
Generated by
1.18.0