Back event changes
[apps/osp/Gallery.git] / src / GlSettingMainForm.cpp
index b1410bd..512e62e 100644 (file)
@@ -1,7 +1,7 @@
 //
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
@@ -20,6 +20,7 @@
  */
 
 #include "GlDropDownCustomItem.h"
+#include "GlFileListPresentationModel.h"
 #include "GlGalleryApp.h"
 #include "GlRadioCustomItem.h"
 #include "GlResourceManager.h"
@@ -39,6 +40,9 @@ using namespace Tizen::Ui::Controls;
 using namespace Tizen::Ui::Scenes;
 
 SettingMainForm::SettingMainForm(void)
+       : __pList(null)
+       , __pPresentationModel(null)
+       , __contentUpdated(false)
 {
        AppLogDebug("ENTER");
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -69,6 +73,7 @@ SettingMainForm::OnInitializing(void)
 {
        AppLogDebug("ENTER");
        __pPresentationModel = SettingPresentationModel::GetInstance();
+       SettingInfo::AddSettingEventListener(*this);
 
        InitializeSettingValues();
 
@@ -77,21 +82,14 @@ SettingMainForm::OnInitializing(void)
        pHeader->SetStyle(HEADER_STYLE_TITLE);
        pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_GALLERY"));
 
-       __pList = static_cast< GroupedListView* >(GetControl(L"IDC_SETTING_LIST"));
+       __pList = static_cast<GroupedListView*>(GetControl(L"IDC_SETTING_LIST"));
 
-       if (__pList != NULL)
+       if (__pList != null)
        {
                __pList->SetItemProvider(*this);
                __pList->AddGroupedListViewItemEventListener(*this);
        }
 
-       Footer* pFooter = GetFooter();
-       if (pFooter)
-       {
-               AppLogDebug("setting back button");
-               pFooter->SetBackButtonEnabled(true);
-       }
-
        SetFormBackEventListener(this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -102,6 +100,7 @@ result
 SettingMainForm::OnTerminating(void)
 {
        AppLogDebug("ENTER");
+       SettingInfo::RemoveSettingEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -132,35 +131,52 @@ SettingMainForm::OnFormBackRequested(Form& source)
        GalleryApp* pApp = dynamic_cast<GalleryApp*>(UiApp::GetInstance());
        if (pApp != null)
        {
-               if (pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_CONFIGURE)
+               if (pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_CONFIGURE && pApp->GetFrameActivated() == true)
                {
                        pApp->SendAppControlResult(APP_CTRL_RESULT_TERMINATED, null);
+                       pApp->Terminate();
+               }
+               else
+               {
+                       SceneManager* pSceneManager = SceneManager::GetInstance();
+                       if (__contentUpdated)
+                       {
+                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
+                       }
+                       else
+                       {
+                               pSceneManager->GoBackward(BackwardSceneTransition());
+                       }
                }
-               pApp->Terminate();
        }
 
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
 void
-SettingMainForm::OnSceneActivatedN(const SceneId& previousSceneId,
-               const SceneId& currentSceneId, IList* pArgs)
+SettingMainForm::OnContentUpdated(void)
 {
        AppLogDebug("ENTER");
+       __contentUpdated = true;
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
 void
-SettingMainForm::OnSceneDeactivated(const SceneId& currentSceneId,
-               const SceneId& nextSceneId)
+SettingMainForm::OnSceneActivatedN(const SceneId& previousSceneId,
+               const SceneId& currentSceneId, IList* pArgs)
 {
        AppLogDebug("ENTER");
+       FileListPresentationModel::GetInstance()->AddContentEventListener(this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
 void
-SettingMainForm::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus status)
+SettingMainForm::OnSceneDeactivated(const SceneId& currentSceneId,
+               const SceneId& nextSceneId)
 {
+       AppLogDebug("ENTER");
+       FileListPresentationModel::GetInstance()->RemoveContentEventListener(this);
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
 void
@@ -251,6 +267,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
                listView.UpdateList();
        }
        break;
+
        case SETTING_INTERVAL_3:
        {
                inputValue = 3 ;
@@ -287,7 +304,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
        }
        break;
 
-       case SETTING_TRANSITION_SLIDE:
+       case SETTING_TRANSITION_PAGE:
        {
                inputValue = 0 ;
                __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
@@ -309,6 +326,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
                listView.UpdateList();
        }
        break;
+
        case SETTING_TRANSITION_ZOOM:
        {
                inputValue = 2 ;
@@ -336,66 +354,56 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
                __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
                                ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, inputValue);
-
        }
        break;
 
-//     case SETTING_SHUFFLE:
-//     {
-//             int shuffleValue = 0;
-//
-//             __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
-//                             ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
-//
-//             if (shuffleValue == 0)
-//             {
-//                     inputValue = 1;
-//             }
-//             else
-//             {
-//                     inputValue = 0;
-//             }
-//
-//             __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
-//                             ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, inputValue);
-//     }
-//     break;
+       case SETTING_SHUFFLE:
+       {
+               int shuffleValue = 0;
+
+               __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
+                               ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffleValue);
+
+               if (shuffleValue == 0)
+               {
+                       inputValue = 1;
+               }
+               else
+               {
+                       inputValue = 0;
+               }
+
+               __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
+                               ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, inputValue);
+       }
+       break;
 
        default:
                break;
        }
 }
-void
-SettingMainForm::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex,
-               SweepDirection direction)
-{
-}
 
 GroupItem*
 SettingMainForm::CreateGroupItem(int groupIndex, int itemWidth)
 {
-       result r = E_FAILURE;
-       String text(L"");
-       GroupItem* pItem = null;
-       const Color ITEM_TEXT_COLOR = CUSTOM_COLOR_SETTINGS_GROUPTITLE;
-
-       pItem = new(std::nothrow) GroupItem();
+       GroupItem* pItem = new (std::nothrow) GroupItem();
        if (pItem == null)
        {
                return null;
        }
-       r = pItem->Construct(Dimension(itemWidth, 46));
+       result r = pItem->Construct(Dimension(itemWidth, 46));
        if (IsFailed(r))
        {
                delete pItem;
                return null;
        }
 
+       String text;
        switch (groupIndex)
        {
        case 0:
-               text = ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW");  // IDS_SLIDESHOW
-               break;
+               text = ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW");
+       break;
 
        default:
                break;
@@ -405,7 +413,7 @@ SettingMainForm::CreateGroupItem(int groupIndex, int itemWidth)
 
        AppLogDebug("background color set result %s", GetErrorMessage(r));
 
-       pItem->SetTextColor(ITEM_TEXT_COLOR);
+       pItem->SetTextColor(CUSTOM_COLOR_SETTINGS_GROUPTITLE);
        return pItem;
 }
 
@@ -419,14 +427,55 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
        int effectiveIndex = 0;
        const Color ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_BACKGROUND;
        const Color ITEM_RADIO_ITEM_BACKGROUND_COLOR = CUSTOM_COLOR_SETTINGS_LISTITEM_RADIO_BACKGROUND;
+       const Color ITEM_BACKGROUND_COLOR_HIGHLIGHTED = CUSTOM_BACKGROUND_COLOR_LISTVIEW_PRESSED_HIGHLIGHTED;
 
        effectiveIndex = effectiveIndex + itemIndex;
        AppLogDebug("SettingMainForm::CreateItem --> groupIndex : %d, itemIndex: %d itemWidth: %d effectiveIndex %d", groupIndex, itemIndex, itemWidth, effectiveIndex);
 
+       String fontSizeStr;
+       int fontSize = 0;
+       int itemHeight = 0;
+       int defaultHeight = 112 ;
+       int defaultFontSize = 44 ;
+
+       SettingInfo::GetValue("http://tizen.org/setting/font.size", fontSizeStr);
+       AppLog("the font value is %S",fontSizeStr.GetPointer());
+
+       if(fontSizeStr == "medium")
+       {
+               fontSize = 44;
+               itemHeight = defaultHeight + ( fontSize - defaultFontSize);
+       }
+       else if(fontSizeStr == "huge")
+       {
+               fontSize =  81;
+               itemHeight = defaultHeight + ( fontSize - defaultFontSize);
+       }
+       else if(fontSizeStr == "giant")
+       {
+               fontSize = 98;
+               itemHeight = defaultHeight + ( fontSize - defaultFontSize);
+       }
+       else if(fontSizeStr == "small")
+       {
+               fontSize = 36;
+               itemHeight = defaultHeight + ( fontSize - defaultFontSize);
+       }
+       else if(fontSizeStr == "large")
+       {
+               fontSize = 64;
+               itemHeight = defaultHeight + ( fontSize - defaultFontSize);
+       }
+       else
+       {
+               fontSize = 44;
+       }
+
+
        if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
        {
-               SettingToggleCustomItem* pItem = new(std::nothrow) SettingToggleCustomItem();
-               r = pItem->Construct(itemWidth, 112);
+               SettingToggleCustomItem* pItem = new (std::nothrow) SettingToggleCustomItem();
+               r = pItem->Construct(itemWidth, itemHeight);
 
                if (IsFailed(r))
                {
@@ -434,8 +483,8 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                        return null;
                }
 
-               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
-               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
+               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, ITEM_BACKGROUND_COLOR);
+               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
 
                if (__pList != null)
                {
@@ -443,22 +492,22 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                }
 
                pItem->SetText(settingInfo[effectiveIndex].titleText);
-               pItem->Make();
+               pItem->Make(fontSize);
 
                return pItem;
        }
        else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_DROPDOWN)
        {
-               DropDownCustomItem* pItem = new(std::nothrow) DropDownCustomItem();
-               r = pItem->Construct(itemWidth);
+               DropDownCustomItem* pItem = new (std::nothrow) DropDownCustomItem();
+               r = pItem->Construct(itemWidth,itemHeight);
                if (IsFailed(r))
                {
                        delete pItem;
                        return null;
                }
 
-               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_BACKGROUND_COLOR);
-               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_BACKGROUND_COLOR);
+               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, ITEM_BACKGROUND_COLOR);
+               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
 
                pItem->SetMainText(settingInfo[effectiveIndex].titleText);
                pItem->SetSubText(settingInfo[effectiveIndex].subText);
