File indexing completed on 2024-06-23 05:13:53

0001 /*  crypto/gui/unknownrecipientwidget.cpp
0002 
0003     This file is part of Kleopatra, the KDE keymanager
0004     SPDX-FileCopyrightText: 2018 Intevation GmbH
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #include "unknownrecipientwidget.h"
0010 
0011 #include <QFont>
0012 #include <QHBoxLayout>
0013 #include <QLabel>
0014 #include <QPushButton>
0015 
0016 #include "commands/lookupcertificatescommand.h"
0017 
0018 #include <KLocalizedString>
0019 
0020 using namespace Kleo;
0021 UnknownRecipientWidget::UnknownRecipientWidget(const char *keyid, QWidget *parent)
0022     : QWidget(parent)
0023 {
0024     auto hLay = new QHBoxLayout(this);
0025 
0026     auto caption = new QLabel(i18nc("Caption for an unknown key/certificate where only ID is known.", "Unknown Recipient:"));
0027 
0028     mKeyID = QString::fromLatin1(keyid);
0029 
0030     auto keyIdLabel = new QLabel(mKeyID);
0031     keyIdLabel->setFont(QFont(QStringLiteral("Monospace")));
0032 
0033     auto lookUpBtn = new QPushButton(i18n("Search"));
0034 
0035     lookUpBtn->setIcon(QIcon::fromTheme(QStringLiteral("edit-find")));
0036     lookUpBtn->setToolTip(i18n("Search on keyserver"));
0037     connect(lookUpBtn, &QPushButton::clicked, this, [this, lookUpBtn]() {
0038         lookUpBtn->setEnabled(false);
0039         auto cmd = new Kleo::Commands::LookupCertificatesCommand(mKeyID, nullptr);
0040         connect(cmd, &Kleo::Commands::LookupCertificatesCommand::finished, this, [lookUpBtn]() {
0041             lookUpBtn->setEnabled(true);
0042         });
0043         cmd->setParentWidget(this->parentWidget());
0044         cmd->start();
0045     });
0046 
0047     hLay->addWidget(caption);
0048     hLay->addWidget(keyIdLabel);
0049     hLay->addWidget(lookUpBtn);
0050     hLay->addStretch(1);
0051 
0052     setToolTip(i18n("The data was encrypted to this key / certificate."));
0053 }
0054 
0055 QString UnknownRecipientWidget::keyID() const
0056 {
0057     return mKeyID;
0058 }
0059 
0060 #include "moc_unknownrecipientwidget.cpp"