Libkleo

keyselectioncombo.h
1/* This file is part of Kleopatra, the KDE keymanager
2 SPDX-FileCopyrightText: 2016 Klarälvdalens Datakonsult AB
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "kleo_export.h"
10
11#include <libkleo/enum.h>
12#include <libkleo/keyusage.h>
13
14#include <QComboBox>
15
16#include <gpgme++/global.h>
17
18#include <memory>
19
20namespace GpgME
21{
22class Key;
23}
24
25namespace Kleo
26{
27class KeyFilter;
28class KeySelectionComboPrivate;
29
30class KLEO_EXPORT KeySelectionCombo : public QComboBox
31{
32 Q_OBJECT
33
34public:
35 explicit KeySelectionCombo(QWidget *parent = nullptr);
36 explicit KeySelectionCombo(bool secretOnly, QWidget *parent = nullptr);
37 /**
38 * @param usage the desired usage of the certificate
39 *
40 * \a usage is used to mark certificates that cannot be used for the desired
41 * usage with an appropriate icon. This is useful in combination with a suitable
42 * key filter.
43 * For example, the key filter could filter out any certificates without
44 * encryption subkeys and the usage flags would mark certificates with expired
45 * encryption subkeys as unusable, so that the users see that there is a
46 * certificate, but that it cannot be used.
47 */
48 explicit KeySelectionCombo(KeyUsage::Flags usage, QWidget *parent = nullptr);
49 /* Overload to help the compiler choose the correct overload if a KeyUsage::Flag is passed as first argument.
50 * Without this overload the compiler tries to use the bool-overload instead of the KeyUsage::Flags-overload
51 * and throws an error. */
52 explicit KeySelectionCombo(KeyUsage::Flag usage, QWidget *parent = nullptr);
53 KeySelectionCombo(bool secretOnly, KeyUsage::Flags usage, QWidget *parent = nullptr);
54 ~KeySelectionCombo() override;
55
56 void setKeyFilter(const std::shared_ptr<const KeyFilter> &kf);
57 std::shared_ptr<const KeyFilter> keyFilter() const;
58
59 void setIdFilter(const QString &id);
60 QString idFilter() const;
61
62 void refreshKeys();
63
64 GpgME::Key currentKey() const;
65 void setCurrentKey(const GpgME::Key &key);
66 void setCurrentKey(const QString &fingerprint);
67
68 void setDefaultKey(const QString &fingerprint);
69 void setDefaultKey(const QString &fingerprint, GpgME::Protocol proto);
70 QString defaultKey() const;
71 QString defaultKey(GpgME::Protocol proto) const;
72
73 void prependCustomItem(const QIcon &icon, const QString &text, const QVariant &data);
74 void appendCustomItem(const QIcon &icon, const QString &text, const QVariant &data);
75 void prependCustomItem(const QIcon &icon, const QString &text, const QVariant &data, const QString &toolTip);
76 void appendCustomItem(const QIcon &icon, const QString &text, const QVariant &data, const QString &toolTip);
77 void removeCustomItem(const QVariant &data);
78
79Q_SIGNALS:
80 void customItemSelected(const QVariant &data);
81 void currentKeyChanged(const GpgME::Key &key);
82 void keyListingFinished();
83
84protected:
85 virtual void init();
86
87private:
88 std::unique_ptr<KeySelectionComboPrivate> const d;
89};
90
91}
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.