diff --git a/CMakeLists.txt b/CMakeLists.txt index 75d550859d9e..1c793739687e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,6 +188,8 @@ endif() # Docs requirements option(ENABLE_DOCS "Enable Building user and developer documentation" ON) if(ENABLE_DOCS) + option(DOCS_QTHELP "If enabled add a target to build the qthelp documentation for qtassistant" ON) + find_package(Sphinx REQUIRED) # run python to see if the theme is installed execute_process( diff --git a/conda/recipes/mantid-developer/meta.yaml b/conda/recipes/mantid-developer/meta.yaml index 70861b9abb86..1ec3842f5ab6 100644 --- a/conda/recipes/mantid-developer/meta.yaml +++ b/conda/recipes/mantid-developer/meta.yaml @@ -37,6 +37,7 @@ requirements: - pycifrw - pydantic - pyqt {{ pyqt }} + - pyqtwebengine - python-dateutil {{ python_dateutil }} - python {{ python }} - python.app # [osx] diff --git a/conda/recipes/mantidqt/meta.yaml b/conda/recipes/mantidqt/meta.yaml index 8eff03bde3ea..4ffd838b9cdc 100644 --- a/conda/recipes/mantidqt/meta.yaml +++ b/conda/recipes/mantidqt/meta.yaml @@ -26,6 +26,7 @@ requirements: - setuptools # [build_platform != target_platform] - numpy {{ numpy }} # [build_platform != target_platform] - pyqt {{ pyqt }} # [build_platform != target_platform] + - pyqtwebengine # [build_platform != target_platform] - qt-main {{ qt_main }} # [build_platform != target_platform] - sip {{ sip }} # [build_platform != target_platform] - {{ cdt('mesa-libgl-devel') }} # [linux] diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 238d485d76e7..c47d6707ff10 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -9,7 +9,6 @@ set(DOCS_MATH_EXT ) set_property(CACHE DOCS_MATH_EXT PROPERTY STRINGS "sphinx.ext.imgmath" "sphinx.ext.mathjax") option(DOCS_PLOTDIRECTIVE "If enabled include plots generated with the plot directive. " OFF) -option(DOCS_QTHELP "If enabled add a target to build the qthelp documentation" ON) option(SPHINX_WARNINGS_AS_ERRORS "non-zero exit if there are sphinx warnings" ON) option(SPHINX_FRESH_ENV "Don't use a saved environment, but rebuild it completely" ON) diff --git a/qt/applications/workbench/workbench/app/main.py b/qt/applications/workbench/workbench/app/main.py index fa29cbdecd24..c9591866619f 100644 --- a/qt/applications/workbench/workbench/app/main.py +++ b/qt/applications/workbench/workbench/app/main.py @@ -9,6 +9,7 @@ import os from mantid import __version__ as mtd_version +from qtpy.QtWebEngineWidgets import QWebEngineView # noqa: F401 import warnings diff --git a/qt/python/mantidqt/mantidqt/widgets/helpwindow/__init__.py b/qt/python/mantidqt/mantidqt/widgets/helpwindow/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowbridge.py b/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowbridge.py new file mode 100644 index 000000000000..d8525f57a607 --- /dev/null +++ b/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowbridge.py @@ -0,0 +1,36 @@ +import os +from mantidqt.widgets.helpwindow.helpwindowpresenter import HelpWindowPresenter +from qtpy.QtCore import QUrl + +_presenter = None + +online_base_url = "https://docs.mantidproject.org/" +# NOTE: Once you build the html docs using the command ninja docs-html, you will need to +# use the command export MANTID_LOCAL_DOCS_BASE="/path/to/build/docs/html". +# If this it not set, this will default to the online docs. +local_docs_base = os.environ.get("MANTID_LOCAL_DOCS_BASE") # e.g. /path/to/build/docs/html + + +def show_help_page(relative_url): + """ + Show the help window at the given relative URL path, e.g. "algorithms/Load-v1.html". + """ + global _presenter + if _presenter is None: + _presenter = HelpWindowPresenter() + + # Default to index.html if no specific file given + if not relative_url or not relative_url.endswith(".html"): + relative_url = "index.html" + + if local_docs_base and os.path.isdir(local_docs_base): + # Use local docs + full_path = os.path.join(local_docs_base, relative_url) + file_url = QUrl.fromLocalFile(full_path) + _presenter.view.browser.setUrl(file_url) + else: + # Use online docs + full_url = online_base_url + relative_url + _presenter.view.browser.setUrl(QUrl(full_url)) + + _presenter.show_help_window() diff --git a/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowmodel.py b/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowmodel.py new file mode 100644 index 000000000000..15ef280736ac --- /dev/null +++ b/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowmodel.py @@ -0,0 +1,7 @@ +class HelpWindowModel: + def __init__(self): + self.help_url = "https://docs.mantidproject.org/" + + def get_help_url(self): + """Get the help documentation URL.""" + return self.help_url diff --git a/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowpresenter.py b/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowpresenter.py new file mode 100644 index 000000000000..e300d102b28e --- /dev/null +++ b/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowpresenter.py @@ -0,0 +1,36 @@ +from .helpwindowview import HelpWindowView +from .helpwindowmodel import HelpWindowModel + + +class HelpWindowPresenter: + def __init__(self, parent_app=None): + """ + Initialize the presenter for the Help Window. + + :param parent_app: Optional parent application to tie the lifecycle of this presenter. + """ + self.model = HelpWindowModel() + self.view = HelpWindowView(self) + self.parent_app = parent_app + self._window_open = False + + if self.parent_app: + self.parent_app.aboutToQuit.connect(self.cleanup) + + def show_help_window(self): + """Show the help window.""" + if not self._window_open: + self._window_open = True + self.view.display() + + def on_close(self): + """Handle actions when the window is closed.""" + print("Help window closed.") + self.cleanup() + + def cleanup(self): + """Ensure proper cleanup of resources.""" + if self._window_open: + self._window_open = False + print("Cleaning up Help Window resources.") + self.view.close() diff --git a/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowview.py b/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowview.py new file mode 100644 index 000000000000..99274df930c7 --- /dev/null +++ b/qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowview.py @@ -0,0 +1,77 @@ +import os +from qtpy.QtWebEngineWidgets import QWebEngineView +from qtpy.QtWidgets import QMainWindow, QVBoxLayout, QToolBar, QPushButton, QWidget +from qtpy.QtCore import QUrl +from qtpy.QtGui import QIcon + + +class HelpWindowView(QMainWindow): + def __init__(self, presenter): + super().__init__() + self.presenter = presenter + self.setWindowTitle("Python Help Window") + self.resize(800, 600) + + # Web browser widget + self.browser = QWebEngineView() + + # Determine initial URL + local_docs_base = os.environ.get("MANTID_LOCAL_DOCS_BASE") + if local_docs_base and os.path.isdir(local_docs_base): + index_path = os.path.join(local_docs_base, "index.html") + self.browser.setUrl(QUrl.fromLocalFile(index_path)) + else: + self.browser.setUrl(QUrl("https://docs.mantidproject.org/")) + + # Toolbar with navigation buttons + self.toolbar = QToolBar("Navigation") + self.addToolBar(self.toolbar) + + # Back button + back_button = QPushButton() + back_button.setIcon(QIcon.fromTheme("go-previous")) + back_button.setToolTip("Go Back") + back_button.clicked.connect(self.browser.back) + self.toolbar.addWidget(back_button) + + # Forward button + forward_button = QPushButton() + forward_button.setIcon(QIcon.fromTheme("go-next")) + forward_button.setToolTip("Go Forward") + forward_button.clicked.connect(self.browser.forward) + self.toolbar.addWidget(forward_button) + + # Home button + home_button = QPushButton() + home_button.setIcon(QIcon.fromTheme("go-home")) + home_button.setToolTip("Go Home") + home_button.clicked.connect(self.go_home) + self.toolbar.addWidget(home_button) + + # Reload button + reload_button = QPushButton() + reload_button.setIcon(QIcon.fromTheme("view-refresh")) + reload_button.setToolTip("Reload") + reload_button.clicked.connect(self.browser.reload) + self.toolbar.addWidget(reload_button) + + # Layout + layout = QVBoxLayout() + layout.addWidget(self.browser) + + container = QWidget() + container.setLayout(layout) + self.setCentralWidget(container) + + def go_home(self): + """Navigate to the home page.""" + self.browser.setUrl(QUrl("https://docs.mantidproject.org/")) + + def display(self): + """Show the help window.""" + self.show() + + def closeEvent(self, event): + """Handle the close event and notify the presenter.""" + self.presenter.on_close() + super().closeEvent(event) diff --git a/qt/widgets/common/CMakeLists.txt b/qt/widgets/common/CMakeLists.txt index a2c396b5e105..0c9929fd36c7 100644 --- a/qt/widgets/common/CMakeLists.txt +++ b/qt/widgets/common/CMakeLists.txt @@ -1,3 +1,5 @@ +option(DDOCS_QTHELP "If enabled add a target to build the qthelp documentation for qtassistant" ON) + set(SRC_FILES src/AddWorkspaceDialog.cpp src/AddWorkspaceMultiDialog.cpp @@ -86,6 +88,8 @@ set(SRC_FILES src/PropertyHandler.cpp src/PropertyWidget.cpp src/PropertyWidgetFactory.cpp + src/PythonHelpBridge.cpp + src/PythonHelpWindow.cpp src/PythonRunner.cpp src/QtAlgorithmRunner.cpp src/QtJobRunner.cpp @@ -159,6 +163,11 @@ set(SRC_FILES src/Python/QHashToDict.cpp ) +if(DDOCS_QTHELP STREQUAL "OFF") + list(APPEND SRC_FILES src/PythonHelpBridge.cpp) + list(APPEND SRC_FILES src/PythonHelpWindow.cpp) +endif() + set(QT5_MOC_FILES inc/MantidQtWidgets/Common/AddWorkspaceDialog.h inc/MantidQtWidgets/Common/AddWorkspaceMultiDialog.h @@ -262,6 +271,11 @@ set(QT5_MOC_FILES inc/MantidQtWidgets/Common/QtPropertyBrowser/WorkspaceEditorFactory.h ) +if(DDOCS_QTHELP STREQUAL "OFF") + list(APPEND QT5_MOC_FILES inc/MantidQtWidgets/Common/PythonHelpBridge.h) + list(APPEND QT5_MOC_FILES inc/MantidQtWidgets/Common/PythonHelpWindow.h) +endif() + # Include files aren't required, but this makes them appear in Visual Studio set(QT5_INC_FILES ${QT5_MOC_FILES} diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h index e8c8fe0d3a45..4b6dce8fc453 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/InterfaceManager.h @@ -138,6 +138,6 @@ class EXPORT_OPT_MANTIDQT_COMMON InterfaceManager { namespace { \ Mantid::Kernel::RegistrationHelper \ register_helpviewer(((MantidQt::API::InterfaceManager::registerHelpWindowFactory( \ - new Mantid::Kernel::Instantiator())), \ + new Mantid::Kernel::Instantiator())), \ 0)); \ } diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h index 9a4a7287de7c..9527d28f7714 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h @@ -43,6 +43,11 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidHelpWindow : public API::MantidHelpInterf void showCustomInterface(const QString &name, const QString &area = QString(), const QString §ion = QString()) override; +public slots: + /// Perform any clean up on main window shutdown + void shutdown() override; + void warning(const QString &msg); + private: void showHelp(const QString &url); void openWebpage(const QUrl &url); @@ -51,17 +56,11 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidHelpWindow : public API::MantidHelpInterf std::string m_collectionFile; /// The window that renders the help information static QPointer g_helpWindow; - /// Whether this is the very first startup of the helpwindow. bool m_firstRun; void findCollectionFile(const std::string &binDir); void determineFileLocs(); - -public slots: - /// Perform any clean up on main window shutdown - void shutdown() override; - void warning(const QString &msg); }; } // namespace MantidWidgets diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/PythonHelpBridge.h b/qt/widgets/common/inc/MantidQtWidgets/Common/PythonHelpBridge.h new file mode 100644 index 000000000000..2740d038fad1 --- /dev/null +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/PythonHelpBridge.h @@ -0,0 +1,22 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2013 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source, +// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS +// SPDX - License - Identifier: GPL - 3.0 + +#pragma once + +#include "MantidQtWidgets/Common/DllOption.h" +#include + +namespace MantidQt { +namespace MantidWidgets { + +class EXPORT_OPT_MANTIDQT_COMMON PythonHelpBridge { +public: + PythonHelpBridge(); + void showHelpPage(const std::string &relative_url); +}; + +} // namespace MantidWidgets +} // namespace MantidQt diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/PythonHelpWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/PythonHelpWindow.h new file mode 100644 index 000000000000..acf5e0c13986 --- /dev/null +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/PythonHelpWindow.h @@ -0,0 +1,32 @@ +#pragma once + +#include "MantidQtWidgets/Common/DllOption.h" +#include "MantidQtWidgets/Common/MantidHelpInterface.h" +#include +#include +#include + +namespace MantidQt { +namespace MantidWidgets { + +class EXPORT_OPT_MANTIDQT_COMMON PythonHelpWindow : public MantidQt::API::MantidHelpInterface { +public: + PythonHelpWindow(); + void showPage(const std::string &url = std::string()) override; + void showPage(const QString &url) override; + void showPage(const QUrl &url) override; + void showAlgorithm(const std::string &name = std::string(), const int version = -1) override; + void showAlgorithm(const QString &name, const int version = -1) override; + void showConcept(const std::string &name) override; + void showConcept(const QString &name) override; + void showFitFunction(const std::string &name = std::string()) override; + void showFitFunction(const QString &name) override; + void showCustomInterface(const std::string &name = std::string(), const std::string &area = std::string(), + const std::string §ion = std::string()) override; + void showCustomInterface(const QString &name, const QString &area = QString(), + const QString §ion = QString()) override; + void shutdown() override; +}; + +} // namespace MantidWidgets +} // namespace MantidQt diff --git a/qt/widgets/common/src/AlgorithmDialog.cpp b/qt/widgets/common/src/AlgorithmDialog.cpp index 564afbf8f6cd..5162597c0843 100644 --- a/qt/widgets/common/src/AlgorithmDialog.cpp +++ b/qt/widgets/common/src/AlgorithmDialog.cpp @@ -14,6 +14,7 @@ #include "MantidQtWidgets/Common/AlgorithmInputHistory.h" #include "MantidQtWidgets/Common/FilePropertyWidget.h" #include "MantidQtWidgets/Common/HelpWindow.h" +#include "MantidQtWidgets/Common/InterfaceManager.h" #include "MantidQtWidgets/Common/MantidWidget.h" #include "MantidQtWidgets/Common/PropertyWidget.h" @@ -707,11 +708,16 @@ void AlgorithmDialog::reject() { void AlgorithmDialog::helpClicked() { // determine the version to show int version(-1); // the latest version - if (m_algorithm) + if (m_algorithm) { version = m_algorithm->version(); + } +#ifndef DOCS_QTHELP + MantidQt::API::InterfaceManager().showAlgorithmHelp(m_algName, version); +#else // bring up the help window HelpWindow::showAlgorithm(m_algName, version); +#endif } //------------------------------------------------------------------------------------------------- diff --git a/qt/widgets/common/src/InterfaceManager.cpp b/qt/widgets/common/src/InterfaceManager.cpp index d8e5d08899c5..abbadc961de9 100644 --- a/qt/widgets/common/src/InterfaceManager.cpp +++ b/qt/widgets/common/src/InterfaceManager.cpp @@ -14,6 +14,7 @@ #include "MantidQtWidgets/Common/MantidDesktopServices.h" #include "MantidQtWidgets/Common/MantidHelpWindow.h" #include "MantidQtWidgets/Common/PluginLibraries.h" +#include "MantidQtWidgets/Common/PythonHelpBridge.h" #include "MantidQtWidgets/Common/UserSubWindow.h" #include "MantidQtWidgets/Common/UserSubWindowFactory.h" @@ -23,7 +24,10 @@ #include "MantidKernel/Logger.h" #include +#include #include +#include +#include using namespace MantidQt::API; using Mantid::Kernel::AbstractInstantiator; @@ -154,7 +158,7 @@ UserSubWindow *InterfaceManager::createSubWindow(const QString &interface_name, g_log.debug() << "Created a specialised interface for " << iname << '\n'; // set the parent. Note - setParent without flags parameter resets the flags - // ie window becomes a child widget + // i.e. window becomes a child widget if (isWindow) { user_win->setParent(parent, user_win->windowFlags()); } else { @@ -233,6 +237,7 @@ MantidHelpInterface *InterfaceManager::createHelpWindow() const { MantidHelpInterface *interface = this->m_helpViewer->createUnwrappedInstance(); if (!interface) { g_log.error("Error creating help window"); + return nullptr; } return interface; } @@ -240,27 +245,58 @@ MantidHelpInterface *InterfaceManager::createHelpWindow() const { void InterfaceManager::showHelpPage(const QString &url) { auto window = createHelpWindow(); - window->showPage(url); + if (window) + window->showPage(url); + else + MantidDesktopServices::openUrl(url); } void InterfaceManager::showAlgorithmHelp(const QString &name, const int version) { auto window = createHelpWindow(); - window->showAlgorithm(name, version); + if (window) + window->showAlgorithm(name, version); + else { + QString url("https://docs.mantidproject.org/algorithms/"); + url += name.isEmpty() ? "index.html" : name + (version > 0 ? "-v" + QString::number(version) + ".html" : ".html"); + MantidDesktopServices::openUrl(url); + } } void InterfaceManager::showConceptHelp(const QString &name) { auto window = createHelpWindow(); - window->showConcept(name); + if (window) + window->showConcept(name); + else { + QString url("https://docs.mantidproject.org/concepts/"); + url += name.isEmpty() ? "index.html" : name + ".html"; + MantidDesktopServices::openUrl(url); + } } void InterfaceManager::showFitFunctionHelp(const QString &name) { auto window = createHelpWindow(); - window->showFitFunction(name); + if (window) + window->showFitFunction(name); + else { + QString url("https://docs.mantidproject.org/fitting/fitfunctions/"); + url += name.isEmpty() ? "index.html" : name + ".html"; + MantidDesktopServices::openUrl(url); + } } void InterfaceManager::showCustomInterfaceHelp(const QString &name, const QString &area, const QString §ion) { auto window = createHelpWindow(); - window->showCustomInterface(name, area, section); + if (window) + window->showCustomInterface(name, area, section); + else { + QString url("https://docs.mantidproject.org/interfaces/"); + if (!area.isEmpty()) + url += area + "/"; + url += name.isEmpty() ? "index.html" : name + ".html"; + if (!section.isEmpty()) + url += "#" + section; + MantidDesktopServices::openUrl(url); + } } void InterfaceManager::showWebPage(const QString &url) { MantidDesktopServices::openUrl(url); } @@ -268,6 +304,7 @@ void InterfaceManager::showWebPage(const QString &url) { MantidDesktopServices:: void InterfaceManager::closeHelpWindow() { if (MantidHelpWindow::helpWindowExists()) { auto window = createHelpWindow(); - window->shutdown(); + if (window) + window->shutdown(); } } diff --git a/qt/widgets/common/src/PythonHelpBridge.cpp b/qt/widgets/common/src/PythonHelpBridge.cpp new file mode 100644 index 000000000000..7ecb9043dbf6 --- /dev/null +++ b/qt/widgets/common/src/PythonHelpBridge.cpp @@ -0,0 +1,51 @@ +// Mantid Repository : https://github.com/mantidproject/mantid +// +// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI, +// NScD Oak Ridge National Laboratory, European Spallation Source, +// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS +// SPDX - License - Identifier: GPL - 3.0 + +#include "MantidQtWidgets/Common/PythonHelpBridge.h" +#include +#include +#include +#include + +namespace { +const std::string MOD_NAME("mantidqt.widgets.helpwindow.helpwindowbridge"); +const boost::python::str MOD_NAME_PY(MOD_NAME); + +boost::python::object getHelpWindowModule() { + static bool imported = false; + static boost::python::object module; + if (!imported) { + module = boost::python::import(MOD_NAME_PY); + imported = true; + } + return module; +} +} // namespace + +namespace MantidQt { +namespace MantidWidgets { + +PythonHelpBridge::PythonHelpBridge() { + if (!Py_IsInitialized()) { + Py_Initialize(); + } +} + +void PythonHelpBridge::showHelpPage(const std::string &relative_url) { + PyGILState_STATE gstate = PyGILState_Ensure(); + try { + boost::python::object module = getHelpWindowModule(); + module.attr("show_help_page")(relative_url); + + } catch (boost::python::error_already_set &) { + PyErr_Print(); + PyGILState_Release(gstate); + throw std::runtime_error("Error calling show_help_page in Python."); + } + PyGILState_Release(gstate); +} +} // namespace MantidWidgets +} // namespace MantidQt diff --git a/qt/widgets/common/src/PythonHelpWindow.cpp b/qt/widgets/common/src/PythonHelpWindow.cpp new file mode 100644 index 000000000000..7504c9ad9fc7 --- /dev/null +++ b/qt/widgets/common/src/PythonHelpWindow.cpp @@ -0,0 +1,92 @@ +#include "MantidQtWidgets/Common/PythonHelpWindow.h" +#include "MantidKernel/RegistrationHelper.h" +#include "MantidQtWidgets/Common/InterfaceManager.h" +#include "MantidQtWidgets/Common/PythonHelpBridge.h" +#include +#include + +namespace MantidQt { +namespace MantidWidgets { + +#ifndef DOCS_QTHELP +REGISTER_HELPWINDOW(PythonHelpWindow) +#endif + +PythonHelpWindow::PythonHelpWindow() : MantidQt::API::MantidHelpInterface() {} + +void PythonHelpWindow::showPage(const std::string &url) { + PythonHelpBridge bridge; + bridge.showHelpPage(url.empty() ? "index.html" : url); +} + +void PythonHelpWindow::showPage(const QString &url) { + PythonHelpBridge bridge; + std::string page = url.isEmpty() ? "index.html" : url.toStdString(); + bridge.showHelpPage(page); +} + +void PythonHelpWindow::showPage(const QUrl &url) { + PythonHelpBridge bridge; + std::string page = url.isEmpty() ? "index.html" : url.toString().toStdString(); + bridge.showHelpPage(page); +} + +void PythonHelpWindow::showAlgorithm(const std::string &name, const int version) { + QString page = "algorithms/" + QString::fromStdString(name); + if (!name.empty() && version > 0) + page += "-v" + QString::number(version) + ".html"; + else if (!name.empty()) + page += ".html"; + else + page = "algorithms/index.html"; + showPage(page); +} + +void PythonHelpWindow::showAlgorithm(const QString &name, const int version) { + std::string n = name.toStdString(); + showAlgorithm(n, version); +} + +void PythonHelpWindow::showConcept(const std::string &name) { + QString page = name.empty() ? "concepts/index.html" : "concepts/" + QString::fromStdString(name) + ".html"; + showPage(page); +} + +void PythonHelpWindow::showConcept(const QString &name) { + std::string n = name.toStdString(); + showConcept(n); +} + +void PythonHelpWindow::showFitFunction(const std::string &name) { + QString page = name.empty() ? "fitting/fitfunctions/index.html" + : "fitting/fitfunctions/" + QString::fromStdString(name) + ".html"; + showPage(page); +} + +void PythonHelpWindow::showFitFunction(const QString &name) { + std::string n = name.toStdString(); + showFitFunction(n); +} + +void PythonHelpWindow::showCustomInterface(const std::string &name, const std::string &area, + const std::string §ion) { + QString areaPath = area.empty() ? "" : QString::fromStdString(area) + "/"; + QString page = "interfaces/" + areaPath + (name.empty() ? "index.html" : QString::fromStdString(name) + ".html"); + if (!section.empty()) + page += "#" + QString::fromStdString(section); + showPage(page); +} + +void PythonHelpWindow::showCustomInterface(const QString &name, const QString &area, const QString §ion) { + std::string n = name.toStdString(); + std::string a = area.toStdString(); + std::string s = section.toStdString(); + showCustomInterface(n, a, s); +} + +void PythonHelpWindow::shutdown() { + // no-op for python help window +} + +} // namespace MantidWidgets +} // namespace MantidQt