summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/webview.cpp28
-rw-r--r--src/webview.h8
2 files changed, 35 insertions, 1 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");
diff --git a/src/webview.h b/src/webview.h
index 79b4a64..a03d517 100644
--- a/src/webview.h
+++ b/src/webview.h
@@ -20,7 +20,12 @@ public:
void reset(const QString baseUrl);
protected:
- QWebView *createWindow(QWebPage::WebWindowType);
+ QWebView *createWindow(QWebPage::WebWindowType) override;
+ void mousePressEvent(QMouseEvent*) override;
+ void keyPressEvent(QKeyEvent*) override;
+ void wheelEvent(QWheelEvent*) override;
+
+ void resetTimeout();
signals:
void triggerReset(const QString &message);
@@ -37,6 +42,7 @@ private:
QStack<QUrl> _urls;
QTimer *_timerAbortMessage;
bool _abortedDownload;
+ bool _inErrorState;
QString _token;
QTimer *_timerReset;
};