Mantid
Loading...
Searching...
No Matches
HelpWindow.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
10#include "MantidKernel/Logger.h"
14
15#include <QUrl>
16#include <QWidget>
17#include <boost/lexical_cast.hpp>
18
19namespace MantidQt::API {
20namespace {
22Mantid::Kernel::Logger g_log("HelpWindow");
23
24} // namespace
25
26using std::string;
27
28void HelpWindow::showPage(const std::string &url) { showPage(QString(url.c_str())); }
29
30void HelpWindow::showPage(const QString &url) {
31 InterfaceManager interfaceManager;
32 MantidHelpInterface *gui = interfaceManager.createHelpWindow();
33 if (gui) {
34 gui->showPage(url);
35 } else {
36 g_log.error() << "Failed to launch help for page " << url.toStdString() << "\n";
37 }
38}
39
40void HelpWindow::showPage(const QUrl &url) {
41 InterfaceManager interfaceManager;
42 MantidHelpInterface *gui = interfaceManager.createHelpWindow();
43 if (gui) {
44 gui->showPage(url);
45 } else {
46 g_log.error() << "Failed to launch help for page " << url.toString().toStdString() << "\n";
47 }
48}
49
50void HelpWindow::showAlgorithm(const std::string &name, const int version) {
51 showAlgorithm(QString(name.c_str()), version);
52}
53
54void HelpWindow::showAlgorithm(const QString &name, const int version) {
55 InterfaceManager interfaceManager;
56 MantidHelpInterface *gui = interfaceManager.createHelpWindow();
57 if (gui) {
58 gui->showAlgorithm(name, version);
59 } else {
60 // Open online help
61 QString baseUrl = "https://docs.mantidproject.org/algorithms/";
62 QString url = baseUrl + name + "-v" + QString::number(version) + ".html";
64 g_log.debug("Opening online help page:\n" + url.toStdString());
65 }
66}
67
68void HelpWindow::showConcept(const std::string &name) { showConcept(QString(name.c_str())); }
69
70void HelpWindow::showConcept(const QString &name) {
71 InterfaceManager interfaceManager;
72 MantidHelpInterface *gui = interfaceManager.createHelpWindow();
73 if (gui) {
74 gui->showConcept(name);
75 } else {
76 g_log.error() << "Failed to launch help for concept " << name.toStdString() << "\n";
77 }
78}
79
80void HelpWindow::showFitFunction(const std::string &name) {
81 InterfaceManager interfaceManager;
82 MantidHelpInterface *gui = interfaceManager.createHelpWindow();
83 if (gui) {
84 gui->showFitFunction(name);
85 } else {
86 g_log.error() << "Failed to launch help for fit function " << name << "\n";
87 }
88}
89
90void HelpWindow::showCustomInterface(const std::string &name, const std::string &area, const std::string &section) {
91 showCustomInterface(QString::fromStdString(name), QString::fromStdString(area), QString::fromStdString(section));
92}
93
94void HelpWindow::showCustomInterface(const QString &name, const QString &area, const QString &section) {
95 InterfaceManager interfaceManager;
96 MantidHelpInterface *gui = interfaceManager.createHelpWindow();
97 if (gui) {
98 gui->showCustomInterface(name, area, section);
99 } else {
100 // Open online help
101 QString baseUrl = "https://docs.mantidproject.org/interfaces/";
102 if (!area.toStdString().empty()) {
103 baseUrl += area + "/";
104 }
105 QString url = baseUrl + name + ".html";
107 g_log.debug("Opening online help page:\n" + url.toStdString());
108 }
109}
110
111} // namespace MantidQt::API
static void showPage(const std::string &url=std::string())
Definition: HelpWindow.cpp:28
static void showCustomInterface(const QString &name, const QString &area=QString(), const QString &section=QString())
Definition: HelpWindow.cpp:94
static void showConcept(const std::string &name=std::string())
Definition: HelpWindow.cpp:68
static void showAlgorithm(const std::string &name=std::string(), const int version=-1)
Definition: HelpWindow.cpp:50
static void showFitFunction(const std::string &name=std::string())
Definition: HelpWindow.cpp:80
This class is responsible for creating the correct dialog for an algorithm.
MantidHelpInterface * createHelpWindow() const
Function that instantiates the help window.
static bool openUrl(const QUrl &url)
Opens a url in the appropriate web browser.
virtual void showConcept(const std::string &name)
virtual void showCustomInterface(const std::string &name, const std::string &area=std::string(), const std::string &section=std::string())
virtual void showFitFunction(const std::string &name=std::string())
virtual void showAlgorithm(const std::string &name=std::string(), const int version=-1)
virtual void showPage(const std::string &url=std::string())
The Logger class is in charge of the publishing messages from the framework through various channels.
Definition: Logger.h:52
void debug(const std::string &msg)
Logs at debug level.
Definition: Logger.cpp:114
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
Kernel::Logger g_log("ExperimentInfo")
static logger object