2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file GlSettingMainForm.cpp
19 * @brief This is the implementation file for SettingMainForm class.
22 #include "GlDropDownCustomItem.h"
23 #include "GlGalleryApp.h"
24 #include "GlRadioCustomItem.h"
25 #include "GlResourceManager.h"
26 #include "GlSettingMainForm.h"
27 #include "GlSettingPresentationModel.h"
28 #include "GlSettingToggleCustomItem.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Content;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::System;
37 using namespace Tizen::Ui;
38 using namespace Tizen::Ui::Controls;
39 using namespace Tizen::Ui::Scenes;
41 SettingMainForm::SettingMainForm(void)
44 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
47 SettingMainForm::~SettingMainForm(void)
52 delete[] pGroupItemCount;
54 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
58 SettingMainForm::Initialize(void)
61 result r = Form::Construct(IDL_FORM_SETTING_MAIN);
62 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
68 SettingMainForm::OnInitializing(void)
71 __pPresentationModel = SettingPresentationModel::GetInstance();
73 InitializeSettingValues();
75 Header* pHeader = GetHeader();
77 pHeader->SetStyle(HEADER_STYLE_TITLE);
78 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_GALLERY"));
80 __pList = static_cast< GroupedListView* >(GetControl(L"IDC_SETTING_LIST"));
84 __pList->SetItemProvider(*this);
85 __pList->AddGroupedListViewItemEventListener(*this);
88 Footer* pFooter = GetFooter();
91 AppLogDebug("setting back button");
92 pFooter->SetBackButtonEnabled(true);
95 SetFormBackEventListener(this);
96 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
102 SettingMainForm::OnTerminating(void)
104 AppLogDebug("ENTER");
105 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
111 SettingMainForm::OnActionPerformed(const Control& source, int actionId)
113 AppLogDebug("ENTER");
114 SceneManager* pSceneManager = SceneManager::GetInstance();
115 AppAssert(pSceneManager);
124 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
128 SettingMainForm::OnFormBackRequested(Form& source)
130 AppLogDebug("ENTER");
132 GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
135 if (pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_CONFIGURE)
137 pApp->SendAppControlResult(APP_CTRL_RESULT_TERMINATED, null);
142 SceneManager* pSceneManager = SceneManager::GetInstance();
143 pSceneManager->GoBackward(BackwardSceneTransition());
147 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
151 SettingMainForm::OnSceneActivatedN(const SceneId& previousSceneId,
152 const SceneId& currentSceneId, IList* pArgs)
154 AppLogDebug("ENTER");
155 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
159 SettingMainForm::OnSceneDeactivated(const SceneId& currentSceneId,
160 const SceneId& nextSceneId)
162 AppLogDebug("ENTER");
163 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
167 SettingMainForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)
172 SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)
174 int effectiveIndex = 0;
177 effectiveIndex = effectiveIndex + itemIndex;
179 if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
181 AppLogDebug("refreshing data child count is %d", settingInfo[effectiveIndex].childCount);
182 if (settingInfo[effectiveIndex].isOpen == false)
184 settingInfo[effectiveIndex].isOpen = true;
185 settingInfo[effectiveIndex].childCount = 0;
186 for (int iter = effectiveIndex + 1; iter < SETTING_MAX; ++iter)
188 if (settingInfo[iter].itemType == ITEM_TYPE_RADIO)
190 settingInfo[effectiveIndex].childCount++;
197 listView.UpdateList();
201 settingInfo[effectiveIndex].isOpen = false;
202 listView.UpdateList();
205 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
208 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
210 if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
215 settingInfo[parentIndex].subText = settingInfo[effectiveIndex].titleText;
217 for (int iter = 0; iter < settingInfo[parentIndex].childCount; ++iter)
219 if (parentIndex + iter + 1 != effectiveIndex)
221 AppLogDebug("long effectiveIndex %d set to false", itemIndex - (effectiveIndex - parentIndex) + iter + 1);
222 settingInfo[parentIndex + iter + 1].isSelected = false;
226 AppLogDebug("effectiveIndex %d set to true", effectiveIndex);
227 settingInfo[effectiveIndex].isSelected = true;
233 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
235 if (settingInfo[effectiveIndex].isSelected == true)
237 settingInfo[effectiveIndex].isSelected = false;
241 settingInfo[effectiveIndex].isSelected = true;
245 __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
249 switch (effectiveIndex)
251 case SETTING_INTERVAL_2:
254 __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER, ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL,
256 listView.UpdateList();
259 case SETTING_INTERVAL_3:
262 __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
263 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, inputValue);
264 listView.UpdateList();
268 case SETTING_INTERVAL_5:
271 __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
272 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, inputValue);
273 listView.UpdateList();
277 case SETTING_INTERVAL_10:
280 __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
281 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, inputValue);
282 listView.UpdateList();
286 case SETTING_INTERVAL_20:
289 __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
290 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, inputValue);
291 listView.UpdateList();
295 case SETTING_TRANSITION_SLIDE:
298 __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
299 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, inputValue);
300 listView.UpdateList();
304 case SETTING_TRANSITION_DISSOLVE:
307 result r = __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
308 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, inputValue);
311 AppLogDebug(" Passed") ;
314 listView.UpdateList();
317 case SETTING_TRANSITION_ZOOM:
320 __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
321 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, inputValue);
322 listView.UpdateList();
328 int repeatValue = 0 ;
330 __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
331 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
333 if (repeatValue == 0)
342 __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
343 ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, inputValue);
348 // case SETTING_SHUFFLE:
350 // int shuffleValue = 0;
352 // __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
353 // ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
355 // if (shuffleValue == 0)
364 // __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
365 // ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, inputValue);
374 SettingMainForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex,
375 SweepDirection direction)
380 SettingMainForm::CreateGroupItem(int groupIndex, int itemWidth)
382 result r = E_FAILURE;
384 GroupItem* pItem = null;
385 const Color ITEM_TEXT_COLOR = CUSTOM_COLOR_SETTINGS_GROUPTITLE;
387 pItem = new(std::nothrow) GroupItem();
392 r = pItem->Construct(Dimension(itemWidth, 46));
402 text = ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW"); // IDS_SLIDESHOW
409 pItem->SetElement(text, null);
411 AppLogDebug("background color set result %s", GetErrorMessage(r));
413 pItem->SetTextColor(ITEM_TEXT_COLOR);
418 SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
420 AppLog("SettingMainForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d ", groupIndex, itemIndex,
423 result r = E_SUCCESS;
424 int effectiveIndex = 0;
425 const Color ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_BACKGROUND;
426 const Color ITEM_RADIO_ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_RADIO_BACKGROUND;
428 effectiveIndex = effectiveIndex + itemIndex;
429 AppLogDebug("SettingMainForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d effectiveIndex %d", groupIndex, itemIndex, itemWidth, effectiveIndex);
431 if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
433 SettingToggleCustomItem* pItem = new(std::nothrow) SettingToggleCustomItem();
434 r = pItem->Construct(itemWidth, 112);
442 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
443 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
447 __pList->SetItemChecked(groupIndex, itemIndex, settingInfo[effectiveIndex].isSelected);
450 pItem->SetText(settingInfo[effectiveIndex].titleText);
455 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
457 DropDownCustomItem* pItem = new(std::nothrow) DropDownCustomItem();
458 r = pItem->Construct(itemWidth);
465 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
466 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
468 pItem->SetMainText(settingInfo[effectiveIndex].titleText);
469 pItem->SetSubText(settingInfo[effectiveIndex].subText);
470 if (settingInfo[effectiveIndex].isOpen)
472 pItem->SetCurState(DROP_DOWN_ITEM_STATE_OPENED);
476 pItem->SetCurState(DROP_DOWN__ITEM_STATE_CLOSED);
489 else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
491 RadioCustomItem* pItem = new(std::nothrow) RadioCustomItem();
494 for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
496 if (settingInfo[parentIndex].itemType == ITEM_TYPE_DROPDOWN)
500 if (settingInfo[parentIndex].isOpen == false)
502 r = pItem->Construct(itemWidth, 0);
503 AppLogDebug("construct with height 0 %s", GetErrorMessage(r));
508 pItem->Construct(itemWidth, 112);
511 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
512 pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
514 pItem->SetText(settingInfo[effectiveIndex].titleText);
515 AppLogDebug("effectiveIndex %d SettingInfo[effectiveIndex].isSelected %d", effectiveIndex, settingInfo[effectiveIndex].isSelected);
517 pItem->SetSelected(settingInfo[effectiveIndex].isSelected);
529 SettingMainForm::DeleteGroupItem(int groupIndex, GroupItem* pItem, int itemWidth)
536 SettingMainForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem, int itemWidth)
543 SettingMainForm::GetGroupCount(void)
551 SettingMainForm::GetItemCount(int groupIndex)
553 AppLog(" SettingMainForm::GetItemCount --> groupIndex : %d,", groupIndex);
554 return pGroupItemCount[groupIndex];
558 SettingMainForm::InitializeSettingValues(void)
560 pGroupItemCount = new(std::nothrow) int[1];
561 pGroupItemCount[0] = 12;
563 int transitionValue = 0;
565 //int shuffletValue = 0;
566 String selectedInterval;
567 String selectedTransition;
569 for (int iter = (int) SETTING_INVALID + 1; iter < (int) SETTING_MAX; ++iter)
571 settingInfo[iter].isSelected = false;
574 result r =__pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER, ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL,
583 selectedInterval = ResourceManager::GetString(L"IDS_MEDIABR_OPT_2_SECONDS");
584 settingInfo[SETTING_INTERVAL_2].isSelected = true;
590 selectedInterval = ResourceManager::GetString(L"IDS_MEDIABR_OPT_3_SECONDS");
591 settingInfo[SETTING_INTERVAL_3].isSelected = true;
597 selectedInterval = ResourceManager::GetString(L"IDS_MEDIABR_BODY_5_SECONDS");
598 settingInfo[SETTING_INTERVAL_5].isSelected = true;
604 selectedInterval = ResourceManager::GetString(L"IDS_MEDIABR_BODY_10_SECONDS");
605 settingInfo[SETTING_INTERVAL_10].isSelected = true;
611 selectedInterval = ResourceManager::GetString(L"IDS_MEDIABR_BODY_20_SECONDS");
612 settingInfo[SETTING_INTERVAL_20].isSelected = true;
621 r = __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
622 ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, transitionValue);
626 switch (transitionValue)
630 selectedTransition = ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDE");
631 settingInfo[SETTING_TRANSITION_SLIDE].isSelected = true;
637 selectedTransition = ResourceManager::GetString(L"IDS_MEDIABR_BODY_DISSOLVE");
638 settingInfo[SETTING_TRANSITION_DISSOLVE].isSelected = true;
644 selectedTransition = ResourceManager::GetString(L"IDS_IV_OPT_ZOOM");
645 settingInfo[SETTING_TRANSITION_ZOOM].isSelected = true;
654 settingInfo[SETTING_SLIDESHOW_INTERVAL_TITLE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_SLIDESHOW_INTERVAL");
655 settingInfo[SETTING_SLIDESHOW_INTERVAL_TITLE].subText = selectedInterval ;
656 settingInfo[SETTING_SLIDESHOW_INTERVAL_TITLE].itemType = ITEM_TYPE_DROPDOWN;
658 settingInfo[SETTING_INTERVAL_2].titleText = ResourceManager::GetString(L"IDS_MEDIABR_OPT_2_SECONDS");
659 settingInfo[SETTING_INTERVAL_2].subText = L"";
660 settingInfo[SETTING_INTERVAL_2].itemType = ITEM_TYPE_RADIO;
662 settingInfo[SETTING_INTERVAL_3].titleText = ResourceManager::GetString(L"IDS_MEDIABR_OPT_3_SECONDS");
663 settingInfo[SETTING_INTERVAL_3].subText = L"";
664 settingInfo[SETTING_INTERVAL_3].itemType = ITEM_TYPE_RADIO;
666 settingInfo[SETTING_INTERVAL_5].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_5_SECONDS");
667 settingInfo[SETTING_INTERVAL_5].subText = L"";
668 settingInfo[SETTING_INTERVAL_5].itemType = ITEM_TYPE_RADIO;
670 settingInfo[SETTING_INTERVAL_10].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_10_SECONDS");
671 settingInfo[SETTING_INTERVAL_10].subText = L"";
672 settingInfo[SETTING_INTERVAL_10].itemType = ITEM_TYPE_RADIO;
674 settingInfo[SETTING_INTERVAL_20].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_20_SECONDS");
675 settingInfo[SETTING_INTERVAL_20].subText = L"";
676 settingInfo[SETTING_INTERVAL_20].itemType = ITEM_TYPE_RADIO;
678 r = __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER, ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
680 settingInfo[SETTING_REPEAT].titleText = L"Repeat";
681 settingInfo[SETTING_REPEAT].itemType = ITEM_TYPE_TOGGLE;
683 if (repeatValue == 0)
685 settingInfo[SETTING_REPEAT].isSelected = false ;
689 settingInfo[SETTING_REPEAT].isSelected = true ;
692 // r = __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
693 // ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffletValue);
695 // settingInfo[SETTING_SHUFFLE].titleText = L"Shuffle";
696 // settingInfo[SETTING_SHUFFLE].itemType = ITEM_TYPE_TOGGLE;
698 // if ( shuffletValue == 0)
700 // settingInfo[SETTING_SHUFFLE].isSelected = false ;
704 // settingInfo[SETTING_SHUFFLE].isSelected = true ;
707 settingInfo[SETTING_TRANSITION_EFFECT_TITLE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_TRANSITION_EFFECT");
708 settingInfo[SETTING_TRANSITION_EFFECT_TITLE].subText = selectedTransition;
709 settingInfo[SETTING_TRANSITION_EFFECT_TITLE].itemType = ITEM_TYPE_DROPDOWN;
711 settingInfo[SETTING_TRANSITION_SLIDE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDE");
712 settingInfo[SETTING_TRANSITION_SLIDE].subText = L"";
713 settingInfo[SETTING_TRANSITION_SLIDE].itemType = ITEM_TYPE_RADIO;
715 settingInfo[SETTING_TRANSITION_DISSOLVE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_DISSOLVE");
716 settingInfo[SETTING_TRANSITION_DISSOLVE].subText = L"";
717 settingInfo[SETTING_TRANSITION_DISSOLVE].itemType = ITEM_TYPE_RADIO;
719 settingInfo[SETTING_TRANSITION_ZOOM].titleText = ResourceManager::GetString(L"IDS_IV_OPT_ZOOM");
720 settingInfo[SETTING_TRANSITION_ZOOM].subText = L"";
721 settingInfo[SETTING_TRANSITION_ZOOM].itemType = ITEM_TYPE_RADIO;
725 SettingMainForm::SettingItemInfo::SettingItemInfo(void)