diff options
Diffstat (limited to 'src/webview.cpp')
-rw-r--r-- | src/webview.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/webview.cpp b/src/webview.cpp index 17a5261..802a5f8 100644 --- a/src/webview.cpp +++ b/src/webview.cpp @@ -29,6 +29,7 @@ WebView::WebView(QWidget* parent) : QWebView(parent), _timerAbortMessage(new QTimer(this)), _abortedDownload(false), + _inErrorState(false), _timerReset(new QTimer(this)) { this->setPage(new UaWebPage); @@ -63,6 +64,31 @@ QWebView* WebView::createWindow(QWebPage::WebWindowType) return this; } +void WebView::mousePressEvent(QMouseEvent* ev) +{ + QWebView::mousePressEvent(ev); + resetTimeout(); +} + +void WebView::keyPressEvent(QKeyEvent* ev) +{ + QWebView::keyPressEvent(ev); + resetTimeout(); +} + +void WebView::wheelEvent(QWheelEvent* ev) +{ + QWebView::wheelEvent(ev); + resetTimeout(); +} + +void WebView::resetTimeout() +{ + if (!_inErrorState) { + _timerReset->start(60000); + } +} + void WebView::unsupportedContent(QNetworkReply* rep) { _abortedDownload = true; @@ -87,9 +113,11 @@ void WebView::onLoadFinished(bool ok) { if (_abortedDownload || !ok) { _abortedDownload = false; + _inErrorState = true; _timerReset->start(10000); return; } + _inErrorState = false; auto user = this->page()->mainFrame()->documentElement().findFirst("#bwlp-username"); auto pass = this->page()->mainFrame()->documentElement().findFirst("#bwlp-password"); auto err = this->page()->mainFrame()->documentElement().findFirst("#bwlp-error"); |