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

0001 /* -*- mode: c++; c-basic-offset:4 -*-
0002     crypto/gui/signerresolvepage_p.h
0003 
0004     This file is part of Kleopatra, the KDE keymanager
0005     SPDX-FileCopyrightText: 2007 Klarälvdalens Datakonsult AB
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include <gpgme++/global.h>
0013 
0014 class QButtonGroup;
0015 class QCheckBox;
0016 class QLabel;
0017 
0018 #include <map>
0019 #include <set>
0020 #include <vector>
0021 
0022 namespace Kleo
0023 {
0024 namespace Crypto
0025 {
0026 namespace Gui
0027 {
0028 
0029 class AbstractSigningProtocolSelectionWidget : public QWidget
0030 {
0031     Q_OBJECT
0032 public:
0033     explicit AbstractSigningProtocolSelectionWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = {});
0034     virtual void setProtocolChecked(GpgME::Protocol protocol, bool checked) = 0;
0035     virtual bool isProtocolChecked(GpgME::Protocol protocol) const = 0;
0036     virtual std::set<GpgME::Protocol> checkedProtocols() const = 0;
0037     virtual void setCertificate(GpgME::Protocol protocol, const GpgME::Key &key) = 0;
0038 
0039 Q_SIGNALS:
0040     void userSelectionChanged();
0041 };
0042 
0043 class SigningProtocolSelectionWidget : public AbstractSigningProtocolSelectionWidget
0044 {
0045     Q_OBJECT
0046 public:
0047     explicit SigningProtocolSelectionWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = {});
0048     void setProtocolChecked(GpgME::Protocol protocol, bool checked) override;
0049     bool isProtocolChecked(GpgME::Protocol protocol) const override;
0050     std::set<GpgME::Protocol> checkedProtocols() const override;
0051     void setCertificate(GpgME::Protocol protocol, const GpgME::Key &key) override;
0052 
0053     void setExclusive(bool exclusive);
0054     bool isExclusive() const;
0055 
0056 private:
0057     QCheckBox *button(GpgME::Protocol p) const;
0058     std::map<GpgME::Protocol, QCheckBox *> m_buttons;
0059     QButtonGroup *m_buttonGroup;
0060 };
0061 
0062 class ReadOnlyProtocolSelectionWidget : public AbstractSigningProtocolSelectionWidget
0063 {
0064     Q_OBJECT
0065 public:
0066     explicit ReadOnlyProtocolSelectionWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = {});
0067     void setProtocolChecked(GpgME::Protocol protocol, bool checked) override;
0068     bool isProtocolChecked(GpgME::Protocol protocol) const override;
0069     std::set<GpgME::Protocol> checkedProtocols() const override;
0070     void setCertificate(GpgME::Protocol protocol, const GpgME::Key &key) override;
0071 
0072 private:
0073     QLabel *label(GpgME::Protocol p) const;
0074     std::map<GpgME::Protocol, QLabel *> m_labels;
0075 };
0076 
0077 }
0078 }
0079 }