gui: ChangeMasterKeyWidget: Clear YubiKeys detected

* Clear the YubiKey detected list on each load.
* In the event the YubiKey was removed, it will no longer be displayed.
* If it's still present it won't be duplicated.
This commit is contained in:
Kyle Manna 2017-01-14 17:36:14 -08:00
parent e17576a6f7
commit a7cf39c7cd

View File

@ -41,6 +41,10 @@ ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
m_ui->repeatPasswordEdit->enableVerifyMode(m_ui->enterPasswordEdit); m_ui->repeatPasswordEdit->enableVerifyMode(m_ui->enterPasswordEdit);
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)),
SLOT(ykDetected(int,bool)),
Qt::QueuedConnection);
} }
ChangeMasterKeyWidget::~ChangeMasterKeyWidget() ChangeMasterKeyWidget::~ChangeMasterKeyWidget()
@ -88,10 +92,8 @@ void ChangeMasterKeyWidget::clearForms()
m_ui->challengeResponseGroup->setChecked(false); m_ui->challengeResponseGroup->setChecked(false);
m_ui->challengeResponseCombo->clear(); m_ui->challengeResponseCombo->clear();
/* YubiKey init is slow */ /* YubiKey init is slow, detect asynchronously to not block the UI */
connect(YubiKey::instance(), SIGNAL(detected(int,bool)), m_ui->challengeResponseCombo->clear();
SLOT(ykDetected(int,bool)),
Qt::QueuedConnection);
QtConcurrent::run(YubiKey::instance(), &YubiKey::detect); QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
m_ui->enterPasswordEdit->setFocus(); m_ui->enterPasswordEdit->setFocus();