From 2e6f8f8d68475f42a6e27d9ffe8eb96ace860c8e Mon Sep 17 00:00:00 2001 From: triplus Date: Wed, 11 Sep 2019 12:12:50 +0200 Subject: [PATCH] AppImage - add support for embedded documentation --- src/Gui/Assistant.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Gui/Assistant.cpp b/src/Gui/Assistant.cpp index 894af99545..629e88a88b 100644 --- a/src/Gui/Assistant.cpp +++ b/src/Gui/Assistant.cpp @@ -99,6 +99,33 @@ bool Assistant::startAssistant() QString doc = QString::fromUtf8(App::Application::getHelpDir().c_str()); QString qhc = doc + exe.toLower() + QLatin1String(".qhc"); + // AppImage mount location changes on each start. Assistant caches freecad.qhc + // file and sets an absolute path. As a result embedded documentation only works + // on the first AppImage start. Register the .gch file, to overcome the issue. + static bool start = true; + if (start) { + char* appimage = getenv("APPIMAGE"); + if (appimage) { + QString qch = doc + exe.toLower() + QLatin1String(".qch"); + QFileInfo fi(qch); + if (!fi.isReadable()) { + QMessageBox::critical(0, tr("%1 Help").arg(exe), + tr("%1 help files not found (%2). You might need to install the %1 documentation package.").arg(exe, qch)); + return false; + } + Base::Console().Log("Help file at %s\n", (const char*)qch.toUtf8()); + QStringList args; + args << QLatin1String("-register") << qch; + proc->start(app, args); + if (!proc->waitForFinished(50000)) { + QMessageBox::critical(0, tr("%1 Help").arg(exe), + tr("Unable to launch Qt Assistant (%1)").arg(app)); + return false; + } + } + start = false; + } + QFileInfo fi(qhc); if (!fi.isReadable()) { QMessageBox::critical(0, tr("%1 Help").arg(exe),