From bfbdb5af4b60a1e21a4c8b04f25bdb3ce2cc75f0 Mon Sep 17 00:00:00 2001 From: Andreas Suter Date: Tue, 11 Apr 2017 10:38:08 +0200 Subject: [PATCH] allow both QtWebKit and QtWebEngine since a lot of distros are not ready yet for QtWebEngine. --- src/musredit_qt5/musredit/PHelp.cpp | 15 +++++++++++++++ src/musredit_qt5/musredit/PHelp.h | 8 ++++++++ src/musredit_qt5/musredit/musredit.pro | 20 +++++++++++++++++++- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/musredit_qt5/musredit/PHelp.cpp b/src/musredit_qt5/musredit/PHelp.cpp index 5d261f41..092925af 100644 --- a/src/musredit_qt5/musredit/PHelp.cpp +++ b/src/musredit_qt5/musredit/PHelp.cpp @@ -28,7 +28,11 @@ ***************************************************************************/ #include +#ifdef HAVE_QT_WEB_ENGINE #include +#else +#include +#endif #include #include @@ -55,7 +59,11 @@ PHelp::PHelp(const QString &url, const bool isDarkTheme) : QNetworkProxyFactory::setUseSystemConfiguration(true); +#ifdef HAVE_QT_WEB_ENGINE fView = new QWebEngineView(this); +#else + fView = new QWebView(this); +#endif fView->load(QUrl(url)); connect(fView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(fView, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); @@ -67,10 +75,17 @@ PHelp::PHelp(const QString &url, const bool isDarkTheme) : connect(fLocationEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QToolBar *toolBar = addToolBar(tr("Navigation")); +#ifdef HAVE_QT_WEB_ENGINE toolBar->addAction(fView->pageAction(QWebEnginePage::Back)); toolBar->addAction(fView->pageAction(QWebEnginePage::Forward)); toolBar->addAction(fView->pageAction(QWebEnginePage::Reload)); toolBar->addAction(fView->pageAction(QWebEnginePage::Stop)); +#else + toolBar->addAction(fView->pageAction(QWebPage::Back)); + toolBar->addAction(fView->pageAction(QWebPage::Forward)); + toolBar->addAction(fView->pageAction(QWebPage::Reload)); + toolBar->addAction(fView->pageAction(QWebPage::Stop)); +#endif toolBar->addWidget(fLocationEdit); QMenu *exitMenu = menuBar()->addMenu(tr("&File")); diff --git a/src/musredit_qt5/musredit/PHelp.h b/src/musredit_qt5/musredit/PHelp.h index b2335009..5b1f7b70 100644 --- a/src/musredit_qt5/musredit/PHelp.h +++ b/src/musredit_qt5/musredit/PHelp.h @@ -32,7 +32,11 @@ #include +#ifdef HAVE_QT_WEB_ENGINE class QWebEngineView; +#else +class QWebView; +#endif QT_BEGIN_NAMESPACE class QLineEdit; QT_END_NAMESPACE @@ -60,7 +64,11 @@ class PHelp : public QMainWindow private: bool fDarkTheme; +#ifdef HAVE_QT_WEB_ENGINE QWebEngineView *fView; ///< web viewer +#else + QWebView *fView; ///< web viewer +#endif QLineEdit *fLocationEdit; ///< url address line edit int fProgress; ///< progress value (0-100) while loading an url }; diff --git a/src/musredit_qt5/musredit/musredit.pro b/src/musredit_qt5/musredit/musredit.pro index 3650eb2a..ba2f3e95 100644 --- a/src/musredit_qt5/musredit/musredit.pro +++ b/src/musredit_qt5/musredit/musredit.pro @@ -1,6 +1,19 @@ TEMPLATE = app TARGET = musredit +packagesExist(Qt5WebEngine) { + message("Qt5WebEngine found") + DEFINES += HAVE_QT_WEB_ENGINE + HAVE_QT_WEB_ENGINE = 1 +} +packagesExist(QtWebKit) { + message("QtWebKit found") + HAVE_QT_WEB_ENGINE = 0 +} +isEmpty(HAVE_QT_WEB_ENGINE) { + message("Neither QtWebKit nor Qt5WebEngine found. Something is wrong, please check") +} + QMAKE_CXXFLAGS += -std=c++11 # install path for musredit @@ -71,7 +84,12 @@ CONFIG += qt \ QT += widgets QT += xml -QT += webenginewidgets +isEqual(HAVE_QT_WEB_ENGINE, 1) { + QT += webenginewidgets +} +isEqual(HAVE_QT_WEB_ENGINE, 0) { + QT += webkitwidgets +} QT += network QT += printsupport QT += svg