File indexing completed on 2024-05-12 05:22:53

0001 /*
0002     test_keygen.cpp
0003 
0004     This file is part of libkleopatra's test suite.
0005     SPDX-FileCopyrightText: 2004 Klarälvdalens Datakonsult AB
0006 
0007     SPDX-License-Identifier: GPL-2.0-only
0008 */
0009 
0010 #include <ui/keyselectiondialog.h>
0011 
0012 #include <gpgme++/key.h>
0013 
0014 #include <KAboutData>
0015 #include <QDebug>
0016 
0017 #include <KLocalizedString>
0018 #include <QApplication>
0019 #include <QCommandLineParser>
0020 #include <vector>
0021 
0022 int main(int argc, char **argv)
0023 {
0024     QApplication app(argc, argv);
0025     KAboutData aboutData(QStringLiteral("test_keyselectiondialog"), i18n("KeySelectionDialog Test"), QStringLiteral("0.1"));
0026     QCommandLineParser parser;
0027     KAboutData::setApplicationData(aboutData);
0028     aboutData.setupCommandLine(&parser);
0029     parser.process(app);
0030     aboutData.processCommandLine(&parser);
0031 
0032     Kleo::KeySelectionDialog dlg(QStringLiteral("Kleo::KeySelectionDialog Test"),
0033                                  QStringLiteral("Please select a key:"),
0034                                  std::vector<GpgME::Key>(),
0035                                  Kleo::KeySelectionDialog::AllKeys,
0036                                  true,
0037                                  true);
0038 
0039     if (dlg.exec() == QDialog::Accepted) {
0040         qDebug() << "accepted; selected key:" << (dlg.selectedKey().userID(0).id() ? dlg.selectedKey().userID(0).id() : "<null>") << "\nselected _keys_:";
0041         for (auto it = dlg.selectedKeys().begin(); it != dlg.selectedKeys().end(); ++it) {
0042             qDebug() << (it->userID(0).id() ? it->userID(0).id() : "<null>");
0043         }
0044     } else {
0045         qDebug() << "rejected";
0046     }
0047 
0048     return 0;
0049 }