Use web view defs provided by qtutilities
This commit is contained in:
parent
aa5a057aab
commit
0dbfda37aa
|
@ -17,7 +17,6 @@ set(WIDGETS_HEADER_FILES
|
||||||
gui/settingsdialog.h
|
gui/settingsdialog.h
|
||||||
gui/webpage.h
|
gui/webpage.h
|
||||||
gui/webviewdialog.h
|
gui/webviewdialog.h
|
||||||
gui/webviewprovider.h
|
|
||||||
gui/dirbuttonsitemdelegate.h
|
gui/dirbuttonsitemdelegate.h
|
||||||
gui/devbuttonsitemdelegate.h
|
gui/devbuttonsitemdelegate.h
|
||||||
gui/downloaditemdelegate.h
|
gui/downloaditemdelegate.h
|
||||||
|
@ -115,7 +114,7 @@ find_package(c++utilities 4.6.0 REQUIRED)
|
||||||
use_cpp_utilities()
|
use_cpp_utilities()
|
||||||
|
|
||||||
# find qtutilities
|
# find qtutilities
|
||||||
find_package(qtutilities 5.1.0 REQUIRED)
|
find_package(qtutilities 5.6.0 REQUIRED)
|
||||||
use_qt_utilities()
|
use_qt_utilities()
|
||||||
|
|
||||||
# find backend libraries
|
# find backend libraries
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef TRAY_WIDGET_H
|
#ifndef TRAY_WIDGET_H
|
||||||
#define TRAY_WIDGET_H
|
#define TRAY_WIDGET_H
|
||||||
|
|
||||||
#include "./webviewprovider.h"
|
|
||||||
|
|
||||||
#include "../application/settings.h"
|
#include "../application/settings.h"
|
||||||
|
|
||||||
#include "../../connector/syncthingconnection.h"
|
#include "../../connector/syncthingconnection.h"
|
||||||
|
|
|
@ -28,8 +28,8 @@ using namespace Data;
|
||||||
|
|
||||||
namespace QtGui {
|
namespace QtGui {
|
||||||
|
|
||||||
WebPage::WebPage(WebViewDialog *dlg, WEB_VIEW_PROVIDER *view) :
|
WebPage::WebPage(WebViewDialog *dlg, SYNCTHINGTRAY_WEB_VIEW *view) :
|
||||||
WEB_PAGE_PROVIDER(view),
|
SYNCTHINGTRAY_WEB_PAGE(view),
|
||||||
m_dlg(dlg),
|
m_dlg(dlg),
|
||||||
m_view(view)
|
m_view(view)
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ WebPage::WebPage(WebViewDialog *dlg, WEB_VIEW_PROVIDER *view) :
|
||||||
connect(this->mainFrame(), &QWebFrame::urlChanged, this, &WebPage::delegateNewWindowToExternalBrowser);
|
connect(this->mainFrame(), &QWebFrame::urlChanged, this, &WebPage::delegateNewWindowToExternalBrowser);
|
||||||
#endif
|
#endif
|
||||||
// -> there need to be a view, though
|
// -> there need to be a view, though
|
||||||
m_view = new WEB_VIEW_PROVIDER;
|
m_view = new SYNCTHINGTRAY_WEB_VIEW;
|
||||||
m_view->setPage(this);
|
m_view->setPage(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ bool WebPage::isSamePage(const QUrl &url1, const QUrl &url2)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
WEB_PAGE_PROVIDER *WebPage::createWindow(WEB_PAGE_PROVIDER::WebWindowType type)
|
SYNCTHINGTRAY_WEB_PAGE *WebPage::createWindow(SYNCTHINGTRAY_WEB_PAGE::WebWindowType type)
|
||||||
{
|
{
|
||||||
Q_UNUSED(type)
|
Q_UNUSED(type)
|
||||||
return new WebPage;
|
return new WebPage;
|
||||||
|
@ -97,7 +97,7 @@ bool WebPage::certificateError(const QWebEngineCertificateError &certificateErro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebPage::acceptNavigationRequest(const QUrl &url, WEB_PAGE_PROVIDER::NavigationType type, bool isMainFrame)
|
bool WebPage::acceptNavigationRequest(const QUrl &url, SYNCTHINGTRAY_WEB_PAGE::NavigationType type, bool isMainFrame)
|
||||||
{
|
{
|
||||||
Q_UNUSED(isMainFrame)
|
Q_UNUSED(isMainFrame)
|
||||||
Q_UNUSED(type)
|
Q_UNUSED(type)
|
||||||
|
@ -105,7 +105,7 @@ bool WebPage::acceptNavigationRequest(const QUrl &url, WEB_PAGE_PROVIDER::Naviga
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // SYNCTHINGTRAY_USE_WEBKIT
|
#else // SYNCTHINGTRAY_USE_WEBKIT
|
||||||
bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, WEB_PAGE_PROVIDER::NavigationType type)
|
bool WebPage::acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, SYNCTHINGTRAY_WEB_PAGE::NavigationType type)
|
||||||
{
|
{
|
||||||
Q_UNUSED(frame)
|
Q_UNUSED(frame)
|
||||||
Q_UNUSED(type)
|
Q_UNUSED(type)
|
||||||
|
|
|
@ -2,15 +2,9 @@
|
||||||
#define WEBPAGE_H
|
#define WEBPAGE_H
|
||||||
#ifndef SYNCTHINGTRAY_NO_WEBVIEW
|
#ifndef SYNCTHINGTRAY_NO_WEBVIEW
|
||||||
|
|
||||||
#include "./webviewprovider.h"
|
#include "./webviewdefs.h"
|
||||||
|
#include "./webviewincludes.h"
|
||||||
|
|
||||||
#if defined(SYNCTHINGTRAY_USE_WEBENGINE)
|
|
||||||
# include <QWebEnginePage>
|
|
||||||
#elif defined(SYNCTHINGTRAY_USE_WEBKIT)
|
|
||||||
# include <QWebPage>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(WEB_VIEW_PROVIDER)
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QAuthenticator)
|
QT_FORWARD_DECLARE_CLASS(QAuthenticator)
|
||||||
QT_FORWARD_DECLARE_CLASS(QNetworkReply)
|
QT_FORWARD_DECLARE_CLASS(QNetworkReply)
|
||||||
QT_FORWARD_DECLARE_CLASS(QNetworkRequest)
|
QT_FORWARD_DECLARE_CLASS(QNetworkRequest)
|
||||||
|
@ -20,16 +14,16 @@ namespace QtGui {
|
||||||
|
|
||||||
class WebViewDialog;
|
class WebViewDialog;
|
||||||
|
|
||||||
class WebPage : public WEB_PAGE_PROVIDER
|
class WebPage : public SYNCTHINGTRAY_WEB_PAGE
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
WebPage(WebViewDialog *dlg = nullptr, WEB_VIEW_PROVIDER *view = nullptr);
|
WebPage(WebViewDialog *dlg = nullptr, SYNCTHINGTRAY_WEB_VIEW *view = nullptr);
|
||||||
|
|
||||||
static bool isSamePage(const QUrl &url1, const QUrl &url2);
|
static bool isSamePage(const QUrl &url1, const QUrl &url2);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WEB_PAGE_PROVIDER *createWindow(WebWindowType type);
|
SYNCTHINGTRAY_WEB_PAGE *createWindow(WebWindowType type);
|
||||||
#ifdef SYNCTHINGTRAY_USE_WEBENGINE
|
#ifdef SYNCTHINGTRAY_USE_WEBENGINE
|
||||||
bool certificateError(const QWebEngineCertificateError &certificateError);
|
bool certificateError(const QWebEngineCertificateError &certificateError);
|
||||||
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
|
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);
|
||||||
|
@ -50,7 +44,7 @@ private:
|
||||||
static bool handleNavigationRequest(const QUrl ¤tUrl, const QUrl &url);
|
static bool handleNavigationRequest(const QUrl ¤tUrl, const QUrl &url);
|
||||||
|
|
||||||
WebViewDialog *m_dlg;
|
WebViewDialog *m_dlg;
|
||||||
WEB_VIEW_PROVIDER *m_view;
|
SYNCTHINGTRAY_WEB_VIEW *m_view;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
// Created via CMake from template webviewdefs.h.in
|
||||||
|
// WARNING! Any changes to this file will be overwritten by the next CMake run!
|
||||||
|
|
||||||
|
#ifndef SYNCTHINGTRAY_WEB_VIEW_DEFINES
|
||||||
|
#define SYNCTHINGTRAY_WEB_VIEW_DEFINES
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#if defined(SYNCTHINGTRAY_USE_WEBENGINE)
|
||||||
|
# define SYNCTHINGTRAY_WEB_VIEW QWebEngineView
|
||||||
|
# define SYNCTHINGTRAY_WEB_PAGE QWebEnginePage
|
||||||
|
#elif defined(SYNCTHINGTRAY_USE_WEBKIT)
|
||||||
|
# define SYNCTHINGTRAY_WEB_VIEW QWebView
|
||||||
|
# define SYNCTHINGTRAY_WEB_PAGE QWebPage
|
||||||
|
# define SYNCTHINGTRAY_WEB_FRAME QWebFrame
|
||||||
|
#elif !defined(SYNCTHINGTRAY_NO_WEBVIEW)
|
||||||
|
# error "No definition for web view provider present."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef SYNCTHINGTRAY_WEB_VIEW
|
||||||
|
QT_FORWARD_DECLARE_CLASS(SYNCTHINGTRAY_WEB_VIEW)
|
||||||
|
#endif
|
||||||
|
#ifdef SYNCTHINGTRAY_WEB_PAGE
|
||||||
|
QT_FORWARD_DECLARE_CLASS(SYNCTHINGTRAY_WEB_PAGE)
|
||||||
|
#endif
|
||||||
|
#ifdef SYNCTHINGTRAY_WEB_FRAME
|
||||||
|
QT_FORWARD_DECLARE_CLASS(SYNCTHINGTRAY_WEB_FRAME)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SYNCTHINGTRAY_WEB_VIEW_DEFINES
|
|
@ -9,12 +9,6 @@
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#if defined(SYNCTHINGTRAY_USE_WEBENGINE)
|
|
||||||
# include <QWebEngineView>
|
|
||||||
#elif defined(SYNCTHINGTRAY_USE_WEBKIT)
|
|
||||||
# include <QWebView>
|
|
||||||
# include <QWebFrame>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace Dialogs;
|
using namespace Dialogs;
|
||||||
|
|
||||||
|
@ -22,14 +16,14 @@ namespace QtGui {
|
||||||
|
|
||||||
WebViewDialog::WebViewDialog(QWidget *parent) :
|
WebViewDialog::WebViewDialog(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
m_view(new WEB_VIEW_PROVIDER(this))
|
m_view(new SYNCTHINGTRAY_WEB_VIEW(this))
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Syncthing"));
|
setWindowTitle(tr("Syncthing"));
|
||||||
setWindowIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/app/syncthingtray.svg")));
|
setWindowIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/app/syncthingtray.svg")));
|
||||||
setCentralWidget(m_view);
|
setCentralWidget(m_view);
|
||||||
|
|
||||||
m_view->setPage(new WebPage(this, m_view));
|
m_view->setPage(new WebPage(this, m_view));
|
||||||
connect(m_view, &WEB_VIEW_PROVIDER::titleChanged, this, &WebViewDialog::setWindowTitle);
|
connect(m_view, &SYNCTHINGTRAY_WEB_VIEW::titleChanged, this, &WebViewDialog::setWindowTitle);
|
||||||
|
|
||||||
#if defined(SYNCTHINGTRAY_USE_WEBENGINE)
|
#if defined(SYNCTHINGTRAY_USE_WEBENGINE)
|
||||||
m_view->installEventFilter(this);
|
m_view->installEventFilter(this);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define WEBVIEW_DIALOG_H
|
#define WEBVIEW_DIALOG_H
|
||||||
#ifndef SYNCTHINGTRAY_NO_WEBVIEW
|
#ifndef SYNCTHINGTRAY_NO_WEBVIEW
|
||||||
|
|
||||||
#include "./webviewprovider.h"
|
#include "./webviewdefs.h"
|
||||||
|
|
||||||
#include "../application/settings.h"
|
#include "../application/settings.h"
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WEB_VIEW_PROVIDER *m_view;
|
SYNCTHINGTRAY_WEB_VIEW *m_view;
|
||||||
Data::SyncthingConnectionSettings m_settings;
|
Data::SyncthingConnectionSettings m_settings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
// Created via CMake from template webviewincludes.h.in
|
||||||
|
// WARNING! Any changes to this file will be overwritten by the next CMake run!
|
||||||
|
|
||||||
|
#ifndef SYNCTHINGTRAY_WEB_VIEW_INCLUDES
|
||||||
|
#define SYNCTHINGTRAY_WEB_VIEW_INCLUDES
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#if defined(SYNCTHINGTRAY_USE_WEBENGINE)
|
||||||
|
# include <QWebEngineView>
|
||||||
|
# include <QWebEnginePage>
|
||||||
|
#elif defined(SYNCTHINGTRAY_USE_WEBKIT)
|
||||||
|
# include <QWebView>
|
||||||
|
# include <QWebPage>
|
||||||
|
# include <QWebFrame>
|
||||||
|
#elif !defined(SYNCTHINGTRAY_NO_WEBVIEW)
|
||||||
|
# error "No definition for web view provider present."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // SYNCTHINGTRAY_WEB_VIEW_INCLUDES
|
|
@ -1,11 +0,0 @@
|
||||||
#ifndef WEB_VIEW_PROVIDER
|
|
||||||
|
|
||||||
#if defined(SYNCTHINGTRAY_USE_WEBENGINE)
|
|
||||||
# define WEB_VIEW_PROVIDER QWebEngineView
|
|
||||||
# define WEB_PAGE_PROVIDER QWebEnginePage
|
|
||||||
#elif defined(SYNCTHINGTRAY_USE_WEBKIT)
|
|
||||||
# define WEB_VIEW_PROVIDER QWebView
|
|
||||||
# define WEB_PAGE_PROVIDER QWebPage
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue