comparison ui/mainwindow.cpp @ 461:1ce835c40eb7

Ask the user if software updates should be installed.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 23 Apr 2014 16:37:17 +0200
parents 37a97621b466
children a8d56a2846a8
comparison
equal deleted inserted replaced
460:f8bed9008362 461:1ce835c40eb7
179 179
180 mSettings.sync(); 180 mSettings.sync();
181 showMessage(); 181 showMessage();
182 } 182 }
183 183
184 void MainWindow::checkUpdates() 184 void MainWindow::checkUpdates(bool downloadSW)
185 { 185 {
186 verifyAvailableData(); 186 verifyAvailableData();
187 187
188 QDateTime listInstalledLastMod = mSettings.value("List/installedDate").toDateTime(); 188 QDateTime listInstalledLastMod = mSettings.value("List/installedDate").toDateTime();
189 QDateTime swInstalledLastMod = mSettings.value("Software/installedDate").toDateTime(); 189 QDateTime swInstalledLastMod = mSettings.value("Software/installedDate").toDateTime();
203 QByteArray(), 203 QByteArray(),
204 QDateTime::currentDateTime(), 204 QDateTime::currentDateTime(),
205 // TODO swInstalledLastMod, 205 // TODO swInstalledLastMod,
206 listInstalledLastMod, 206 listInstalledLastMod,
207 swResource, 207 swResource,
208 listResource); 208 listResource,
209 downloadSW);
209 210
210 connect(downloader, SIGNAL(newListAvailable(const QString&, const QDateTime&)), 211 connect(downloader, SIGNAL(newListAvailable(const QString&, const QDateTime&)),
211 this, SLOT(handleNewList(const QString&, const QDateTime&))); 212 this, SLOT(handleNewList(const QString&, const QDateTime&)));
212 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)), 213 if (!downloadSW) {
213 this, SLOT(handleNewSW(const QString&, const QDateTime&))); 214 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
215 this, SLOT(newSWAvailable(const QString&, const QDateTime&)));
216 }
217 else {
218 connect(downloader, SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&)),
219 this, SLOT(handleNewSW(const QString&, const QDateTime&)));
220 }
214 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater())); 221 connect(downloader, SIGNAL(finished()), downloader, SLOT(deleteLater()));
215 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), 222 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
216 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); 223 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
217 downloader->start(); 224 downloader->start();
218 } 225 }
219 226
227 void MainWindow::newSWAvailable(const QString &fileName, const QDateTime &date) {
228 QMessageBox msgBox;
229 msgBox.setIcon(QMessageBox::Information);
230 msgBox.setText("<h3>" + tr("New Software version is available.") + "</h3>");
231 msgBox.setInformativeText(tr("Do you want to install the new Version?"));
232 msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
233 msgBox.setDefaultButton(QMessageBox::Yes);
234 int selection = msgBox.exec();
235 if (selection == QMessageBox::Yes) {
236 checkUpdates(true);
237 }
238 }
220 239
221 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error) 240 void MainWindow::downloaderError(const QString &message, SSLConnection::ErrorCode error)
222 { 241 {
223 mCurMessage = message; 242 mCurMessage = message;
224 showMessage(); 243 showMessage();

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