File indexing completed on 2025-01-05 04:55:46
0001 /* 0002 ui/cryptoconfigentryreaderport.cpp 0003 0004 This file is part of libkleopatra 0005 SPDX-FileCopyrightText: 2021 g10 Code GmbH 0006 SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #include <config-libkleo.h> 0012 0013 #include "cryptoconfigentryreaderport_p.h" 0014 0015 #include "cryptoconfigmodule.h" 0016 #include "readerportselection.h" 0017 0018 #include <libkleo/scdaemon.h> 0019 0020 #include <libkleo_debug.h> 0021 0022 #include <KLocalizedString> 0023 0024 #include <QGpgME/CryptoConfig> 0025 #if __has_include(<QGpgME/Debug>) 0026 #include <QGpgME/Debug> 0027 #endif 0028 0029 #include <QGridLayout> 0030 #include <QLabel> 0031 0032 #include <gpgme++/error.h> 0033 0034 namespace Kleo 0035 { 0036 0037 CryptoConfigEntryReaderPort::CryptoConfigEntryReaderPort(CryptoConfigModule *module, 0038 QGpgME::CryptoConfigEntry *entry, 0039 const QString &entryName, 0040 QGridLayout *layout, 0041 QWidget *parent) 0042 : CryptoConfigEntryGUI{module, entry, entryName} 0043 , mReaderPort{new ReaderPortSelection{parent}} 0044 { 0045 auto const label = new QLabel{i18nc("@label:listbox Reader for smart cards", "Reader to connect to"), parent}; 0046 label->setBuddy(mReaderPort); 0047 0048 if (entry->isReadOnly()) { 0049 label->setEnabled(false); 0050 mReaderPort->setEnabled(false); 0051 } else { 0052 connect(mReaderPort, &ReaderPortSelection::valueChanged, this, &CryptoConfigEntryReaderPort::slotChanged); 0053 } 0054 0055 const int row = layout->rowCount(); 0056 layout->addWidget(label, row, 1); 0057 layout->addWidget(mReaderPort, row, 2); 0058 } 0059 0060 void CryptoConfigEntryReaderPort::doSave() 0061 { 0062 if (mEntry->isReadOnly()) { 0063 return; 0064 } 0065 mEntry->setStringValue(mReaderPort->value()); 0066 } 0067 0068 void CryptoConfigEntryReaderPort::doLoad() 0069 { 0070 mReaderPort->setValue(mEntry->stringValue()); 0071 } 0072 0073 } // namespace Kleo 0074 0075 #include "moc_cryptoconfigentryreaderport_p.cpp"