changeset 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 9db7034b2d6c
children 75e39c52aa94
files ui/CMakeLists.txt ui/administratorwindow.cpp ui/certificatediffdialog.cpp ui/certificatediffdialog.h
diffstat 4 files changed, 114 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ui/CMakeLists.txt	Thu May 22 18:28:07 2014 +0200
+++ b/ui/CMakeLists.txt	Thu May 22 18:29:14 2014 +0200
@@ -47,6 +47,7 @@
     ${CMAKE_CURRENT_SOURCE_DIR}/createinstallerdialog.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/aboutdialog.cpp
     ${CMAKE_CURRENT_SOURCE_DIR}/createcertlistdialog.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/certificatediffdialog.cpp
     ${CERTIFICATELIST_SOURCES}
 )
 
--- a/ui/administratorwindow.cpp	Thu May 22 18:28:07 2014 +0200
+++ b/ui/administratorwindow.cpp	Thu May 22 18:29:14 2014 +0200
@@ -27,6 +27,7 @@
 #include "certificatetabledelegate.h"
 #include "createinstallerdialog.h"
 #include "createcertlistdialog.h"
+#include "certificatediffdialog.h"
 #include "aboutdialog.h"
 
 AdministratorWindow::AdministratorWindow() {
@@ -153,8 +154,12 @@
 
 void AdministratorWindow::saveCertificateFile()
 {
-    CreateCertListDialog *dialog = new CreateCertListDialog(this);
-    dialog->show();
+    CertificateDiffDialog *diffDialog = new CertificateDiffDialog(this);
+    int ret = diffDialog->exec();
+    if (ret == QDialog::Accepted) {
+        CreateCertListDialog *dialog = new CreateCertListDialog(this);
+        dialog->show();
+    }
 }
 
 void AdministratorWindow::addCertificates()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/certificatediffdialog.cpp	Thu May 22 18:29:14 2014 +0200
@@ -0,0 +1,69 @@
+/* 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 "certificatediffdialog.h"
+#include "administratorwindow.h"
+
+#include <QDebug>
+#include <QPushButton>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QScrollArea>
+#include <QLabel>
+
+CertificateDiffDialog::CertificateDiffDialog(AdministratorWindow *parent) :
+    QDialog(parent),
+    mAdminWindow(parent)
+{
+    setWindowTitle(tr("TrustBridge - List changes"));
+    setupGUI();
+    resize(560, 200);
+}
+
+void CertificateDiffDialog::setupGUI()
+{
+    /* Top level layout / widgets */
+    QVBoxLayout *topLayout = new QVBoxLayout;
+    QHBoxLayout *buttonLayout = new QHBoxLayout;
+
+    QLabel *header = new QLabel(tr("The following certificates are changed:"));
+
+    QScrollArea *content = new QScrollArea;
+    QList<Certificate> changes = mAdminWindow->currentChanges();
+    QLabel *certLabel = new QLabel;
+    certLabel->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
+    QString certString;
+    foreach(const Certificate& cert, changes) {
+        QString status = cert.isInstallCert() ? tr("New") : tr("Remove");
+        certString += status + ": " +
+            cert.subjectCN() + " " +
+            cert.fingerprint() + "\n";
+    }
+    certLabel->setText(certString);
+
+    content->setWidget(certLabel);
+
+    QPushButton *accept = new QPushButton(tr("Ok"));
+    QPushButton *reject = new QPushButton(tr("Cancel"));
+    connect(accept, SIGNAL(clicked()), this, SLOT(accept()));
+    connect(reject, SIGNAL(clicked()), this, SLOT(reject()));
+
+    buttonLayout->insertStretch(0, 10);
+    buttonLayout->addWidget(accept);
+    buttonLayout->addWidget(reject);
+
+    QFrame *bottomSeparator = new QFrame();
+    bottomSeparator->setFrameShape(QFrame::HLine);
+    bottomSeparator->setFrameShadow(QFrame::Sunken);
+
+    topLayout->addWidget(header);
+    topLayout->addWidget(content);
+    topLayout->addWidget(bottomSeparator);
+    topLayout->addLayout(buttonLayout);
+
+    setLayout(topLayout);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ui/certificatediffdialog.h	Thu May 22 18:29:14 2014 +0200
@@ -0,0 +1,37 @@
+/* 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.
+ */
+#ifndef CERTIFICATEDIFFDIALOG_H
+#define CERTIFICATEDIFFDIALOG_H
+
+#include <QDialog>
+#include <QMainWindow>
+
+/**
+ * @file certificatediffdialog.h
+ * @brief The dialog to show the changes made in the certificate list.
+ */
+
+class AdministratorWindow;
+
+class CertificateDiffDialog : public QDialog
+{
+    Q_OBJECT
+public:
+    /** @brief Create a dialog showing the changes made in the certificate list.
+     */
+    CertificateDiffDialog(AdministratorWindow *parent);
+
+private:
+    void setupGUI();
+
+    AdministratorWindow *mAdminWindow;
+
+private slots:
+};
+
+#endif // CERTIFICATEDIFFDIALOG_H

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