Libkleo

cryptoconfigentryreaderport.cpp
1/*
2 ui/cryptoconfigentryreaderport.cpp
3
4 This file is part of libkleopatra
5 SPDX-FileCopyrightText: 2021 g10 Code GmbH
6 SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#include <config-libkleo.h>
12
13#include "cryptoconfigentryreaderport_p.h"
14
15#include "cryptoconfigmodule.h"
16#include "readerportselection.h"
17
18#include <libkleo/scdaemon.h>
19
20#include <libkleo_debug.h>
21
22#include <KLocalizedString>
23
24#include <QGpgME/CryptoConfig>
25#if __has_include(<QGpgME/Debug>)
26#include <QGpgME/Debug>
27#endif
28
29#include <QGridLayout>
30#include <QLabel>
31
32#include <gpgme++/error.h>
33
34namespace Kleo
35{
36
37CryptoConfigEntryReaderPort::CryptoConfigEntryReaderPort(CryptoConfigModule *module,
38 QGpgME::CryptoConfigEntry *entry,
39 const QString &entryName,
40 QGridLayout *layout,
41 QWidget *parent)
42 : CryptoConfigEntryGUI{module, entry, entryName}
43 , mReaderPort{new ReaderPortSelection{parent}}
44{
45 auto const label = new QLabel{i18nc("@label:listbox Reader for smart cards", "Reader to connect to"), parent};
46 label->setBuddy(mReaderPort);
47
48 if (entry->isReadOnly()) {
49 label->setEnabled(false);
50 mReaderPort->setEnabled(false);
51 } else {
52 connect(mReaderPort, &ReaderPortSelection::valueChanged, this, &CryptoConfigEntryReaderPort::slotChanged);
53 }
54
55 const int row = layout->rowCount();
56 layout->addWidget(label, row, 1);
57 layout->addWidget(mReaderPort, row, 2);
58}
59
60void CryptoConfigEntryReaderPort::doSave()
61{
62 if (mEntry->isReadOnly()) {
63 return;
64 }
65 mEntry->setStringValue(mReaderPort->value());
66}
67
68void CryptoConfigEntryReaderPort::doLoad()
69{
70 mReaderPort->setValue(mEntry->stringValue());
71}
72
73} // namespace Kleo
74
75#include "moc_cryptoconfigentryreaderport_p.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void addWidget(QWidget *widget, int fromRow, int fromColumn, int rowSpan, int columnSpan, Qt::Alignment alignment)
int rowCount() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:56:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.