forked from qt-creator/qt-creator
Help: Simplify and unify code
The help widget doesn't need to resolve the external help viewer instance manually, we have an entrypoint for that already. Change-Id: I6875c434428baac3f1883813207cf318d7d3dc09 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -133,7 +133,7 @@ public:
|
|||||||
void setupHelpEngineIfNeeded();
|
void setupHelpEngineIfNeeded();
|
||||||
|
|
||||||
void highlightSearchTermsInContextHelp();
|
void highlightSearchTermsInContextHelp();
|
||||||
void handleHelpRequest(const QUrl &url, Core::HelpManager::HelpViewerLocation location);
|
void showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location);
|
||||||
|
|
||||||
void slotSystemInformation();
|
void slotSystemInformation();
|
||||||
|
|
||||||
@@ -190,6 +190,11 @@ HelpPlugin::~HelpPlugin()
|
|||||||
m_helpManager = nullptr;
|
m_helpManager = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HelpPlugin::showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location)
|
||||||
|
{
|
||||||
|
dd->showHelpUrl(url, location);
|
||||||
|
}
|
||||||
|
|
||||||
bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
bool HelpPlugin::initialize(const QStringList &arguments, QString *error)
|
||||||
{
|
{
|
||||||
Q_UNUSED(arguments)
|
Q_UNUSED(arguments)
|
||||||
@@ -225,7 +230,7 @@ HelpPluginPrivate::HelpPluginPrivate()
|
|||||||
connect(LocalHelpManager::instance(), &LocalHelpManager::returnOnCloseChanged,
|
connect(LocalHelpManager::instance(), &LocalHelpManager::returnOnCloseChanged,
|
||||||
m_centralWidget, &CentralWidget::updateCloseButton);
|
m_centralWidget, &CentralWidget::updateCloseButton);
|
||||||
connect(HelpManager::instance(), &HelpManager::helpRequested,
|
connect(HelpManager::instance(), &HelpManager::helpRequested,
|
||||||
this, &HelpPluginPrivate::handleHelpRequest);
|
this, &HelpPluginPrivate::showHelpUrl);
|
||||||
connect(&m_searchTaskHandler, &SearchTaskHandler::search,
|
connect(&m_searchTaskHandler, &SearchTaskHandler::search,
|
||||||
this, &QDesktopServices::openUrl);
|
this, &QDesktopServices::openUrl);
|
||||||
|
|
||||||
@@ -585,11 +590,6 @@ HelpWidget *HelpPluginPrivate::helpWidgetForWindow(QWidget *window)
|
|||||||
return m_centralWidget;
|
return m_centralWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpViewer *HelpPlugin::viewerForHelpViewerLocation(Core::HelpManager::HelpViewerLocation location)
|
|
||||||
{
|
|
||||||
return dd->viewerForHelpViewerLocation(location);
|
|
||||||
}
|
|
||||||
|
|
||||||
HelpViewer *HelpPluginPrivate::viewerForHelpViewerLocation(
|
HelpViewer *HelpPluginPrivate::viewerForHelpViewerLocation(
|
||||||
Core::HelpManager::HelpViewerLocation location)
|
Core::HelpManager::HelpViewerLocation location)
|
||||||
{
|
{
|
||||||
@@ -613,11 +613,6 @@ HelpViewer *HelpPluginPrivate::viewerForHelpViewerLocation(
|
|||||||
return helpModeHelpViewer();
|
return helpModeHelpViewer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPlugin::showInHelpViewer(const QUrl &url, HelpViewer *viewer)
|
|
||||||
{
|
|
||||||
dd->showInHelpViewer(url, viewer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void HelpPluginPrivate::showInHelpViewer(const QUrl &url, HelpViewer *viewer)
|
void HelpPluginPrivate::showInHelpViewer(const QUrl &url, HelpViewer *viewer)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(viewer, return);
|
QTC_ASSERT(viewer, return);
|
||||||
@@ -726,8 +721,7 @@ void HelpPluginPrivate::highlightSearchTermsInContextHelp()
|
|||||||
m_contextHelpHighlightId.clear();
|
m_contextHelpHighlightId.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpPluginPrivate::handleHelpRequest(const QUrl &url,
|
void HelpPluginPrivate::showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location)
|
||||||
Core::HelpManager::HelpViewerLocation location)
|
|
||||||
{
|
{
|
||||||
static const QString qtcreatorUnversionedID = "org.qt-project.qtcreator";
|
static const QString qtcreatorUnversionedID = "org.qt-project.qtcreator";
|
||||||
if (url.host() == qtcreatorUnversionedID) {
|
if (url.host() == qtcreatorUnversionedID) {
|
||||||
@@ -735,7 +729,7 @@ void HelpPluginPrivate::handleHelpRequest(const QUrl &url,
|
|||||||
QUrl versioned = url;
|
QUrl versioned = url;
|
||||||
versioned.setHost(qtcreatorUnversionedID + "."
|
versioned.setHost(qtcreatorUnversionedID + "."
|
||||||
+ QString::fromLatin1(Core::Constants::IDE_VERSION_LONG).remove('.'));
|
+ QString::fromLatin1(Core::Constants::IDE_VERSION_LONG).remove('.'));
|
||||||
handleHelpRequest(versioned, location);
|
showHelpUrl(versioned, location);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,8 +46,7 @@ public:
|
|||||||
HelpPlugin();
|
HelpPlugin();
|
||||||
~HelpPlugin() final;
|
~HelpPlugin() final;
|
||||||
|
|
||||||
static HelpViewer *viewerForHelpViewerLocation(Core::HelpManager::HelpViewerLocation location);
|
static void showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location);
|
||||||
static void showInHelpViewer(const QUrl &url, HelpViewer *viewer);
|
|
||||||
static HelpViewer *createHelpViewer(qreal zoom);
|
static HelpViewer *createHelpViewer(qreal zoom);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -69,8 +69,7 @@ namespace Internal {
|
|||||||
|
|
||||||
static void openUrlInWindow(const QUrl &url)
|
static void openUrlInWindow(const QUrl &url)
|
||||||
{
|
{
|
||||||
HelpViewer *viewer = HelpPlugin::viewerForHelpViewerLocation(Core::HelpManager::ExternalHelpAlways);
|
HelpPlugin::showHelpUrl(url, Core::HelpManager::ExternalHelpAlways);
|
||||||
HelpPlugin::showInHelpViewer(url, viewer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isBookmarkable(const QUrl &url)
|
static bool isBookmarkable(const QUrl &url)
|
||||||
|
Reference in New Issue
Block a user