syncthingtray/widgets/webview/webpage.h

65 lines
2.3 KiB
C
Raw Normal View History

2016-08-25 00:45:32 +02:00
#ifndef WEBPAGE_H
#define WEBPAGE_H
#ifndef SYNCTHINGWIDGETS_NO_WEBVIEW
2016-08-25 00:45:32 +02:00
#include "./webviewdefs.h"
#include "./webviewincludes.h"
2016-08-25 00:45:32 +02:00
#include "../global.h"
2016-08-25 00:45:32 +02:00
QT_FORWARD_DECLARE_CLASS(QAuthenticator)
QT_FORWARD_DECLARE_CLASS(QNetworkReply)
QT_FORWARD_DECLARE_CLASS(QNetworkRequest)
2016-09-01 16:34:30 +02:00
QT_FORWARD_DECLARE_CLASS(QSslError)
2016-08-25 00:45:32 +02:00
namespace QtGui {
2016-09-03 20:14:52 +02:00
class WebViewDialog;
2017-05-01 03:34:43 +02:00
class SYNCTHINGWIDGETS_EXPORT WebPage : public SYNCTHINGWIDGETS_WEB_PAGE {
2016-08-25 00:45:32 +02:00
Q_OBJECT
public:
#ifdef SYNCTHINGWIDGETS_USE_WEBENGINE
WebPage(QWebEngineProfile *profile = nullptr, WebViewDialog *dlg = nullptr, SYNCTHINGWIDGETS_WEB_VIEW *view = nullptr);
#else
WebPage(WebViewDialog *dlg = nullptr, SYNCTHINGWIDGETS_WEB_VIEW *view = nullptr);
#endif
2016-08-25 00:45:32 +02:00
static bool isSamePage(const QUrl &url1, const QUrl &url2);
2016-08-25 00:45:32 +02:00
protected:
2018-10-10 21:26:46 +02:00
SYNCTHINGWIDGETS_WEB_PAGE *createWindow(WebWindowType type) override;
#ifdef SYNCTHINGWIDGETS_USE_WEBENGINE
2018-10-10 21:26:46 +02:00
bool certificateError(const QWebEngineCertificateError &certificateError) override;
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override;
void javaScriptConsoleMessage(
2018-10-10 21:26:46 +02:00
QWebEnginePage::JavaScriptConsoleMessageLevel level, const QString &message, int lineNumber, const QString &sourceID) override;
#else
bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, NavigationType type) override;
void javaScriptConsoleMessage(const QString &message, int lineNumber, const QString &sourceID) override;
2016-09-01 16:34:30 +02:00
#endif
2016-08-25 00:45:32 +02:00
2020-03-08 13:50:32 +01:00
private Q_SLOTS:
void delegateNewWindowToExternalBrowser(const QUrl &url);
2016-08-25 00:45:32 +02:00
void supplyCredentials(const QUrl &requestUrl, QAuthenticator *authenticator);
void supplyCredentials(QNetworkReply *reply, QAuthenticator *authenticator);
void supplyCredentials(QAuthenticator *authenticator);
#ifdef SYNCTHINGWIDGETS_USE_WEBKIT
2016-09-01 16:34:30 +02:00
void handleSslErrors(QNetworkReply *, const QList<QSslError> &errors);
#endif
void injectJavaScripts(bool ok);
void processJavaScriptConsoleMessage(const QString &message);
void injectJavaScript(const QString &scriptSource);
void showFolderPathSelection(const QString &defaultDir);
2016-08-25 00:45:32 +02:00
private:
static bool handleNavigationRequest(const QUrl &currentUrl, const QUrl &url);
2016-09-03 20:14:52 +02:00
WebViewDialog *m_dlg;
SYNCTHINGWIDGETS_WEB_VIEW *m_view;
2016-08-25 00:45:32 +02:00
};
} // namespace QtGui
2016-08-25 00:45:32 +02:00
#endif // SYNCTHINGWIDGETS_NO_WEBVIEW
2016-08-25 00:45:32 +02:00
#endif // WEBPAGE_H