Libkleo

useridselectioncombo.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 UserIDSelectionComboPrivate;
29
30class KLEO_EXPORT UserIDSelectionCombo : public QWidget
31{
32 Q_OBJECT
33
34public:
35 explicit UserIDSelectionCombo(QWidget *parent = nullptr);
36 explicit UserIDSelectionCombo(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 UserIDSelectionCombo(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 UserIDSelectionCombo(KeyUsage::Flag usage, QWidget *parent = nullptr);
53 UserIDSelectionCombo(bool secretOnly, KeyUsage::Flags usage, QWidget *parent = nullptr);
54 ~UserIDSelectionCombo() 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 GpgME::UserID currentUserID() const;
69 void setCurrentUserID(const GpgME::UserID &userID);
70
71 void setDefaultKey(const QString &fingerprint);
72 void setDefaultKey(const QString &fingerprint, GpgME::Protocol proto);
73 QString defaultKey() const;
74 QString defaultKey(GpgME::Protocol proto) const;
75
76 void prependCustomItem(const QIcon &icon, const QString &text, const QVariant &data);
77 void appendCustomItem(const QIcon &icon, const QString &text, const QVariant &data);
78 void prependCustomItem(const QIcon &icon, const QString &text, const QVariant &data, const QString &toolTip);
79 void appendCustomItem(const QIcon &icon, const QString &text, const QVariant &data, const QString &toolTip);
80 void removeCustomItem(const QVariant &data);
81
82 QComboBox *combo() const;
83
84 int findUserId(const GpgME::UserID &userId) const;
85
86Q_SIGNALS:
87 void customItemSelected(const QVariant &data);
88 void currentKeyChanged(const GpgME::Key &key);
89 void keyListingFinished();
90 void certificateSelectionRequested();
91
92protected:
93 virtual void init();
94
95private:
96 std::unique_ptr<UserIDSelectionComboPrivate> const d;
97};
98
99}
QCA_EXPORT void init()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:51:41 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.