annotate ui/mainwindow.cpp @ 432:16b5cd858571

Updated layout and certificate details in trustbridge installer.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 22 Apr 2014 11:20:13 +0200
parents 09bb19e5e369
children dbcc7740b9d8
rev   line source
404
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 393
diff changeset
1 /* Copyright (C) 2014 by Bundesamt für Sicherheit in der Informationstechnik
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 393
diff changeset
2 * Software engineering by Intevation GmbH
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 393
diff changeset
3 *
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 393
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 393
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 393
diff changeset
6 * See LICENSE.txt for details.
17e1c8f37d72 Add License
Andre Heinecke <aheinecke@intevation.de>
parents: 393
diff changeset
7 */
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8 #include "mainwindow.h"
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10 #include <QDebug>
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
11 #include <QProgressDialog>
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12 #include <QMessageBox>
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13 #include <QSystemTrayIcon>
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 #include <QAction>
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 #include <QDialog>
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 #include <QMenu>
2
cf88cc432b9d Add quit action
Andre Heinecke <aheinecke@intevation.de>
parents: 0
diff changeset
17 #include <QApplication>
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
18 #include <QFile>
19
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
19 #include <QTimer>
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
20 #include <QHBoxLayout>
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
21 #include <QVBoxLayout>
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
22 #include <QGroupBox>
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
23 #include <QSplitter>
205
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
24 #include <QLabel>
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
25 #include <QImage>
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
26 #include <QCheckBox>
19
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
27
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
28 // The amount of time in minutes stay silent if we have
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
29 // something to say
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
30 #define NAG_INTERVAL_MINUTES 60
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31
409
09bb19e5e369 Remove m13 mentions and change test certificate to intevation.de
Andre Heinecke <aheinecke@intevation.de>
parents: 407
diff changeset
32 #ifndef APPNAME
09bb19e5e369 Remove m13 mentions and change test certificate to intevation.de
Andre Heinecke <aheinecke@intevation.de>
parents: 407
diff changeset
33 #define APPNAME "TrustBridge"
09bb19e5e369 Remove m13 mentions and change test certificate to intevation.de
Andre Heinecke <aheinecke@intevation.de>
parents: 407
diff changeset
34 #endif
09bb19e5e369 Remove m13 mentions and change test certificate to intevation.de
Andre Heinecke <aheinecke@intevation.de>
parents: 407
diff changeset
35
09bb19e5e369 Remove m13 mentions and change test certificate to intevation.de
Andre Heinecke <aheinecke@intevation.de>
parents: 407
diff changeset
36 #define SERVER_URL "https://files.intevation.de:443"
09bb19e5e369 Remove m13 mentions and change test certificate to intevation.de
Andre Heinecke <aheinecke@intevation.de>
parents: 407
diff changeset
37 #define LIST_RESOURCE "/users/aheinecke/zertifikatsliste_1.txt"
09bb19e5e369 Remove m13 mentions and change test certificate to intevation.de
Andre Heinecke <aheinecke@intevation.de>
parents: 407
diff changeset
38 #define SW_RESOURCE "/users/aheinecke/zertifikatsliste_1.txt"
72
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
39
7
992c0ec57660 Add unit tests make CertificateList work.
Andre Heinecke <aheinecke@intevation.de>
parents: 2
diff changeset
40 #include "certificatelist.h"
10
fe39d93f1261 Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents: 7
diff changeset
41 #include "downloader.h"
191
246c21b1727f Show the help dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 189
diff changeset
42 #include "helpdialog.h"
200
fe424c5fc875 Show the about dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 191
diff changeset
43 #include "aboutdialog.h"
212
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
44 #include "statusdialog.h"
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
45 #include "certificateitemdelegate.h"
274
90432cb1f374 Added a separator to certificate list to demonstrate how it works.
Raimund Renkert <rrenkert@intevation.de>
parents: 271
diff changeset
46 #include "separatoritemdelegate.h"
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
47 #include "installwrapper.h"
7
992c0ec57660 Add unit tests make CertificateList work.
Andre Heinecke <aheinecke@intevation.de>
parents: 2
diff changeset
48
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
49 MainWindow::MainWindow(bool trayMode):
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
50 mTrayMode(trayMode)
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
51 {
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52 createActions();
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53 createTrayIcon();
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
54 createMenuBar();
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
55 createContent();
45
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 31
diff changeset
56 qRegisterMetaType<SSLConnection::ErrorCode>("SSLConnection::ErrorCode");
265
ffd47b045d19 Added certificate status enum and register it as metatype.
Raimund Renkert <rrenkert@intevation.de>
parents: 250
diff changeset
57 qRegisterMetaType<Certificate::Status>("Certificate::Status");
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
59 connect(mTrayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
60 this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
19
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
61
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
62 mMessageTimer = new QTimer(this);
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
63 connect(mMessageTimer, SIGNAL(timeout()), this, SLOT(showMessage()));
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
64 mMessageTimer->setInterval(NAG_INTERVAL_MINUTES * 60 * 1000);
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
65 mMessageTimer->start();
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
66 checkUpdates();
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
67 loadUnselectedCertificates();
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
68 loadCertificateList();
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
69 if (!trayMode) {
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
70 show();
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
71 }
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
73
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
74 void MainWindow::iconActivated(QSystemTrayIcon::ActivationReason reason)
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
75 {
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
76 switch (reason) {
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
77 case QSystemTrayIcon::Trigger:
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
78 case QSystemTrayIcon::MiddleClick:
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
79 showMessage();
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
80 break;
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
81 case QSystemTrayIcon::DoubleClick:
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
82 show();
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
83 break;
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
84 default:
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
85 ;
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
86 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
87 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
88
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
89 void MainWindow::messageClicked()
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
90 {
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
91 if (mCurState == NewListAvailable) {
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
92 show();
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
93 }
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
94 }
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
95
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
96 void MainWindow::showMessage()
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
97 {
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
98 if (!isVisible() && !mCurMessage.isEmpty()) {
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
99 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage,
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
100 QSystemTrayIcon::Information, 5000);
19
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
101 mMessageTimer->start(); // Restart the timer so that we don't spam
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
102 }
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
103 }
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
104
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
105 void MainWindow::verifyAvailableData()
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
106 {
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
107 QString availableFileName = mSettings.value("List/available").toString();
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
108 QString installedFileName = mSettings.value("List/installed").toString();
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
109 QString swFileName = mSettings.value("Software/available").toString();
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
110
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
111 if (!availableFileName.isEmpty()) {
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
112 mListToInstall.readList(availableFileName.toLocal8Bit().constData());
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
113 if (!mListToInstall.isValid()) {
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 72
diff changeset
114 mCurState = TransferError;
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
115 // Probably a bug when Qt fileName is encoded and cFileName
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
116 // fails because of this. This needs a unit test!
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
117 // Maybe check that the file is in our data directory
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
118 QFile::remove(availableFileName);
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
119 mSettings.remove("List/available");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
120 mSettings.remove("List/availableDate");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
121 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
122 } else {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
123 // Make sure the available notation is also removed
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
124 mSettings.remove("List/available");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
125 mSettings.remove("List/availableDate");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
126 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
127
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
128 if (!installedFileName.isEmpty()) {
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
129 mInstalledList.readList(installedFileName.toLocal8Bit().constData());
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
130 if (!mInstalledList.isValid()) {
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
131 // Probably a bug when Qt fileName is encoded and cFileName
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
132 // fails because of this. This needs a unit test!
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
133 // Maybe check that the file is in our data directory
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
134 QFile::remove(installedFileName);
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
135 mSettings.remove("List/installed");
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
136 mSettings.remove("List/installedDate");
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
137 }
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
138 } else {
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
139 // Make sure the available notation is also removed
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
140 mSettings.remove("List/installed");
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
141 mSettings.remove("List/installedDate");
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
142 }
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
143
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
144 if (!swFileName.isEmpty()) {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
145 // TODO
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
146 } else {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
147 mSettings.remove("Software/available");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
148 mSettings.remove("Software/availableDate");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
149 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
150 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
151
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
152 void MainWindow::handleNewList(const QString& fileName, const QDateTime& modDate) {
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
153 mSettings.setValue("List/available", fileName);
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
154 mSettings.setValue("List/availableDate", modDate);
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
155
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
156 verifyAvailableData();
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
157 if (!mListToInstall.isValid()) {
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
158 /* Downloader provided invalid files */
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
159 /* TODO: Error count. Error handling. Otherwise
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
160 * we can go into an endless loop here */
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
161
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
162 /* Retry the download again in 10 - 20 minutes */
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
163 QTimer::singleShot(600000 + (qrand() % 60000), this, SLOT(checkUpdates()));
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 72
diff changeset
164 } else {
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 72
diff changeset
165 mCurMessage = tr("An updated certificate list is available. Click here to install.");
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 72
diff changeset
166 setState(NewListAvailable);
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 72
diff changeset
167 showMessage();
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
168 loadCertificateList();
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
169 }
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
170 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
171
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
172 void MainWindow::handleNewSW(const QString& fileName, const QDateTime& modDate) {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
173 mCurMessage = tr("An update for %1 is available. Click here to install.").arg(
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
174 QApplication::applicationName());
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
175 setState(NewSoftwareAvailable);
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
176 mSettings.setValue("Software/available", fileName);
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
177 mSettings.setValue("Software/availableDate", modDate);
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
178
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
179 mSettings.sync();
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
180 showMessage();
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
181 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
182
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
183 void MainWindow::checkUpdates()
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
184 {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
185 verifyAvailableData();
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
186
17
c12825a651ed Read out content-length and use this to skip existing files
Andre Heinecke <aheinecke@intevation.de>
parents: 16
diff changeset
187 QDateTime listInstalledLastMod = mSettings.value("List/installedDate").toDateTime();
c12825a651ed Read out content-length and use this to skip existing files
Andre Heinecke <aheinecke@intevation.de>
parents: 16
diff changeset
188 QDateTime swInstalledLastMod = mSettings.value("Software/installedDate").toDateTime();
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
189
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
190 QString listResource = QString::fromLatin1(LIST_RESOURCE);
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
191 QString swResource = QString::fromLatin1(SW_RESOURCE);
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
192
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
193 #ifndef RELEASE_BUILD
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
194 /* Use this for testing to specify another file name for updates */
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
195 listResource = mSettings.value("List/resource", listResource).toString();
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
196 swResource = mSettings.value("Software/resource", swResource).toString();
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
197 #endif
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
198
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
199
72
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
200 Downloader* downloader = new Downloader(this,
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
201 QString::fromLatin1(SERVER_URL),
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
202 QByteArray(),
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
203 QDateTime::currentDateTime(),
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
204 // TODO swInstalledLastMod,
72
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
205 listInstalledLastMod,
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
206 QString::fromLatin1(SW_RESOURCE),
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
207 QString::fromLatin1(LIST_RESOURCE));
17
c12825a651ed Read out content-length and use this to skip existing files
Andre Heinecke <aheinecke@intevation.de>
parents: 16
diff changeset
208
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
209 connect(downloader, SIGNAL(newListAvailable(const QString&, const QDateTime&)),
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
210 this, SLOT(handleNewList(const QString&, const QDateTime&)));
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
211 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
212 this, SLOT(handleNewSW(const QString&, const QDateTime&)));
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
213 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater()));
45
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 31
diff changeset
214 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 31
diff changeset
215 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
10
fe39d93f1261 Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents: 7
diff changeset
216 downloader->start();
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
217 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
218
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
219
45
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 31
diff changeset
220 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error)
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
221 {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
222 mCurMessage = message;
27
62cd56cea09b Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 19
diff changeset
223 showMessage();
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
224 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
225
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
226
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
227 void MainWindow::createActions()
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
228 {
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
229 mCheckUpdates = new QAction(tr("Check for Updates"), this);
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
230 connect(mCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdates()));
2
cf88cc432b9d Add quit action
Andre Heinecke <aheinecke@intevation.de>
parents: 0
diff changeset
231 mQuitAction = new QAction(tr("Quit"), this);
cf88cc432b9d Add quit action
Andre Heinecke <aheinecke@intevation.de>
parents: 0
diff changeset
232 connect(mQuitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
233 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
234
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
235 void MainWindow::createTrayIcon()
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
236 {
11
7e2f14c7aba2 Split up downloader component and further implement it
Andre Heinecke <aheinecke@intevation.de>
parents: 10
diff changeset
237 QIcon trayImg(":/img/tray_22.png");
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
238
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
239 mTrayMenu = new QMenu(this);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
240 mTrayMenu->addAction(mCheckUpdates);
2
cf88cc432b9d Add quit action
Andre Heinecke <aheinecke@intevation.de>
parents: 0
diff changeset
241 mTrayMenu->addAction(mQuitAction);
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
242
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
243 mTrayIcon = new QSystemTrayIcon(this);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
244 mTrayIcon->setContextMenu(mTrayMenu);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
245
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
246 mTrayIcon->setIcon(trayImg);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
247 setWindowIcon(trayImg);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
248 mTrayIcon->show();
407
af53c40e74b1 Rename m13ui to TrustBridge
Andre Heinecke <aheinecke@intevation.de>
parents: 404
diff changeset
249 mTrayIcon->setToolTip(tr("TrustBridge"));
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
250
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
251 connect(mTrayIcon, SIGNAL(messageClicked()), this, SLOT(messageClicked()));
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
252 }
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
253
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
254 void MainWindow::createMenuBar()
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
255 {
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
256 mMenuBar = new QMenuBar(this);
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
257 QMenu *mMenu = new QMenu(tr("Menu"), mMenuBar);
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
258 mMenuBar->addMenu(mMenu);
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
259 QAction *update = mMenu->addAction(tr("Force Update"));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
260 QAction *settings = mMenu->addAction(tr("Settings"));
212
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
261 QAction *status = mMenu->addAction(tr("Statusdialog"));
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
262 mMenu->addSeparator();
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
263 QAction *help = mMenu->addAction(tr("Help"));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
264 QAction *about = mMenu->addAction(tr("About"));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
265 mMenu->addSeparator();
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
266 QAction *quit = mMenu->addAction(tr("Quit"));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
267 connect(update, SIGNAL(triggered()), this, SLOT(checkUpdates()));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
268 connect(settings, SIGNAL(triggered()), this, SLOT(showSettings()));
212
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
269 connect(status, SIGNAL(triggered()), this, SLOT(showStatus()));
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
270 connect(help, SIGNAL(triggered()), this, SLOT(showHelp()));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
271 connect(about, SIGNAL(triggered()), this, SLOT(showAbout()));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
272 connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
273 setMenuBar(mMenuBar);
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
274 }
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
275
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
276 void MainWindow::createContent()
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
277 {
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
278 // Create a central widget containing the main layout.
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
279 QWidget *base = new QWidget;
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
280
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
281 // Layouts and Container
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
282 QHBoxLayout *mainLayout = new QHBoxLayout;
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
283 QVBoxLayout *infoLayout = new QVBoxLayout;
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
284 QVBoxLayout *certLayout = new QVBoxLayout;
432
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
285 QHBoxLayout *detailLayout = new QHBoxLayout;
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
286 QVBoxLayout *detailLabelLayout = new QVBoxLayout;
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
287 QVBoxLayout *detailContentLayout = new QVBoxLayout;
205
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
288 QHBoxLayout *headerLayout = new QHBoxLayout;
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
289 QVBoxLayout *headerTextLayout = new QVBoxLayout;
271
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
290 QHBoxLayout *bottomLayout = new QHBoxLayout;
432
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
291 QVBoxLayout *settingsLayout = new QVBoxLayout;
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
292
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
293 // The certificate list
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
294 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
295 mCertListWidget = new QListWidget;
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
296 mCertListWidget->setItemDelegate(new CertificateItemDelegate);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
297 connect(mCertListWidget, SIGNAL(itemClicked(QListWidgetItem*)),
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
298 this, SLOT(showDetails(QListWidgetItem*)));
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
299 certLayout->addWidget(mCertListWidget);
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
300 certBox->setLayout(certLayout);
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
301
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
302 // The header (icon, about text)
205
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
303 QImage *logoImage = new QImage(":/img/logo.png");
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
304 QLabel *logo = new QLabel;
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
305 logo->setBackgroundRole(QPalette::Base);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
306 logo->setPixmap(QPixmap::fromImage(*logoImage));
409
09bb19e5e369 Remove m13 mentions and change test certificate to intevation.de
Andre Heinecke <aheinecke@intevation.de>
parents: 407
diff changeset
307 QLabel *title = new QLabel("<h2>" + QString::fromLatin1(APPNAME) + "</h2>");
205
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
308 QLabel *subTitle = new QLabel("This Software installs and removes Certificates");
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
309 headerTextLayout->addWidget(title);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
310 headerTextLayout->addWidget(subTitle);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
311 headerLayout->addWidget(logo);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
312 headerLayout->addLayout(headerTextLayout);
210
9c51c472e596 Some mainwindow layout improvements and new icons for certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 205
diff changeset
313 headerLayout->setStretch(0, 0);
9c51c472e596 Some mainwindow layout improvements and new icons for certificate list.
Raimund Renkert <rrenkert@intevation.de>
parents: 205
diff changeset
314 headerLayout->setStretch(1, 10);
205
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
315
271
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
316 // The settings.
432
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
317 QGroupBox *settingsBox = new QGroupBox(tr("Settings"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
318 mAutoUpdateOption = new QCheckBox(tr("Autoupdate"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
319 mAutoStartOption = new QCheckBox(tr("Autostart"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
320 settingsLayout->addWidget(mAutoUpdateOption);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
321 settingsLayout->addWidget(mAutoStartOption);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
322 settingsBox->setLayout(settingsLayout);
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
323 // connect(autoUpdateOption, SIGNAL(stateChanged()), this, SLOT(setAutoUpdate()));
271
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
324
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
325 // The buttons.
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
326 bottomLayout->setAlignment(Qt::AlignBottom);
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
327 installButton = new QPushButton(tr("Install selected"));
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
328 installButton->setFixedHeight(80);
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
329 connect(installButton, SIGNAL(clicked()), this, SLOT(resizeButtons()));
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
330 connect(installButton, SIGNAL(clicked()), this, SLOT(installCerts()));
271
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
331 quitButton = new QPushButton(tr("Quit"));
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
332 quitButton->setFixedHeight(20);
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
333 connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
334 bottomLayout->insertStretch(0, 10);
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
335 bottomLayout->addWidget(installButton);
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
336 bottomLayout->setAlignment(installButton, Qt::AlignBottom);
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
337 bottomLayout->addWidget(quitButton);
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
338 bottomLayout->setAlignment(quitButton, Qt::AlignBottom);
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
339
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
340 // The certificate details
271
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
341 QGroupBox *detailBox = new QGroupBox(tr("Details"));
432
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
342 QLabel *subjectCN = new QLabel(tr("Subject Common Name:"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
343 QLabel *subjectOU = new QLabel(tr("Subject Organisation:"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
344 QLabel *issuerCN = new QLabel(tr("Issuer Common Name:"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
345 QLabel *issuerOU = new QLabel(tr("Issuer Organisation:"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
346 QLabel *validFrom = new QLabel(tr("Valid from:"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
347 QLabel *validTo = new QLabel(tr("Valid to:"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
348 QLabel *fingerprint = new QLabel(tr("Fingerprint:"));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
349 detailLabelLayout->addWidget(subjectCN);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
350 detailLabelLayout->addWidget(subjectOU);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
351 detailLabelLayout->addWidget(issuerCN);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
352 detailLabelLayout->addWidget(issuerOU);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
353 detailLabelLayout->addWidget(validFrom);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
354 detailLabelLayout->addWidget(validTo);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
355 detailLabelLayout->addWidget(fingerprint);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
356 mSubjectCN = new QLabel(tr(""));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
357 mSubjectOU = new QLabel(tr(""));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
358 mIssuerCN = new QLabel(tr(""));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
359 mIssuerOU = new QLabel(tr(""));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
360 mValidFrom = new QLabel(tr(""));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
361 mValidTo = new QLabel(tr(""));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
362 mFingerprint = new QLabel(tr(""));
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
363 detailContentLayout->addWidget(mSubjectCN);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
364 detailContentLayout->addWidget(mSubjectOU);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
365 detailContentLayout->addWidget(mIssuerCN);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
366 detailContentLayout->addWidget(mIssuerOU);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
367 detailContentLayout->addWidget(mValidFrom);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
368 detailContentLayout->addWidget(mValidTo);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
369 detailContentLayout->addWidget(mFingerprint);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
370 detailLayout->addLayout(detailLabelLayout);
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
371 detailLayout->addLayout(detailContentLayout);
271
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
372 detailBox->setLayout(detailLayout);
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
373
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
374 infoLayout->addSpacing(20);
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
375 infoLayout->addLayout(headerLayout);
271
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
376 infoLayout->addWidget(detailBox);
432
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
377 infoLayout->addWidget(settingsBox);
271
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
378 infoLayout->addLayout(bottomLayout);
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
379
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
380 mainLayout->addWidget(certBox);
250
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
381 mainLayout->addLayout(infoLayout);
1e112cf41e92 Updated the mainwindow layout.
Raimund Renkert <rrenkert@intevation.de>
parents: 249
diff changeset
382
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
383
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
384 // QMainWindow allready has a layout. All child layouts and widgets are
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
385 // managed in the central widget.
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
386 base->setLayout(mainLayout);
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
387 setCentralWidget(base);
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
388 }
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
389
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
390 void MainWindow::loadCertificateList()
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
391 {
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
392 mCertListWidget->clear();
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
393 int i = 0;
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
394
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
395 /* TODO: if nothing is available (neither old nor new) add some progress
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
396 * indication */
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
397
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
398 foreach (const Certificate &cert, mListToInstall.isValid() ?
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
399 mListToInstall.getCertificates() :
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
400 mInstalledList.getCertificates()) {
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
401 if (!cert.isValid()) {
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
402 qWarning() << "Invalid certificate in list";
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
403 continue;
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
404 }
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
405 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
274
90432cb1f374 Added a separator to certificate list to demonstrate how it works.
Raimund Renkert <rrenkert@intevation.de>
parents: 271
diff changeset
406 SeparatorItemDelegate *separator = new SeparatorItemDelegate();
432
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
407 item->setData(CertificateItemDelegate::DetailsRole, QVariant::fromValue(cert));
372
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
408 Qt::CheckState checkedState = mPreviouslyUnselected.contains(cert.base64Line()) ?
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
409 Qt::Unchecked : Qt::Checked;
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
410
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
411 bool isOld = mInstalledList.getCertificates().contains(cert);
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
412 qDebug() << "Found old certificate.";
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
413 /* TODO properly work with that information. */
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
414
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
415 if (cert.isInstallCert()) {
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
416 // This if statements is for testing! @TODO Remove this!
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
417 if (isOld) {
375
9e38a4bcd44e Move certificateitem role into the certificateitemdelagate where it belongs.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 372
diff changeset
418 item->setData(CertificateItemDelegate::StatusRole, Certificate::InstallOld);
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
419 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
420 }
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
421 else {
375
9e38a4bcd44e Move certificateitem role into the certificateitemdelagate where it belongs.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 372
diff changeset
422 item->setData(CertificateItemDelegate::StatusRole, Certificate::InstallNew);
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
423 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
424 }
274
90432cb1f374 Added a separator to certificate list to demonstrate how it works.
Raimund Renkert <rrenkert@intevation.de>
parents: 271
diff changeset
425 if (i == 3) {
90432cb1f374 Added a separator to certificate list to demonstrate how it works.
Raimund Renkert <rrenkert@intevation.de>
parents: 271
diff changeset
426 QListWidgetItem *sep = new QListWidgetItem("New certificates");
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
427 mCertListWidget->setItemDelegateForRow(i, separator);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
428 mCertListWidget->addItem(sep);
274
90432cb1f374 Added a separator to certificate list to demonstrate how it works.
Raimund Renkert <rrenkert@intevation.de>
parents: 271
diff changeset
429 i++;
90432cb1f374 Added a separator to certificate list to demonstrate how it works.
Raimund Renkert <rrenkert@intevation.de>
parents: 271
diff changeset
430 }
372
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
431 item->setCheckState(checkedState);
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
432 }
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
433 else {
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
434 // This if statements is for testing! @TODO Remove this!
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
435 if (i > 35) {
375
9e38a4bcd44e Move certificateitem role into the certificateitemdelagate where it belongs.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 372
diff changeset
436 item->setData(CertificateItemDelegate::StatusRole, Certificate::RemoveNew);
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
437 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
372
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
438 item->setCheckState(checkedState);
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
439 }
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
440 else {
375
9e38a4bcd44e Move certificateitem role into the certificateitemdelagate where it belongs.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 372
diff changeset
441 item->setData(CertificateItemDelegate::StatusRole, Certificate::RemoveOld);
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
442 item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
443 }
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
444 }
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
445 mCertListWidget->addItem(item);
267
89e8783866f8 Use the certificate item delegate in the mainwind list view.
Raimund Renkert <rrenkert@intevation.de>
parents: 265
diff changeset
446 i++;
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
447 }
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
448 }
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
449
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
450 void MainWindow::showSettings()
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
451 {
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
452 qDebug() << "show settingsdialog";
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
453 }
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
454
212
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
455 void MainWindow::showStatus()
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
456 {
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
457 qDebug() << "show settingsdialog";
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
458 StatusDialog *status = new StatusDialog(this);
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
459 status->show();
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
460 }
f7176140d20d Added menu entry to show the status dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 210
diff changeset
461
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
462 void MainWindow::showHelp()
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
463 {
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
464 qDebug() << "show helpdialog";
191
246c21b1727f Show the help dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 189
diff changeset
465 HelpDialog *help = new HelpDialog(this);
246c21b1727f Show the help dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 189
diff changeset
466 help->show();
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
467 }
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
468
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
469 void MainWindow::showAbout()
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
470 {
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
471 qDebug() << "show aboutdialog";
200
fe424c5fc875 Show the about dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 191
diff changeset
472 AboutDialog *about = new AboutDialog(this);
fe424c5fc875 Show the about dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 191
diff changeset
473 about->show();
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
474 }
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
475
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
476 void MainWindow::showDetails(QListWidgetItem *item)
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
477 {
432
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
478 Certificate cert = item->data(CertificateItemDelegate::DetailsRole).value<Certificate>();
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
479 mSubjectCN->setText(cert.subjectCN());
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
480 mSubjectOU->setText(cert.subjectOU());
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
481 mIssuerCN->setText(cert.issuerCN());
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
482 mIssuerOU->setText(cert.issuerO());
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
483 mValidFrom->setText(cert.validFrom().toString());
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
484 mValidTo->setText(cert.validTo().toString());
16b5cd858571 Updated layout and certificate details in trustbridge installer.
Raimund Renkert <rrenkert@intevation.de>
parents: 409
diff changeset
485 mFingerprint->setText(cert.fingerprint());
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
486 }
271
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
487
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
488 void MainWindow::resizeButtons()
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
489 {
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
490 installButton->setFixedHeight(20);
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
491 quitButton->setFixedHeight(80);
1ae15ea73850 Some GUI desing and layout changes.
Raimund Renkert <rrenkert@intevation.de>
parents: 267
diff changeset
492 }
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
493
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
494 void MainWindow::installerError(const QString& errMsg) {
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
495 QMessageBox::warning(this, tr("Error executing update"), errMsg);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
496 }
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
497
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
498 void MainWindow::installerSuccess() {
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
499 if (mCurState == NewListAvailable) {
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
500 mCurState = NothingChanged;
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
501 mCurMessage = QString();
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
502
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
503 QString listFileName = mSettings.value("List/available").toString();
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
504 QDateTime listFileDate = mSettings.value("List/availableDate").toDateTime();
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
505
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
506 mSettings.remove("List/available");
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
507 mSettings.remove("List/availableDate");
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
508
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
509 if (listFileName.isEmpty() || !listFileDate.isValid()) {
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
510 qWarning() << "Error accessing settings";
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
511 return; /* Try again with next check */
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
512 }
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
513
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
514 mSettings.setValue("List/installed", listFileName);
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
515 mSettings.setValue("List/installedDate", listFileDate);
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
516 }
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
517 }
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
518
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
519 void MainWindow::installCerts() {
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
520 QStringList choices;
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
521
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
522 for (int i = 0; i < mCertListWidget->count(); i++) {
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
523 QListWidgetItem *item = mCertListWidget->item(i);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
524 if (item->checkState() == Qt::Checked) {
375
9e38a4bcd44e Move certificateitem role into the certificateitemdelagate where it belongs.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 372
diff changeset
525 choices << item->data(CertificateItemDelegate::B64LineRole).toString();
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
526 continue;
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
527 }
375
9e38a4bcd44e Move certificateitem role into the certificateitemdelagate where it belongs.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 372
diff changeset
528 QString certLine = item->data(CertificateItemDelegate::B64LineRole).toString();
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
529 if (certLine.startsWith("I:")) {
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
530 certLine[0] = 'R';
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
531 choices << certLine;
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
532 }
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
533 }
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
534
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
535 QProgressDialog *progress = new QProgressDialog(this);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
536 progress->setWindowModality(Qt::WindowModal);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
537 progress->setLabelText(tr("Installing certificates..."));
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
538 progress->setCancelButton(0);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
539 progress->setRange(0,0);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
540 progress->setMinimumDuration(0);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
541 progress->show();
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
542
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
543 InstallWrapper *instWrap = new InstallWrapper(this,
393
ae2ef965a41b Provide installer with old list in case there are no news
Andre Heinecke <andre.heinecke@intevation.de>
parents: 389
diff changeset
544 mListToInstall.isValid() ?
ae2ef965a41b Provide installer with old list in case there are no news
Andre Heinecke <andre.heinecke@intevation.de>
parents: 389
diff changeset
545 mListToInstall.fileName() :
ae2ef965a41b Provide installer with old list in case there are no news
Andre Heinecke <andre.heinecke@intevation.de>
parents: 389
diff changeset
546 mInstalledList.fileName(),
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
547 choices);
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
548 /* Clean up object and progress dialog */
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
549 connect(instWrap, SIGNAL(finished()), instWrap, SLOT(deleteLater()));
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
550 connect(instWrap, SIGNAL(finished()), progress, SLOT(deleteLater()));
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
551 connect(instWrap, SIGNAL(finished()), progress, SLOT(cancel()));
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
552 connect(instWrap, SIGNAL(installationSuccessful()),
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
553 this, SLOT(installerSuccess()));
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
554 connect(instWrap, SIGNAL(error(const QString &)),
389
3be838c3e4d8 Handle installation success. Save / load last installed list.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 375
diff changeset
555 this, SLOT(installerError(const QString &)));
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
556 instWrap->start();
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
557
372
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
558 if (!saveUnselectedCertificates()) {
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
559 qWarning() << "Failed to save previosly unselected certificates.";
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
560 }
365
75f7288ad67b Switch from listupdatedialog to installwrapper. Minor UI improvements
Andre Heinecke <aheinecke@intevation.de>
parents: 274
diff changeset
561 }
372
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
562
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
563 void MainWindow::loadUnselectedCertificates()
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
564 {
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
565 mPreviouslyUnselected.clear();
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
566 mSettings.beginGroup("unselected");
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
567 QStringList keys = mSettings.allKeys();
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
568 foreach (const QString &key, keys) {
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
569 mPreviouslyUnselected << mSettings.value(key, QString()).toString();
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
570 }
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
571 mSettings.endGroup();
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
572 }
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
573
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
574 bool MainWindow::saveUnselectedCertificates()
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
575 {
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
576 mSettings.beginGroup("unselected");
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
577 mSettings.remove(""); /* Clears old choices */
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
578 for (int i = 0; i < mCertListWidget->count(); i++) {
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
579 QListWidgetItem *item = mCertListWidget->item(i);
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
580 if (item->checkState() != Qt::Checked) {
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
581 mSettings.setValue(QString::fromLatin1("cert%1").arg(i),
375
9e38a4bcd44e Move certificateitem role into the certificateitemdelagate where it belongs.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 372
diff changeset
582 item->data(CertificateItemDelegate::B64LineRole).toString());
372
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
583 }
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
584 }
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
585 mSettings.endGroup();
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
586 mSettings.sync();
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
587 return mSettings.status() == QSettings::NoError;
6cc124e79066 Add save/load unselected and add role enumerator
Andre Heinecke <andre.heinecke@intevation.de>
parents: 365
diff changeset
588 }

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