|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 //USER |
|
18 #include "logsmainwindow.h" |
|
19 #include "logsviewmanager.h" |
|
20 #include "logsservicehandler.h" |
|
21 #include "logslogger.h" |
|
22 #include "logsdefs.h" |
|
23 |
|
24 //SYSTEM |
|
25 #include <QObject> |
|
26 #include <hbmainwindow.h> |
|
27 #include <hbapplication.h> |
|
28 #include <hbstyleloader.h> |
|
29 #include <QTranslator> |
|
30 |
|
31 int main(int argc, char *argv[]) |
|
32 { |
|
33 LOGS_QDEBUG( "logs [UI] -> main()" ) |
|
34 |
|
35 HbApplication app(argc, argv); |
|
36 LogsMainWindow window; |
|
37 |
|
38 QString lang = QLocale::system().name(); |
|
39 QString path = "z:/resource/qt/translations/"; |
|
40 //Load common translator |
|
41 QTranslator commontranslator; |
|
42 bool returncode = false; |
|
43 LOGS_QDEBUG("logs [UI] loading common strings translator"); |
|
44 returncode = commontranslator.load( path + "common_" + lang + ".qm"); |
|
45 if (returncode==false) { |
|
46 LOGS_QDEBUG("logs [UI] unable to open file: " + path + "common_" + lang + ".qm"); |
|
47 } else { |
|
48 app.installTranslator(&commontranslator); |
|
49 } |
|
50 |
|
51 //Load application-specific translator |
|
52 QTranslator translator; |
|
53 LOGS_QDEBUG("logs [UI] loading application strings translator"); |
|
54 LOGS_QDEBUG("logs [UI] translation filename dialer_" + lang + ".qm"); |
|
55 returncode = translator.load( path + "dialer_" + lang + ".qm"); |
|
56 if (returncode==false) { |
|
57 LOGS_QDEBUG("logs [UI] .qm file not found from "+path); |
|
58 path = ":/"; |
|
59 returncode = translator.load( path + "logs_default.qm"); |
|
60 LOGS_QDEBUG("logs [UI]: fallback to default language file logs_default.qm"); |
|
61 } |
|
62 |
|
63 if (returncode==false) { |
|
64 LOGS_QDEBUG( "logs [UI] .qm file not found from "+path); |
|
65 } else { |
|
66 LOGS_QDEBUG( "logs [UI] .qm loaded successfully from "+path); |
|
67 } |
|
68 |
|
69 app.installTranslator(&translator); |
|
70 HbStyleLoader::registerFilePath(":/logslayouts"); |
|
71 |
|
72 // Create service handler asap so that services are published fast. |
|
73 // Servicehandler cannot be created before HbApplication creation. |
|
74 // This can cause problem of service request not coming through if |
|
75 // HbApplication creation takes long time. |
|
76 LogsServiceHandler service(window); |
|
77 LogsViewManager viewManager(window, service); |
|
78 |
|
79 // Don't show window yet as app might be started at background |
|
80 int err = app.exec(); |
|
81 |
|
82 HbStyleLoader::unregisterFilePath(":/logslayouts"); |
|
83 |
|
84 LOGS_QDEBUG( "logs [UI] <- main()" ) |
|
85 return err; |
|
86 } |