Keep key file text when provided on command line

* Fixes #10552
This commit is contained in:
Jonathan White 2024-04-29 17:15:25 -04:00
parent 92b30ae7ec
commit 83623c896f
2 changed files with 5 additions and 17 deletions

View File

@ -87,19 +87,15 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase())); connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(openDatabase()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject())); connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
connect(m_ui->addKeyFileLinkLabel, &QLabel::linkActivated, this, [&](const QString&) { connect(m_ui->addKeyFileLinkLabel, &QLabel::linkActivated, this, &DatabaseOpenWidget::browseKeyFile);
if (browseKeyFile()) {
toggleKeyFileComponent(true);
}
});
connect(m_ui->keyFileLineEdit, &PasswordWidget::textChanged, this, [&](const QString& text) { connect(m_ui->keyFileLineEdit, &PasswordWidget::textChanged, this, [&](const QString& text) {
if (text.isEmpty() && m_ui->keyFileLineEdit->isVisible()) { bool state = !text.isEmpty();
toggleKeyFileComponent(false); m_ui->addKeyFileLinkLabel->setVisible(!state);
} m_ui->selectKeyFileComponent->setVisible(state);
}); });
connect(m_ui->useHardwareKeyCheckBox, &QCheckBox::toggled, m_ui->hardwareKeyCombo, &QComboBox::setEnabled); connect(m_ui->useHardwareKeyCheckBox, &QCheckBox::toggled, m_ui->hardwareKeyCombo, &QComboBox::setEnabled);
toggleKeyFileComponent(false); m_ui->selectKeyFileComponent->setVisible(false);
toggleHardwareKeyComponent(false); toggleHardwareKeyComponent(false);
QSizePolicy sp = m_ui->hardwareKeyProgress->sizePolicy(); QSizePolicy sp = m_ui->hardwareKeyProgress->sizePolicy();
@ -140,12 +136,6 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
DatabaseOpenWidget::~DatabaseOpenWidget() = default; DatabaseOpenWidget::~DatabaseOpenWidget() = default;
void DatabaseOpenWidget::toggleKeyFileComponent(bool state)
{
m_ui->addKeyFileLinkLabel->setVisible(!state);
m_ui->selectKeyFileComponent->setVisible(state);
}
void DatabaseOpenWidget::toggleHardwareKeyComponent(bool state) void DatabaseOpenWidget::toggleHardwareKeyComponent(bool state)
{ {
m_ui->hardwareKeyProgress->setVisible(false); m_ui->hardwareKeyProgress->setVisible(false);
@ -241,7 +231,6 @@ void DatabaseOpenWidget::load(const QString& filename)
auto lastKeyFiles = config()->get(Config::LastKeyFiles).toHash(); auto lastKeyFiles = config()->get(Config::LastKeyFiles).toHash();
if (lastKeyFiles.contains(m_filename)) { if (lastKeyFiles.contains(m_filename)) {
m_ui->keyFileLineEdit->setText(lastKeyFiles[m_filename].toString()); m_ui->keyFileLineEdit->setText(lastKeyFiles[m_filename].toString());
toggleKeyFileComponent(true);
} }
} }

View File

@ -78,7 +78,6 @@ protected slots:
private slots: private slots:
bool browseKeyFile(); bool browseKeyFile();
void toggleKeyFileComponent(bool state);
void toggleHardwareKeyComponent(bool state); void toggleHardwareKeyComponent(bool state);
void pollHardwareKey(bool manualTrigger = false); void pollHardwareKey(bool manualTrigger = false);
void hardwareKeyResponse(bool found); void hardwareKeyResponse(bool found);