From c3dde65180362b1868d882096e57567f9adfa4cb Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Thu, 17 Mar 2022 11:15:48 +0100 Subject: [PATCH] Gui: Disable use of qassistant Displaying of help pages is now handled by the Help addon. In case the Help addon is not installed, an info message is shown. --- src/Base/Interpreter.cpp | 14 +++++++++----- src/Base/Interpreter.h | 2 +- src/Gui/MainWindow.cpp | 14 +++++++------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 3de634ce05..f3524900b9 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -468,7 +468,7 @@ void InterpreterSingleton::runFile(const char*pxFileName, bool local) } } -bool InterpreterSingleton::loadModule(const char* psModName) +bool InterpreterSingleton::loadModule(const char* psModName, bool nofail) { // buffer acrobatics //PyBuf ModName(psModName); @@ -478,10 +478,14 @@ bool InterpreterSingleton::loadModule(const char* psModName) module = PP_Load_Module(psModName); if (!module) { - if (PyErr_ExceptionMatches(PyExc_SystemExit)) - throw SystemExitException(); - else - throw PyException(); + if (nofail) + return false; + else { + if (PyErr_ExceptionMatches(PyExc_SystemExit)) + throw SystemExitException(); + else + throw PyException(); + } } return true; diff --git a/src/Base/Interpreter.h b/src/Base/Interpreter.h index 472b74602e..4fddafafa1 100644 --- a/src/Base/Interpreter.h +++ b/src/Base/Interpreter.h @@ -237,7 +237,7 @@ public: //@{ /* Loads a module */ - bool loadModule(const char* psModName); + bool loadModule(const char* psModName, bool nofail=false); /// Add an additional python path void addPythonPath(const char* Path); static void addType(PyTypeObject* Type,PyObject* Module, const char * Name); diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 2778761f47..d7368ec4ef 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -692,18 +692,18 @@ void MainWindow::whatsThis() void MainWindow::showDocumentation(const QString& help) { - // temporary - allows to enable/disable the use of the Help module - ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Help"); - bool useHelpModule = hGrp->GetBool("UseHelpModule", false); - if (useHelpModule) { + if (Base::Interpreter().loadModule("Help",true)) { Gui::Command::addModule(Gui::Command::Gui,"Help"); Gui::Command::doCommand(Gui::Command::Gui,"Help.show(\"%s\")", help.toStdString().c_str()); } else { QUrl url(help); if (url.scheme().isEmpty()) { - QString page; - page = QString::fromUtf8("%1.html").arg(help); - d->assistant->showDocumentation(page); + //QString page; + //page = QString::fromUtf8("%1.html").arg(help); + //d->assistant->showDocumentation(page); + QMessageBox::critical(getMainWindow(), tr("Help addon needed!"), + tr("The Help system of FreeCAD is now handled by the \"Help\" addon." + "Install it with menu Tools > Addons Manager")); } else { QDesktopServices::openUrl(url);