view ui/createcertlistdialog.cpp @ 412:340b8759d005

Wording und icons in TrustBridge Administration main window.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 16 Apr 2014 17:21:54 +0200
parents 17e1c8f37d72
children 860affe19416
line wrap: on
line source
/* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
 * Software engineering by Intevation GmbH
 *
 * This file is Free Software under the GNU GPL (v>=2)
 * and comes with ABSOLUTELY NO WARRANTY!
 * See LICENSE.txt for details.
 */
#include "createcertlistdialog.h"
#include <QDebug>
#include <QDir>
#include <QPushButton>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QLabel>
#include <QFileDialog>

CreateCertListDialog::CreateCertListDialog(QMainWindow *parent) :
    QDialog(parent)
{
    setWindowTitle(tr("adminstrator - Create signed certificate list"));
    setupGUI();
}

void CreateCertListDialog::setupGUI()
{
    /* Top level layout / widgets */
    QVBoxLayout *topLayout = new QVBoxLayout;
    QHBoxLayout *headerLayout = new QHBoxLayout;
    QVBoxLayout *centerLayout = new QVBoxLayout;
    QHBoxLayout *bottomLayout = new QHBoxLayout;
    QHBoxLayout *certLayout = new QHBoxLayout;
    QHBoxLayout *saveLayout = new QHBoxLayout;

    QString descString = tr("Create a new, signed certificate list.\n");
    descString.append("Select the certificate and destination directory.");
    QLabel *description = new QLabel(descString);
    headerLayout->addWidget(description);

    QLabel *certLabel = new QLabel("Select certificate:");
    certLabel->setFixedWidth(140);
    mCertFile = new QLineEdit();
    QPushButton *certSelect = new QPushButton("...");
    connect(certSelect, SIGNAL(clicked()), this, SLOT(openCertificateSelect()));
    certSelect->setFixedWidth(30);
    certLayout->addWidget(certLabel);
    certLayout->addWidget(mCertFile);
    certLayout->addWidget(certSelect);

    QLabel *saveLabel = new QLabel("Select target location:");
    saveLabel->setFixedWidth(140);
    mSaveFile = new QLineEdit();
    QPushButton *saveSelect = new QPushButton("...");
    connect(saveSelect, SIGNAL(clicked()), this, SLOT(openSaveLocation()));
    saveSelect->setFixedWidth(30);
    saveLayout->addWidget(saveLabel);
    saveLayout->addWidget(mSaveFile);
    saveLayout->addWidget(saveSelect);

    centerLayout->addLayout(certLayout);
    centerLayout->addLayout(saveLayout);

    QPushButton *create = new QPushButton(tr("Create List"));
    connect(create, SIGNAL(clicked()), this, SLOT(createList()));
    bottomLayout->insertStretch(0, 10);
    bottomLayout->addWidget(create);

    topLayout->addLayout(headerLayout);
    topLayout->addLayout(centerLayout);
    topLayout->insertStretch(2, 10);
    topLayout->addLayout(bottomLayout);

    setLayout(topLayout);

    return;
}

void CreateCertListDialog::openCertificateSelect()
{
    QString certFile = QFileDialog::getOpenFileName(
        this, tr("Select certificate"), QDir::homePath(), "*.pem *.der *.crt");
    mCertFile->setText(certFile);
}

void CreateCertListDialog::openSaveLocation()
{
    QString saveFile = QFileDialog::getExistingDirectory(
        this, tr("Select target location"), QDir::homePath());
    mSaveFile->setText(saveFile);
}

void CreateCertListDialog::createList()
{
    qDebug() << "and now create the certificate list using:";
    qDebug() << "certificate: " << mCertFile->text();
    qDebug() << "target" << mSaveFile->text();
    // TODO
}

http://wald.intevation.org/projects/trustbridge/