|
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: Big clock Screensaver plugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <QApplication> |
|
19 #include <QTranslator> |
|
20 #include <QLocale> |
|
21 |
|
22 #include <qserviceinterfacedescriptor.h> |
|
23 #include <qabstractsecuritysession.h> |
|
24 #include <qservicecontext.h> |
|
25 |
|
26 #include "snsrbigclockscreensaverplugin.h" |
|
27 #include "snsrbigclockscreensaver.h" |
|
28 |
|
29 const char *gBigClockInterfaceName = "com.nokia.screensaver.ISnsrBigClockScreensaver"; |
|
30 |
|
31 /*! |
|
32 \class SnsrBigClockScreensaverPlugin |
|
33 \ingroup group_snsrbigclockscreensaverplugin |
|
34 \brief Screensaver big clock screensaver plugin collects ready-made screensaver clock. |
|
35 */ |
|
36 |
|
37 #ifdef COVERAGE_MEASUREMENT |
|
38 #pragma CTC SKIP |
|
39 #endif //COVERAGE_MEASUREMENT |
|
40 |
|
41 /*! |
|
42 \reimp |
|
43 */ |
|
44 QObject *SnsrBigClockScreensaverPlugin::createInstance( |
|
45 const QServiceInterfaceDescriptor &descriptor, |
|
46 QServiceContext *context, |
|
47 QAbstractSecuritySession *session) |
|
48 { |
|
49 Q_UNUSED(context); |
|
50 Q_UNUSED(session); |
|
51 |
|
52 if (descriptor.interfaceName() == QLatin1String(gBigClockInterfaceName)) { |
|
53 LoadTranslator(); |
|
54 return new SnsrBigClockScreensaver(); |
|
55 } |
|
56 return 0; |
|
57 } |
|
58 |
|
59 |
|
60 /*! |
|
61 Loads a translator. |
|
62 */ |
|
63 void SnsrBigClockScreensaverPlugin::LoadTranslator() |
|
64 { |
|
65 QString locale = QLocale::system().name(); |
|
66 QString filename = QString("snsrbigclockscreensaverplugin_%1").arg(locale); |
|
67 QTranslator *translator = new QTranslator(this); |
|
68 #ifdef Q_OS_SYMBIAN |
|
69 bool loaded(false); |
|
70 // TRAP is must here, otherwise it crashes |
|
71 TRAP_IGNORE( |
|
72 loaded = translator->load(filename, |
|
73 QString("z:/resource/qt/translations")); |
|
74 if (!loaded) { |
|
75 loaded = translator->load(filename, |
|
76 QString("c:/resource/qt/translations")); |
|
77 } |
|
78 ); |
|
79 #else |
|
80 translator->load(filename, QString("resource/qt/translations") ); |
|
81 #endif //Q_OS_SYMBIAN |
|
82 |
|
83 qApp->installTranslator(translator); |
|
84 } |
|
85 |
|
86 Q_EXPORT_PLUGIN2(snsrbigclockscreensaverplugin, SnsrBigClockScreensaverPlugin) |
|
87 |
|
88 #ifdef COVERAGE_MEASUREMENT |
|
89 #pragma CTC ENDSKIP |
|
90 #endif //COVERAGE_MEASUREMENT |