QTfrontend/ui/page/pagefeedback.cpp
changeset 8383 b557c73a7593
parent 8328 03684c667664
equal deleted inserted replaced
8382:67e257b98422 8383:b557c73a7593
    46 #endif
    46 #endif
    47 
    47 
    48 #include <stdint.h>
    48 #include <stdint.h>
    49 
    49 
    50 #include "pagefeedback.h"
    50 #include "pagefeedback.h"
       
    51 #include "MessageDialog.h"
    51 #include "hwconsts.h"
    52 #include "hwconsts.h"
    52 
    53 
    53 QLayout * PageFeedback::bodyLayoutDefinition()
    54 QLayout * PageFeedback::bodyLayoutDefinition()
    54 {
    55 {
    55     QVBoxLayout * pageLayout = new QVBoxLayout();
    56     QVBoxLayout * pageLayout = new QVBoxLayout();
   142     if (reply == genCaptchaRequest)
   143     if (reply == genCaptchaRequest)
   143     {
   144     {
   144         if (reply->error() != QNetworkReply::NoError)
   145         if (reply->error() != QNetworkReply::NoError)
   145         {
   146         {
   146             qDebug() << "Error generating captcha image: " << reply->errorString();
   147             qDebug() << "Error generating captcha image: " << reply->errorString();
   147             ShowErrorMessage(QMessageBox::tr("Failed to generate captcha"));
   148             MessageDialog::ShowErrorMessage(QMessageBox::tr("Failed to generate captcha"), this);
   148             return;
   149             return;
   149         }
   150         }
   150 
   151 
   151         bool okay;
   152         bool okay;
   152         QByteArray body = reply->readAll();
   153         QByteArray body = reply->readAll();
   153         captchaID = QString(body).toInt(&okay);
   154         captchaID = QString(body).toInt(&okay);
   154 
   155 
   155         if (!okay)
   156         if (!okay)
   156         {
   157         {
   157             qDebug() << "Failed to get captcha ID: " << body;
   158             qDebug() << "Failed to get captcha ID: " << body;
   158             ShowErrorMessage(QMessageBox::tr("Failed to generate captcha"));
   159             MessageDialog::ShowErrorMessage(QMessageBox::tr("Failed to generate captcha"), this);
   159             return;
   160             return;
   160         }
   161         }
   161 
   162 
   162         QString url = "http://hedgewars.org/feedback/?captcha&id=";
   163         QString url = "http://hedgewars.org/feedback/?captcha&id=";
   163         url += QString::number(captchaID);
   164         url += QString::number(captchaID);
   170     else if (reply == captchaImageRequest)
   171     else if (reply == captchaImageRequest)
   171     {
   172     {
   172         if (reply->error() != QNetworkReply::NoError)
   173         if (reply->error() != QNetworkReply::NoError)
   173         {
   174         {
   174             qDebug() << "Error loading captcha image: " << reply->errorString();
   175             qDebug() << "Error loading captcha image: " << reply->errorString();
   175             ShowErrorMessage(QMessageBox::tr("Failed to download captcha"));
   176             MessageDialog::ShowErrorMessage(QMessageBox::tr("Failed to download captcha"), this);
   176             return;
   177             return;
   177         }
   178         }
   178 
   179 
   179         QByteArray imageData = reply->readAll();
   180         QByteArray imageData = reply->readAll();
   180         QPixmap pixmap;
   181         QPixmap pixmap;
   368 void PageFeedback::connectSignals()
   369 void PageFeedback::connectSignals()
   369 {
   370 {
   370     //TODO
   371     //TODO
   371 }
   372 }
   372 
   373 
   373 void PageFeedback::ShowErrorMessage(const QString & msg)
       
   374 {
       
   375     QMessageBox msgMsg(this);
       
   376     msgMsg.setIcon(QMessageBox::Warning);
       
   377     msgMsg.setWindowTitle(QMessageBox::tr("Hedgewars - Error"));
       
   378     msgMsg.setText(msg);
       
   379     msgMsg.setWindowModality(Qt::WindowModal);
       
   380     msgMsg.exec();
       
   381 }
       
   382 
       
   383 void PageFeedback::ShowSpecs()
   374 void PageFeedback::ShowSpecs()
   384 {
   375 {
   385     QMessageBox msgMsg(this);
   376     QMessageBox msgMsg(this);
   386     msgMsg.setIcon(QMessageBox::Information);
   377     msgMsg.setIcon(QMessageBox::Information);
   387     msgMsg.setWindowTitle(QMessageBox::tr("System Information Preview"));
   378     msgMsg.setWindowTitle(QMessageBox::tr("System Information Preview"));