Mercurial > trustbridge
annotate ui/createcertlistdialog.cpp @ 446:43090637d6ae
Check if list item is checkable before adding the item to unselected list.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 23 Apr 2014 11:55:28 +0200 |
parents | d1819cd56dee |
children | efd1bd85112f |
rev | line source |
---|---|
404 | 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 */ | |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 #include "createcertlistdialog.h" |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 #include <QDebug> |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 #include <QDir> |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 #include <QPushButton> |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 #include <QGroupBox> |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 #include <QHBoxLayout> |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 #include <QVBoxLayout> |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 #include <QLabel> |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 #include <QFileDialog> |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
17 #include <QStandardPaths> |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
18 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 CreateCertListDialog::CreateCertListDialog(QMainWindow *parent) : |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 QDialog(parent) |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 { |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
22 setWindowTitle(tr("Save certificate list")); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 setupGUI(); |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
24 resize(500, 200); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 } |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 void CreateCertListDialog::setupGUI() |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 { |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 /* Top level layout / widgets */ |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 QVBoxLayout *topLayout = new QVBoxLayout; |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
31 QVBoxLayout *headerLayout = new QVBoxLayout; |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
32 QHBoxLayout *headerSubLayout = new QHBoxLayout; |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
33 QHBoxLayout *centerLayout = new QHBoxLayout; |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 QHBoxLayout *bottomLayout = new QHBoxLayout; |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
35 QVBoxLayout *labelLayout = new QVBoxLayout; |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
36 QVBoxLayout *fieldLayout = new QVBoxLayout; |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
37 QVBoxLayout *buttonLayout = new QVBoxLayout; |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
39 QLabel *header = new QLabel("<h3>" + tr("Save certificate list") + "</h3>"); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
40 QLabel *description = new QLabel( |
426
d7cda835abd6
Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents:
417
diff
changeset
|
41 tr("Save all managed root certificates in a new, signed certificate list.")); |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
42 headerSubLayout->insertSpacing(0, 40); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
43 headerSubLayout->addWidget(description); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
44 QFrame *headerSeparator = new QFrame(); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
45 headerSeparator->setFrameShape(QFrame::HLine); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
46 headerSeparator->setFrameShadow(QFrame::Sunken); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
47 headerLayout->addWidget(header); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
48 headerLayout->addLayout(headerSubLayout); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
49 headerLayout->addWidget(headerSeparator); |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
50 headerLayout->insertSpacing(3, 10); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
52 QLabel *certLabel = new QLabel("Select signature certificate (secret key):"); |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
53 QLabel *saveLabel = new QLabel("Select output folder:"); |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
54 labelLayout->addWidget(certLabel); |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
55 labelLayout->addWidget(saveLabel); |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
56 |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 mCertFile = new QLineEdit(); |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
58 mSaveFile = new QLineEdit(); |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
59 fieldLayout->addWidget(mCertFile); |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
60 fieldLayout->addWidget(mSaveFile); |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
61 |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 QPushButton *certSelect = new QPushButton("..."); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 certSelect->setFixedWidth(30); |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
64 connect(certSelect, SIGNAL(clicked()), this, SLOT(openCertificateSelect())); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 QPushButton *saveSelect = new QPushButton("..."); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 connect(saveSelect, SIGNAL(clicked()), this, SLOT(openSaveLocation())); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 saveSelect->setFixedWidth(30); |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
68 buttonLayout->addWidget(certSelect); |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
69 buttonLayout->addWidget(saveSelect); |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
70 |
426
d7cda835abd6
Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents:
417
diff
changeset
|
71 QString footerText = tr("In addition, each certificate list will be saved " |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
72 "automatically in the archive directory:\n"); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
73 // TODO print out the path, not the displayName. |
426
d7cda835abd6
Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents:
417
diff
changeset
|
74 footerText.append(QStandardPaths::writableLocation( |
d7cda835abd6
Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents:
417
diff
changeset
|
75 QStandardPaths::DataLocation)); |
d7cda835abd6
Some wording and Layout in TrustBridge Administration.
Raimund Renkert <rrenkert@intevation.de>
parents:
417
diff
changeset
|
76 //footerText.append(QStandardPaths::displayName(QStandardPaths::DataLocation)); |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
77 QLabel *footer = new QLabel(footerText); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
78 |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
79 centerLayout->addLayout(labelLayout); |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
80 centerLayout->addLayout(fieldLayout); |
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
81 centerLayout->addLayout(buttonLayout); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
83 QPushButton *create = new QPushButton(tr("Save list")); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
84 connect(create, SIGNAL(clicked()), this, SLOT(createList())); |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
85 QPushButton *cancel = new QPushButton(tr("Cancel")); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
86 connect(cancel, SIGNAL(clicked()), this, SLOT(close())); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
87 bottomLayout->insertStretch(0, 10); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 bottomLayout->addWidget(create); |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
89 bottomLayout->addWidget(cancel); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
90 |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
91 QFrame *bottomSeparator = new QFrame(); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
92 bottomSeparator->setFrameShape(QFrame::HLine); |
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
93 bottomSeparator->setFrameShadow(QFrame::Sunken); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
94 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
95 topLayout->addLayout(headerLayout); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
96 topLayout->addLayout(centerLayout); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
97 topLayout->insertStretch(2, 10); |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
98 topLayout->addWidget(footer); |
428
d1819cd56dee
Updated dialog layout.
Raimund Renkert <rrenkert@intevation.de>
parents:
426
diff
changeset
|
99 topLayout->insertSpacing(4, 10); |
413
860affe19416
Wording und Layout in TrustBridge create certificate file dialog.
Raimund Renkert <rrenkert@intevation.de>
parents:
404
diff
changeset
|
100 topLayout->addWidget(bottomSeparator); |
367
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
101 topLayout->addLayout(bottomLayout); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
102 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 setLayout(topLayout); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
104 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 return; |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 } |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 void CreateCertListDialog::openCertificateSelect() |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
109 { |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
110 QString certFile = QFileDialog::getOpenFileName( |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 this, tr("Select certificate"), QDir::homePath(), "*.pem *.der *.crt"); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
112 mCertFile->setText(certFile); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
113 } |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
114 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
115 void CreateCertListDialog::openSaveLocation() |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
116 { |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
117 QString saveFile = QFileDialog::getExistingDirectory( |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
118 this, tr("Select target location"), QDir::homePath()); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
119 mSaveFile->setText(saveFile); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
120 } |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
121 |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
122 void CreateCertListDialog::createList() |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
123 { |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
124 qDebug() << "and now create the certificate list using:"; |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
125 qDebug() << "certificate: " << mCertFile->text(); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
126 qDebug() << "target" << mSaveFile->text(); |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
127 // TODO |
9491782a8f5a
Added dialog to create a signed certificate list file.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
128 } |