From 809416c993afe9a9c7dac3c2cad784864f39a2cd Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 22 Jan 2019 14:53:45 +0100 Subject: [PATCH] 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 --- src/plugins/help/helpplugin.cpp | 24 +++++++++--------------- src/plugins/help/helpplugin.h | 3 +-- src/plugins/help/helpwidget.cpp | 3 +-- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index 6f2454da901..6da825dd3f6 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -133,7 +133,7 @@ public: void setupHelpEngineIfNeeded(); void highlightSearchTermsInContextHelp(); - void handleHelpRequest(const QUrl &url, Core::HelpManager::HelpViewerLocation location); + void showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location); void slotSystemInformation(); @@ -190,6 +190,11 @@ HelpPlugin::~HelpPlugin() 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) { Q_UNUSED(arguments) @@ -225,7 +230,7 @@ HelpPluginPrivate::HelpPluginPrivate() connect(LocalHelpManager::instance(), &LocalHelpManager::returnOnCloseChanged, m_centralWidget, &CentralWidget::updateCloseButton); connect(HelpManager::instance(), &HelpManager::helpRequested, - this, &HelpPluginPrivate::handleHelpRequest); + this, &HelpPluginPrivate::showHelpUrl); connect(&m_searchTaskHandler, &SearchTaskHandler::search, this, &QDesktopServices::openUrl); @@ -585,11 +590,6 @@ HelpWidget *HelpPluginPrivate::helpWidgetForWindow(QWidget *window) return m_centralWidget; } -HelpViewer *HelpPlugin::viewerForHelpViewerLocation(Core::HelpManager::HelpViewerLocation location) -{ - return dd->viewerForHelpViewerLocation(location); -} - HelpViewer *HelpPluginPrivate::viewerForHelpViewerLocation( Core::HelpManager::HelpViewerLocation location) { @@ -613,11 +613,6 @@ HelpViewer *HelpPluginPrivate::viewerForHelpViewerLocation( return helpModeHelpViewer(); } -void HelpPlugin::showInHelpViewer(const QUrl &url, HelpViewer *viewer) -{ - dd->showInHelpViewer(url, viewer); -} - void HelpPluginPrivate::showInHelpViewer(const QUrl &url, HelpViewer *viewer) { QTC_ASSERT(viewer, return); @@ -726,8 +721,7 @@ void HelpPluginPrivate::highlightSearchTermsInContextHelp() m_contextHelpHighlightId.clear(); } -void HelpPluginPrivate::handleHelpRequest(const QUrl &url, - Core::HelpManager::HelpViewerLocation location) +void HelpPluginPrivate::showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location) { static const QString qtcreatorUnversionedID = "org.qt-project.qtcreator"; if (url.host() == qtcreatorUnversionedID) { @@ -735,7 +729,7 @@ void HelpPluginPrivate::handleHelpRequest(const QUrl &url, QUrl versioned = url; versioned.setHost(qtcreatorUnversionedID + "." + QString::fromLatin1(Core::Constants::IDE_VERSION_LONG).remove('.')); - handleHelpRequest(versioned, location); + showHelpUrl(versioned, location); return; } diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h index 03358914988..dfba86fcc77 100644 --- a/src/plugins/help/helpplugin.h +++ b/src/plugins/help/helpplugin.h @@ -46,8 +46,7 @@ public: HelpPlugin(); ~HelpPlugin() final; - static HelpViewer *viewerForHelpViewerLocation(Core::HelpManager::HelpViewerLocation location); - static void showInHelpViewer(const QUrl &url, HelpViewer *viewer); + static void showHelpUrl(const QUrl &url, Core::HelpManager::HelpViewerLocation location); static HelpViewer *createHelpViewer(qreal zoom); private: diff --git a/src/plugins/help/helpwidget.cpp b/src/plugins/help/helpwidget.cpp index 355cb460ab7..d07cf9e1458 100644 --- a/src/plugins/help/helpwidget.cpp +++ b/src/plugins/help/helpwidget.cpp @@ -69,8 +69,7 @@ namespace Internal { static void openUrlInWindow(const QUrl &url) { - HelpViewer *viewer = HelpPlugin::viewerForHelpViewerLocation(Core::HelpManager::ExternalHelpAlways); - HelpPlugin::showInHelpViewer(url, viewer); + HelpPlugin::showHelpUrl(url, Core::HelpManager::ExternalHelpAlways); } static bool isBookmarkable(const QUrl &url)