Skip to content

File tree

2 files changed

+45
-2
lines changed

2 files changed

+45
-2
lines changed
 

‎src/helpviewer/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ SET (HELP_SRCS
66
main.cpp
77
qgshelpserver.cpp
88
qgshelpviewer.cpp
9+
../core/qgsapplication.cpp
10+
../core/qgslogger.cpp
911
)
1012

1113
SET (HELP_UIS qgshelpviewerbase.ui)
@@ -30,13 +32,15 @@ QT4_WRAP_CPP (HELP_MOC_SRCS ${HELP_MOC_HDRS})
3032
ADD_EXECUTABLE (qgis_help MACOSX_BUNDLE ${HELP_SRCS} ${HELP_MOC_SRCS} ${HELP_UIS_H})
3133

3234
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
35+
${CMAKE_CURRENT_SOURCE_DIR}/../core
3336
${CMAKE_CURRENT_BINARY_DIR}
3437
${SQLITE3_INCLUDE_DIR}
3538
)
3639

3740
TARGET_LINK_LIBRARIES(qgis_help
3841
${QT_LIBRARIES}
3942
${SQLITE3_LIBRARY}
43+
qgis_core
4044
)
4145

4246

‎src/helpviewer/main.cpp

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,56 @@
11
#include <iostream>
2-
#include <qapplication.h>
2+
#include <qgsapplication.h>
33
#include <qstring.h>
4+
#include <QTextCodec>
5+
#include <QTranslator>
46
#include "qgshelpserver.h"
57
#include "qgshelpviewer.h"
8+
#include "qgsapplication.h"
69

710
int main( int argc, char ** argv )
811
{
9-
QApplication a( argc, argv );
12+
QgsApplication a( argc, argv, true );
1013
QString context = QString::null;
14+
QString myTranslationCode="";
15+
1116
if(argc == 2)
1217
{
1318
context = argv[1];
1419
}
20+
#ifdef Q_OS_MACX
21+
// If we're on Mac, we have the resource library way above us...
22+
a.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+
1554
QgsHelpViewer w(context);
1655
w.show();
1756

0 commit comments

Comments
 (0)
Please sign in to comment.