Tell the user if the report couldn't be sent.

This commit is contained in:
dfighter1985 2015-02-20 02:54:05 +01:00
parent dddcf6158c
commit 35eeb4697d
4 changed files with 22 additions and 4 deletions

View file

@ -20,6 +20,7 @@
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QUrl> #include <QUrl>
#include <QNetworkRequest> #include <QNetworkRequest>
#include <QNetworkReply>
namespace namespace
{ {
@ -37,7 +38,7 @@ QObject( parent )
{ {
m_pvt = new RCErrorSocketPvt(); m_pvt = new RCErrorSocketPvt();
connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished() ) ); connect( &m_pvt->mgr, SIGNAL( finished( QNetworkReply* ) ), this, SLOT( onFinished( QNetworkReply* ) ) );
} }
RCErrorSocket::~RCErrorSocket() RCErrorSocket::~RCErrorSocket()
@ -59,8 +60,11 @@ void RCErrorSocket::sendReport( const RCErrorData &data )
m_pvt->mgr.post( request, params.encodedQuery() ); m_pvt->mgr.post( request, params.encodedQuery() );
} }
void RCErrorSocket::onFinished() void RCErrorSocket::onFinished( QNetworkReply *reply )
{ {
Q_EMIT reportSent(); if( reply->error() != QNetworkReply::NoError )
Q_EMIT reportFailed();
else
Q_EMIT reportSent();
} }

View file

@ -24,6 +24,7 @@
#include "rcerror_data.h" #include "rcerror_data.h"
class RCErrorSocketPvt; class RCErrorSocketPvt;
class QNetworkReply;
class RCErrorSocket : public QObject class RCErrorSocket : public QObject
{ {
@ -37,9 +38,10 @@ public:
Q_SIGNALS: Q_SIGNALS:
void reportSent(); void reportSent();
void reportFailed();
private Q_SLOTS: private Q_SLOTS:
void onFinished(); void onFinished( QNetworkReply *reply );
private: private:
RCErrorSocketPvt *m_pvt; RCErrorSocketPvt *m_pvt;

View file

@ -39,6 +39,7 @@ QWidget( parent )
connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) ); connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) );
connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) ); connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) );
connect( m_socket, SIGNAL( reportFailed() ), this, SLOT( onReportFailed() ) );
} }
RCErrorWidget::~RCErrorWidget() RCErrorWidget::~RCErrorWidget()
@ -97,3 +98,13 @@ void RCErrorWidget::onReportSent()
close(); close();
} }
void RCErrorWidget::onReportFailed()
{
QApplication::setOverrideCursor( Qt::ArrowCursor );
QMessageBox::information( this,
tr( "Report failed" ),
tr( "Failed to send the report..." ) );
close();
}

View file

@ -41,6 +41,7 @@ private Q_SLOTS:
void onCBClicked(); void onCBClicked();
void onReportSent(); void onReportSent();
void onReportFailed();
private: private:
Ui::RCErrorWidget m_ui; Ui::RCErrorWidget m_ui;