File indexing completed on 2024-10-06 04:31:43
0001 /*************************************************************************** 0002 * Copyright (C) 2009 Matthias Fuchs <mat69@gmx.net> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify * 0005 * it under the terms of the GNU General Public License as published by * 0006 * the Free Software Foundation; either version 2 of the License, or * 0007 * (at your option) any later version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, * 0010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0012 * GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License * 0015 * along with this program; if not, write to the * 0016 * Free Software Foundation, Inc., * 0017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * 0018 ***************************************************************************/ 0019 0020 #include "verificationpreferences.h" 0021 #include "preferencesdialog.h" 0022 #include "settings.h" 0023 0024 #include <KConfigDialog> 0025 #include <KLineEdit> 0026 #include <KLocalizedString> 0027 #include <KUrlRequester> 0028 0029 VerificationPreferences::VerificationPreferences(PreferencesDialog *parent, Qt::WindowFlags f) 0030 : QWidget(parent, f) 0031 { 0032 ui.setupUi(this); 0033 0034 m_tempKeyServers = Settings::signatureKeyServers(); 0035 ui.keyservers->upButton()->setText(i18n("&Increase Priority")); 0036 ui.keyservers->downButton()->setText(i18n("&Decrease Priority")); 0037 ui.keyservers->setItems(m_tempKeyServers); 0038 0039 #ifndef HAVE_QGPGME 0040 ui.signatureGroup->hide(); 0041 #endif 0042 0043 connect(ui.keyservers, &KEditListWidget::changed, this, &VerificationPreferences::changed); 0044 connect(parent, &KConfigDialog::accepted, this, &VerificationPreferences::slotAccpeted); 0045 connect(parent, &KConfigDialog::rejected, this, &VerificationPreferences::slotRejected); 0046 connect(parent, &PreferencesDialog::resetDefaults, this, &VerificationPreferences::slotDefaultClicked); 0047 } 0048 0049 void VerificationPreferences::slotAccpeted() 0050 { 0051 ui.keyservers->lineEdit()->clear(); 0052 m_tempKeyServers = ui.keyservers->items(); 0053 Settings::self()->setSignatureKeyServers(m_tempKeyServers); 0054 Settings::self()->save(); 0055 } 0056 0057 void VerificationPreferences::slotRejected() 0058 { 0059 // PreferencesDialog is not recreated, so we have to manually stop the 0060 // settings from changing 0061 ui.keyservers->setItems(m_tempKeyServers); 0062 ui.keyservers->lineEdit()->clear(); 0063 } 0064 0065 void VerificationPreferences::slotDefaultClicked() 0066 { 0067 ui.keyservers->lineEdit()->clear(); 0068 KConfigSkeletonItem *item = Settings::self()->findItem("SignatureKeyServers"); 0069 if (item) { 0070 item->readDefault(Settings::self()->config()); 0071 ui.keyservers->setItems(Settings::signatureKeyServers()); 0072 } 0073 } 0074 0075 #include "moc_verificationpreferences.cpp"