Commit 7270636c authored by Eike Ziller's avatar Eike Ziller

Help/OS X: Use native viewer by default if welcome uses QQuickWidget

Since using window container breaks the native view hierarchy
(QTBUG-39363), we can use the native viewer only if we use QQuickWidget
for the welcome screen.

Task-number: QTBUG-39363
Change-Id: I26407a5c1db558d9a8ac6d79c37e3ffa0e009ed6
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
parent ee635941
......@@ -67,9 +67,13 @@ osx {
QT += macextras
HEADERS += macwebkithelpviewer.h
OBJECTIVE_SOURCES += macwebkithelpviewer.mm
LIBS += -framework WebKit -framework AppKit
!isEmpty(USE_QUICK_WIDGET) {
DEFINES += QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
}
}
RESOURCES += help.qrc
include(../../shared/help/help.pri)
......@@ -95,6 +95,8 @@
#include <QHelpEngine>
#include <functional>
using namespace Help::Internal;
static const char kExternalWindowStateKey[] = "Help/ExternalWindowState";
......@@ -355,21 +357,37 @@ HelpViewer *HelpPlugin::externalHelpViewer()
HelpViewer *HelpPlugin::createHelpViewer(qreal zoom)
{
HelpViewer *viewer = 0;
const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
if (backend.compare(QLatin1String("native"), Qt::CaseInsensitive) == 0) {
// check for backends
typedef std::function<HelpViewer *()> ViewerFactory;
QHash<QString, ViewerFactory> factories; // id -> factory
#ifdef QTC_MAC_NATIVE_HELPVIEWER
viewer = new MacWebKitHelpViewer();
#else
qWarning() << "native help viewer is requested, but was not enabled during compilation";
factories.insert(QLatin1String("native"), []() { return new MacWebKitHelpViewer(); });
#endif
} else if (backend.compare(QLatin1String("textbrowser"), Qt::CaseInsensitive) != 0) {
#ifndef QT_NO_WEBKIT
viewer = new QtWebKitHelpViewer();
factories.insert(QLatin1String("qtwebkit"), []() { return new QtWebKitHelpViewer(); });
#endif
factories.insert(QLatin1String("textbrowser"), []() { return new TextBrowserHelpViewer(); });
ViewerFactory factory;
// check requested backend
const QString backend = QLatin1String(qgetenv("QTC_HELPVIEWER_BACKEND"));
if (!backend.isEmpty()) {
factory = factories.value(backend);
if (!factory)
qWarning("Help viewer backend \"%s\" not found, using default.", qPrintable(backend));
}
if (!viewer)
viewer = new TextBrowserHelpViewer();
// default setting
#ifdef QTC_MAC_NATIVE_HELPVIEWER_DEFAULT
if (!factory)
factory = factories.value(QLatin1String("native"));
#endif
if (!factory)
factory = factories.value(QLatin1String("qtwebkit"));
if (!factory)
factory = factories.value(QLatin1String("textbrowser"));
QTC_ASSERT(factory, return 0);
HelpViewer *viewer = factory();
// initialize font
QVariant fontSetting = LocalHelpManager::engineFontSettings();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment