annotate ui/mainwindow.cpp @ 205:a3f542bf38f7

Added header for mainwindow.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 26 Mar 2014 15:21:34 +0100
parents fe424c5fc875
children 9c51c472e596
rev   line source
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 #include "mainwindow.h"
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 #include <QDebug>
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 #include <QMessageBox>
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5 #include <QSystemTrayIcon>
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 #include <QAction>
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 #include <QDialog>
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8 #include <QMenu>
2
cf88cc432b9d Add quit action
Andre Heinecke <aheinecke@intevation.de>
parents: 0
diff changeset
9 #include <QApplication>
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
10 #include <QFile>
19
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
11 #include <QTimer>
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
12 #include <QHBoxLayout>
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
13 #include <QVBoxLayout>
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
14 #include <QGroupBox>
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
15 #include <QPushButton>
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
16 #include <QSplitter>
205
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
17 #include <QLabel>
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
18 #include <QImage>
19
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
19
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
20 // 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
21 // something to say
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
22 #define NAG_INTERVAL_MINUTES 2
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23
72
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
24 #define SERVER_URL "https://files.kolab.org:443"
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
25 #define LIST_RESOURCE "/incoming/aheinecke/test"
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
26 #define SW_RESOURCE "/incoming/aheinecke/test"
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
27
7
992c0ec57660 Add unit tests make CertificateList work.
Andre Heinecke <aheinecke@intevation.de>
parents: 2
diff changeset
28 #include "certificatelist.h"
10
fe39d93f1261 Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents: 7
diff changeset
29 #include "downloader.h"
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
30 #include "listupdatedialog.h"
191
246c21b1727f Show the help dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 189
diff changeset
31 #include "helpdialog.h"
200
fe424c5fc875 Show the about dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 191
diff changeset
32 #include "aboutdialog.h"
7
992c0ec57660 Add unit tests make CertificateList work.
Andre Heinecke <aheinecke@intevation.de>
parents: 2
diff changeset
33
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 MainWindow::MainWindow() {
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 createActions();
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 createTrayIcon();
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
37 createMenuBar();
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
38 createContent();
45
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 31
diff changeset
39 qRegisterMetaType<SSLConnection::ErrorCode>("SSLConnection::ErrorCode");
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 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
42 this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
19
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
43
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
44 mMessageTimer = new QTimer(this);
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
45 connect(mMessageTimer, SIGNAL(timeout()), this, SLOT(showMessage()));
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
46 mMessageTimer->setInterval(NAG_INTERVAL_MINUTES * 60 * 1000);
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
47 mMessageTimer->start();
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
48 checkUpdates();
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 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
52 {
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53 switch (reason) {
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54 case QSystemTrayIcon::Trigger:
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55 case QSystemTrayIcon::MiddleClick:
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56 showMessage();
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57 break;
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
58 case QSystemTrayIcon::DoubleClick:
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
59 // TODO show menu
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
60 break;
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61 default:
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62 ;
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
63 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
64 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
65
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
66 void MainWindow::messageClicked()
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
67 {
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
68 if (mCurState == NewListAvailable) {
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
69 ListUpdateDialog *listUpdateDialog = new ListUpdateDialog(this,
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
70 mListToInstall);
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
71 listUpdateDialog->show();
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
72 qDebug() << "NewListAvailable";
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
73 }
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
74 }
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
75
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
76 void MainWindow::showMessage()
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
77 {
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
78 if (!mCurMessage.isEmpty()) {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
79 mTrayIcon->showMessage(QApplication::applicationName(), mCurMessage,
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
80 QSystemTrayIcon::Information, 5000);
19
9af6198deb8e Add timed trigger for the message
Andre Heinecke <aheinecke@intevation.de>
parents: 17
diff changeset
81 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
82 }
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
83 }
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
84
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
85 void MainWindow::verifyAvailableData()
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
86 {
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
87 QString listFileName = mSettings.value("List/available").toString();
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
88 QString swFileName = mSettings.value("Software/available").toString();
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
89
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
90 if (!listFileName.isEmpty()) {
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
91 mListToInstall.readList(listFileName.toLocal8Bit().constData());
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
92 if (!mListToInstall.isValid()) {
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 72
diff changeset
93 mCurState = TransferError;
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
94 // 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
95 // 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
96 // Maybe check that the file is in our data directory
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
97 QFile::remove(listFileName);
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
98 mSettings.remove("List/available");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
99 mSettings.remove("List/availableDate");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
100 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
101 } else {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
102 // 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
103 mSettings.remove("List/available");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
104 mSettings.remove("List/availableDate");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
105 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
106
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
107 if (!swFileName.isEmpty()) {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
108 // TODO
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
109 } else {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
110 mSettings.remove("Software/available");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
111 mSettings.remove("Software/availableDate");
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
112 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
113 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
114
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
115 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
116 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
117 mSettings.setValue("List/availableDate", modDate);
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
118
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
119 verifyAvailableData();
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
120 if (!mListToInstall.isValid()) {
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
121 /* 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
122 /* 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
123 * 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
124
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
125 /* 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
126 QTimer::singleShot(600000 + (qrand() % 60000), this, SLOT(checkUpdates()));
82
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 72
diff changeset
127 } else {
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 72
diff changeset
128 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
129 setState(NewListAvailable);
1f27d6db5ee3 Polarssl based certificate handling
Andre Heinecke <aheinecke@intevation.de>
parents: 72
diff changeset
130 showMessage();
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
131 loadCertificateList();
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
132 }
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
133 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
134
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
135 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
136 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
137 QApplication::applicationName());
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
138 setState(NewSoftwareAvailable);
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
139 mSettings.setValue("Software/available", fileName);
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
140 mSettings.setValue("Software/availableDate", modDate);
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
141
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
142 mSettings.sync();
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
143 showMessage();
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
144 }
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
145
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
146 void MainWindow::checkUpdates()
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
147 {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
148 verifyAvailableData();
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
149
17
c12825a651ed Read out content-length and use this to skip existing files
Andre Heinecke <aheinecke@intevation.de>
parents: 16
diff changeset
150 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
151 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
152
72
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
153 Downloader* downloader = new Downloader(this,
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
154 QString::fromLatin1(SERVER_URL),
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
155 QByteArray(),
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
156 QDateTime::currentDateTime(),
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
157 // swInstalledLastMod,
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
158 listInstalledLastMod,
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
159 QString::fromLatin1(SW_RESOURCE),
7e304573ebd1 Add some testing hacks for interactive testing
Andre Heinecke <aheinecke@intevation.de>
parents: 71
diff changeset
160 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
161
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
162 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
163 this, SLOT(handleNewList(const QString&, const QDateTime&)));
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
164 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
165 this, SLOT(handleNewSW(const QString&, const QDateTime&)));
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
166 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
167 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
168 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
10
fe39d93f1261 Start on Downloader component
Andre Heinecke <aheinecke@intevation.de>
parents: 7
diff changeset
169 downloader->start();
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
170 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
171
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
172
45
c6125d73faf4 Move SSLConnection into it's own class
Andre Heinecke <aheinecke@intevation.de>
parents: 31
diff changeset
173 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
174 {
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
175 mCurMessage = message;
27
62cd56cea09b Start on polarssl Downloader.
Andre Heinecke <andre.heinecke@intevation.de>
parents: 19
diff changeset
176 showMessage();
16
225a5ec20dad Use QSettings and manage downloader from mainwindow.
Andre Heinecke <aheinecke@intevation.de>
parents: 11
diff changeset
177 }
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
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
180 void MainWindow::createActions()
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
181 {
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
182 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
183 connect(mCheckUpdates, SIGNAL(triggered()), this, SLOT(checkUpdates()));
2
cf88cc432b9d Add quit action
Andre Heinecke <aheinecke@intevation.de>
parents: 0
diff changeset
184 mQuitAction = new QAction(tr("Quit"), this);
cf88cc432b9d Add quit action
Andre Heinecke <aheinecke@intevation.de>
parents: 0
diff changeset
185 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
186 }
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
187
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
188 void MainWindow::createTrayIcon()
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
189 {
11
7e2f14c7aba2 Split up downloader component and further implement it
Andre Heinecke <aheinecke@intevation.de>
parents: 10
diff changeset
190 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
191
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
192 mTrayMenu = new QMenu(this);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
193 mTrayMenu->addAction(mCheckUpdates);
2
cf88cc432b9d Add quit action
Andre Heinecke <aheinecke@intevation.de>
parents: 0
diff changeset
194 mTrayMenu->addAction(mQuitAction);
0
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
195
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
196 mTrayIcon = new QSystemTrayIcon(this);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
197 mTrayIcon->setContextMenu(mTrayMenu);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
198
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
199 mTrayIcon->setIcon(trayImg);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
200 setWindowIcon(trayImg);
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
201 mTrayIcon->show();
cb0cde2c5eb9 Initial commit. Basically a Hello World with a Tray Icon.
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
202 mTrayIcon->setToolTip(tr("m13ui"));
71
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
203
f22a99f7cb69 Add certificatelist to install as member. Look for updates on startup
Andre Heinecke <aheinecke@intevation.de>
parents: 45
diff changeset
204 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
205 }
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
206
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
207 void MainWindow::createMenuBar()
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
208 {
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
209 mMenuBar = new QMenuBar(this);
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
210 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
211 mMenuBar->addMenu(mMenu);
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
212 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
213 QAction *settings = mMenu->addAction(tr("Settings"));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
214 mMenu->addSeparator();
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
215 QAction *help = mMenu->addAction(tr("Help"));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
216 QAction *about = mMenu->addAction(tr("About"));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
217 mMenu->addSeparator();
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
218 QAction *quit = mMenu->addAction(tr("Quit"));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
219 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
220 connect(settings, SIGNAL(triggered()), this, SLOT(showSettings()));
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
221 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
222 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
223 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
224 setMenuBar(mMenuBar);
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
225 }
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
226
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
227 void MainWindow::createContent()
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
228 {
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
229 // Create a central widget containing the main layout.
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
230 QWidget *base = new QWidget;
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
231
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
232 QVBoxLayout *mainLayout = new QVBoxLayout;
205
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
233 QHBoxLayout *headerLayout = new QHBoxLayout;
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
234 QVBoxLayout *headerTextLayout = new QVBoxLayout;
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
235 QHBoxLayout *certLayout = new QHBoxLayout;
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
236 QHBoxLayout *bottomLayout = new QHBoxLayout;
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
237
205
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
238 QImage *logoImage = new QImage(":/img/logo.png");
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
239 QLabel *logo = new QLabel;
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
240 logo->setBackgroundRole(QPalette::Base);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
241 logo->setScaledContents(true);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
242 logo->setPixmap(QPixmap::fromImage(*logoImage));
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
243 QLabel *title = new QLabel("<h3>" + tr("Certificate Installer") + "</h3>");
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
244 QLabel *subTitle = new QLabel("This Software installs and removes Certificates");
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
245 headerTextLayout->addWidget(title);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
246 headerTextLayout->addWidget(subTitle);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
247 headerLayout->addWidget(logo);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
248 headerLayout->addLayout(headerTextLayout);
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
249
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
250 QGroupBox *certBox = new QGroupBox(tr("Managed Certificates"));
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
251 certificateList = new QListWidget;
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
252 connect(certificateList, SIGNAL(itemClicked(QListWidgetItem*)),
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
253 this, SLOT(showDetails(QListWidgetItem*)));
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
254 certificateDetails = new QTextEdit;
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
255 certificateDetails->setReadOnly(true);
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
256 QSplitter *splitter = new QSplitter(certBox);
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
257 splitter->addWidget(certificateList);
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
258 splitter->addWidget(certificateDetails);
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
259 certLayout->addWidget(splitter);
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
260 certBox->setLayout(certLayout);
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
261
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
262 QPushButton *update = new QPushButton("Search for Updates");
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
263 connect(update, SIGNAL(clicked()), this, SLOT(checkUpdates()));
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
264 bottomLayout->insertStretch(0, 10);
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
265 bottomLayout->addWidget(update);
205
a3f542bf38f7 Added header for mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 200
diff changeset
266 mainLayout->addLayout(headerLayout);
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
267 mainLayout->addWidget(certBox);
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
268 mainLayout->addLayout(bottomLayout);
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
269
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
270 // 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
271 // managed in the central widget.
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
272 base->setLayout(mainLayout);
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
273 setCentralWidget(base);
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
274 }
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
275
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
276 void MainWindow::loadCertificateList()
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
277 {
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
278 qDebug() << "display certificates";
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
279 certificateList->clear();
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
280 foreach (const Certificate &cert, mListToInstall.getInstallCertificates()) {
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
281 if (!cert.isValid()) {
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
282 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
283 continue;
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
284 }
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
285 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
286 item->setData(Qt::UserRole, cert.details());
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
287 QIcon *certIcon = new QIcon(":/img/tray_22.png");
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
288 item->setIcon(*certIcon);
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
289 certificateList->addItem(item);
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
290 }
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
291 foreach (const Certificate& cert, mListToInstall.getRemoveCertificates()) {
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
292 if (!cert.isValid()) {
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
293 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
294 continue;
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
295 }
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
296 QListWidgetItem* item = new QListWidgetItem(cert.shortDescription());
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
297 item->setData(Qt::UserRole, cert.details());
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
298 QIcon *certIcon = new QIcon(":/img/tray_22.png");
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
299 item->setIcon(*certIcon);
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
300 certificateList->addItem(item);
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
301 }
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
302 }
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
303
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
304 void MainWindow::showSettings()
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
305 {
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
306 qDebug() << "show settingsdialog";
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
307 }
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
308
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
309 void MainWindow::showHelp()
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
310 {
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
311 qDebug() << "show helpdialog";
191
246c21b1727f Show the help dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 189
diff changeset
312 HelpDialog *help = new HelpDialog(this);
246c21b1727f Show the help dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 189
diff changeset
313 help->show();
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
314 }
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
315
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
316 void MainWindow::showAbout()
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
317 {
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
318 qDebug() << "show aboutdialog";
200
fe424c5fc875 Show the about dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 191
diff changeset
319 AboutDialog *about = new AboutDialog(this);
fe424c5fc875 Show the about dialog.
Raimund Renkert <rrenkert@intevation.de>
parents: 191
diff changeset
320 about->show();
155
c0fdb8d336cf Added menubar/menu and method stubs to mainwindow.
Raimund Renkert <rrenkert@intevation.de>
parents: 82
diff changeset
321 }
187
0c06a608e15f Create the mainwindow content.
Raimund Renkert <rrenkert@intevation.de>
parents: 155
diff changeset
322
189
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
323 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
324 {
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
325 qDebug() << "show details";
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
326 QString details = item->data(Qt::UserRole).toString();
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
327 certificateDetails->setPlainText(details);
5f0d45ca9de4 Show certificates in the list view and details in the textfield.
Raimund Renkert <rrenkert@intevation.de>
parents: 187
diff changeset
328 }

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