mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-26 15:59:50 -05:00
Implement create key file in ChangeMasterKeyWidget
This commit is contained in:
parent
01706483fb
commit
5217199d0a
@ -22,6 +22,7 @@
|
||||
|
||||
#include "keys/FileKey.h"
|
||||
#include "keys/PasswordKey.h"
|
||||
#include "gui/FileDialog.h"
|
||||
|
||||
ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
|
||||
: DialogyWidget(parent)
|
||||
@ -32,6 +33,7 @@ ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
|
||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(generateKey()));
|
||||
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
|
||||
connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePassword(bool)));
|
||||
connect(m_ui->createKeyFileButton, SIGNAL(clicked()), SLOT(createKeyFile()));
|
||||
}
|
||||
|
||||
ChangeMasterKeyWidget::~ChangeMasterKeyWidget()
|
||||
@ -44,6 +46,29 @@ void ChangeMasterKeyWidget::togglePassword(bool checked)
|
||||
m_ui->repeatPasswordEdit->setEchoMode(checked ? QLineEdit::Password : QLineEdit::Normal);
|
||||
}
|
||||
|
||||
void ChangeMasterKeyWidget::createKeyFile()
|
||||
{
|
||||
QString fileName = fileDialog()->getSaveFileName(this, tr("CreateKeyFile..."), QString(),
|
||||
tr("Key Files") + " (*.key);;" + tr("All files (*)"));
|
||||
|
||||
if (!fileName.isEmpty()) {
|
||||
QString errorMsg;
|
||||
bool created = FileKey::create(fileName, &errorMsg);
|
||||
if(!created)
|
||||
{
|
||||
QMessageBox::warning(this, tr("Error"), tr("Unable to create Key File : ") + errorMsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(m_ui->keyFileGroup->isEnabled())
|
||||
{
|
||||
m_ui->keyFileCombo->setEditText(fileName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ChangeMasterKeyWidget::clearForms()
|
||||
{
|
||||
m_key.clear();
|
||||
|
@ -46,6 +46,7 @@ private Q_SLOTS:
|
||||
void generateKey();
|
||||
void reject();
|
||||
void togglePassword(bool checked);
|
||||
void createKeyFile();
|
||||
|
||||
private:
|
||||
const QScopedPointer<Ui::ChangeMasterKeyWidget> m_ui;
|
||||
|
Loading…
Reference in New Issue
Block a user