check for network for feedback dialog too
authorkoda
Sat, 06 Apr 2013 01:11:49 +0200
changeset 8878 b03dc99f2f2e
parent 8876 bd8df772dbe6
child 8880 71ed64b18540
check for network for feedback dialog too
QTfrontend/hwform.cpp
QTfrontend/hwform.h
--- a/QTfrontend/hwform.cpp	Sat Apr 06 01:02:28 2013 +0200
+++ b/QTfrontend/hwform.cpp	Sat Apr 06 01:11:49 2013 +0200
@@ -2010,8 +2010,22 @@
 
 void HWForm::showFeedbackDialog()
 {
-    FeedbackDialog dialog(this);
-    dialog.exec();
+    QNetworkRequest newRequest(QUrl("http://www.hedgewars.org"));
+
+    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
+    QNetworkReply *reply = manager->get(newRequest);
+    connect(reply, SIGNAL(finished()), this, SLOT(showFeedbackDialogNetChecked()));
+}
+
+void HWForm::showFeedbackDialogNetChecked()
+{
+    QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
+
+    if (reply && (reply->error() == QNetworkReply::NoError)) {
+        FeedbackDialog dialog(this);
+        dialog.exec();
+    } else
+        MessageDialog::ShowErrorMessage(tr("This page requires an internet connection."), this);
 }
 
 void HWForm::startGame()
--- a/QTfrontend/hwform.h	Sat Apr 06 01:02:28 2013 +0200
+++ b/QTfrontend/hwform.h	Sat Apr 06 01:11:49 2013 +0200
@@ -129,6 +129,7 @@
         void UpdateCampaignPageProgress(int index);
         void InitCampaignPage();
         void showFeedbackDialog();
+        void showFeedbackDialogNetChecked();
 
         void NetGameChangeStatus(bool isMaster);
         void NetGameMaster();