comparison ui/certificatediffdialog.cpp @ 566:8728ae882b6a

Added dialog to show the differences before saving a certificate list.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 22 May 2014 18:29:14 +0200
parents
children
comparison
equal deleted inserted replaced
565:9db7034b2d6c 566:8728ae882b6a
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU GPL (v>=2)
5 * and comes with ABSOLUTELY NO WARRANTY!
6 * See LICENSE.txt for details.
7 */
8 #include "certificatediffdialog.h"
9 #include "administratorwindow.h"
10
11 #include <QDebug>
12 #include <QPushButton>
13 #include <QHBoxLayout>
14 #include <QVBoxLayout>
15 #include <QScrollArea>
16 #include <QLabel>
17
18 CertificateDiffDialog::CertificateDiffDialog(AdministratorWindow *parent) :
19 QDialog(parent),
20 mAdminWindow(parent)
21 {
22 setWindowTitle(tr("TrustBridge - List changes"));
23 setupGUI();
24 resize(560, 200);
25 }
26
27 void CertificateDiffDialog::setupGUI()
28 {
29 /* Top level layout / widgets */
30 QVBoxLayout *topLayout = new QVBoxLayout;
31 QHBoxLayout *buttonLayout = new QHBoxLayout;
32
33 QLabel *header = new QLabel(tr("The following certificates are changed:"));
34
35 QScrollArea *content = new QScrollArea;
36 QList<Certificate> changes = mAdminWindow->currentChanges();
37 QLabel *certLabel = new QLabel;
38 certLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
39 QString certString;
40 foreach(const Certificate& cert, changes) {
41 QString status = cert.isInstallCert() ? tr("New") : tr("Remove");
42 certString += status + ": " +
43 cert.subjectCN() + " " +
44 cert.fingerprint() + "\n";
45 }
46 certLabel->setText(certString);
47
48 content->setWidget(certLabel);
49
50 QPushButton *accept = new QPushButton(tr("Ok"));
51 QPushButton *reject = new QPushButton(tr("Cancel"));
52 connect(accept, SIGNAL(clicked()), this, SLOT(accept()));
53 connect(reject, SIGNAL(clicked()), this, SLOT(reject()));
54
55 buttonLayout->insertStretch(0, 10);
56 buttonLayout->addWidget(accept);
57 buttonLayout->addWidget(reject);
58
59 QFrame *bottomSeparator = new QFrame();
60 bottomSeparator->setFrameShape(QFrame::HLine);
61 bottomSeparator->setFrameShadow(QFrame::Sunken);
62
63 topLayout->addWidget(header);
64 topLayout->addWidget(content);
65 topLayout->addWidget(bottomSeparator);
66 topLayout->addLayout(buttonLayout);
67
68 setLayout(topLayout);
69 }

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