1 /* -*- mode: c++; c-basic-offset:4 -*- 2 dialogs/certificateselectiondialog.h 3 4 This file is part of Kleopatra, the KDE keymanager 5 SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB 6 7 SPDX-License-Identifier: GPL-2.0-or-later 8 */ 9 10 #pragma once 11 12 #include <QDialog> 13 14 #include <utils/pimpl_ptr.h> 15 16 #include <gpgme++/global.h> 17 18 #include <memory> 19 #include <vector> 20 21 namespace GpgME 22 { 23 class Key; 24 } 25 26 namespace Kleo 27 { 28 29 class KeyFilter; 30 class KeyGroup; 31 32 namespace Dialogs 33 { 34 35 class CertificateSelectionDialog : public QDialog 36 { 37 Q_OBJECT 38 Q_FLAGS(Options) 39 public: 40 enum Option { 41 SingleSelection = 0x00, 42 MultiSelection = 0x01, 43 44 SignOnly = 0x02, 45 EncryptOnly = 0x04, 46 AnyCertificate = 0x06, 47 48 OpenPGPFormat = 0x08, 49 CMSFormat = 0x10, 50 AnyFormat = 0x18, 51 52 Certificates = 0x00, 53 SecretKeys = 0x20, 54 55 IncludeGroups = 0x40, 56 57 OptionMask 58 }; 59 Q_DECLARE_FLAGS(Options, Option) 60 61 static Option optionsFromProtocol(GpgME::Protocol proto); 62 63 explicit CertificateSelectionDialog(QWidget *parent = nullptr); 64 ~CertificateSelectionDialog() override; 65 66 void setCustomLabelText(const QString &text); 67 QString customLabelText() const; 68 69 void setOptions(Options options); 70 Options options() const; 71 72 void selectCertificates(const std::vector<GpgME::Key> &certs); 73 void selectCertificate(const GpgME::Key &key); 74 75 std::vector<GpgME::Key> selectedCertificates() const; 76 GpgME::Key selectedCertificate() const; 77 78 void selectGroups(const std::vector<Kleo::KeyGroup> &groups); 79 std::vector<Kleo::KeyGroup> selectedGroups() const; 80 81 static void filterAllowedKeys(std::vector<GpgME::Key> &keys, int options); 82 83 public Q_SLOTS: 84 void setStringFilter(const QString &text); 85 void setKeyFilter(const std::shared_ptr<Kleo::KeyFilter> &filter); 86 void accept() override; 87 88 protected: 89 void hideEvent(QHideEvent *) override; 90 91 private: 92 class Private; 93 kdtools::pimpl_ptr<Private> d; 94 }; 95 96 } 97 } 98 99 Q_DECLARE_OPERATORS_FOR_FLAGS(Kleo::Dialogs::CertificateSelectionDialog::Options) 100 101