[PATCH 2 of 2] Added dialog to show the differences before saving a certificate list

Wald Commits scm-commit at wald.intevation.org
Thu May 22 18:29:55 CEST 2014


# HG changeset patch
# User Raimund Renkert <rrenkert at intevation.de>
# Date 1400776154 -7200
# Node ID 8728ae882b6a0045e92092a193a579dd1d4a303f
# Parent  9db7034b2d6cc637443264aeaa918d67b66b91e9
Added dialog to show the differences before saving a certificate list.

diff -r 9db7034b2d6c -r 8728ae882b6a ui/CMakeLists.txt
--- 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}
 )
 
diff -r 9db7034b2d6c -r 8728ae882b6a ui/administratorwindow.cpp
--- 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()
diff -r 9db7034b2d6c -r 8728ae882b6a ui/certificatediffdialog.cpp
--- /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);
+}
diff -r 9db7034b2d6c -r 8728ae882b6a ui/certificatediffdialog.h
--- /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


More information about the Trustbridge-commits mailing list