Commit 8932a36c authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Trigger a full update of the card status after the NullPIN was set

... and disable the whole widget while setting the PIN
parent 66c0a62e
......@@ -43,7 +43,7 @@ NetKeyWidget::NetKeyWidget(QWidget *parent) :
mVersionLabel(new QLabel(this)),
mLearnKeysLabel(new QLabel(this)),
mErrorLabel(new QLabel(this)),
mNullPinWidget(new NullPinWidget()),
mNullPinWidget(new NullPinWidget(this)),
mLearnKeysBtn(new QPushButton(this)),
mChangeNKSPINBtn(new QPushButton(this)),
mChangeSigGPINBtn(new QPushButton(this)),
......
......@@ -42,11 +42,9 @@ NullPinWidget::NullPinWidget(QWidget *parent)
mSigGBtn = new QPushButton(i18nc("SigG is an identifier for a type of keys on a NetKey card", "Set SigG PIN"));
connect(mNKSBtn, &QPushButton::clicked, this, [this] () {
mNKSBtn->setEnabled(false);
doChangePin(false);
});
connect(mSigGBtn, &QPushButton::clicked, this, [this] () {
mSigGBtn->setEnabled(false);
doChangePin(true);
});
......@@ -66,6 +64,7 @@ void NullPinWidget::setSerialNumber(const std::string &serialNumber)
void NullPinWidget::doChangePin(bool sigG)
{
parentWidget()->setEnabled(false);
auto ret = KMessageBox::warningContinueCancel(this,
i18n("Setting a PIN is required but <b>can't be reverted</b>.") +
QStringLiteral("<p>%1</p><p>%2</p>").arg(
......@@ -78,12 +77,14 @@ void NullPinWidget::doChangePin(bool sigG)
KStandardGuiItem::cancel());
if (ret != KMessageBox::Continue) {
parentWidget()->setEnabled(true);
return;
}
const auto nksCard = ReaderStatus::instance()->getCard<NetKeyCard>(mSerialNumber);
if (!nksCard) {
KMessageBox::error(this, i18n("Failed to find the NetKey card with the serial number: %1", QString::fromStdString(mSerialNumber)));
parentWidget()->setEnabled(true);
return;
}
......@@ -96,24 +97,16 @@ void NullPinWidget::doChangePin(bool sigG)
}
}
void NullPinWidget::handleResult(const GpgME::Error &err, QPushButton *btn)
void NullPinWidget::handleResult(const GpgME::Error &err)
{
btn->setEnabled(true);
if (err.isCanceled()) {
return;
}
if (err) {
KMessageBox::error(this, i18nc("@info",
"Failed to set PIN: %1", QString::fromLatin1(err.asString())),
i18nc("@title", "Error"));
return;
}
btn->setVisible(false);
if (!mNKSBtn->isVisible() && !mSigGBtn->isVisible()) {
// Both pins are set, we can hide.
setVisible(false);
} else if (!err.isCanceled()) {
ReaderStatus::mutableInstance()->updateStatus();
}
parentWidget()->setEnabled(true);
}
void NullPinWidget::setSigGVisible(bool val)
......@@ -128,10 +121,10 @@ void NullPinWidget::setNKSVisible(bool val)
void NullPinWidget::setSigGPinSettingResult(const GpgME::Error &err)
{
handleResult(err, mSigGBtn);
handleResult(err);
}
void NullPinWidget::setNksPinSettingResult(const GpgME::Error &err)
{
handleResult(err, mNKSBtn);
handleResult(err);
}
......@@ -32,7 +32,7 @@ public:
private:
void doChangePin(bool sigG);
void handleResult(const GpgME::Error &err, QPushButton *btn);
void handleResult(const GpgME::Error &err);
private Q_SLOTS:
void setSigGPinSettingResult(const GpgME::Error &err);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment