summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-03-24 16:10:16 +0100
committerNils Schwabe2014-03-24 16:10:16 +0100
commit24aaf7978b1c4c685f086641ab5794a5b5ea3541 (patch)
tree5402e7459055eb3b68709035eaca29af6e50785f /src/dialog.cpp
parentadded choosersettings which remember the last selected session (diff)
downloadvmchooser2-24aaf7978b1c4c685f086641ab5794a5b5ea3541.tar.gz
vmchooser2-24aaf7978b1c4c685f086641ab5794a5b5ea3541.tar.xz
vmchooser2-24aaf7978b1c4c685f086641ab5794a5b5ea3541.zip
added news and help download
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index 9fdbaa9..4e65d16 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -7,6 +7,7 @@
#include <QProcess>
#include <QTimer>
#include <QDesktopWidget>
+#include <QDateTime>
#include "ui_dialog.h"
#include "sessiontreeitem.h"
@@ -483,3 +484,51 @@ void Dialog::on_helpNewsButton_clicked() {
ui->newsBox->show();
}
}
+
+void Dialog::addNewsAfterDownload(QNetworkReply* reply) {
+ if (reply->error() != QNetworkReply::NoError) {
+ if (debugMode) {
+ qDebug() << "Could not get news.";
+ }
+ return;
+ }
+ QByteArray data = reply->readAll();
+ QDomDocument doc;
+ if (!doc.setContent(data)) {
+ qDebug() << "News XML contains errors.";
+ return;
+ }
+ QDomElement newsNode = doc.firstChildElement("news");
+ QDateTime timestamp;
+ timestamp.setTime_t(newsNode.firstChildElement("date").text().toInt());
+
+ if (ChooserSettings::getSetting("last-news").toUInt() > timestamp.toTime_t()) {
+ return;
+ }
+
+ // format and print news
+ ui->newsTextBrowser->setText(QString("<p style='font-size:16px; margin-bottom: 2px;'>" + newsNode.firstChildElement("headline").text() + "</p> <small>"
+ + timestamp.toString(Qt::SystemLocaleShortDate) + "</small><p>"
+ + newsNode.firstChildElement("info").text() + "</p>"));
+
+ on_helpNewsButton_clicked();
+}
+
+void Dialog::addHelpAfterDownload(QNetworkReply* reply) {
+ if (reply->error() != QNetworkReply::NoError) {
+ if (debugMode) {
+ qDebug() << "Could not get news.";
+ }
+ return;
+ }
+ QByteArray data = reply->readAll();
+
+ QDomDocument doc;
+ if (!doc.setContent(data)) {
+ qDebug() << "Help file contains errors.";
+ return;
+ }
+
+ ui->helpTextBrowser->setText(QString(data));
+
+}