1 /* -*- mode: c++; c-basic-offset:4 -*- 2 crypto/gui/signerresolvepage_p.h 3 4 This file is part of Kleopatra, the KDE keymanager 5 SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB 6 7 SPDX-License-Identifier: GPL-2.0-or-later 8 */ 9 10 #pragma once 11 12 #include <gpgme++/global.h> 13 14 class QButtonGroup; 15 class QCheckBox; 16 class QLabel; 17 18 #include <vector> 19 #include <map> 20 #include <set> 21 22 namespace Kleo 23 { 24 namespace Crypto 25 { 26 namespace Gui 27 { 28 29 class AbstractSigningProtocolSelectionWidget : public QWidget 30 { 31 Q_OBJECT 32 public: 33 explicit AbstractSigningProtocolSelectionWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = {}); 34 virtual void setProtocolChecked(GpgME::Protocol protocol, bool checked) = 0; 35 virtual bool isProtocolChecked(GpgME::Protocol protocol) const = 0; 36 virtual std::set<GpgME::Protocol> checkedProtocols() const = 0; 37 virtual void setCertificate(GpgME::Protocol protocol, const GpgME::Key &key) = 0; 38 39 Q_SIGNALS: 40 void userSelectionChanged(); 41 }; 42 43 class SigningProtocolSelectionWidget : public AbstractSigningProtocolSelectionWidget 44 { 45 Q_OBJECT 46 public: 47 explicit SigningProtocolSelectionWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = {}); 48 void setProtocolChecked(GpgME::Protocol protocol, bool checked) override; 49 bool isProtocolChecked(GpgME::Protocol protocol) const override; 50 std::set<GpgME::Protocol> checkedProtocols() const override; 51 void setCertificate(GpgME::Protocol protocol, const GpgME::Key &key) override; 52 53 void setExclusive(bool exclusive); 54 bool isExclusive() const; 55 56 private: 57 QCheckBox *button(GpgME::Protocol p) const; 58 std::map<GpgME::Protocol, QCheckBox *> m_buttons; 59 QButtonGroup *m_buttonGroup; 60 }; 61 62 class ReadOnlyProtocolSelectionWidget : public AbstractSigningProtocolSelectionWidget 63 { 64 Q_OBJECT 65 public: 66 explicit ReadOnlyProtocolSelectionWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = {}); 67 void setProtocolChecked(GpgME::Protocol protocol, bool checked) override; 68 bool isProtocolChecked(GpgME::Protocol protocol) const override; 69 std::set<GpgME::Protocol> checkedProtocols() const override; 70 void setCertificate(GpgME::Protocol protocol, const GpgME::Key &key) override; 71 72 private: 73 QLabel *label(GpgME::Protocol p) const; 74 std::map<GpgME::Protocol, QLabel *> m_labels; 75 }; 76 77 } 78 } 79 } 80 81