mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 08:49:42 -05:00
Add redetect button to ChangeMasterKeyWidget and only poll for Yubikeys when the challenge response group is enabled
This commit is contained in:
parent
eb23dda99b
commit
c7defdc06f
@ -44,9 +44,11 @@ ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
|
|||||||
connect(m_ui->createKeyFileButton, SIGNAL(clicked()), SLOT(createKeyFile()));
|
connect(m_ui->createKeyFileButton, SIGNAL(clicked()), SLOT(createKeyFile()));
|
||||||
connect(m_ui->browseKeyFileButton, SIGNAL(clicked()), SLOT(browseKeyFile()));
|
connect(m_ui->browseKeyFileButton, SIGNAL(clicked()), SLOT(browseKeyFile()));
|
||||||
|
|
||||||
connect(YubiKey::instance(), SIGNAL(detected(int,bool)),
|
connect(m_ui->challengeResponseGroup, SIGNAL(clicked(bool)), SLOT(challengeResponseGroupToggled(bool)));
|
||||||
SLOT(ykDetected(int,bool)),
|
connect(m_ui->buttonRedetectYubikey, SIGNAL(clicked()), SLOT(pollYubikey()));
|
||||||
Qt::QueuedConnection);
|
|
||||||
|
connect(YubiKey::instance(), SIGNAL(detected(int,bool)), SLOT(yubikeyDetected(int,bool)), Qt::QueuedConnection);
|
||||||
|
connect(YubiKey::instance(), SIGNAL(notFound()), SLOT(noYubikeyFound()), Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChangeMasterKeyWidget::~ChangeMasterKeyWidget()
|
ChangeMasterKeyWidget::~ChangeMasterKeyWidget()
|
||||||
@ -89,14 +91,9 @@ void ChangeMasterKeyWidget::clearForms()
|
|||||||
m_ui->repeatPasswordEdit->setText("");
|
m_ui->repeatPasswordEdit->setText("");
|
||||||
m_ui->keyFileGroup->setChecked(false);
|
m_ui->keyFileGroup->setChecked(false);
|
||||||
m_ui->togglePasswordButton->setChecked(false);
|
m_ui->togglePasswordButton->setChecked(false);
|
||||||
// TODO: clear m_ui->keyFileCombo
|
|
||||||
|
|
||||||
m_ui->challengeResponseGroup->setChecked(false);
|
m_ui->challengeResponseGroup->setChecked(false);
|
||||||
m_ui->challengeResponseCombo->clear();
|
m_ui->comboChallengeResponse->clear();
|
||||||
|
|
||||||
/* YubiKey init is slow, detect asynchronously to not block the UI */
|
|
||||||
m_ui->challengeResponseCombo->clear();
|
|
||||||
QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
|
|
||||||
|
|
||||||
m_ui->enterPasswordEdit->setFocus();
|
m_ui->enterPasswordEdit->setFocus();
|
||||||
}
|
}
|
||||||
@ -146,29 +143,50 @@ void ChangeMasterKeyWidget::generateKey()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_ui->challengeResponseGroup->isChecked()) {
|
if (m_ui->challengeResponseGroup->isChecked()) {
|
||||||
int i = m_ui->challengeResponseCombo->currentIndex();
|
int i = m_ui->comboChallengeResponse->currentIndex();
|
||||||
i = m_ui->challengeResponseCombo->itemData(i).toInt();
|
i = m_ui->comboChallengeResponse->itemData(i).toInt();
|
||||||
YkChallengeResponseKey key(i);
|
YkChallengeResponseKey key(i);
|
||||||
|
|
||||||
m_key.addChallengeResponseKey(key);
|
m_key.addChallengeResponseKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->messageWidget->hideMessage();
|
m_ui->messageWidget->hideMessage();
|
||||||
Q_EMIT editFinished(true);
|
emit editFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ChangeMasterKeyWidget::reject()
|
void ChangeMasterKeyWidget::reject()
|
||||||
{
|
{
|
||||||
Q_EMIT editFinished(false);
|
emit editFinished(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChangeMasterKeyWidget::challengeResponseGroupToggled(bool checked)
|
||||||
|
{
|
||||||
|
if (checked)
|
||||||
|
pollYubikey();
|
||||||
|
}
|
||||||
|
|
||||||
void ChangeMasterKeyWidget::ykDetected(int slot, bool blocking)
|
void ChangeMasterKeyWidget::pollYubikey()
|
||||||
|
{
|
||||||
|
m_ui->buttonRedetectYubikey->setEnabled(false);
|
||||||
|
m_ui->comboChallengeResponse->setEnabled(false);
|
||||||
|
m_ui->comboChallengeResponse->clear();
|
||||||
|
|
||||||
|
// YubiKey init is slow, detect asynchronously to not block the UI
|
||||||
|
QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChangeMasterKeyWidget::yubikeyDetected(int slot, bool blocking)
|
||||||
{
|
{
|
||||||
YkChallengeResponseKey yk(slot, blocking);
|
YkChallengeResponseKey yk(slot, blocking);
|
||||||
m_ui->challengeResponseCombo->addItem(yk.getName(), QVariant(slot));
|
m_ui->comboChallengeResponse->addItem(yk.getName(), QVariant(slot));
|
||||||
m_ui->challengeResponseGroup->setEnabled(true);
|
m_ui->comboChallengeResponse->setEnabled(m_ui->challengeResponseGroup->isChecked());
|
||||||
|
m_ui->buttonRedetectYubikey->setEnabled(m_ui->challengeResponseGroup->isChecked());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChangeMasterKeyWidget::noYubikeyFound()
|
||||||
|
{
|
||||||
|
m_ui->buttonRedetectYubikey->setEnabled(m_ui->challengeResponseGroup->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeMasterKeyWidget::setCancelEnabled(bool enabled)
|
void ChangeMasterKeyWidget::setCancelEnabled(bool enabled)
|
||||||
|
@ -48,7 +48,10 @@ private Q_SLOTS:
|
|||||||
void reject();
|
void reject();
|
||||||
void createKeyFile();
|
void createKeyFile();
|
||||||
void browseKeyFile();
|
void browseKeyFile();
|
||||||
void ykDetected(int slot, bool blocking);
|
void yubikeyDetected(int slot, bool blocking);
|
||||||
|
void noYubikeyFound();
|
||||||
|
void challengeResponseGroupToggled(bool checked);
|
||||||
|
void pollYubikey();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QScopedPointer<Ui::ChangeMasterKeyWidget> m_ui;
|
const QScopedPointer<Ui::ChangeMasterKeyWidget> m_ui;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>818</width>
|
<width>818</width>
|
||||||
<height>397</height>
|
<height>424</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
@ -90,7 +90,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="keyFileGroup">
|
<widget class="QGroupBox" name="keyFileGroup">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Key file</string>
|
<string>&Key file</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -129,22 +129,32 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="challengeResponseGroup">
|
<widget class="QGroupBox" name="challengeResponseGroup">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Challenge Response</string>
|
<string>Cha&llenge Response</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<property name="checked">
|
||||||
<item row="0" column="1">
|
<bool>true</bool>
|
||||||
<widget class="QComboBox" name="challengeResponseCombo"/>
|
</property>
|
||||||
</item>
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="challengeResponseLabel">
|
<widget class="QComboBox" name="comboChallengeResponse">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonRedetectYubikey">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Challenge Response:</string>
|
<string>Refresh</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user