Show busy indicator while scanning for YubiKeys

This commit is contained in:
Janek Bevendorff 2017-02-20 23:20:32 +01:00
parent c49aa6beef
commit 5d068dfb23
No known key found for this signature in database
GPG Key ID: CFEC2F6850BFFA53
4 changed files with 111 additions and 33 deletions

View File

@ -36,11 +36,17 @@ ChangeMasterKeyWidget::ChangeMasterKeyWidget(QWidget* parent)
m_ui->messageWidget->setHidden(true); m_ui->messageWidget->setHidden(true);
m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
m_ui->repeatPasswordEdit->enableVerifyMode(m_ui->enterPasswordEdit);
m_ui->yubikeyProgress->setVisible(false);
QSizePolicy sp = m_ui->yubikeyProgress->sizePolicy();
sp.setRetainSizeWhenHidden(true);
m_ui->yubikeyProgress->setSizePolicy(sp);
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(generateKey())); connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(generateKey()));
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject())); connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), m_ui->enterPasswordEdit, SLOT(setShowPassword(bool))); connect(m_ui->togglePasswordButton, SIGNAL(toggled(bool)), m_ui->enterPasswordEdit, SLOT(setShowPassword(bool)));
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()));
@ -178,6 +184,7 @@ void ChangeMasterKeyWidget::pollYubikey()
m_ui->buttonRedetectYubikey->setEnabled(false); m_ui->buttonRedetectYubikey->setEnabled(false);
m_ui->comboChallengeResponse->setEnabled(false); m_ui->comboChallengeResponse->setEnabled(false);
m_ui->comboChallengeResponse->clear(); m_ui->comboChallengeResponse->clear();
m_ui->yubikeyProgress->setVisible(true);
// YubiKey init is slow, detect asynchronously to not block the UI // YubiKey init is slow, detect asynchronously to not block the UI
QtConcurrent::run(YubiKey::instance(), &YubiKey::detect); QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
@ -189,11 +196,13 @@ void ChangeMasterKeyWidget::yubikeyDetected(int slot, bool blocking)
m_ui->comboChallengeResponse->addItem(yk.getName(), QVariant(slot)); m_ui->comboChallengeResponse->addItem(yk.getName(), QVariant(slot));
m_ui->comboChallengeResponse->setEnabled(m_ui->challengeResponseGroup->isChecked()); m_ui->comboChallengeResponse->setEnabled(m_ui->challengeResponseGroup->isChecked());
m_ui->buttonRedetectYubikey->setEnabled(m_ui->challengeResponseGroup->isChecked()); m_ui->buttonRedetectYubikey->setEnabled(m_ui->challengeResponseGroup->isChecked());
m_ui->yubikeyProgress->setVisible(false);
} }
void ChangeMasterKeyWidget::noYubikeyFound() void ChangeMasterKeyWidget::noYubikeyFound()
{ {
m_ui->buttonRedetectYubikey->setEnabled(m_ui->challengeResponseGroup->isChecked()); m_ui->buttonRedetectYubikey->setEnabled(m_ui->challengeResponseGroup->isChecked());
m_ui->yubikeyProgress->setVisible(false);
} }
void ChangeMasterKeyWidget::setCancelEnabled(bool enabled) void ChangeMasterKeyWidget::setCancelEnabled(bool enabled)

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>818</width> <width>818</width>
<height>424</height> <height>471</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
@ -142,21 +142,47 @@
</property> </property>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QComboBox" name="comboChallengeResponse"> <layout class="QGridLayout" name="gridLayout_4">
<property name="sizePolicy"> <property name="verticalSpacing">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <number>0</number>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
</widget> <item row="0" column="1">
</item> <widget class="QPushButton" name="buttonRedetectYubikey">
<item row="0" column="1"> <property name="text">
<widget class="QPushButton" name="buttonRedetectYubikey"> <string>Refresh</string>
<property name="text"> </property>
<string>Refresh</string> </widget>
</property> </item>
</widget> <item row="0" column="0">
<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="1" column="0">
<widget class="QProgressBar" name="yubikeyProgress">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>2</height>
</size>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>

