diff --git a/src/ui/messagebox.cpp b/src/ui/messagebox.cpp index 305fe8bd7..1f1d79995 100644 --- a/src/ui/messagebox.cpp +++ b/src/ui/messagebox.cpp @@ -1,105 +1,84 @@ /* messagebox.cpp This file is part of libkleopatra, the KDE keymanagement library SPDX-FileCopyrightText: 2004 Klarälvdalens Datakonsult AB SPDX-License-Identifier: GPL-2.0-or-later */ #include #include "messagebox.h" #include "auditlogviewer.h" #include #include #include #include #include #include #include #include #include #include #include #include using namespace Kleo; using namespace GpgME; using namespace QGpgME; namespace { bool showAuditLogButton(const AuditLogEntry &auditLog) { if (auditLog.error().code() == GPG_ERR_NOT_IMPLEMENTED) { qCDebug(KLEO_UI_LOG) << "not showing audit log button (not supported)"; return false; } if (auditLog.error().code() == GPG_ERR_NO_DATA) { qCDebug(KLEO_UI_LOG) << "not showing audit log button (GPG_ERR_NO_DATA)"; return false; } if (!auditLog.error() && auditLog.text().isEmpty()) { qCDebug(KLEO_UI_LOG) << "not showing audit log button (success, but result empty)"; return false; } return true; } void showMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &text, const AuditLogEntry &auditLog, const QString &caption, KMessageBox::Options options) { QDialog *dialog = new QDialog(parent); dialog->setWindowTitle(caption); QDialogButtonBox *box = new QDialogButtonBox(showAuditLogButton(auditLog) ? (QDialogButtonBox::Yes | QDialogButtonBox::No) : QDialogButtonBox::Yes, parent); QPushButton *yesButton = box->button(QDialogButtonBox::Yes); yesButton->setDefault(true); dialog->setObjectName(QStringLiteral("error")); dialog->setModal(true); KGuiItem::assign(yesButton, KStandardGuiItem::ok()); KGuiItem::assign(box->button(QDialogButtonBox::No), KGuiItem(i18n("&Show Audit Log"))); if (QDialogButtonBox::No == KMessageBox::createKMessageBox(dialog, box, icon, text, QStringList(), QString(), nullptr, options)) { AuditLogViewer::showAuditLog(parent, auditLog); } } } -void MessageBox::auditLog(QWidget *parent, const Job *job, const QString &caption) +void MessageBox::auditLog(QWidget *parent, const QString &log, const QString &title) { - if (!job) { - return; - } - AuditLogViewer::showAuditLog(parent, AuditLogEntry::fromJob(job), caption); -} - -void MessageBox::auditLog(QWidget *parent, const QString &log, const QString &caption) -{ - AuditLogViewer::showAuditLog(parent, AuditLogEntry{log, Error{}}, caption); -} - -void MessageBox::auditLog(QWidget *parent, const Job *job) -{ - if (!job) { - return; - } - AuditLogViewer::showAuditLog(parent, AuditLogEntry::fromJob(job)); -} - -void MessageBox::auditLog(QWidget *parent, const QString &log) -{ - AuditLogViewer::showAuditLog(parent, AuditLogEntry{log, Error{}}); + AuditLogViewer::showAuditLog(parent, AuditLogEntry{log, Error{}}, title); } diff --git a/src/ui/messagebox.h b/src/ui/messagebox.h index 70fb6e094..5cbf7a789 100644 --- a/src/ui/messagebox.h +++ b/src/ui/messagebox.h @@ -1,57 +1,42 @@ /* messagebox.h This file is part of libkleopatra, the KDE keymanagement library SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include "kleo_export.h" #include #undef MessageBox // Windows namespace GpgME { class SigningResult; class EncryptionResult; } namespace QGpgME { class Job; } class QWidget; class QString; namespace Kleo { namespace MessageBox { KLEO_EXPORT KLEO_DEPRECATED_VERSION(5, 23, "Use AuditLogViewer::showAuditLog()") -void auditLog(QWidget *parent, const QGpgME::Job *job, const QString &caption); - -KLEO_EXPORT -KLEO_DEPRECATED_VERSION(5, 23, "Use AuditLogViewer::showAuditLog()") -void auditLog(QWidget *parent, const QGpgME::Job *job); - -KLEO_EXPORT -KLEO_DEPRECATED_VERSION(5, 23, "Use AuditLogViewer::showAuditLog()") -void auditLog(QWidget *parent, const QString &log, const QString &caption); - -KLEO_EXPORT -KLEO_DEPRECATED_VERSION(5, 23, "Use AuditLogViewer::showAuditLog()") -void auditLog(QWidget *parent, const QString &log); - -KLEO_EXPORT -bool showAuditLogButton(const QGpgME::Job *job); +void auditLog(QWidget *parent, const QString &log, const QString &title = {}); } }