@@ -468,10 +517,10 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                }
                else
                {
-                       pItem->SetCurState(DROP_DOWN__ITEM_STATE_CLOSED);
+                       pItem->SetCurState(DROP_DOWN_ITEM_STATE_CLOSED);
                }
 
-               r = pItem->Make();
+               r = pItem->Make(fontSize,itemHeight);
 
                if (IsFailed(r))
                {
@@ -483,7 +532,7 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
        }
        else if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_RADIO)
        {
-               RadioCustomItem* pItem = new(std::nothrow) RadioCustomItem();
+               RadioCustomItem* pItem = new (std::nothrow) RadioCustomItem();
                int parentIndex = 0;
 
                for (parentIndex = effectiveIndex; parentIndex > SETTING_INVALID; parentIndex--)
@@ -500,17 +549,17 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                }
                else
                {
-                       pItem->Construct(itemWidth, 112);
+                       pItem->Construct(itemWidth, itemHeight);
                }
 
-               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
-               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED,ITEM_RADIO_ITEM_BACKGROUND_COLOR);
+               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, ITEM_RADIO_ITEM_BACKGROUND_COLOR);
+               pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_PRESSED, ITEM_BACKGROUND_COLOR_HIGHLIGHTED);
 
                pItem->SetText(settingInfo[effectiveIndex].titleText);
                AppLogDebug("effectiveIndex %d SettingInfo[effectiveIndex].isSelected %d", effectiveIndex, settingInfo[effectiveIndex].isSelected);
 
                pItem->SetSelected(settingInfo[effectiveIndex].isSelected);
