1
1
/***************************************************************************
2
* Copyright (c) 2008 Werner Mayer <wmayer@users.sourceforge.net> *
2
* Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net> *
4
4
* This file is part of the FreeCAD CAx development system. *
53
53
void Assistant::showDocumentation(const QString &page)
55
//Base::Console().Message("Open page %s\n", (const char*)page.toUtf8());
57
55
if (!startAssistant())
59
QTextStream str(proc);
60
str << QLatin1String("SetSource qthelp://com.freecad/doc/")
61
<< page << QLatin1Char('\0') << endl;
57
if (!page.isEmpty()) {
58
QTextStream str(proc);
59
str << QLatin1String("SetSource qthelp://org.freecad.usermanual/doc/")
60
<< page << QLatin1Char('\0') << endl;
64
64
bool Assistant::startAssistant()
66
#if QT_VERSION < 0x040400
67
QMessageBox::critical(0, QObject::tr("FreeCAD Help"),
68
QObject::tr("Unable to load documentation.\n"
69
"In order to load it Qt 4.4 or higher is required."));
67
74
proc = new QProcess();
69
76
if (proc->state() != QProcess::Running) {
79
app = QDir::convertSeparators(QString::fromUtf8
80
(App::GetApplication().GetHomePath()) + QLatin1String("bin/"));
70
82
QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
71
//QString app = QLatin1String("C:/Temp/qt/");
72
84
#if !defined(Q_OS_MAC)
73
85
app += QLatin1String("assistant");
78
90
// get the name of the executable and the doc path
79
91
QString exe = QString::fromUtf8(App::Application::Config()["ExeName"].c_str());
80
QString doc = QString::fromUtf8(App::Application::Config()["DocPath"].c_str());
92
QString doc = QString::fromUtf8(App::Application::getHelpDir().c_str());
93
QString qhc = doc + exe.toLower() + QLatin1String(".qhc");
95
static bool first = true;
97
Base::Console().Log("Help file at %s\n", (const char*)doc.toUtf8());
99
// we have first to register the qch befor qhc works!
100
//QString qch = doc + exe.toLower() + QLatin1String(".qch");
103
//args //<< QLatin1String("-collectionFile") << qhc
104
// << QLatin1String("-register") << qch;
106
//proc->start(app, args);
107
//// start the registering, error if take longer then 10 seconds
108
//if (!proc->waitForFinished(20000)) {
109
// QMessageBox::critical(0, QObject::tr("FreeCAD Help"),
110
// QObject::tr("Unable to launch Qt Assistant (%1)").arg(app));
83
args << QLatin1String("-collectionFile")
84
<< QString(QLatin1String("%1%2.qhc")).arg(doc).arg(exe.toLower())
117
args << QLatin1String("-collectionFile") << qhc
85
118
<< QLatin1String("-enableRemoteControl");
87
args.append(QLatin1String("-server"));
88
args.append(QLatin1String("-profile"));
89
args.append(QLatin1String("test.adp"));
92
120
proc->start(app, args);