47 namespace |
47 namespace |
48 { |
48 { |
49 const char KTranslationPath[] = "resource/qt/translations"; |
49 const char KTranslationPath[] = "resource/qt/translations"; |
50 const char KTsDialogType[] = "com.nokia.taskswitcher.tsdevicedialogplugin/1.0"; |
50 const char KTsDialogType[] = "com.nokia.taskswitcher.tsdevicedialogplugin/1.0"; |
51 const char KActivityManaged [] = "com.nokia.qt.activities.ActivityManager"; |
51 const char KActivityManaged [] = "com.nokia.qt.activities.ActivityManager"; |
52 } |
52 } |
53 |
53 |
54 /*! |
54 /*! |
55 Constructor. |
55 Constructor. |
56 */ |
56 */ |
57 TsDeviceDialogPlugin::TsDeviceDialogPlugin() |
57 TsDeviceDialogPlugin::TsDeviceDialogPlugin() |
58 : |
58 : |
59 mModel(0), |
59 mModel(0), |
60 mStorage(0), |
60 mStorage(0), |
61 mTriedToLoadTranslation(false) |
61 mTriedToLoadTranslation(false) |
62 { |
62 { |
63 } |
63 } |
64 |
64 |
65 TsDeviceDialogPlugin::~TsDeviceDialogPlugin() |
65 TsDeviceDialogPlugin::~TsDeviceDialogPlugin() |
66 { |
66 { |
67 delete mModel; |
67 delete mModel; |
68 } |
68 } |
69 /*! |
69 /*! |
70 \reimp |
70 \reimp |
71 */ |
71 */ |
72 bool TsDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType, |
72 bool TsDeviceDialogPlugin::accessAllowed(const QString &deviceDialogType, |
73 const QVariantMap ¶meters, |
73 const QVariantMap ¶meters, |
74 const QVariantMap &securityInfo) const |
74 const QVariantMap &securityInfo) const |
75 { |
75 { |
76 Q_UNUSED(deviceDialogType) |
76 Q_UNUSED(deviceDialogType) |
77 Q_UNUSED(parameters) |
77 Q_UNUSED(parameters) |
78 Q_UNUSED(securityInfo) |
78 Q_UNUSED(securityInfo) |
83 } |
83 } |
84 |
84 |
85 /*! |
85 /*! |
86 \reimp |
86 \reimp |
87 */ |
87 */ |
88 HbDeviceDialogInterface * |
88 HbDeviceDialogInterface * |
89 TsDeviceDialogPlugin::createDeviceDialog(const QString &deviceDialogType, |
89 TsDeviceDialogPlugin::createDeviceDialog(const QString &deviceDialogType, |
90 const QVariantMap ¶meters) |
90 const QVariantMap ¶meters) |
91 { |
91 { |
92 Q_UNUSED(parameters) |
92 Q_UNUSED(parameters) |
93 HbDeviceDialogInterface *dialogInterface(0); |
93 HbDeviceDialogInterface *dialogInterface(0); |
94 if (deviceDialogType == QString(KTsDialogType)) { |
94 if (deviceDialogType == QString(KTsDialogType)) { |
95 // lazy loading of translation |
95 // lazy loading of translation |
96 if (!mTriedToLoadTranslation) { |
96 if (!mTriedToLoadTranslation) { |
97 mTriedToLoadTranslation = true; |
97 mTriedToLoadTranslation = true; |
98 |
98 |
99 QTranslator *translator = new QTranslator(this); |
99 QTranslator *translator = new QTranslator(this); |
100 QString translationFile = |
100 QString translationFile = |
101 QString("taskswitcher_%1").arg(QLocale::system().name()); |
101 QString("taskswitcher_%1").arg(QLocale::system().name()); |
102 |
102 |
103 bool translationLoaded(false); |
103 bool translationLoaded(false); |
104 #ifdef Q_OS_SYMBIAN |
104 #ifdef Q_OS_SYMBIAN |
105 translationLoaded = |
105 translationLoaded = |
106 translator->load(translationFile, |
106 translator->load(translationFile, |
107 QString("z:/") + KTranslationPath); |
107 QString("z:/") + KTranslationPath); |
108 if (!translationLoaded) { |
108 if (!translationLoaded) { |
109 translationLoaded = |
109 translationLoaded = |
110 translator->load(translationFile, |
110 translator->load(translationFile, |
111 QString("c:/") + KTranslationPath); |
111 QString("c:/") + KTranslationPath); |
112 } |
112 } |
113 #else |
113 #else |
114 translationLoaded = |
114 translationLoaded = |
115 translator->load(translationFile, |
115 translator->load(translationFile, |
116 QString(KTranslationPath)); |
116 QString(KTranslationPath)); |
117 #endif //Q_OS_SYMBIAN |
117 #endif //Q_OS_SYMBIAN |
118 |
118 |
119 Q_ASSERT(translationLoaded); |
119 Q_ASSERT(translationLoaded); |
120 qApp->installTranslator(translator); |
120 qApp->installTranslator(translator); |
121 } |
121 } |
122 |
122 |
123 // lazy loading of model |
123 // lazy loading of model |
124 if (!mModel) { |
124 if (!mModel) { |
125 mStorage = new TsTaskMonitor(this); |
125 mStorage = new TsTaskMonitor(this); |
126 |
126 |
127 QServiceManager serviceManager; |
127 QServiceManager serviceManager; |
128 QObject *activityManager(serviceManager.loadInterface(KActivityManaged)); |
128 QObject *activityManager(serviceManager.loadInterface(KActivityManaged)); |
129 if (activityManager) { |
129 if (activityManager) { |
130 activityManager->setParent(this); //make it autodestructed |
130 activityManager->setParent(this); //make it autodestructed |
131 } else { |
131 } else { |
132 activityManager = this; //activity plugin is not present. provide invalid instance because its not critical functionality. |
132 activityManager = this; //activity plugin is not present. provide invalid instance because its not critical functionality. |
133 //QMetaObject::invokeMethod is safe to use in such a case. |
133 //QMetaObject::invokeMethod is safe to use in such a case. |
134 } |
134 } |
135 mModel = new TsModel(*mStorage, *activityManager); |
135 mModel = new TsModel(*mStorage, *activityManager); |
136 } |
136 } |
137 |
137 |
138 // ensure the dismiss request property is set to false |
138 // ensure the dismiss request property is set to false |
139 |
139 |
140 QValueSpacePublisher dismissRequestPublisher(TsProperty::KTsPath); |
140 QValueSpacePublisher dismissRequestPublisher(TsProperty::KTsPath); |
141 dismissRequestPublisher.setValue(TsProperty::KDismissRequestPath, static_cast<int>(false)); |
141 dismissRequestPublisher.setValue(TsProperty::KDismissRequestPath, static_cast<int>(false)); |
142 dismissRequestPublisher.sync(); |
142 dismissRequestPublisher.sync(); |
143 |
143 |
144 |
144 |
145 // create device dialog |
145 // create device dialog |
146 dialogInterface = new TsDeviceDialogContainer(mModel); |
146 dialogInterface = new TsDeviceDialogContainer(mModel); |
147 } |
147 } |
148 return dialogInterface; |
148 return dialogInterface; |
149 } |
149 } |
150 |
150 |
151 /*! |
151 /*! |
152 \reimp |
152 \reimp |
153 */ |
153 */ |
154 bool TsDeviceDialogPlugin::deviceDialogInfo(const QString &deviceDialogType, |
154 bool TsDeviceDialogPlugin::deviceDialogInfo(const QString &deviceDialogType, |
155 const QVariantMap ¶meters, |
155 const QVariantMap ¶meters, |
156 DeviceDialogInfo *info) const |
156 DeviceDialogInfo *info) const |
157 { |
157 { |
158 Q_UNUSED(parameters) |
158 Q_UNUSED(parameters) |
159 Q_UNUSED(deviceDialogType) |
159 Q_UNUSED(deviceDialogType) |
160 |
160 |