View File

@ -49,6 +49,11 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
m_ui->yubikeyProgress->setVisible(false);
QSizePolicy sp = m_ui->yubikeyProgress->sizePolicy();
sp.setRetainSizeWhenHidden(true);
m_ui->yubikeyProgress->setSizePolicy(sp);
m_ui->buttonTogglePassword->setIcon(filePath()->onOffIcon("actions", "password-show")); m_ui->buttonTogglePassword->setIcon(filePath()->onOffIcon("actions", "password-show"));
connect(m_ui->buttonTogglePassword, SIGNAL(toggled(bool)), connect(m_ui->buttonTogglePassword, SIGNAL(toggled(bool)),
m_ui->editPassword, SLOT(setShowPassword(bool))); m_ui->editPassword, SLOT(setShowPassword(bool)));
@ -255,6 +260,7 @@ void DatabaseOpenWidget::pollYubikey()
m_ui->checkChallengeResponse->setChecked(false); m_ui->checkChallengeResponse->setChecked(false);
m_ui->comboChallengeResponse->setEnabled(false); m_ui->comboChallengeResponse->setEnabled(false);
m_ui->comboChallengeResponse->clear(); m_ui->comboChallengeResponse->clear();
m_ui->yubikeyProgress->setVisible(true);
QtConcurrent::run(YubiKey::instance(), &YubiKey::detect); QtConcurrent::run(YubiKey::instance(), &YubiKey::detect);
} }
@ -265,6 +271,7 @@ void DatabaseOpenWidget::yubikeyDetected(int slot, bool blocking)
m_ui->comboChallengeResponse->setEnabled(true); m_ui->comboChallengeResponse->setEnabled(true);
m_ui->checkChallengeResponse->setEnabled(true); m_ui->checkChallengeResponse->setEnabled(true);
m_ui->buttonRedetectYubikey->setEnabled(true); m_ui->buttonRedetectYubikey->setEnabled(true);
m_ui->yubikeyProgress->setVisible(false);
if (config()->get("RememberLastKeyFiles").toBool()) { if (config()->get("RememberLastKeyFiles").toBool()) {
QHash<QString, QVariant> lastChallengeResponse = config()->get("LastChallengeResponse").toHash(); QHash<QString, QVariant> lastChallengeResponse = config()->get("LastChallengeResponse").toHash();
@ -277,4 +284,5 @@ void DatabaseOpenWidget::yubikeyDetected(int slot, bool blocking)
void DatabaseOpenWidget::noYubikeyFound() void DatabaseOpenWidget::noYubikeyFound()
{ {
m_ui->buttonRedetectYubikey->setEnabled(true); m_ui->buttonRedetectYubikey->setEnabled(true);
m_ui->yubikeyProgress->setVisible(false);
} }

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>596</width> <width>596</width>
<height>264</height> <height>302</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0,1,0,0,3"> <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0,1,0,0,3">
@ -142,25 +142,28 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="0"> <item row="5" column="2">
<widget class="QCheckBox" name="checkChallengeResponse"> <layout class="QGridLayout" name="gridLayout_2">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Challenge Response:</string>
</property>
</widget>
</item>
<item row="4" column="2">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin"> <property name="leftMargin">
<number>5</number> <number>5</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>5</number> <number>5</number>
</property> </property>
<item> <property name="verticalSpacing">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QPushButton" name="buttonRedetectYubikey">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QComboBox" name="comboChallengeResponse"> <widget class="QComboBox" name="comboChallengeResponse">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
@ -176,13 +179,45 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="0">
<widget class="QProgressBar" name="yubikeyProgress">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>2</height>
</size>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>0</number>
</property>
<property name="value">
<number>-1</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item> <item>
<widget class="QPushButton" name="buttonRedetectYubikey"> <widget class="QCheckBox" name="checkChallengeResponse">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Refresh</string> <string>Challenge Response:</string>
</property> </property>
</widget> </widget>
</item> </item>