Make Core independent from QtHelp

We don't want various plugins to depend on the Help plugin,
but we also do not want Core to depend on QtHelp.
For example when turning the Help plugin off, documentation should
actually no longer be registered through QtHelp. So we need
parts of the interface in Core, which must then be delegated
to the actual implementation in Help.

As positive side-effects the interface in Core will be slimmer,
and the code in the Help plugin can later be simplified, too,
because then we don't have the "Core" and the "Gui" help engines
separated in different plugins anymore, which should remove the
need for some setup indirections.

Task-number: QTCREATORBUG-20381
Change-Id: I634c5811c45d6a3dfd6ddc682cae270e38384cbf
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2018-08-31 16:00:32 +02:00
parent 25400751a4
commit 2c17fbe8dd
21 changed files with 788 additions and 600 deletions

View File

@@ -33,6 +33,7 @@
#include "helpconstants.h"
#include "helpfindsupport.h"
#include "helpindexfilter.h"
#include "helpmanager.h"
#include "helpmode.h"
#include "helpviewer.h"
#include "localhelpmanager.h"
@@ -145,7 +146,7 @@ public:
HelpViewer *externalHelpViewer();
HelpViewer *helpModeHelpViewer();
HelpWidget *helpWidgetForWindow(QWidget *window);
HelpViewer *viewerForHelpViewerLocation(HelpManager::HelpViewerLocation location);
HelpViewer *viewerForHelpViewerLocation(Core::HelpManager::HelpViewerLocation location);
void showInHelpViewer(const QUrl &url, HelpViewer *viewer);
void doSetupIfNeeded();
@@ -160,7 +161,7 @@ public:
GeneralSettingsPage m_generalSettingsPage;
bool m_setupNeeded = true;
LocalHelpManager m_helpManager;
LocalHelpManager m_localHelpManager;
OpenPagesManager m_openPagesManager;
QString m_contextHelpHighlightId;
@@ -173,11 +174,19 @@ public:
};
static HelpPluginPrivate *dd = nullptr;
static HelpManager *m_helpManager = nullptr;
HelpPlugin::HelpPlugin()
{
m_helpManager = new HelpManager;
}
HelpPlugin::~HelpPlugin()
{
delete dd;
dd = nullptr;
delete m_helpManager;
m_helpManager = nullptr;
}
bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
@@ -221,8 +230,10 @@ HelpPluginPrivate::HelpPluginPrivate()
connect(&m_filterSettingsPage, &FilterSettingsPage::filtersChanged,
this, &HelpPluginPrivate::setupHelpEngineIfNeeded);
connect(HelpManager::instance(), &HelpManager::documentationChanged,
this, &HelpPluginPrivate::setupHelpEngineIfNeeded);
connect(Core::HelpManager::Signals::instance(),
&Core::HelpManager::Signals::documentationChanged,
this,
&HelpPluginPrivate::setupHelpEngineIfNeeded);
connect(HelpManager::instance(), &HelpManager::collectionFileChanged,
this, &HelpPluginPrivate::setupHelpEngineIfNeeded);
@@ -319,7 +330,13 @@ void HelpPlugin::extensionsInitialized()
QStringList filesToRegister;
// we might need to register creators inbuild help
filesToRegister.append(ICore::documentationPath() + "/qtcreator.qch");
HelpManager::registerDocumentation(filesToRegister);
Core::HelpManager::registerDocumentation(filesToRegister);
}
bool HelpPlugin::delayedInitialize()
{
HelpManager::setupHelpManager();
return true;
}
ExtensionSystem::IPlugin::ShutdownFlag HelpPlugin::aboutToShutdown()
@@ -524,7 +541,7 @@ void HelpPluginPrivate::setupHelpEngineIfNeeded()
{
LocalHelpManager::setEngineNeedsUpdate();
if (ModeManager::currentModeId() == m_mode.id()
|| LocalHelpManager::contextHelpOption() == HelpManager::ExternalHelpAlways)
|| LocalHelpManager::contextHelpOption() == Core::HelpManager::ExternalHelpAlways)
LocalHelpManager::setupGuiHelpEngine();
}
@@ -564,29 +581,30 @@ HelpWidget *HelpPluginPrivate::helpWidgetForWindow(QWidget *window)
return m_centralWidget;
}
HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocation location)
HelpViewer *HelpPlugin::viewerForHelpViewerLocation(Core::HelpManager::HelpViewerLocation location)
{
return dd->viewerForHelpViewerLocation(location);
}
HelpViewer *HelpPluginPrivate::viewerForHelpViewerLocation(HelpManager::HelpViewerLocation location)
HelpViewer *HelpPluginPrivate::viewerForHelpViewerLocation(
Core::HelpManager::HelpViewerLocation location)
{
HelpManager::HelpViewerLocation actualLocation = location;
if (location == HelpManager::SideBySideIfPossible)
actualLocation = canShowHelpSideBySide() ? HelpManager::SideBySideAlways
: HelpManager::HelpModeAlways;
Core::HelpManager::HelpViewerLocation actualLocation = location;
if (location == Core::HelpManager::SideBySideIfPossible)
actualLocation = canShowHelpSideBySide() ? Core::HelpManager::SideBySideAlways
: Core::HelpManager::HelpModeAlways;
if (actualLocation == HelpManager::ExternalHelpAlways)
if (actualLocation == Core::HelpManager::ExternalHelpAlways)
return externalHelpViewer();
if (actualLocation == HelpManager::SideBySideAlways) {
if (actualLocation == Core::HelpManager::SideBySideAlways) {
createRightPaneContextViewer();
RightPaneWidget::instance()->setWidget(m_rightPaneSideBarWidget);
RightPaneWidget::instance()->setShown(true);
return m_rightPaneSideBarWidget->currentViewer();
}
QTC_CHECK(actualLocation == HelpManager::HelpModeAlways);
QTC_CHECK(actualLocation == Core::HelpManager::HelpModeAlways);
return helpModeHelpViewer();
}
@@ -658,7 +676,7 @@ void HelpPluginPrivate::showContextHelp(const QString &contextHelpId)
HelpViewer *viewer = viewerForContextHelp();
QTC_ASSERT(viewer, return);
QMap<QString, QUrl> links = HelpManager::linksForIdentifier(contextHelpId);
QMap<QString, QUrl> links = Core::HelpManager::linksForIdentifier(contextHelpId);
// Maybe the id is already an URL
if (links.isEmpty() && LocalHelpManager::isValidUrl(contextHelpId))
links.insert(contextHelpId, contextHelpId);
@@ -702,7 +720,8 @@ void HelpPluginPrivate::highlightSearchTermsInContextHelp()
m_contextHelpHighlightId.clear();
}
void HelpPluginPrivate::handleHelpRequest(const QUrl &url, HelpManager::HelpViewerLocation location)
void HelpPluginPrivate::handleHelpRequest(const QUrl &url,
Core::HelpManager::HelpViewerLocation location)
{
static const QString qtcreatorUnversionedID = "org.qt-project.qtcreator";
if (url.host() == qtcreatorUnversionedID) {