~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/Gui/Assistant.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2010-01-11 08:48:33 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100111084833-4g9vgdqbkw8u34zb
Tags: 0.9.2646.5-1
* New upstream version (closes: #561696).
* Added swig to Build-Depends (closes: #563523, #563772).
* Removed python-opencv from Build-Depends and Recommends (closes: #560768).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (c) 2008 Werner Mayer <wmayer@users.sourceforge.net>        *
 
2
 *   Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net>     *
3
3
 *                                                                         *
4
4
 *   This file is part of the FreeCAD CAx development system.              *
5
5
 *                                                                         *
29
29
# include <QMessageBox>
30
30
# include <QProcess>
31
31
# include <QTextStream>
32
 
#endif
 
32
#endif
33
33
 
34
34
#include "Assistant.h"
35
35
#include <Base/Console.h>
52
52
 
53
53
void Assistant::showDocumentation(const QString &page)
54
54
{
55
 
    //Base::Console().Message("Open page %s\n", (const char*)page.toUtf8());
56
 
    //return;
57
55
    if (!startAssistant())
58
56
        return;
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;
 
61
    }
62
62
}
63
63
 
64
64
bool Assistant::startAssistant()
65
65
{
 
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."));
 
70
    return false;
 
71
#endif
 
72
 
66
73
    if (!proc)
67
74
        proc = new QProcess();
68
75
 
69
76
    if (proc->state() != QProcess::Running) {
 
77
#ifdef Q_OS_WIN
 
78
        QString app;
 
79
        app = QDir::convertSeparators(QString::fromUtf8
 
80
            (App::GetApplication().GetHomePath()) + QLatin1String("bin/"));
 
81
#else
70
82
        QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath) + QDir::separator();
71
 
        //QString app = QLatin1String("C:/Temp/qt/");
 
83
#endif 
72
84
#if !defined(Q_OS_MAC)
73
85
        app += QLatin1String("assistant");
74
86
#else
77
89
 
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");
 
94
 
 
95
        static bool first = true;
 
96
        if (first) {
 
97
            Base::Console().Log("Help file at %s\n", (const char*)doc.toUtf8());
 
98
            first = false;
 
99
            // we have first to register the qch befor qhc works!
 
100
            //QString qch = doc + exe.toLower() + QLatin1String(".qch");
 
101
            //QStringList args;
81
102
 
 
103
            //args   //<< QLatin1String("-collectionFile") << qhc
 
104
            //       << QLatin1String("-register") << qch;
 
105
            //        
 
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));
 
111
            //    return false;
 
112
            //}
 
113
        }
 
114
 
82
115
        QStringList args;
83
 
        args << QLatin1String("-collectionFile")
84
 
             << QString(QLatin1String("%1%2.qhc")).arg(doc).arg(exe.toLower())
 
116
 
 
117
        args << QLatin1String("-collectionFile") << qhc
85
118
             << QLatin1String("-enableRemoteControl");
86
 
#if 0
87
 
        args.append(QLatin1String("-server"));
88
 
        args.append(QLatin1String("-profile"));
89
 
        args.append(QLatin1String("test.adp"));
90
 
#endif
91
119
 
92
120
        proc->start(app, args);
93
121
 
97
125
            return false;
98
126
        }
99
127
    }
100
 
    
 
128
 
101
129
    return true;
102
130
}