feat: allow QML UI to reset a model::AccountInput object
Being able to reset an account input model to the default state allows for QML UI to safely reuse an account input. This lets it delegate populating to other code and then finally forward it to other QML code when control returns to the UI. Issues: #7, #14master
parent
cb9032d1c3
commit
d33d2c777d
|
@ -36,6 +36,21 @@ namespace model
|
|||
{
|
||||
}
|
||||
|
||||
void AccountInput::reset(void)
|
||||
{
|
||||
setType(TokenType::Totp);
|
||||
setName(QString());
|
||||
setIssuer(QString());
|
||||
setSecret(QString());
|
||||
setTokenLength(6U);
|
||||
setTimeStep(30U);
|
||||
setAlgorithm(TOTPAlgorithm::Sha1);
|
||||
setEpoch(DEFAULT_EPOCH);
|
||||
setChecksum(false);
|
||||
setCounter(0ULL);
|
||||
setDynamicTruncation();
|
||||
}
|
||||
|
||||
void AccountInput::createNewAccount(accounts::AccountStorage *storage) const
|
||||
{
|
||||
if (!storage) {
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace model
|
|||
Q_ENUM(TokenType)
|
||||
AccountInput(QObject *parent = nullptr);
|
||||
void createNewAccount(accounts::AccountStorage *storage) const;
|
||||
Q_INVOKABLE void reset(void);
|
||||
public:
|
||||
TokenType type(void) const;
|
||||
void setType(model::AccountInput::TokenType type);
|
||||
|
|
Loading…
Reference in New Issue