diff --git a/src/gui/ChangeMasterKeyWidget.cpp b/src/gui/ChangeMasterKeyWidget.cpp index b223d392..bb963d3c 100644 --- a/src/gui/ChangeMasterKeyWidget.cpp +++ b/src/gui/ChangeMasterKeyWidget.cpp @@ -177,8 +177,6 @@ void ChangeMasterKeyWidget::generateKey() bool blocking = i & true; int slot = i >> 1; auto key = QSharedPointer(new YkChallengeResponseKey(slot, blocking)); - connect(key.data(), SIGNAL(userInteractionRequired()), SLOT(showYubiKeyPopup())); - connect(key.data(), SIGNAL(userConfirmed()), SLOT(hideYubiKeyPopup())); m_key.addChallengeResponseKey(key); } #endif @@ -241,15 +239,3 @@ void ChangeMasterKeyWidget::setCancelEnabled(bool enabled) { m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(enabled); } - -void ChangeMasterKeyWidget::showYubiKeyPopup() -{ - KEEPASSXC_MAIN_WINDOW->displayGlobalMessage(tr("Please touch the button on your YubiKey!"), MessageWidget::Information); - KEEPASSXC_MAIN_WINDOW->setEnabled(false); -} - -void ChangeMasterKeyWidget::hideYubiKeyPopup() -{ - KEEPASSXC_MAIN_WINDOW->hideGlobalMessage(); - KEEPASSXC_MAIN_WINDOW->setEnabled(true); -} diff --git a/src/gui/ChangeMasterKeyWidget.h b/src/gui/ChangeMasterKeyWidget.h index fdc7f952..b3e09727 100644 --- a/src/gui/ChangeMasterKeyWidget.h +++ b/src/gui/ChangeMasterKeyWidget.h @@ -55,8 +55,6 @@ private slots: void noYubikeyFound(); void challengeResponseGroupToggled(bool checked); void pollYubikey(); - void showYubiKeyPopup(); - void hideYubiKeyPopup(); private: const QScopedPointer m_ui; diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 03a560c2..2eebcae3 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -214,8 +214,6 @@ CompositeKey DatabaseOpenWidget::databaseKey() bool blocking = i & true; int slot = i >> 1; auto key = QSharedPointer(new YkChallengeResponseKey(slot, blocking)); - connect(key.data(), SIGNAL(userInteractionRequired()), SLOT(showYubiKeyPopup())); - connect(key.data(), SIGNAL(userConfirmed()), SLOT(hideYubiKeyPopup())); masterKey.addChallengeResponseKey(key); } #endif @@ -266,18 +264,6 @@ void DatabaseOpenWidget::pollYubikey() QtConcurrent::run(YubiKey::instance(), &YubiKey::detect); } -void DatabaseOpenWidget::showYubiKeyPopup() -{ - m_ui->messageWidget->showMessage(tr("Please touch the button on your YubiKey!"), MessageWidget::Information); - KEEPASSXC_MAIN_WINDOW->setEnabled(false); -} - -void DatabaseOpenWidget::hideYubiKeyPopup() -{ - m_ui->messageWidget->hideMessage(); - KEEPASSXC_MAIN_WINDOW->setEnabled(true); -} - void DatabaseOpenWidget::yubikeyDetected(int slot, bool blocking) { YkChallengeResponseKey yk(slot, blocking); diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index eee705a7..caba70a6 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -53,8 +53,6 @@ protected: protected slots: virtual void openDatabase(); - void showYubiKeyPopup(); - void hideYubiKeyPopup(); void reject(); private slots: diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index e9a05e5d..9a9ef3dc 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -871,3 +871,14 @@ void MainWindow::hideTabMessage() } } +void MainWindow::showYubiKeyPopup() +{ + displayGlobalMessage(tr("Please touch the button on your YubiKey!"), MessageWidget::Information); + setEnabled(false); +} + +void MainWindow::hideYubiKeyPopup() +{ + hideGlobalMessage(); + setEnabled(true); +} diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index c3262a3c..eb677fbb 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -47,6 +47,8 @@ public Q_SLOTS: void displayGlobalMessage(const QString& text, MessageWidget::MessageType type); void displayTabMessage(const QString& text, MessageWidget::MessageType type); void hideGlobalMessage(); + void showYubiKeyPopup(); + void hideYubiKeyPopup(); protected: void closeEvent(QCloseEvent* event) override; diff --git a/src/keys/YkChallengeResponseKey.cpp b/src/keys/YkChallengeResponseKey.cpp index 039d7a1e..31ad1d86 100644 --- a/src/keys/YkChallengeResponseKey.cpp +++ b/src/keys/YkChallengeResponseKey.cpp @@ -20,6 +20,7 @@ #include "core/Tools.h" #include "crypto/CryptoHash.h" #include "crypto/Random.h" +#include "gui/MainWindow.h" #include #include @@ -32,6 +33,9 @@ YkChallengeResponseKey::YkChallengeResponseKey(int slot, bool blocking) : m_slot(slot), m_blocking(blocking) { + + connect(this, SIGNAL(userInteractionRequired()), KEEPASSXC_MAIN_WINDOW, SLOT(showYubiKeyPopup())); + connect(this, SIGNAL(userConfirmed()), KEEPASSXC_MAIN_WINDOW, SLOT(hideYubiKeyPopup())); } QByteArray YkChallengeResponseKey::rawKey() const