File indexing completed on 2024-12-08 05:13:59
0001 /* 0002 SPDX-FileCopyrightText: 2002 Jean-Baptiste Mardelle <bj@altern.org> 0003 SPDX-FileCopyrightText: 2007, 2011 Rolf Eike Beer <kde@opensource.sf-tec.de> 0004 SPDX-FileCopyrightText: 2011 Luis Ángel Fernández Fernández <laffdez@gmail.com> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "keyexport.h" 0009 #include <KMessageBox> 0010 0011 KeyExport::KeyExport(QWidget *parent, const QStringList &keyservers) 0012 : QDialog(parent), 0013 Ui_KeyExport() 0014 { 0015 setupUi(this); 0016 0017 buttonBox->button(QDialogButtonBox::Ok)->setShortcut(Qt::CTRL | Qt::Key_Return); 0018 connect(buttonBox, &QDialogButtonBox::accepted, this, &KeyExport::accept); 0019 connect(buttonBox, &QDialogButtonBox::rejected, this, &KeyExport::reject); 0020 newFilename->setWindowTitle(i18n("Save File")); 0021 newFilename->setMode(KFile::File); 0022 0023 if (!keyservers.isEmpty()) { 0024 checkServer->setEnabled(true); 0025 checkServer->setToolTip(QString()); 0026 destServer->addItems(keyservers); 0027 } 0028 0029 connect(checkServer, &QRadioButton::toggled, destServer, &QComboBox::setEnabled); 0030 connect(checkFile, &QRadioButton::toggled, newFilename, &KUrlRequester::setEnabled); 0031 } 0032 0033 void KeyExport::accept() 0034 { 0035 if (checkFile->isChecked()) { 0036 if (QFile::exists(newFilename->url().path().simplified())) { 0037 const QString message = i18n("Overwrite existing file %1?", newFilename->url().fileName()); 0038 int result = KMessageBox::warningContinueCancel(this, message, QString(), KStandardGuiItem::overwrite()); 0039 if (KMessageBox::Cancel == result) 0040 return; 0041 } 0042 } 0043 0044 QDialog::accept(); 0045 }