musredit help system if neither QWebEngine nor QWebKit is found.
If neither QWebEngine nor QWebKit is found, do not generate an build error anymore. Instead just show a default window stating that the help system is not available due to missing Qt web libs.
This commit is contained in:
parent
c5c5b16c46
commit
2d3ec33aa1
@ -5,16 +5,20 @@ find_package(Qt5WebEngine QUIET)
|
|||||||
find_package(Qt5WebKit QUIET)
|
find_package(Qt5WebKit QUIET)
|
||||||
|
|
||||||
set(qt_libs Qt5::Core Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Svg Qt5::PrintSupport)
|
set(qt_libs Qt5::Core Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Svg Qt5::PrintSupport)
|
||||||
|
set(Qt5NoWeb 0)
|
||||||
if (Qt5WebEngine_FOUND)
|
if (Qt5WebEngine_FOUND)
|
||||||
message("-- Qt5WebEngine is present.")
|
message("-- Qt5WebEngine is present.")
|
||||||
find_package(Qt5WebEngineWidgets QUIET CONFIG REQUIRED)
|
find_package(Qt5WebEngineWidgets QUIET CONFIG REQUIRED)
|
||||||
set(qt_libs ${qt_libs} Qt5::WebEngine Qt5::WebEngineWidgets)
|
set(qt_libs ${qt_libs} Qt5::WebEngine Qt5::WebEngineWidgets)
|
||||||
|
# unset a potentially found Qt5Webkit
|
||||||
|
unset(Qt5WebKit_FOUND)
|
||||||
elseif (Qt5WebKit_FOUND)
|
elseif (Qt5WebKit_FOUND)
|
||||||
message("-- Qt5WebKit is present.")
|
message("-- Qt5WebKit is present.")
|
||||||
find_package(Qt5WebKitWidgets QUIET CONFIG REQUIRED)
|
find_package(Qt5WebKitWidgets QUIET CONFIG REQUIRED)
|
||||||
set(qt_libs ${qt_libs} Qt5::WebKit Qt5::WebKitWidgets)
|
set(qt_libs ${qt_libs} Qt5::WebKit Qt5::WebKitWidgets)
|
||||||
else (Qt5WebEngine_FOUND)
|
else (Qt5WebEngine_FOUND)
|
||||||
message("-- Neither Qt5WebEngine nor Qt5WebKit found.")
|
message("-- Neither Qt5WebEngine nor Qt5WebKit found.")
|
||||||
|
set(Qt5NoWeb 1)
|
||||||
endif (Qt5WebEngine_FOUND)
|
endif (Qt5WebEngine_FOUND)
|
||||||
|
|
||||||
set(musredit_src
|
set(musredit_src
|
||||||
@ -116,6 +120,15 @@ else (APPLE)
|
|||||||
)
|
)
|
||||||
endif (APPLE)
|
endif (APPLE)
|
||||||
|
|
||||||
|
# set necessary tags depending if QtWebEngine, QtWebKit,
|
||||||
|
# or none of both are given
|
||||||
|
if (Qt5WebKit_FOUND)
|
||||||
|
target_compile_options(musredit
|
||||||
|
BEFORE PRIVATE
|
||||||
|
-DHAVE_QT_WEB_KIT
|
||||||
|
)
|
||||||
|
endif (Qt5WebKit_FOUND)
|
||||||
|
|
||||||
if (Qt5WebEngine_FOUND)
|
if (Qt5WebEngine_FOUND)
|
||||||
target_compile_options(musredit
|
target_compile_options(musredit
|
||||||
BEFORE PRIVATE
|
BEFORE PRIVATE
|
||||||
@ -123,6 +136,13 @@ if (Qt5WebEngine_FOUND)
|
|||||||
)
|
)
|
||||||
endif (Qt5WebEngine_FOUND)
|
endif (Qt5WebEngine_FOUND)
|
||||||
|
|
||||||
|
if (Qt5NoWeb)
|
||||||
|
target_compile_options(musredit
|
||||||
|
BEFORE PRIVATE
|
||||||
|
-DHAVE_QT_NO_WEB
|
||||||
|
)
|
||||||
|
endif (Qt5NoWeb)
|
||||||
|
|
||||||
target_include_directories(musredit
|
target_include_directories(musredit
|
||||||
BEFORE PRIVATE
|
BEFORE PRIVATE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||||
|
@ -30,9 +30,13 @@
|
|||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#ifdef HAVE_QT_WEB_ENGINE
|
#ifdef HAVE_QT_WEB_ENGINE
|
||||||
#include <QWebEngineView>
|
#include <QWebEngineView>
|
||||||
#else
|
#endif
|
||||||
|
#ifdef HAVE_QT_WEB_KIT
|
||||||
#include <QtWebKitWidgets>
|
#include <QtWebKitWidgets>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_QT_NO_WEB
|
||||||
|
#include <QPlainTextEdit>
|
||||||
|
#endif
|
||||||
#include <QNetworkProxyFactory>
|
#include <QNetworkProxyFactory>
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
@ -61,14 +65,24 @@ PHelp::PHelp(const QString &url, const bool isDarkTheme) :
|
|||||||
|
|
||||||
#ifdef HAVE_QT_WEB_ENGINE
|
#ifdef HAVE_QT_WEB_ENGINE
|
||||||
fView = new QWebEngineView(this);
|
fView = new QWebEngineView(this);
|
||||||
#else
|
#endif
|
||||||
|
#ifdef HAVE_QT_WEB_KIT
|
||||||
fView = new QWebView(this);
|
fView = new QWebView(this);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_QT_NO_WEB
|
||||||
|
fView = new QPlainTextEdit(this);
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_QT_NO_WEB
|
||||||
fView->load(QUrl(url));
|
fView->load(QUrl(url));
|
||||||
connect(fView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
|
connect(fView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation()));
|
||||||
connect(fView, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
|
connect(fView, SIGNAL(titleChanged(QString)), SLOT(adjustTitle()));
|
||||||
connect(fView, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
|
connect(fView, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
|
||||||
connect(fView, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
|
connect(fView, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
|
||||||
|
#else
|
||||||
|
fView->setPlainText("Within the current setup there is NO Help available.");
|
||||||
|
fView->appendPlainText("The necessary Qt web libs where not found when setting up musredit.");
|
||||||
|
fView->setReadOnly(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
fLocationEdit = new QLineEdit(this);
|
fLocationEdit = new QLineEdit(this);
|
||||||
fLocationEdit->setSizePolicy(QSizePolicy::Expanding, fLocationEdit->sizePolicy().verticalPolicy());
|
fLocationEdit->setSizePolicy(QSizePolicy::Expanding, fLocationEdit->sizePolicy().verticalPolicy());
|
||||||
@ -80,7 +94,8 @@ PHelp::PHelp(const QString &url, const bool isDarkTheme) :
|
|||||||
toolBar->addAction(fView->pageAction(QWebEnginePage::Forward));
|
toolBar->addAction(fView->pageAction(QWebEnginePage::Forward));
|
||||||
toolBar->addAction(fView->pageAction(QWebEnginePage::Reload));
|
toolBar->addAction(fView->pageAction(QWebEnginePage::Reload));
|
||||||
toolBar->addAction(fView->pageAction(QWebEnginePage::Stop));
|
toolBar->addAction(fView->pageAction(QWebEnginePage::Stop));
|
||||||
#else
|
#endif
|
||||||
|
#ifdef HAVE_QT_WEB_KIT
|
||||||
toolBar->addAction(fView->pageAction(QWebPage::Back));
|
toolBar->addAction(fView->pageAction(QWebPage::Back));
|
||||||
toolBar->addAction(fView->pageAction(QWebPage::Forward));
|
toolBar->addAction(fView->pageAction(QWebPage::Forward));
|
||||||
toolBar->addAction(fView->pageAction(QWebPage::Reload));
|
toolBar->addAction(fView->pageAction(QWebPage::Reload));
|
||||||
@ -127,7 +142,9 @@ void PHelp::done()
|
|||||||
*/
|
*/
|
||||||
void PHelp::adjustLocation()
|
void PHelp::adjustLocation()
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_QT_NO_WEB
|
||||||
fLocationEdit->setText(fView->url().toString());
|
fLocationEdit->setText(fView->url().toString());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@ -138,8 +155,10 @@ void PHelp::adjustLocation()
|
|||||||
void PHelp::changeLocation()
|
void PHelp::changeLocation()
|
||||||
{
|
{
|
||||||
QUrl url = QUrl(fLocationEdit->text());
|
QUrl url = QUrl(fLocationEdit->text());
|
||||||
|
#ifndef HAVE_QT_NO_WEB
|
||||||
fView->load(url);
|
fView->load(url);
|
||||||
fView->setFocus();
|
fView->setFocus();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@ -149,10 +168,12 @@ void PHelp::changeLocation()
|
|||||||
*/
|
*/
|
||||||
void PHelp::adjustTitle()
|
void PHelp::adjustTitle()
|
||||||
{
|
{
|
||||||
|
#ifndef HAVE_QT_NO_WEB
|
||||||
if (fProgress <= 0 || fProgress >= 100)
|
if (fProgress <= 0 || fProgress >= 100)
|
||||||
setWindowTitle(fView->title());
|
setWindowTitle(fView->title());
|
||||||
else
|
else
|
||||||
setWindowTitle(QString("%1 (%2%)").arg(fView->title()).arg(fProgress));
|
setWindowTitle(QString("%1 (%2%)").arg(fView->title()).arg(fProgress));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
|
|
||||||
#ifdef HAVE_QT_WEB_ENGINE
|
#ifdef HAVE_QT_WEB_ENGINE
|
||||||
class QWebEngineView;
|
class QWebEngineView;
|
||||||
#else
|
#endif
|
||||||
|
#ifdef HAVE_QT_WEB_KIT
|
||||||
class QWebView;
|
class QWebView;
|
||||||
#endif
|
#endif
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -66,8 +67,12 @@ class PHelp : public QMainWindow
|
|||||||
bool fDarkTheme;
|
bool fDarkTheme;
|
||||||
#ifdef HAVE_QT_WEB_ENGINE
|
#ifdef HAVE_QT_WEB_ENGINE
|
||||||
QWebEngineView *fView; ///< web viewer
|
QWebEngineView *fView; ///< web viewer
|
||||||
#else
|
#endif
|
||||||
|
#ifdef HAVE_QT_WEB_KIT
|
||||||
QWebView *fView; ///< web viewer
|
QWebView *fView; ///< web viewer
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_QT_NO_WEB
|
||||||
|
QPlainTextEdit *fView; ///< dialog stating that there is NO web viewer
|
||||||
#endif
|
#endif
|
||||||
QLineEdit *fLocationEdit; ///< url address line edit
|
QLineEdit *fLocationEdit; ///< url address line edit
|
||||||
int fProgress; ///< progress value (0-100) while loading an url
|
int fProgress; ///< progress value (0-100) while loading an url
|
||||||
|
Loading…
x
Reference in New Issue
Block a user