2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-06-11 13:11:37 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-06-11 13:11:37 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-06-11 13:11:37 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-06-11 13:11:37 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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"
|
|
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginspec.h>
|
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
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
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.
|
|
|
|
|
QTC_CHECK(plugin && plugin->pluginSpec()
|
|
|
|
|
&& plugin->pluginSpec()->state() >= ExtensionSystem::PluginSpec::Initialized);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
void unregisterDocumentation(const QStringList &nameSpaces)
|
2010-06-11 13:11:37 +02:00
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
if (checkInstance())
|
|
|
|
|
m_instance->unregisterDocumentation(nameSpaces);
|
2010-06-11 13:11:37 +02:00
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
QMap<QString, QUrl> linksForIdentifier(const QString &id)
|
2010-06-11 13:11:37 +02:00
|
|
|
{
|
2018-08-31 16:00:32 +02:00
|
|
|
return checkInstance() ? m_instance->linksForIdentifier(id) : QMap<QString, QUrl>();
|
2010-06-11 13:11:37 +02: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
|
|
|
}
|
|
|
|
|
|
2018-08-31 16:00:32 +02:00
|
|
|
} // HelpManager
|
|
|
|
|
} // Core
|