display a message when network is down or server is not reachable, nemo also made the page refresh at display time 0.9.16
authorkoda
Fri, 14 Oct 2011 19:00:31 +0200
branch0.9.16
changeset 5999 dad168522e3b
parent 5997 a9495e0bd418
child 6001 24b3a7ba3884
display a message when network is down or server is not reachable, nemo also made the page refresh at display time
QTfrontend/hwform.cpp
QTfrontend/pagedata.cpp
--- a/QTfrontend/hwform.cpp	Wed Oct 12 04:14:38 2011 +0200
+++ b/QTfrontend/hwform.cpp	Fri Oct 14 19:00:31 2011 +0200
@@ -471,6 +471,10 @@
 #ifdef USE_XFIRE
     updateXfire();
 #endif
+    if (id == ID_PAGE_DATADOWNLOAD)
+    {
+        ui.pageDataDownload->fetchList();
+    }
     if (id == ID_PAGE_DRAWMAP) {
         DrawMapScene * scene;
         if(lastid == ID_PAGE_MULTIPLAYER)
--- a/QTfrontend/pagedata.cpp	Wed Oct 12 04:14:38 2011 +0200
+++ b/QTfrontend/pagedata.cpp	Fri Oct 14 19:00:31 2011 +0200
@@ -51,7 +51,7 @@
     progressBarsLayout = new QVBoxLayout();
     pageLayout->addLayout(progressBarsLayout, 1, 0, 1, 3);
 
-    fetchList();
+    web->setHtml("<center><h2>Hedgewars Downloadable Content</h2><br><br><i>Loading, please wait</i></center>");
 }
 
 void PageDataDownload::request(const QUrl &url)
@@ -95,7 +95,7 @@
 {
     QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender());
 
-    if(reply)
+    if(reply && (reply->error() == QNetworkReply::NoError))
     {
         QString html = QString::fromUtf8(reply->readAll());
         int begin = html.indexOf("<!-- BEGIN -->");
@@ -107,6 +107,10 @@
         }
         web->setHtml(html);
     }
+    else
+    {
+        web->setHtml("<center><h2>Hedgewars Downloadable Content</h2><br><br><p><i><h4>This page requires an internet connection.</i></h4></center>");
+    }
 }
 
 void PageDataDownload::fileDownloaded()
@@ -146,7 +150,7 @@
 
 void PageDataDownload::fetchList()
 {
-    request(QUrl("http://hedgewars.org/content.html"));
+    request(QUrl("http://www.hedgewars.org/content.html"));
 }
 
 bool PageDataDownload::extractDataPack(QByteArray * buf)