allow both QtWebKit and QtWebEngine since a lot of distros are not ready yet for QtWebEngine.

This commit is contained in:
suter_a 2017-04-11 10:38:08 +02:00
parent b1fce70959
commit bfbdb5af4b
3 changed files with 42 additions and 1 deletions

View File

@ -28,7 +28,11 @@
***************************************************************************/
#include <QtWidgets>
#ifdef HAVE_QT_WEB_ENGINE
#include <QWebEngineView>
#else
#include <QtWebKitWidgets>
#endif
#include <QNetworkProxyFactory>
#include <QtDebug>
@ -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"));

View File

@ -32,7 +32,11 @@
#include <QtWidgets>
#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
};

View File

@ -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