19 #include <QGraphicsProxyWidget> |
19 #include <QGraphicsProxyWidget> |
20 // needed for localization |
20 // needed for localization |
21 #include <QLocale> |
21 #include <QLocale> |
22 #include <HbTranslator> |
22 #include <HbTranslator> |
23 #include <hbmainwindow.h> |
23 #include <hbmainwindow.h> |
24 #include <xqserviceutil.h> |
24 #include <afactivation.h> |
25 |
25 |
26 #ifdef Q_OS_SYMBIAN |
26 #ifdef Q_OS_SYMBIAN |
27 #include <coemain.h> |
27 #include <coemain.h> |
28 #include <eikenv.h> |
28 #include <eikenv.h> |
|
29 #include <XQSettingsManager> |
29 #endif // Q_OS_SYMBIAN |
30 #endif // Q_OS_SYMBIAN |
30 |
31 |
31 #include "cxeengine.h" |
32 #include "cxeengine.h" |
32 #include "cxecameradevicecontrol.h" |
33 #include "cxecameradevicecontrol.h" |
33 #include "cxuiapplication.h" |
34 #include "cxuiapplication.h" |
34 #include "cxuiviewmanager.h" |
35 #include "cxuiviewmanager.h" |
35 #include "cxuiapplicationstate.h" |
36 #include "cxuiapplicationstate.h" |
36 #include "cxuienums.h" |
37 #include "cxuienums.h" |
37 #include "cxutils.h" |
38 #include "cxutils.h" |
38 #include "cxuiserviceprovider.h" |
39 #include "cxuiserviceprovider.h" |
|
40 #include "cxuidisplaypropertyhandler.h" |
39 |
41 |
40 #ifdef Q_OS_SYMBIAN |
42 #ifdef Q_OS_SYMBIAN |
41 #include "OstTraceDefinitions.h" |
43 #include "OstTraceDefinitions.h" |
42 #ifdef OST_TRACE_COMPILER_IN_USE |
44 #ifdef OST_TRACE_COMPILER_IN_USE |
43 #include "mainTraces.h" |
45 #include "mainTraces.h" |
48 |
50 |
49 // CONSTANTS |
51 // CONSTANTS |
50 const QString TRANSLATIONS_PATH = "/resource/qt/translations/"; |
52 const QString TRANSLATIONS_PATH = "/resource/qt/translations/"; |
51 const QString TRANSLATIONS_FILE = "camera"; |
53 const QString TRANSLATIONS_FILE = "camera"; |
52 |
54 |
|
55 const long int CAMERAX_USE_RASTER_PS_UID = 0x2726beef; |
|
56 const unsigned long int CAMERAX_USE_RASTER_PS_KEY = 0; |
|
57 |
53 int main(int argc, char *argv[]) |
58 int main(int argc, char *argv[]) |
54 { |
59 { |
55 CX_DEBUG(("CxUI: entering main()")); |
60 CX_DEBUG(("CxUI: entering main()")); |
56 OstTrace0( camerax_performance, _MAIN, "msg: e_CX_STARTUP 1" ); |
61 OstTrace0( camerax_performance, _MAIN, "msg: e_CX_STARTUP 1" ); |
57 |
62 |
58 Q_INIT_RESOURCE(cxui); |
63 Q_INIT_RESOURCE(cxui); |
59 |
64 |
60 // Use software rendering / raster graphics system to save graphics memory |
65 #ifdef Q_OS_SYMBIAN |
61 CX_DEBUG(("CxUI: Take raster graphics system into use")); |
66 XQSettingsManager settingManager; |
62 QApplication::setGraphicsSystem("raster"); |
67 XQPublishAndSubscribeSettingsKey useRasterGraphicsSystemKey( |
|
68 CAMERAX_USE_RASTER_PS_UID, CAMERAX_USE_RASTER_PS_KEY); |
|
69 QVariant useRasterGraphicsSystemValue = |
|
70 settingManager.readItemValue(useRasterGraphicsSystemKey, |
|
71 XQSettingsManager::TypeInt); |
|
72 |
|
73 if (useRasterGraphicsSystemValue.isNull() |
|
74 || !useRasterGraphicsSystemValue.toInt()) { |
|
75 // Either there was an error reading the value or the value was |
|
76 // zero. Raster graphics system should be forced |
|
77 CX_DEBUG(("CxUI: Take raster graphics system into use")); |
|
78 QApplication::setGraphicsSystem("raster"); |
|
79 } |
|
80 #endif |
63 |
81 |
64 OstTrace0( camerax_performance, DUP1__MAIN, "msg: e_CX_HBAPP_CREATION 1" ); |
82 OstTrace0( camerax_performance, DUP1__MAIN, "msg: e_CX_HBAPP_CREATION 1" ); |
65 CxuiApplication app(argc, argv); |
83 CxuiApplication app(argc, argv); |
66 OstTrace0( camerax_performance, DUP2__MAIN, "msg: e_CX_HBAPP_CREATION 0" ); |
84 OstTrace0( camerax_performance, DUP2__MAIN, "msg: e_CX_HBAPP_CREATION 0" ); |
67 |
85 |
70 // ui construction. |
88 // ui construction. |
71 OstTrace0( camerax_performance, DUP7__MAIN, "msg: e_CX_CREATE_ENGINE 1" ); |
89 OstTrace0( camerax_performance, DUP7__MAIN, "msg: e_CX_CREATE_ENGINE 1" ); |
72 CxeEngine *engine = CxeEngine::createEngine(); |
90 CxeEngine *engine = CxeEngine::createEngine(); |
73 OstTrace0( camerax_performance, DUP8__MAIN, "msg: e_CX_CREATE_ENGINE 0" ); |
91 OstTrace0( camerax_performance, DUP8__MAIN, "msg: e_CX_CREATE_ENGINE 0" ); |
74 |
92 |
75 if (app.activateReason() == Hb::ActivationReasonService || |
93 AfActivation activation; |
76 // @todo: There's a bug in orbit and we never get Hb::ActivationReasonService as |
94 if (activation.reason() == Af::ActivationReasonService) { |
77 // activation reason. Use XQServiceUtil to determine if starting service as |
|
78 // a workaround for now |
|
79 XQServiceUtil::isService()) { |
|
80 CX_DEBUG(("CxUI: Camera started as service")); |
95 CX_DEBUG(("CxUI: Camera started as service")); |
81 // Embedded mode. Engine is inited to correct mode |
96 // Embedded mode. Engine is inited to correct mode |
82 // by service provider when request arrives |
97 // by service provider when request arrives |
83 CX_DEBUG(("CxUI: creating serviceprovider")); |
98 CX_DEBUG(("CxUI: creating serviceprovider")); |
84 CxuiServiceProvider::create(engine); |
99 CxuiServiceProvider::create(engine); |
85 CX_DEBUG(("CxUI: done")); |
100 CX_DEBUG(("CxUI: done")); |
86 } else if (app.activateReason() == Hb::ActivationReasonActivity) { |
101 } else if (activation.reason() == Af::ActivationReasonActivity) { |
87 CX_DEBUG(("CxUI: Camera started as activity")); |
102 CX_DEBUG(("CxUI: Camera started as activity")); |
88 Cxe::CameraMode mode = Cxe::ImageMode; |
103 Cxe::CameraMode mode = Cxe::ImageMode; |
89 QString activityId = app.activateId(); |
104 QString activityId = activation.name(); |
90 if (activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY || |
105 if (activityId == CxuiActivityIds::VIDEO_PRECAPTURE_ACTIVITY || |
91 activityId == CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY) { |
106 activityId == CxuiActivityIds::VIDEO_POSTCAPTURE_ACTIVITY) { |
92 mode = Cxe::VideoMode; |
107 mode = Cxe::VideoMode; |
93 } |
108 } |
94 |
109 |
117 OstTrace0( camerax_performance, DUP4__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 0" ); |
132 OstTrace0( camerax_performance, DUP4__MAIN, "msg: e_CX_LOAD_TRANSLATIONS 0" ); |
118 CX_DEBUG(("CxUI: ..translations loaded")); |
133 CX_DEBUG(("CxUI: ..translations loaded")); |
119 |
134 |
120 // Create main window |
135 // Create main window |
121 OstTrace0( camerax_performance, DUP5__MAIN, "msg: e_CX_MAINWINDOW_CREATION 1" ); |
136 OstTrace0( camerax_performance, DUP5__MAIN, "msg: e_CX_MAINWINDOW_CREATION 1" ); |
122 HbMainWindow mainWindow(0, Hb::WindowFlagTransparent | Hb::WindowFlagNoBackground); |
137 HbMainWindow *mainWindow = new HbMainWindow(0, Hb::WindowFlagTransparent | Hb::WindowFlagNoBackground); |
123 mainWindow.setAttribute(Qt::WA_NoBackground); |
138 mainWindow->setAttribute(Qt::WA_NoBackground); |
124 OstTrace0( camerax_performance, DUP6__MAIN, "msg: e_CX_MAINWINDOW_CREATION 0" ); |
139 OstTrace0( camerax_performance, DUP6__MAIN, "msg: e_CX_MAINWINDOW_CREATION 0" ); |
125 |
140 |
126 // Set main window to landscape and full screen |
141 // Set main window to landscape and full screen |
127 OstTrace0( camerax_performance, DUP13__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 1" ); |
142 OstTrace0( camerax_performance, DUP13__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 1" ); |
128 mainWindow.setOrientation(Qt::Horizontal); |
143 mainWindow->setOrientation(Qt::Horizontal); |
129 OstTrace0( camerax_performance, DUP14__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 0" ); |
144 OstTrace0( camerax_performance, DUP14__MAIN, "msg: e_CX_MAINWINDOW_SETORIENTATION 0" ); |
130 OstTrace0( camerax_performance, DUP15__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 1" ); |
145 OstTrace0( camerax_performance, DUP15__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 1" ); |
131 |
146 |
132 #ifdef Q_OS_SYMBIAN |
147 #ifdef Q_OS_SYMBIAN |
133 mainWindow.showFullScreen(); |
148 mainWindow->showFullScreen(); |
134 #else |
149 #else |
135 /* |
150 /* |
136 * todo : check if this is an Orbit bug or if there's a better solution |
151 * todo : check if this is an Orbit bug or if there's a better solution |
137 */ |
152 */ |
138 mainWindow.resize(640, 360); |
153 mainWindow->resize(640, 360); |
139 mainWindow.setOrientation(Qt::Vertical, false); |
154 mainWindow->setOrientation(Qt::Vertical, false); |
140 mainWindow.show(); |
155 mainWindow->show(); |
141 mainWindow.setOrientation(Qt::Horizontal, false); |
156 mainWindow->setOrientation(Qt::Horizontal, false); |
142 #endif //Q_OS_SYMBIAN |
157 #endif //Q_OS_SYMBIAN |
143 OstTrace0( camerax_performance, DUP16__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 0" ); |
158 OstTrace0( camerax_performance, DUP16__MAIN, "msg: e_CX_MAINWINDOW_FULLSCREEN 0" ); |
144 |
159 |
145 // Create view manager |
160 // Create view manager |
146 OstTrace0( camerax_performance, DUP11__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 1" ); |
161 OstTrace0( camerax_performance, DUP11__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 1" ); |
147 CxuiViewManager *viewManager = new CxuiViewManager(app, mainWindow, *engine); |
162 CxuiViewManager *viewManager = new CxuiViewManager(app, *mainWindow, *engine); |
148 OstTrace0( camerax_performance, DUP12__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 0" ); |
163 OstTrace0( camerax_performance, DUP12__MAIN, "msg: e_CX_CREATE_VIEW_MANAGER 0" ); |
149 |
164 |
150 // Give main window id to engine for setting up viewfinder window behind it |
165 // Give main window id to engine for setting up viewfinder window behind it |
151 OstTrace0( camerax_performance, DUP17__MAIN, "msg: e_CX_PREPAREWINDOW 1" ); |
166 OstTrace0( camerax_performance, DUP17__MAIN, "msg: e_CX_PREPAREWINDOW 1" ); |
152 engine->viewfinderControl().setWindow(mainWindow.effectiveWinId()); |
167 engine->viewfinderControl().setWindow(mainWindow->effectiveWinId()); |
153 OstTrace0( camerax_performance, DUP18__MAIN, "msg: e_CX_PREPAREWINDOW 0" ); |
168 OstTrace0( camerax_performance, DUP18__MAIN, "msg: e_CX_PREPAREWINDOW 0" ); |
|
169 |
|
170 // connect display handler to vf state changes |
|
171 CxuiDisplayPropertyHandler displayHandler; |
|
172 QObject::connect(&engine->viewfinderControl(), SIGNAL(stateChanged(CxeViewfinderControl::State, CxeError::Id)), |
|
173 &displayHandler, SLOT(handleVfStateChanged(CxeViewfinderControl::State, CxeError::Id))); |
154 |
174 |
155 int returnValue = app.exec(); |
175 int returnValue = app.exec(); |
156 |
176 |
157 delete viewManager; |
177 delete viewManager; |
|
178 viewManager = NULL; |
158 CxuiServiceProvider::destroy(); // delete service provider instance |
179 CxuiServiceProvider::destroy(); // delete service provider instance |
|
180 engine->cameraDeviceControl().release(); |
|
181 delete mainWindow; |
|
182 mainWindow = NULL; |
159 delete engine; |
183 delete engine; |
|
184 engine = NULL; |
160 |
185 |
161 return returnValue; |
186 return returnValue; |
162 } |
187 } |