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

Add helper for reporting success to the user

Add success helper (with default window title "Success") as counterpart
for the error helper.
parent ee608dc1
Pipeline #177355 passed with stage
in 3 minutes and 38 seconds
......@@ -231,9 +231,7 @@ void CertificateToPIVCardCommand::certificateToPIVCardDone(const Error &err)
d->error(i18nc("@info", "Writing the certificate to the card failed: %1", QString::fromUtf8(err.asString())));
} else if (!err.isCanceled()) {
KMessageBox::information(d->parentWidgetOrView(),
i18nc("@info", "Writing the certificate to the card succeeded."),
i18nc("@title", "Success"));
d->success(i18nc("@info", "Writing the certificate to the card succeeded."));
ReaderStatus::mutableInstance()->updateStatus();
}
......
......@@ -207,7 +207,7 @@ void ChangePinCommand::Private::slotResult(const GpgME::Error& err)
if (err) {
error(errorMessage(keyRef, mode, QString::fromLatin1(err.asString())));
} else if (!err.isCanceled()) {
information(successMessage(keyRef, mode), i18nc("@title", "Success"));
success(successMessage(keyRef, mode));
ReaderStatus::mutableInstance()->updateStatus();
}
finished();
......
......@@ -14,6 +14,7 @@
#include <Libkleo/KeyListModel>
#include <KLocalizedString>
#include <KMessageBox>
#include <QAbstractItemView>
......@@ -94,6 +95,16 @@ public:
KMessageBox::error(parentWidgetOrView(), text, caption, options);
}
}
void success(const QString &text, const QString &caption = {}, KMessageBox::Options options = KMessageBox::Notify) const
{
static const QString noDontShowAgainName{};
const QString title = caption.isEmpty() ? i18nc("@title:window", "Success") : caption;
if (parentWId) {
KMessageBox::informationWId(parentWId, text, title, noDontShowAgainName, options);
} else {
KMessageBox::information(parentWidgetOrView(), text, title, noDontShowAgainName, options);
}
}
void information(const QString &text, const QString &caption = QString(), const QString &dontShowAgainName = QString(), KMessageBox::Options options = KMessageBox::Notify) const
{
if (parentWId) {
......
......@@ -169,8 +169,7 @@ void CreateOpenPGPKeyFromCardKeysCommand::Private::slotResult(const Error &err)
} else if (err) {
error(i18nc("@info", "Creating an OpenPGP key from the card keys failed: %1", QString::fromUtf8(err.asString())));
} else {
information(i18nc("@info", "Successfully generated an OpenPGP key from the card keys."),
i18nc("@title", "Success"));
success(i18nc("@info", "Successfully generated an OpenPGP key from the card keys."));
}
finished();
......
......@@ -464,8 +464,7 @@ void KeyToCardCommand::keyToOpenPGPCardDone(const GpgME::Error &err)
ReaderStatus::mutableInstance()->startSimpleTransaction(card, cmd.toUtf8(), this, "deleteDone");
}
*/
d->information(i18nc("@info", "Successfully copied the key to the card."),
i18nc("@title", "Success"));
d->success(i18nc("@info", "Successfully copied the key to the card."));
ReaderStatus::mutableInstance()->updateStatus();
}
d->finished();
......@@ -487,8 +486,7 @@ void KeyToCardCommand::keyToPIVCardDone(const GpgME::Error &err)
d->error(i18nc("@info",
"Copying the key pair to the card failed: %1", QString::fromUtf8(err.asString())));
} else if (!err.isCanceled()) {
d->information(i18nc("@info", "Successfully copied the key pair to the card."),
i18nc("@title", "Success"));
d->success(i18nc("@info", "Successfully copied the key pair to the card."));
ReaderStatus::mutableInstance()->updateStatus();
}
......
......@@ -214,7 +214,7 @@ void PIVGenerateCardKeyCommand::Private::slotResult(const GpgME::Error& err)
error(i18nc("@info", "Generating key failed: %1", QString::fromLatin1(err.asString())));
} else if (!err.isCanceled()) {
information(i18nc("@info", "Key successfully generated."), i18nc("@title", "Success"));
success(i18nc("@info", "Key successfully generated."));
ReaderStatus::mutableInstance()->updateStatus();
}
finished();
......
......@@ -206,7 +206,7 @@ void SetPIVCardApplicationAdministrationKeyCommand::Private::slotResult(const Gp
if (err) {
error(i18nc("@info", "Setting the PIV Card Application Administration Key failed: %1", QString::fromLatin1(err.asString())));
} else if (!err.isCanceled()) {
information(i18nc("@info", "PIV Card Application Administration Key set successfully."), i18nc("@title", "Success"));
success(i18nc("@info", "PIV Card Application Administration Key set successfully."));
ReaderStatus::mutableInstance()->updateStatus();
}
finished();
......
Supports Markdown
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