-               pItem->Make();
+               pItem->Make(fontSize);
 
                return pItem;
        }
@@ -552,12 +601,12 @@ SettingMainForm::GetItemCount(int groupIndex)
 void
 SettingMainForm::InitializeSettingValues(void)
 {
-       pGroupItemCount = new(std::nothrow) int[1];
-       pGroupItemCount[0] = 12;
+       pGroupItemCount = new (std::nothrow) int[1];
+       pGroupItemCount[0] = 13;
        int interval = 0;
        int transitionValue = 0;
        int repeatValue = 0;
-       //int shuffletValue = 0;
+       int shuffletValue = 0;
        String selectedInterval;
        String selectedTransition;
 
@@ -622,8 +671,8 @@ SettingMainForm::InitializeSettingValues(void)
                {
                case 0:
                {
-                       selectedTransition = ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDE");
-                       settingInfo[SETTING_TRANSITION_SLIDE].isSelected = true;
+                       selectedTransition = ResourceManager::GetString(L"IDS_EBOOK_BODY_PAGE");
+                       settingInfo[SETTING_TRANSITION_PAGE].isSelected = true;
                }
                break;
 
@@ -672,7 +721,7 @@ SettingMainForm::InitializeSettingValues(void)
 
        r = __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER, ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
 
-       settingInfo[SETTING_REPEAT].titleText = L"Repeat";
+       settingInfo[SETTING_REPEAT].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_REPEAT");
        settingInfo[SETTING_REPEAT].itemType = ITEM_TYPE_TOGGLE;
 
        if (repeatValue == 0)
@@ -684,28 +733,28 @@ SettingMainForm::InitializeSettingValues(void)
                settingInfo[SETTING_REPEAT].isSelected = true ;
        }
 
-//     r = __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
-//                     ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffletValue);
-//
-//     settingInfo[SETTING_SHUFFLE].titleText = L"Shuffle";
-//     settingInfo[SETTING_SHUFFLE].itemType = ITEM_TYPE_TOGGLE;
-//
-//     if ( shuffletValue == 0)
-//     {
-//             settingInfo[SETTING_SHUFFLE].isSelected = false ;
-//     }
-//     else
-//     {
-//             settingInfo[SETTING_SHUFFLE].isSelected = true ;
-//     }
+       r = __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
+                       ENTRY_NAME_IMAGE_VIEWER_SHUFFLE_VALUE, shuffletValue);
+
+       settingInfo[SETTING_SHUFFLE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_SHUFFLE");
+       settingInfo[SETTING_SHUFFLE].itemType = ITEM_TYPE_TOGGLE;
+
+       if (shuffletValue == 0)
+       {
+               settingInfo[SETTING_SHUFFLE].isSelected = false ;
+       }
+       else
+       {
+               settingInfo[SETTING_SHUFFLE].isSelected = true ;
+       }
 
        settingInfo[SETTING_TRANSITION_EFFECT_TITLE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_TRANSITION_EFFECT");
        settingInfo[SETTING_TRANSITION_EFFECT_TITLE].subText = selectedTransition;
        settingInfo[SETTING_TRANSITION_EFFECT_TITLE].itemType = ITEM_TYPE_DROPDOWN;
 
-       settingInfo[SETTING_TRANSITION_SLIDE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDE");
-       settingInfo[SETTING_TRANSITION_SLIDE].subText = L"";
-       settingInfo[SETTING_TRANSITION_SLIDE].itemType = ITEM_TYPE_RADIO;
+       settingInfo[SETTING_TRANSITION_PAGE].titleText = ResourceManager::GetString(L"IDS_EBOOK_BODY_PAGE");
+       settingInfo[SETTING_TRANSITION_PAGE].subText = L"";
+       settingInfo[SETTING_TRANSITION_PAGE].itemType = ITEM_TYPE_RADIO;
 
        settingInfo[SETTING_TRANSITION_DISSOLVE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_DISSOLVE");
        settingInfo[SETTING_TRANSITION_DISSOLVE].subText = L"";
@@ -714,14 +763,23 @@ SettingMainForm::InitializeSettingValues(void)
        settingInfo[SETTING_TRANSITION_ZOOM].titleText = ResourceManager::GetString(L"IDS_IV_OPT_ZOOM");
        settingInfo[SETTING_TRANSITION_ZOOM].subText = L"";
        settingInfo[SETTING_TRANSITION_ZOOM].itemType = ITEM_TYPE_RADIO;
-
 }
 
 SettingMainForm::SettingItemInfo::SettingItemInfo(void)
+       : childCount(0)
+       , isOpen(false)
+       , isSelected(false)
+{
+}
+
+
+void
+SettingMainForm::OnSettingChanged(String& key)
 {
-       titleText = L"";
-       subText = L"";
-       childCount = 0;
-       isOpen = false;
-       isSelected = false ;
+       AppLogDebug("ENTER");
+       if (key == L"http://tizen.org/setting/font.size")
+       {
+               __pList->UpdateList();
+       }
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }