Unverified Commit 03ab3498 authored by Peterson, Peter's avatar Peterson, Peter Committed by GitHub
Browse files

Merge pull request #30787 from mantidproject/help_url_error

Improved interface help interaction (ornlnext)
parents 7b6eb20e 149fb210
......@@ -40,8 +40,10 @@ public:
virtual void showFitFunction(const std::string &name = std::string());
virtual void showFitFunction(const QString &name);
virtual void showCustomInterface(const std::string &name,
const std::string &area = std::string(),
const std::string &section = std::string());
virtual void showCustomInterface(const QString &name,
const QString &area = QString(),
const QString &section = QString());
public slots:
......
......@@ -44,8 +44,9 @@ public:
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,
void showCustomInterface(const QString &name, const QString &area = QString(),
const QString &section = QString()) override;
private:
......@@ -73,4 +74,4 @@ public slots:
};
} // namespace MantidWidgets
} // namespace MantidQt
\ No newline at end of file
} // namespace MantidQt
......@@ -117,21 +117,27 @@ void HelpWindow::showFitFunction(QWidget *parent, const std::string &name) {
}
void HelpWindow::showCustomInterface(QWidget *parent, const std::string &name,
const std::string &area,
const std::string &section) {
showCustomInterface(parent, QString::fromStdString(name),
QString::fromStdString(area),
QString::fromStdString(section));
}
void HelpWindow::showCustomInterface(QWidget *parent, const QString &name,
const QString &area,
const QString &section) {
InterfaceManager interfaceManager;
MantidHelpInterface *gui = interfaceManager.createHelpWindow();
if (gui) {
connectParent(gui, parent);
gui->showCustomInterface(name, section);
gui->showCustomInterface(name, area, section);
} else {
// Open online help
QString baseUrl = "https://docs.mantidproject.org/interfaces/";
if (!area.toStdString().empty()) {
baseUrl += area + "/";
}
QString url = baseUrl + name + ".html";
MantidDesktopServices::openUrl(QUrl(url));
g_log.debug("Opening online help page:\n" + url.toStdString());
......
......@@ -283,9 +283,11 @@ void InterfaceManager::showFitFunctionHelp(const QString &name) {
window->showFitFunction(name);
}
void InterfaceManager::showCustomInterfaceHelp(const QString &name) {
void InterfaceManager::showCustomInterfaceHelp(const QString &name,
const QString &area,
const QString &section) {
auto window = createHelpWindow();
window->showCustomInterface(name);
window->showCustomInterface(name, area, section);
}
void InterfaceManager::showWebPage(const QString &url) {
......
......@@ -245,7 +245,7 @@ QListWidget *ManageUserDirectories::listWidget(QObject *sender) {
/// Show the help for ManageUserDirectories
void ManageUserDirectories::helpClicked() {
HelpWindow::showCustomInterface(nullptr, HELP_ID);
HelpWindow::showCustomInterface(nullptr, HELP_ID, "framework");
}
/// Close the dialog without saving the configuration
......
......@@ -56,14 +56,18 @@ void MantidHelpInterface::showFitFunction(const QString &name) {
}
void MantidHelpInterface::showCustomInterface(const std::string &name,
const std::string &area,
const std::string &section) {
UNUSED_ARG(name);
UNUSED_ARG(area);
UNUSED_ARG(section);
}
void MantidHelpInterface::showCustomInterface(const QString &name,
const QString &area,
const QString &section) {
UNUSED_ARG(name);
UNUSED_ARG(area);
UNUSED_ARG(section);
}
......
......@@ -322,24 +322,32 @@ void MantidHelpWindow::showFitFunction(const QString &name) {
* Show the help page for a given custom interface.
*
* @param name The name of the interface to show
* @param area :: the folder in the custom interface documentation directory
* @param section :: the section of the interface to show
*/
void MantidHelpWindow::showCustomInterface(const QString &name,
const QString &area,
const QString &section) {
this->showCustomInterface(name.toStdString(), section.toStdString());
this->showCustomInterface(name.toStdString(), area.toStdString(),
section.toStdString());
}
/**
* Show the help page for a given custom interface.
*
* @param name The name of the interface to show
* @param area :: the folder in the custom interface documentation directory
* @param section :: the section of the interface to show
*/
void MantidHelpWindow::showCustomInterface(const std::string &name,
const std::string &area,
const std::string &section) {
if (bool(g_helpWindow)) {
QString url(BASE_URL);
url += "interfaces/";
if (!area.empty()) {
url += QString::fromStdString(area) + "/";
}
if (name.empty()) {
url += "index.html";
} else {
......
......@@ -375,7 +375,7 @@ void pqHelpWindow::showPage(const QString &url,
//-----------------------------------------------------------------------------
void pqHelpWindow::showPage(const QUrl &url, bool linkClicked /* = false */) {
if (url.scheme() == QTHELP_SCHEME) {
if (this->m_helpEngine->findFile(url).isValid()) {
if (this->isExistingPage(url)) {
if (!linkClicked)
this->m_browser->setUrl(url);
} else {
......@@ -450,5 +450,6 @@ void pqHelpWindow::showHomePage(const QString &namespace_name) {
//-----------------------------------------------------------------------------
bool pqHelpWindow::isExistingPage(const QUrl &url) {
return this->m_helpEngine->findFile(url).isValid();
return (this->m_helpEngine->findFile(url).isValid() &&
(this->m_helpEngine->fileData(url).size() > 0));
}
......@@ -130,10 +130,6 @@ class DGSPlannerGUI(QtWidgets.QWidget):
self.assistant_process = QtCore.QProcess(self)
# pylint: disable=protected-access
self.mantidplot_name = 'DGS Planner'
self.collection_file = os.path.join(mantid._bindir, '../docs/qthelp/MantidProject.qhc')
version = ".".join(mantid.__version__.split(".")[:2])
self.qt_url = 'qthelp://org.sphinx.mantidproject.' + version + '/doc/interfaces/DGS Planner.html'
self.external_url = 'http://docs.mantidproject.org/nightly/interfaces/framework/DGS Planner.html'
# control for cancel button
self.iterations = 0
self.progress_canceled = False
......@@ -158,11 +154,7 @@ class DGSPlannerGUI(QtWidgets.QWidget):
self.masterDict.update(copy.deepcopy(d))
def help(self):
show_interface_help(self.mantidplot_name,
self.assistant_process,
self.collection_file,
self.qt_url,
self.external_url)
show_interface_help(self.mantidplot_name, self.assistant_process, area='direct')
def closeEvent(self, event):
self.assistant_process.close()
......
......@@ -142,7 +142,7 @@ class EngineeringDiffractionGui(QtWidgets.QMainWindow, Ui_main_window):
self.comboBox_instrument.currentIndexChanged.connect(slot)
def open_help_window(self):
InterfaceManager().showCustomInterfaceHelp(self.doc)
InterfaceManager().showCustomInterfaceHelp(self.doc,'diffraction')
def open_settings(self):
self.settings_presenter.show()
......
......@@ -1070,7 +1070,7 @@ class MainWindow(QMainWindow):
def helpClicked(self):
try:
import mantidqt
mantidqt.interfacemanager.InterfaceManager().showCustomInterfaceHelp("Filter Events")
mantidqt.interfacemanager.InterfaceManager().showCustomInterfaceHelp("Filter Events","utility")
except ImportError:
url = ("http://docs.mantidproject.org/nightly/interfaces/{}.html"
"".format("Filter Events"))
......
......@@ -140,6 +140,9 @@ class DrillView(QMainWindow):
super(DrillView, self).__init__(None, Qt.Window)
self.here = os.path.dirname(os.path.realpath(__file__))
# help
self.assistant_process = QProcess(self)
# setup ui
uic.loadUi(os.path.join(self.here, 'ui/main.ui'), self)
self.setup_header()
......@@ -254,6 +257,8 @@ class DrillView(QMainWindow):
Args:
event (QCloseEvent): the close event
"""
self.assistant_process.close()
self.assistant_process.waitForFinished()
children = self.findChildren(QDialog)
for child in children:
child.close()
......@@ -421,8 +426,8 @@ class DrillView(QMainWindow):
"""
Popup the help window.
"""
InterfaceManager().showHelpPage(
"qthelp://org.mantidproject/doc/interfaces/DrILL.html")
from mantidqt.gui_helper import show_interface_help
show_interface_help("DrILL",self.assistant_process,area="ILL")
def automatic_filling(self):
"""
......
......@@ -98,7 +98,7 @@ class SANSSaveOtherDialog(QtWidgets.QDialog, Ui_SaveOtherDialog):
def _on_help_button_clicked(self):
try:
import mantidqt
mantidqt.interfacemanager.InterfaceManager().showCustomInterfaceHelp('sans_save_other')
mantidqt.interfacemanager.InterfaceManager().showCustomInterfaceHelp('sans_save_other','isis_sans')
except:
pass
......
......@@ -62,4 +62,4 @@ class HelpWidgetView(QtWidgets.QWidget):
manageuserdirectories.ManageUserDirectories.openManageUserDirectories()
def _on_help_button_clicked(self):
InterfaceManager().showCustomInterfaceHelp(self.doc)
InterfaceManager().showCustomInterfaceHelp(self.doc, 'muon')
......@@ -681,7 +681,7 @@ class PyChopGui(QMainWindow):
"""
try:
import mantidqt
mantidqt.interfacemanager.InterfaceManager().showCustomInterfaceHelp("PyChop")
mantidqt.interfacemanager.InterfaceManager().showCustomInterfaceHelp("PyChop", 'direct')
except ImportError:
helpTxt = "PyChop is a tool to allow direct inelastic neutron\nscattering users to estimate the inelastic resolution\n"
helpTxt += "and incident flux for a given spectrometer setting.\n\nFirst select the instrument, chopper settings and\n"
......
......@@ -6,7 +6,6 @@
# SPDX - License - Identifier: GPL - 3.0 +
from mantidqt.gui_helper import show_interface_help
import numpy as np
import os
import mantid
from qtpy import QtWidgets
from mantidqt.MPLwidgets import *
......@@ -206,19 +205,11 @@ class QECoverageGUI(QtWidgets.QWidget):
self.assistant_process = QtCore.QProcess(self)
# pylint: disable=protected-access
self.mantidplot_name='QE Coverage'
self.collection_file = os.path.join(mantid._bindir, '../docs/qthelp/MantidProject.qhc')
version = ".".join(mantid.__version__.split(".")[:2])
self.qt_url = 'qthelp://org.sphinx.mantidproject.' + version + '/doc/interfaces/QE Coverage.html'
self.external_url = 'http://docs.mantidproject.org/nightly/interfaces/utility/QE Coverage.html'
#register startup
mantid.UsageService.registerFeatureUsage(mantid.kernel.FeatureType.Interface,"QECoverage",False)
def onHelp(self):
show_interface_help(self.mantidplot_name,
self.assistant_process,
self.collection_file,
self.qt_url,
self.external_url)
show_interface_help(self.mantidplot_name, self.assistant_process, area='utility')
def closeEvent(self, event):
self.assistant_process.close()
......
......@@ -44,4 +44,4 @@ class SampleTransmissionCalculatorPresenter(object):
def help_window(self):
gui_name = 'Sample Transmission Calculator'
InterfaceManager().showCustomInterfaceHelp(gui_name)
InterfaceManager().showCustomInterfaceHelp(gui_name,'general')
......@@ -8,7 +8,6 @@
from qtpy.QtWidgets import QMainWindow, QMessageBox
from qtpy.QtGui import QDoubleValidator
from qtpy import QtCore
import os
from mantid.kernel import Logger
from mantidqt.gui_helper import show_interface_help
import math
......@@ -80,12 +79,7 @@ class MainWindow(QMainWindow):
#help
self.assistant_process = QtCore.QProcess(self)
# pylint: disable=protected-access
import mantid
self.mantidplot_name = 'TOF Converter'
self.collection_file = os.path.join(mantid._bindir, '../docs/qthelp/MantidProject.qhc')
version = ".".join(mantid.__version__.split(".")[:2])
self.qt_url = 'qthelp://org.sphinx.mantidproject.' + version + '/doc/interfaces/TOF Converter.html'
self.external_url = 'http://docs.mantidproject.org/nightly/interfaces/utility/TOF Converter.html'
try:
import mantid
......@@ -96,8 +90,7 @@ class MainWindow(QMainWindow):
pass
def helpClicked(self):
show_interface_help(self.mantidplot_name, self.assistant_process, self.collection_file,
self.qt_url, self.external_url)
show_interface_help(self.mantidplot_name, self.assistant_process, area='utility')
def closeEvent(self, event):
self.assistant_process.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment