summaryrefslogtreecommitdiffstats
path: root/src/dialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/dialog.cpp')
-rw-r--r--src/dialog.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index cd2b9b6..aefb6f9 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -571,13 +571,19 @@ void Dialog::addNewsAfterDownload(QNetworkReply* reply) {
return;
}
QDomElement newsNode = doc.firstChildElement("news");
+ QDomElement timeNode = newsNode.firstChildElement("date");
+ QDomElement infoNode = newsNode.firstChildElement("info");
QDateTime timestamp;
- timestamp.setTime_t(newsNode.firstChildElement("date").text().toInt());
+ timestamp.setTime_t(timeNode.text().toInt());
- // 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>"));
+ if (timeNode.isNull() || infoNode.isNull()) {
+ ui->newsTextBrowser->setText(QCoreApplication::instance()->translate("Dialog", "Could not get news. (//news/date or //news/info missing)"));
+ } else {
+ // 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>"
+ + infoNode.text() + "</p>"));
+ }
if (ChooserSettings::getSetting("last-news").toUInt() < timestamp.toTime_t()) {
// show news if not seen before
@@ -640,7 +646,12 @@ void Dialog::addHelpAfterDownload(QNetworkReply* reply) {
return;
}
- ui->helpTextBrowser->setText(QString(data));
+ QDomElement newsNode = doc.firstChildElement("news").firstChildElement("info");
+ if (newsNode.isNull()) {
+ ui->helpTextBrowser->setText(QCoreApplication::instance()->translate("Dialog", "Could not get help (XML has no //news/info)"));
+ } else {
+ ui->helpTextBrowser->setText(newsNode.text());
+ }
// make backup
QFile file(help_backup_filename);