Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7c77ae9
Changes to facilitate new HelpWindow design
darshdinger Dec 5, 2024
a764445
Some updates to make branch current, tests in next
darshdinger Dec 9, 2024
ef23499
Most recent changes.
darshdinger Dec 10, 2024
7f85219
Updating branch with latest changes
darshdinger Dec 11, 2024
af66060
Make qtassistant a compile time option
peterfpeterson Dec 12, 2024
1bda78b
Hopefully this is a compile time implementation
darshdinger Dec 13, 2024
4d17218
Smal fixes
darshdinger Dec 16, 2024
18e4991
Final updates
darshdinger Dec 16, 2024
432bda5
More updates and Pete's changes
darshdinger Dec 17, 2024
35b39bb
Revert some of Petes changes and some more updates
darshdinger Dec 17, 2024
ca0a981
Reverted changes.
darshdinger Dec 18, 2024
2a6b4b0
Some more changes to hopefully fix build issue
darshdinger Dec 18, 2024
a87a85d
Another update to PythonHelpWindow
darshdinger Dec 18, 2024
0ff65c5
Get the code to compile
peterfpeterson Dec 18, 2024
7ee369a
Updates to InterfaceManager (remove extra stuff)
darshdinger Dec 18, 2024
59da208
Messed up in my last changes to InterfaceManager
darshdinger Dec 18, 2024
7c776f6
Change how module is written in code
peterfpeterson Dec 18, 2024
6c0c0d1
Fix pre-processor macro
peterfpeterson Dec 18, 2024
94e27fb
Add pyqtwebengine dependency for new help window
peterfpeterson Dec 19, 2024
50870c4
Some fixes, seg fault investigation on local
darshdinger Dec 23, 2024
7248ff1
Updates to fix cppcheck.
darshdinger Jan 6, 2025
5810f2c
...
darshdinger Jan 6, 2025
a287cc0
...
darshdinger Jan 6, 2025
b1cec60
fixup! ...
darshdinger Jan 6, 2025
49f3055
fixup! Merge branch '37248-remove-qtassistant-and-reduce-size-of-mant…
darshdinger Jan 6, 2025
f6fabc5
Changes to facilitate new HelpWindow design
darshdinger Dec 5, 2024
ba7b9f2
Merge branch '37248-remove-qtassistant-and-reduce-size-of-mantiddocs-…
darshdinger Jan 7, 2025
9eb6c9c
Updates to CMakeLists.txt for cppcheck
darshdinger Jan 27, 2025
1bd6fd9
Merge branch 'ornl-next' into 37248-remove-qtassistant-and-reduce-siz…
darshdinger Jan 27, 2025
1af261f
Merge branch 'ornl-next' into 37248-remove-qtassistant-and-reduce-siz…
darshdinger Feb 5, 2025
7dfa4b4
Updates to make it all work
darshdinger Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions conda/recipes/mantid-developer/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ requirements:
- pycifrw
- pydantic
- pyqt {{ pyqt }}
- pyqtwebengine
- python-dateutil {{ python_dateutil }}
- python {{ python }}
- python.app # [osx]
Expand Down
1 change: 1 addition & 0 deletions conda/recipes/mantidqt/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 0 additions & 1 deletion docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions qt/applications/workbench/workbench/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os

from mantid import __version__ as mtd_version
from qtpy.QtWebEngineWidgets import QWebEngineView # noqa: F401
import warnings


Expand Down
Empty file.
36 changes: 36 additions & 0 deletions qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowbridge.py
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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()
77 changes: 77 additions & 0 deletions qt/python/mantidqt/mantidqt/widgets/helpwindow/helpwindowview.py
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions qt/widgets/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ class EXPORT_OPT_MANTIDQT_COMMON InterfaceManager {
namespace { \
Mantid::Kernel::RegistrationHelper \
register_helpviewer(((MantidQt::API::InterfaceManager::registerHelpWindowFactory( \
new Mantid::Kernel::Instantiator<TYPE, MantidHelpInterface>())), \
new Mantid::Kernel::Instantiator<TYPE, MantidQt::API::MantidHelpInterface>())), \
0)); \
}
11 changes: 5 additions & 6 deletions qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidHelpWindow : public API::MantidHelpInterf
void showCustomInterface(const QString &name, const QString &area = QString(),
const QString &section = 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);
Expand All @@ -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<pqHelpWindow> 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
Expand Down
22 changes: 22 additions & 0 deletions qt/widgets/common/inc/MantidQtWidgets/Common/PythonHelpBridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 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 <string>

namespace MantidQt {
namespace MantidWidgets {

class EXPORT_OPT_MANTIDQT_COMMON PythonHelpBridge {
public:
PythonHelpBridge();
void showHelpPage(const std::string &relative_url);
};

} // namespace MantidWidgets
} // namespace MantidQt
32 changes: 32 additions & 0 deletions qt/widgets/common/inc/MantidQtWidgets/Common/PythonHelpWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "MantidQtWidgets/Common/DllOption.h"
#include "MantidQtWidgets/Common/MantidHelpInterface.h"
#include <QString>
#include <QUrl>
#include <string>

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 &section = std::string()) override;
void showCustomInterface(const QString &name, const QString &area = QString(),
const QString &section = QString()) override;
void shutdown() override;
};

} // namespace MantidWidgets
} // namespace MantidQt
8 changes: 7 additions & 1 deletion qt/widgets/common/src/AlgorithmDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
}

//-------------------------------------------------------------------------------------------------
Expand Down
Loading