diff options
-rw-r--r-- | src/slxbrowser.cpp | 21 | ||||
-rw-r--r-- | src/slxbrowser.h | 1 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/slxbrowser.cpp b/src/slxbrowser.cpp index a8fc1d8..02a3d50 100644 --- a/src/slxbrowser.cpp +++ b/src/slxbrowser.cpp @@ -7,9 +7,10 @@ #include <QProgressBar> SLXbrowser::SLXbrowser(QString url, bool fullscreen, bool ignoreSslErrors, int reloadIntervalSeconds) - : QMainWindow(NULL), + : QMainWindow(nullptr), _url(url), _ignoreSslErrors(ignoreSslErrors), + _unsupportedUri(false), _reloadIntervalMs(reloadIntervalSeconds * 1000) { if (fullscreen) { @@ -68,7 +69,7 @@ void SLXbrowser::loadStarted() void SLXbrowser::loadFinished(bool ok) { _progress->hide(); - if (!_browser->wasAbortedDownload() && !ok) { + if (!_browser->wasAbortedDownload() && !_unsupportedUri && !ok) { _browser->page()->mainFrame()->setHtml("<html><body style='background:blue;color:white'><br><br><center><h1>Page Load Error</h1><pre id='content'></pre></body></html>"); QWebElement el = _browser->page()->mainFrame()->documentElement().findFirst("#content"); QString str; @@ -90,8 +91,15 @@ void SLXbrowser::loadFinished(bool ok) _normalError.clear(); _reset.start(30000); } else if (_reloadIntervalMs > 0) { - _reset.start(_reloadIntervalMs); + _reset.start(_reloadIntervalMs); } + if (_unsupportedUri && !ok) { + QMessageBox::warning(this->parentWidget(), QString::fromUtf8("Denied"), + QString::fromUtf8("This URL type is not supported.\n\n" + "Diese Art Link wird nicht unterstützt.\n\n" + "(z.B. Mail)")); + } + _unsupportedUri = false; } void SLXbrowser::loadProgress(int progress) @@ -110,7 +118,12 @@ void SLXbrowser::sslErrors(QNetworkReply* reply, const QList<QSslError>& errors) void SLXbrowser::requestFinished(QNetworkReply *reply) { - if (reply->error() != QNetworkReply::NoError) { + if (reply->error() == QNetworkReply::NoError) { + _unsupportedUri = false; + } else if (reply->error() == QNetworkReply::ProtocolUnknownError) { + _unsupportedUri = true; + } else { + qDebug() << reply->error(); _normalError = reply->errorString(); } } diff --git a/src/slxbrowser.h b/src/slxbrowser.h index acbb7d8..c036821 100644 --- a/src/slxbrowser.h +++ b/src/slxbrowser.h @@ -29,6 +29,7 @@ private slots: private: QString _url; bool _ignoreSslErrors; + bool _unsupportedUri; WebView *_browser; QProgressBar *_progress; QTimer _reset; |