Add error notification for image upload

This commit is contained in:
lupoDharkael
2017-07-06 13:11:00 +02:00
parent 4e021c6292
commit 0525abe17c
3 changed files with 71 additions and 49 deletions

View File

@@ -37,6 +37,7 @@
#include <QClipboard>
#include <QSettings>
#include <QNetworkReply>
#include <QMessageBox>
#include <QDesktopServices>
// CaptureWidget is the main component used to capture the screen. It contains an
@@ -437,7 +438,18 @@ void CaptureWidget::openURL(QNetworkReply *reply) {
QString data = QString::fromUtf8(reply->readAll());
QString imageID = data.split("\"").at(5);
QString url = QString("http://i.imgur.com/%1.png").arg(imageID);
QDesktopServices::openUrl(url);
bool successful = QDesktopServices::openUrl(url);
if (!successful) {
QMessageBox openErrBox(QMessageBox::Warning, QObject::tr("Resource Error"),
QObject::tr("Unable to open the URL."));
openErrBox.setWindowIcon(QIcon(":img/flameshot.png"));
openErrBox.exec();
}
} else {
QMessageBox netErrBox(QMessageBox::Warning, "Network Error",
reply->errorString());
netErrBox.setWindowIcon(QIcon(":img/flameshot.png"));
netErrBox.exec();
}
close();
}