xca/widgets/ExportCert.cpp
Christian Hohnstaedt de851ed3a9 Changed all header includes to QT4 names and included the correct component name
By Andreas Piesk. Thanks!

adapt to HEAD since the patch is based on 0.6.4

drop qt4/Qt include in list of includes during configuration
2010-06-13 11:49:38 +02:00

66 lines
1.6 KiB
C++

/* vi: set sw=4 ts=4:
*
* Copyright (C) 2001 - 2009 Christian Hohnstaedt.
*
* All rights reserved.
*/
#include "ExportCert.h"
#include "lib/base.h"
#include "lib/func.h"
#include <QtGui/QComboBox>
#include <QtGui/QLineEdit>
#include <QtGui/QFileDialog>
#include <QtGui/QMessageBox>
#include <QtCore/QStringList>
ExportCert::ExportCert(QWidget *parent, QString fname, bool hasKey)
:QDialog(parent)
{
setupUi(this);
filename->setText(fname);
setWindowTitle(tr(XCA_TITLE));
QStringList sl;
sl << "PEM" << "PEM with Certificate chain" <<
"PEM all trusted Certificates" << "PEM all Certificates" <<
"DER" << "PKCS #7" << "PKCS #7 with Certificate chain" <<
"PKCS #7 all trusted Certificates" <<"PKCS #7 all Certificates";
if (hasKey) {
sl << "PKCS #12" << "PKCS #12 with Certificate chain" <<
"PEM Cert + key" << "PEM Cert + PKCS8 key";
}
exportFormat->addItems(sl);
}
void ExportCert::on_fileBut_clicked()
{
QString s = QFileDialog::getSaveFileName(this, tr("Save key as"),
filename->text(),
tr("X509 Certificates ( *.cer *.crt *.p12 );;All files ( * )"),
NULL, QFileDialog::DontConfirmOverwrite);
if (!s.isEmpty()) {
QDir::convertSeparators(s);
filename->setText(s);
}
on_exportFormat_activated(0);
}
void ExportCert::on_exportFormat_activated(int c)
{
QStringList suffix;
suffix << "crt" << "crt" << "crt" << "crt" << "cer" << "p7b" <<
"p7b" << "p7b" << "p7b" << "p12" << "p12" << "pem" << "pem";
filename->setText(changeFilenameSuffix(filename->text(), suffix, c));
}
void ExportCert::on_okButton_clicked()
{
if (mayWriteFile(filename->text()))
accept();
}