blob: 98c596d363d220349b2bd716a2e419abfb27b2d5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#ifndef WEBVIEW_H_
#define WEBVIEW_H_
#include <QStack>
#include <QWebView>
#include <QNetworkRequest>
class QNetworkReply;
class QTimer;
/**
* Make sure pages that want to load in a new tab are actually loaded in the same page,
* and remember the previous URL in case the "new tab" requests to be closed.
*/
class WebView : public QWebView
{
Q_OBJECT
public:
WebView(QWidget* parent = NULL);
void reset(const QString baseUrl);
protected:
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);
void startAuthentication(const QString &user, const QString &pass);
protected slots:
void windowCloseRequested();
void unsupportedContent(QNetworkReply*);
void downloadRequest(QNetworkRequest);
void downloadDeniedMessage();
void onLoadFinished(bool ok);
private:
QStack<QUrl> _urls;
QTimer *_timerAbortMessage;
bool _abortedDownload;
bool _inErrorState;
QString _token;
QTimer *_timerReset;
bool _firstLoad;
};
#endif
|