diff --git a/tray/CMakeLists.txt b/tray/CMakeLists.txt index 19312f5..f038276 100644 --- a/tray/CMakeLists.txt +++ b/tray/CMakeLists.txt @@ -17,7 +17,6 @@ set(WIDGETS_HEADER_FILES gui/settingsdialog.h gui/webpage.h gui/webviewdialog.h - gui/webviewprovider.h gui/dirbuttonsitemdelegate.h gui/devbuttonsitemdelegate.h gui/downloaditemdelegate.h @@ -115,7 +114,7 @@ find_package(c++utilities 4.6.0 REQUIRED) use_cpp_utilities() # find qtutilities -find_package(qtutilities 5.1.0 REQUIRED) +find_package(qtutilities 5.6.0 REQUIRED) use_qt_utilities() # find backend libraries diff --git a/tray/gui/traywidget.h b/tray/gui/traywidget.h index 0cae0dd..44e1602 100644 --- a/tray/gui/traywidget.h +++ b/tray/gui/traywidget.h @@ -1,8 +1,6 @@ #ifndef TRAY_WIDGET_H #define TRAY_WIDGET_H -#include "./webviewprovider.h" - #include "../application/settings.h" #include "../../connector/syncthingconnection.h" diff --git a/tray/gui/webpage.cpp b/tray/gui/webpage.cpp index 07f4b40..4fa7b13 100644 --- a/tray/gui/webpage.cpp +++ b/tray/gui/webpage.cpp @@ -28,8 +28,8 @@ using namespace Data; namespace QtGui { -WebPage::WebPage(WebViewDialog *dlg, WEB_VIEW_PROVIDER *view) : - WEB_PAGE_PROVIDER(view), +WebPage::WebPage(WebViewDialog *dlg, SYNCTHINGTRAY_WEB_VIEW *view) : + SYNCTHINGTRAY_WEB_PAGE(view), m_dlg(dlg), m_view(view) { @@ -52,7 +52,7 @@ WebPage::WebPage(WebViewDialog *dlg, WEB_VIEW_PROVIDER *view) : connect(this->mainFrame(), &QWebFrame::urlChanged, this, &WebPage::delegateNewWindowToExternalBrowser); #endif // -> there need to be a view, though - m_view = new WEB_VIEW_PROVIDER; + m_view = new SYNCTHINGTRAY_WEB_VIEW; m_view->setPage(this); } } @@ -77,7 +77,7 @@ bool WebPage::isSamePage(const QUrl &url1, const QUrl &url2) 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) 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(type) @@ -105,7 +105,7 @@ bool WebPage::acceptNavigationRequest(const QUrl &url, WEB_PAGE_PROVIDER::Naviga } #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(type) diff --git a/tray/gui/webpage.h b/tray/gui/webpage.h index 321cb88..6b6c77c 100644 --- a/tray/gui/webpage.h +++ b/tray/gui/webpage.h @@ -2,15 +2,9 @@ #define WEBPAGE_H #ifndef SYNCTHINGTRAY_NO_WEBVIEW -#include "./webviewprovider.h" +#include "./webviewdefs.h" +#include "./webviewincludes.h" -#if defined(SYNCTHINGTRAY_USE_WEBENGINE) -# include -#elif defined(SYNCTHINGTRAY_USE_WEBKIT) -# include -#endif - -QT_FORWARD_DECLARE_CLASS(WEB_VIEW_PROVIDER) QT_FORWARD_DECLARE_CLASS(QAuthenticator) QT_FORWARD_DECLARE_CLASS(QNetworkReply) QT_FORWARD_DECLARE_CLASS(QNetworkRequest) @@ -20,16 +14,16 @@ namespace QtGui { class WebViewDialog; -class WebPage : public WEB_PAGE_PROVIDER +class WebPage : public SYNCTHINGTRAY_WEB_PAGE { Q_OBJECT 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); protected: - WEB_PAGE_PROVIDER *createWindow(WebWindowType type); + SYNCTHINGTRAY_WEB_PAGE *createWindow(WebWindowType type); #ifdef SYNCTHINGTRAY_USE_WEBENGINE bool certificateError(const QWebEngineCertificateError &certificateError); bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame); @@ -50,7 +44,7 @@ private: static bool handleNavigationRequest(const QUrl ¤tUrl, const QUrl &url); WebViewDialog *m_dlg; - WEB_VIEW_PROVIDER *m_view; + SYNCTHINGTRAY_WEB_VIEW *m_view; }; } diff --git a/tray/gui/webviewdefs.h b/tray/gui/webviewdefs.h new file mode 100644 index 0000000..d5cce5d --- /dev/null +++ b/tray/gui/webviewdefs.h @@ -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 + +#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 diff --git a/tray/gui/webviewdialog.cpp b/tray/gui/webviewdialog.cpp index ac4f8cc..c33aa83 100644 --- a/tray/gui/webviewdialog.cpp +++ b/tray/gui/webviewdialog.cpp @@ -9,12 +9,6 @@ #include #include #include -#if defined(SYNCTHINGTRAY_USE_WEBENGINE) -# include -#elif defined(SYNCTHINGTRAY_USE_WEBKIT) -# include -# include -#endif using namespace Dialogs; @@ -22,14 +16,14 @@ namespace QtGui { WebViewDialog::WebViewDialog(QWidget *parent) : QMainWindow(parent), - m_view(new WEB_VIEW_PROVIDER(this)) + m_view(new SYNCTHINGTRAY_WEB_VIEW(this)) { setWindowTitle(tr("Syncthing")); setWindowIcon(QIcon(QStringLiteral(":/icons/hicolor/scalable/app/syncthingtray.svg"))); setCentralWidget(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) m_view->installEventFilter(this); diff --git a/tray/gui/webviewdialog.h b/tray/gui/webviewdialog.h index 038146c..39840dc 100644 --- a/tray/gui/webviewdialog.h +++ b/tray/gui/webviewdialog.h @@ -2,7 +2,7 @@ #define WEBVIEW_DIALOG_H #ifndef SYNCTHINGTRAY_NO_WEBVIEW -#include "./webviewprovider.h" +#include "./webviewdefs.h" #include "../application/settings.h" @@ -39,7 +39,7 @@ protected: #endif private: - WEB_VIEW_PROVIDER *m_view; + SYNCTHINGTRAY_WEB_VIEW *m_view; Data::SyncthingConnectionSettings m_settings; }; diff --git a/tray/gui/webviewincludes.h b/tray/gui/webviewincludes.h new file mode 100644 index 0000000..8f98c0a --- /dev/null +++ b/tray/gui/webviewincludes.h @@ -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 + +#if defined(SYNCTHINGTRAY_USE_WEBENGINE) +# include +# include +#elif defined(SYNCTHINGTRAY_USE_WEBKIT) +# include +# include +# include +#elif !defined(SYNCTHINGTRAY_NO_WEBVIEW) +# error "No definition for web view provider present." +#endif + +#endif // SYNCTHINGTRAY_WEB_VIEW_INCLUDES diff --git a/tray/gui/webviewprovider.h b/tray/gui/webviewprovider.h deleted file mode 100644 index 1ce8b12..0000000 --- a/tray/gui/webviewprovider.h +++ /dev/null @@ -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