|
1 /* |
|
2 * Copyright (c) 2010 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 |
|
18 #include <hbdataform.h> |
|
19 #include <hbdataformmodelitem.h> |
|
20 #include <hbdataformmodel.h> |
|
21 #include <hbdataformviewitem.h> |
|
22 #include <hbaction.h> |
|
23 #include <hbmenu.h> |
|
24 #include <hbtoolbar.h> |
|
25 #include <hbabstractviewitem.h> |
|
26 #include <hbaction.h> |
|
27 |
|
28 |
|
29 #include "settingsview.h" |
|
30 #include "enginewrapper.h" |
|
31 #include "sgengine.h" |
|
32 #include "hbslider.h" |
|
33 #include "notifications.h" |
|
34 |
|
35 |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 |
|
39 SettingsView::SettingsView(HbView &mainView, HbMainWindow &mainWindow, EngineWrapper &engineWrapper): |
|
40 mEngineWrapper(engineWrapper), |
|
41 mMainWindow(mainWindow), |
|
42 mMainView(mainView) |
|
43 { |
|
44 // Set title and add this view to main window |
|
45 setTitle("Settings"); |
|
46 |
|
47 HbAction *actionSaveSettings = menu()->addAction(QString("Save & close")); |
|
48 HbAction *actionCancel = menu()->addAction("Cancel & close"); |
|
49 |
|
50 toolBar()->addAction(actionSaveSettings); |
|
51 toolBar()->addAction(actionCancel); |
|
52 |
|
53 |
|
54 //create setting form |
|
55 mSettingForm = new HbDataForm(); |
|
56 |
|
57 //create a model class |
|
58 mModel = new HbDataFormModel(this); |
|
59 |
|
60 // DataFormItem for mode selection |
|
61 mModeItem = mModel->appendDataFormItem( |
|
62 HbDataFormModelItem::RadioButtonListItem, QString("Capture mode"), 0); |
|
63 mModeItem->setContentWidgetData(QString("items"), CAPTUREMODES); |
|
64 |
|
65 // Create setting model |
|
66 createSingleCaptureComponents(mModel, 0); |
|
67 createSequentialCaptureComponents(mModel, 0); |
|
68 createVideoCaptureComponents(mModel, 0); |
|
69 |
|
70 // Set created model model to form |
|
71 mSettingForm->setModel(mModel); |
|
72 setWidget(mSettingForm);//takes ownership |
|
73 |
|
74 // Get view item of mode selection item |
|
75 HbDataFormViewItem *viewItemVideoPage = static_cast<HbDataFormViewItem*>(mSettingForm->itemByIndex(mModel->indexFromItem(mModeItem))); |
|
76 |
|
77 loadSettings(); |
|
78 |
|
79 // Connect signals from item modifications and close with this form's slots |
|
80 connect(actionSaveSettings, SIGNAL(triggered()), this, SLOT(saveAndClose())); |
|
81 connect(actionCancel, SIGNAL(triggered()), this, SLOT(close())); |
|
82 |
|
83 HbAction *mDefaultNavigationAction = new HbAction(Hb::QuitNaviAction, this); |
|
84 connect(mDefaultNavigationAction,SIGNAL(triggered()), this, SLOT(saveAndClose())); |
|
85 setNavigationAction(mDefaultNavigationAction); |
|
86 |
|
87 |
|
88 |
|
89 } |
|
90 |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 |
|
94 SettingsView::~SettingsView() |
|
95 { |
|
96 |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 |
|
101 void SettingsView::loadSettings() |
|
102 { |
|
103 |
|
104 // get settings from engine; |
|
105 mSettings = mEngineWrapper.getGrabSettings(); |
|
106 |
|
107 //Capture mode |
|
108 mModeItem->setContentWidgetData("selected", mSettings.mCaptureMode); |
|
109 |
|
110 // Still image |
|
111 mImageHotKeyItem->setContentWidgetData("selected", mSettings.mSingleCaptureHotkey); |
|
112 mImageFormatItem->setContentWidgetData("selected", mSettings.mSingleCaptureImageFormat); |
|
113 mImageMemoryInUseItem->setContentWidgetData("selected", mSettings.mSingleCaptureMemoryInUseMultiDrive); |
|
114 mImageFileNameItem->setContentWidgetData("text", mSettings.mSingleCaptureFileName); |
|
115 |
|
116 // Seguantial image components |
|
117 mSequantialHotKeyItem->setContentWidgetData("selected", mSettings.mSequantialCaptureHotkey); |
|
118 mSequantialFormatItem->setContentWidgetData("selected", mSettings.mSequantialCaptureImageFormat); |
|
119 mSequantialDelayItem->setContentWidgetData("text", mSettings.mSequantialCaptureDelay); |
|
120 mSequantialMemoryInUseItem->setContentWidgetData("selected", mSettings.mSequantialCaptureMemoryInUseMultiDrive); |
|
121 mSequantialFileNameItem->setContentWidgetData("text", mSettings.mSequantialCaptureFileName); |
|
122 |
|
123 // Video capture components |
|
124 mVideoHotKeyItem->setContentWidgetData("selected", mSettings.mVideoCaptureHotkey); |
|
125 mVideoFormatItem->setContentWidgetData("selected", mSettings.mVideoCaptureVideoFormat); |
|
126 mVideoMemoryInUseItem->setContentWidgetData("selected", mSettings.mVideoCaptureMemoryInUseMultiDrive); |
|
127 mVideoFileNameItem->setContentWidgetData("text", mSettings.mVideoCaptureFileName); |
|
128 |
|
129 |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 |
|
134 void SettingsView::createSingleCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent) |
|
135 { |
|
136 |
|
137 // Create Group for single image components |
|
138 mGroupImageCapture = model->appendDataFormGroup(QString("Single image settings"), parent); |
|
139 |
|
140 // DataFormItem for hotkey selection |
|
141 mImageHotKeyItem = model->appendDataFormItem( |
|
142 HbDataFormModelItem::RadioButtonListItem, QString("Capture hotkey"), mGroupImageCapture); |
|
143 mImageHotKeyItem->setContentWidgetData(QString("items"), KEYS); |
|
144 |
|
145 // DataFormItem for image format selection |
|
146 mImageFormatItem = model->appendDataFormItem( |
|
147 HbDataFormModelItem::RadioButtonListItem, QString("Image format"), mGroupImageCapture); |
|
148 mImageFormatItem->setContentWidgetData(QString("items"), IMAGEFORMATS); |
|
149 |
|
150 // DataFormItem for memory in use selection |
|
151 mImageMemoryInUseItem = model->appendDataFormItem( |
|
152 HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupImageCapture); |
|
153 mImageMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES); |
|
154 |
|
155 // DataFormItem for file name |
|
156 mImageFileNameItem = model->appendDataFormItem( |
|
157 HbDataFormModelItem::TextItem, QString("File name"), mGroupImageCapture); |
|
158 mImageFileNameItem->setContentWidgetData(QString("text"), QString("Shot")); |
|
159 |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 |
|
164 void SettingsView::createSequentialCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent) |
|
165 { |
|
166 |
|
167 |
|
168 // Create Group for sequential image components |
|
169 mGroupSeguantialCapture = model->appendDataFormGroup(QString("Sequential image settings"), parent); |
|
170 |
|
171 // DataFormItem for hotkey selection |
|
172 mSequantialHotKeyItem = model->appendDataFormItem( |
|
173 HbDataFormModelItem::RadioButtonListItem, QString("Capture hotkey"), mGroupSeguantialCapture); |
|
174 mSequantialHotKeyItem->setContentWidgetData(QString("items"), KEYS); |
|
175 |
|
176 // DataFormItem for image format selection |
|
177 mSequantialFormatItem = model->appendDataFormItem( |
|
178 HbDataFormModelItem::RadioButtonListItem, QString("Image format"), mGroupSeguantialCapture); |
|
179 mSequantialFormatItem->setContentWidgetData(QString("items"), IMAGEFORMATS); |
|
180 |
|
181 // DataFormItem for delay between images selection |
|
182 mSequantialDelayItem = model->appendDataFormItem( |
|
183 HbDataFormModelItem::TextItem, QString("Delay between two images(ms)"), mGroupSeguantialCapture); |
|
184 mSequantialDelayItem->setContentWidgetData(QString("text"), QString("Shot")); |
|
185 |
|
186 // DataFormItem for memory selection |
|
187 mSequantialMemoryInUseItem = model->appendDataFormItem( |
|
188 HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupSeguantialCapture); |
|
189 mSequantialMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES); |
|
190 |
|
191 // DataFormItem for file name |
|
192 mSequantialFileNameItem = model->appendDataFormItem( |
|
193 HbDataFormModelItem::TextItem, QString("File name"), mGroupSeguantialCapture); |
|
194 mSequantialFileNameItem->setContentWidgetData(QString("text"), QString("Shot")); |
|
195 |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 |
|
200 void SettingsView::createVideoCaptureComponents(HbDataFormModel *model, HbDataFormModelItem *parent) |
|
201 { |
|
202 |
|
203 // Create Group for video capturing components |
|
204 mGroupVideoCapture = model->appendDataFormGroup(QString("Video settings"), parent); |
|
205 |
|
206 // DataFormItem for hotkey selection |
|
207 mVideoHotKeyItem = model->appendDataFormItem( |
|
208 HbDataFormModelItem::RadioButtonListItem, QString("Start/Stop hotkey"), mGroupVideoCapture); |
|
209 mVideoHotKeyItem->setContentWidgetData(QString("items"), KEYS); |
|
210 |
|
211 // DataFormItem for video format selection |
|
212 mVideoFormatItem = model->appendDataFormItem( |
|
213 HbDataFormModelItem::RadioButtonListItem, QString("Video format"), mGroupVideoCapture); |
|
214 mVideoFormatItem->setContentWidgetData(QString("items"), VIDEOFORMATS); |
|
215 |
|
216 // DataFormItem for memory selection |
|
217 mVideoMemoryInUseItem = model->appendDataFormItem( |
|
218 HbDataFormModelItem::RadioButtonListItem, QString("Memory in use"), mGroupVideoCapture); |
|
219 mVideoMemoryInUseItem->setContentWidgetData(QString("items"), MEMORYMODES); |
|
220 |
|
221 // DataFormItem for file name |
|
222 mVideoFileNameItem = model->appendDataFormItem( |
|
223 HbDataFormModelItem::TextItem, QString("File name"), mGroupVideoCapture); |
|
224 mVideoFileNameItem->setContentWidgetData(QString("text"), QString("Video")); |
|
225 |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 |
|
230 void SettingsView::saveAndClose() |
|
231 { |
|
232 |
|
233 readFormItems(); |
|
234 if (!mEngineWrapper.saveSettings(mSettings)) { |
|
235 Notifications::error("Unable to save settings"); |
|
236 } |
|
237 |
|
238 mEngineWrapper.EnableRcpOfFoc(EFalse); |
|
239 mMainWindow.setCurrentView(&mMainView); |
|
240 |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 |
|
245 void SettingsView::readFormItems() |
|
246 { |
|
247 |
|
248 //TODO this does not work correctly with WK38 ( Text box items ) |
|
249 |
|
250 mSettings.mCaptureMode = mModeItem->contentWidgetData("selected").toInt(); |
|
251 |
|
252 mSettings.mSingleCaptureImageFormat = mImageFormatItem->contentWidgetData("selected").toInt(); |
|
253 mSettings.mSingleCaptureHotkey = mImageHotKeyItem->contentWidgetData("selected").toInt(); |
|
254 mSettings.mSingleCaptureMemoryInUseMultiDrive = mImageMemoryInUseItem->contentWidgetData("selected").toInt(); |
|
255 mSettings.mSingleCaptureFileName = mImageFileNameItem->contentWidgetData("text").toString(); |
|
256 |
|
257 mSettings.mSequantialCaptureImageFormat = mSequantialFormatItem->contentWidgetData("selected").toInt(); |
|
258 mSettings.mSequantialCaptureHotkey = mSequantialHotKeyItem ->contentWidgetData("selected").toInt(); |
|
259 mSettings.mSequantialCaptureMemoryInUseMultiDrive = mSequantialMemoryInUseItem ->contentWidgetData("selected").toInt(); |
|
260 mSettings.mSequantialCaptureFileName = mSequantialFileNameItem->contentWidgetData("text").toString(); |
|
261 mSettings.mSequantialCaptureDelay = mSequantialDelayItem->contentWidgetData("text").toInt(); |
|
262 |
|
263 |
|
264 mSettings.mVideoCaptureVideoFormat = mVideoFormatItem->contentWidgetData("selected").toInt(); |
|
265 mSettings.mVideoCaptureHotkey = mVideoHotKeyItem ->contentWidgetData("selected").toInt(); |
|
266 mSettings.mVideoCaptureMemoryInUseMultiDrive = mVideoMemoryInUseItem ->contentWidgetData("selected").toInt(); |
|
267 mSettings.mVideoCaptureFileName = mVideoFileNameItem ->contentWidgetData("text").toString(); |
|
268 |
|
269 |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 |
|
274 void SettingsView::close() |
|
275 { |
|
276 mEngineWrapper.EnableRcpOfFoc(EFalse); |
|
277 mMainWindow.setCurrentView(&mMainView); |
|
278 } |