134 |
134 |
135 |
135 |
136 void PageDataDownload::pageDownloaded() |
136 void PageDataDownload::pageDownloaded() |
137 { |
137 { |
138 QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); |
138 QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); |
139 |
139 const char *html = |
140 if (reply && (reply->error() == QNetworkReply::NoError)) { |
140 "<center><h2>Hedgewars Downloadable Content</h2><br><br>" |
141 QString html = QString::fromUtf8(reply->readAll()); |
141 "<h4><i>%1</i></h4></center>"; |
142 int begin = html.indexOf("<!-- BEGIN -->"); |
142 |
143 int end = html.indexOf("<!-- END -->"); |
143 if (reply) { |
144 if(begin != -1 && begin < end) |
144 if (reply->error() == QNetworkReply::NoError) |
145 { |
145 { |
146 html.truncate(end); |
146 QString html = QString::fromUtf8(reply->readAll()); |
147 html.remove(0, begin); |
147 int begin = html.indexOf("<!-- BEGIN -->"); |
148 } |
148 int end = html.indexOf("<!-- END -->"); |
149 web->setHtml(html); |
149 if(begin != -1 && begin < end) |
150 } else |
150 { |
151 web->setHtml(QString( |
151 html.truncate(end); |
152 "<center><h2>Hedgewars Downloadable Content</h2><br><br>" |
152 html.remove(0, begin); |
153 "<p><i><h4>%1</i></h4></p></center>") |
153 } |
154 .arg(tr("This page requires an internet connection."))); |
154 web->setHtml(html); |
|
155 } |
|
156 else |
|
157 { |
|
158 QString message = reply->error() == QNetworkReply::UnknownNetworkError ? |
|
159 tr("Unknown network error (possibly missing SSL library).") : |
|
160 QString(tr("This feature requires an Internet connection, but you don't appear to be online (error code: %1).")).arg(reply->error()); |
|
161 web->setHtml(QString(html).arg(message)); |
|
162 } |
|
163 } |
|
164 else { |
|
165 web->setHtml(QString(html).arg(tr("Internal error: Reply object is invalid."))); |
|
166 } |
155 } |
167 } |
156 |
168 |
157 void PageDataDownload::fileDownloaded() |
169 void PageDataDownload::fileDownloaded() |
158 { |
170 { |
159 QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); |
171 QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); |