QTfrontend/ui/page/pagedata.cpp
changeset 12679 8d266b2d0f9c
parent 12487 eeeb7e8de95c
child 13289 b504131f7405
--- a/QTfrontend/ui/page/pagedata.cpp	Sun Oct 08 16:50:47 2017 +0200
+++ b/QTfrontend/ui/page/pagedata.cpp	Sun Oct 08 19:04:20 2017 +0200
@@ -136,22 +136,34 @@
 void PageDataDownload::pageDownloaded()
 {
     QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender());
+    const char *html =
+        "<center><h2>Hedgewars Downloadable Content</h2><br><br>"
+        "<h4><i>%1</i></h4></center>";
 
-    if (reply && (reply->error() == QNetworkReply::NoError)) {
-        QString html = QString::fromUtf8(reply->readAll());
-        int begin = html.indexOf("<!-- BEGIN -->");
-        int end = html.indexOf("<!-- END -->");
-        if(begin != -1 && begin < end)
+    if (reply) {
+        if (reply->error() == QNetworkReply::NoError)
         {
-            html.truncate(end);
-            html.remove(0, begin);
+            QString html = QString::fromUtf8(reply->readAll());
+                    int begin = html.indexOf("<!-- BEGIN -->");
+                    int end = html.indexOf("<!-- END -->");
+                    if(begin != -1 && begin < end)
+                    {
+                        html.truncate(end);
+                        html.remove(0, begin);
+                    }
+                    web->setHtml(html);
         }
-        web->setHtml(html);
-    } else
-        web->setHtml(QString(
-            "<center><h2>Hedgewars Downloadable Content</h2><br><br>"
-            "<p><i><h4>%1</i></h4></p></center>")
-            .arg(tr("This page requires an internet connection.")));
+        else
+        {
+            QString message = reply->error() == QNetworkReply::UnknownNetworkError ?
+                tr("Unknown network error (possibly missing SSL library).") :
+                QString(tr("This feature requires an Internet connection, but you don't appear to be online (error code: %1).")).arg(reply->error());
+            web->setHtml(QString(html).arg(message));
+        }
+    }
+    else {
+        web->setHtml(QString(html).arg(tr("Internal error: Reply object is invalid.")));
+    }
 }
 
 void PageDataDownload::fileDownloaded()