2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-06-11 13:11:37 +02:00
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
#include "helpmanager_implementation.h"
|
2010-06-11 13:11:37 +02:00
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
#include "coreplugin.h"
|
|
|
|
|
|
2023-02-09 07:23:39 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2018-08-31 16:00:32 +02:00
|
|
|
#include <extensionsystem/pluginspec.h>
|
2023-02-09 07:23:39 +01:00
|
|
|
|
2014-12-01 17:07:03 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2010-06-11 13:11:37 +02:00
|
|
|
|
2018-09-19 14:39:46 +02:00
|
|
|
#include <QCoreApplication>
|
|
|
|
|
#include <QDir>
|
2017-02-08 10:57:10 +01:00
|
|
|
#include <QUrl>
|
|
|
|
|
|
2010-06-11 13:11:37 +02:00
|
|
|
namespace Core {
|
2018-08-31 16:00:32 +02:00
|
|
|
namespace HelpManager {
|
2010-06-11 13:11:37 +02:00
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
// makes sure that plugins can connect to HelpManager signals even if the Help plugin is not loaded
|
|
|
|
|
Q_GLOBAL_STATIC(Signals, m_signals)
|
2014-12-02 17:51:14 +01:00
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
static Implementation *m_instance = nullptr;
|
2018-02-12 13:28:37 +01:00
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
static bool checkInstance()
|
2011-09-02 19:05:12 +02:00
|
|
|
{
|
2023-02-09 07:23:39 +01:00
|
|
|
static bool afterPluginCreation = false;
|
|
|
|
|
if (!afterPluginCreation) {
|
|
|
|
|
using namespace ExtensionSystem;
|
|
|
|
|
auto plugin = Internal::CorePlugin::instance();
|
|
|
|
|
// HelpManager API can only be used after the actual implementation has been created by the
|
|
|
|
|
// Help plugin, so check that the plugins have all been created. That is the case
|
|
|
|
|
// when the Core plugin is initialized.
|
|
|
|
|
PluginSpec *pluginSpec = PluginManager::specForPlugin(plugin);
|
|
|
|
|
afterPluginCreation = (plugin && pluginSpec && pluginSpec->state() >= PluginSpec::Initialized);
|
|
|
|
|
QTC_CHECK(afterPluginCreation);
|
|
|
|
|
}
|
2018-08-31 16:00:32 +02:00
|
|
|
return m_instance != nullptr;
|
2010-06-11 13:11:37 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
Signals *Signals::instance()
|
2010-06-11 13:11:37 +02:00
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
return m_signals;
|
2010-06-11 13:11:37 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
Implementation::Implementation()
|
2010-06-11 13:11:37 +02:00
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
QTC_CHECK(!m_instance);
|
|
|
|
|
m_instance = this;
|
2014-12-02 17:51:14 +01:00
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
Implementation::~Implementation()
|
2010-06-11 13:11:37 +02:00
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
m_instance = nullptr;
|
2010-06-11 13:11:37 +02:00
|
|
|
}
|
|
|
|
|
|
2018-09-19 14:39:46 +02:00
|
|
|
QString documentationPath()
|
|
|
|
|
{
|
|
|
|
|
return QDir::cleanPath(QCoreApplication::applicationDirPath() + '/' + RELATIVE_DOC_PATH);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
void registerDocumentation(const QStringList &files)
|
2010-06-11 13:11:37 +02:00
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
if (checkInstance())
|
|
|
|
|
m_instance->registerDocumentation(files);
|
2010-06-11 13:11:37 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-04 16:01:36 +02:00
|
|
|
void unregisterDocumentation(const QStringList &fileNames)
|
|
|
|
|
{
|
|
|
|
|
if (checkInstance())
|
|
|
|
|
m_instance->unregisterDocumentation(fileNames);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-16 13:28:28 +02:00
|
|
|
QMultiMap<QString, QUrl> linksForIdentifier(const QString &id)
|
2010-06-11 13:11:37 +02:00
|
|
|
{
|
2019-10-16 13:28:28 +02:00
|
|
|
return checkInstance() ? m_instance->linksForIdentifier(id) : QMultiMap<QString, QUrl>();
|
2010-06-11 13:11:37 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-16 13:28:28 +02:00
|
|
|
QMultiMap<QString, QUrl> linksForKeyword(const QString &keyword)
|
2019-02-01 15:52:43 +01:00
|
|
|
{
|
2019-10-16 13:28:28 +02:00
|
|
|
return checkInstance() ? m_instance->linksForKeyword(keyword) : QMultiMap<QString, QUrl>();
|
2019-02-01 15:52:43 +01:00
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
QByteArray fileData(const QUrl &url)
|
2010-07-12 13:24:45 +02:00
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
return checkInstance() ? m_instance->fileData(url) : QByteArray();
|
2010-07-12 13:24:45 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-24 10:42:24 +01:00
|
|
|
void showHelpUrl(const QUrl &url, HelpManager::HelpViewerLocation location)
|
2010-06-11 13:11:37 +02:00
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
if (checkInstance())
|
2019-01-24 10:42:24 +01:00
|
|
|
m_instance->showHelpUrl(url, location);
|
2014-06-20 17:24:18 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-24 10:42:24 +01:00
|
|
|
void showHelpUrl(const QString &url, HelpViewerLocation location)
|
2014-06-20 17:24:18 +02:00
|
|
|
{
|
2019-01-24 10:42:24 +01:00
|
|
|
showHelpUrl(QUrl(url), location);
|
2010-06-11 13:11:37 +02:00
|
|
|
}
|
|
|
|
|
|
2024-03-01 10:15:05 +01:00
|
|
|
void setBlockedDocumentation(const QStringList &fileNames)
|
|
|
|
|
{
|
|
|
|
|
if (checkInstance())
|
|
|
|
|
m_instance->setBlockedDocumentation(fileNames);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
} // HelpManager
|
|
|
|
|
} // Core
|