Allow opening databases that have no password and keyfile.

Closes #391
This commit is contained in:
Felix Geyer 2016-01-31 16:17:24 +01:00
parent eb56bd8973
commit 7a017041bf
2 changed files with 1 additions and 16 deletions

View File

@ -49,10 +49,6 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
connect(m_ui->editPassword, SIGNAL(textChanged(QString)), SLOT(activatePassword()));
connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(activateKeyFile()));
connect(m_ui->checkPassword, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
connect(m_ui->checkKeyFile, SIGNAL(toggled(bool)), SLOT(setOkButtonEnabled()));
connect(m_ui->comboKeyFile, SIGNAL(editTextChanged(QString)), SLOT(setOkButtonEnabled()));
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
}
@ -75,6 +71,7 @@ void DatabaseOpenWidget::load(const QString& filename)
}
}
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
m_ui->editPassword->setFocus();
}
@ -99,9 +96,6 @@ void DatabaseOpenWidget::openDatabase()
{
KeePass2Reader reader;
CompositeKey masterKey = databaseKey();
if (masterKey.isEmpty()) {
return;
}
QFile file(m_filename);
if (!file.open(QIODevice::ReadOnly)) {
@ -172,14 +166,6 @@ void DatabaseOpenWidget::activateKeyFile()
m_ui->checkKeyFile->setChecked(true);
}
void DatabaseOpenWidget::setOkButtonEnabled()
{
bool enable = m_ui->checkPassword->isChecked()
|| (m_ui->checkKeyFile->isChecked() && !m_ui->comboKeyFile->currentText().isEmpty());
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enable);
}
void DatabaseOpenWidget::browseKeyFile()
{
QString filters = QString("%1 (*);;%2 (*.key)").arg(tr("All files"), tr("Key files"));

View File

@ -54,7 +54,6 @@ protected Q_SLOTS:
private Q_SLOTS:
void activatePassword();
void activateKeyFile();
void setOkButtonEnabled();
void browseKeyFile();
protected: