1 |
1 |
#include <iostream>
|
2 |
2 |
#include <qapplication.h>
|
3 |
3 |
#include <qstring.h>
|
|
4 |
#include <QTextCodec>
|
|
5 |
#include <QTranslator>
|
4 |
6 |
#include "qgshelpserver.h"
|
5 |
7 |
#include "qgshelpviewer.h"
|
|
8 |
#include "qgsapplication.h"
|
6 |
9 |
|
7 |
10 |
int main( int argc, char ** argv )
|
8 |
11 |
{
|
9 |
|
QApplication a( argc, argv );
|
|
12 |
QgsApplication a( argc, argv, true );
|
10 |
13 |
QString context = QString::null;
|
|
14 |
QString myTranslationCode="";
|
|
15 |
|
11 |
16 |
if(argc == 2)
|
12 |
17 |
{
|
13 |
18 |
context = argv[1];
|
14 |
19 |
}
|
|
20 |
#ifdef Q_OS_MACX
|
|
21 |
// If we're on Mac, we have the resource library way above us...
|
|
22 |
QgsApplication::setPkgDataPath(QgsApplication::prefixPath()+"/../../../../share/qgis");
|
|
23 |
#endif
|
|
24 |
|
|
25 |
QString i18nPath = QgsApplication::i18nPath();
|
|
26 |
if (myTranslationCode.isEmpty())
|
|
27 |
{
|
|
28 |
myTranslationCode = QTextCodec::locale();
|
|
29 |
}
|
|
30 |
#ifdef QGISDEBUG
|
|
31 |
std::cout << "Setting translation to "
|
|
32 |
<< i18nPath.toLocal8Bit().data() << "/qgis_" << myTranslationCode.toLocal8Bit().data() << std::endl;
|
|
33 |
#endif
|
|
34 |
|
|
35 |
/* Translation file for Qt.
|
|
36 |
* The strings from the QMenuBar context section are used by Qt/Mac to shift
|
|
37 |
* the About, Preferences and Quit items to the Mac Application menu.
|
|
38 |
* These items must be translated identically in both qt_ and qgis_ files.
|
|
39 |
*/
|
|
40 |
QTranslator qttor(0);
|
|
41 |
if (qttor.load(QString("qt_") + myTranslationCode, i18nPath))
|
|
42 |
{
|
|
43 |
a.installTranslator(&qttor);
|
|
44 |
}
|
|
45 |
|
|
46 |
/* Translation file for QGIS.
|
|
47 |
*/
|
|
48 |
QTranslator qgistor(0);
|
|
49 |
if (qgistor.load(QString("qgis_") + myTranslationCode, i18nPath))
|
|
50 |
{
|
|
51 |
a.installTranslator(&qgistor);
|
|
52 |
}
|
|
53 |
|
15 |
54 |
QgsHelpViewer w(context);
|
16 |
55 |
w.show();
|
17 |
56 |
|