Fixed issue 51868
[apps/osp/Gallery.git] / src / GlSettingMainForm.cpp
index 2a80e51..deeba34 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"
@@ -41,6 +42,7 @@ using namespace Tizen::Ui::Scenes;
 SettingMainForm::SettingMainForm(void)
        : __pList(null)
        , __pPresentationModel(null)
+       , __contentUpdated(false)
 {
        AppLogDebug("ENTER");
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
@@ -71,8 +73,7 @@ SettingMainForm::OnInitializing(void)
 {
        AppLogDebug("ENTER");
        __pPresentationModel = SettingPresentationModel::GetInstance();
-
-       InitializeSettingValues();
+       SettingInfo::AddSettingEventListener(*this);
 
        Header* pHeader = GetHeader();
        AppAssert(pHeader);
@@ -87,13 +88,6 @@ SettingMainForm::OnInitializing(void)
                __pList->AddGroupedListViewItemEventListener(*this);
        }
 
-       Footer* pFooter = GetFooter();
-       if (pFooter)
-       {
-               AppLogDebug("setting back button");
-               pFooter->SetBackButtonEnabled(true);
-       }
-
        SetFormBackEventListener(this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
@@ -104,6 +98,7 @@ result
 SettingMainForm::OnTerminating(void)
 {
        AppLogDebug("ENTER");
+       SettingInfo::RemoveSettingEventListener(*this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -136,13 +131,23 @@ SettingMainForm::OnFormBackRequested(Form& source)
        {
                if (pApp->GetAppControlOperationId() == APPCONTROL_OPERATION_ID_CONFIGURE)
                {
-                       pApp->SendAppControlResult(APP_CTRL_RESULT_TERMINATED, null);
-                       pApp->Terminate();
+                       if (pApp->GetFrameActivated() == true)
+                       {
+                               pApp->SendAppControlResult(APP_CTRL_RESULT_TERMINATED, null);
+                               pApp->Terminate();
+                       }
                }
                else
                {
                        SceneManager* pSceneManager = SceneManager::GetInstance();
-                       pSceneManager->GoBackward(BackwardSceneTransition());
+                       if (__contentUpdated)
+                       {
+                               pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALBUM_LIST));
+                       }
+                       else
+                       {
+                               pSceneManager->GoBackward(BackwardSceneTransition());
+                       }
                }
        }
 
@@ -150,10 +155,22 @@ SettingMainForm::OnFormBackRequested(Form& source)
 }
 
 void
+SettingMainForm::OnContentUpdated(void)
+{
+       AppLogDebug("ENTER");
+       __contentUpdated = true;
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}
+
+void
 SettingMainForm::OnSceneActivatedN(const SceneId& previousSceneId,
                const SceneId& currentSceneId, IList* pArgs)
 {
        AppLogDebug("ENTER");
+
+       FileListPresentationModel::GetInstance()->AddContentEventListener(this);
+       __pPresentationModel->CreateDefaultRegistry();
+       InitializeSettingValues();
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -162,6 +179,8 @@ SettingMainForm::OnSceneDeactivated(const SceneId& currentSceneId,
                const SceneId& nextSceneId)
 {
        AppLogDebug("ENTER");
+       __pPresentationModel->DeleteRegistry();
+       FileListPresentationModel::GetInstance()->RemoveContentEventListener(this);
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 }
 
@@ -169,7 +188,7 @@ void
 SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus status)
 {
        int effectiveIndex = 0;
-       int inputValue = 0 ;
+       int inputValue = 0;
 
        effectiveIndex = effectiveIndex + itemIndex;
 
@@ -184,7 +203,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
                        {
                                if (settingInfo[iter].itemType == ITEM_TYPE_RADIO)
                                {
-                                       settingInfo[effectiveIndex].childCount++;
+                                       ++settingInfo[effectiveIndex].childCount;
                                }
                                else
                                {
@@ -247,7 +266,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
        {
        case SETTING_INTERVAL_2:
        {
-               inputValue = 2 ;
+               inputValue = 2;
                __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER, ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL,
                                inputValue);
                listView.UpdateList();
@@ -256,7 +275,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
        case SETTING_INTERVAL_3:
        {
-               inputValue = 3 ;
+               inputValue = 3;
                __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
                                ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, inputValue);
                listView.UpdateList();
@@ -265,7 +284,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
        case SETTING_INTERVAL_5:
        {
-               inputValue = 5 ;
+               inputValue = 5;
                __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
                                ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, inputValue);
                listView.UpdateList();
@@ -274,7 +293,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
        case SETTING_INTERVAL_10:
        {
-               inputValue = 10 ;
+               inputValue = 10;
                __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
                                ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, inputValue);
                listView.UpdateList();
@@ -283,7 +302,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
        case SETTING_INTERVAL_20:
        {
-               inputValue = 20 ;
+               inputValue = 20;
                __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
                                ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_INTERVAL, inputValue);
                listView.UpdateList();
@@ -292,7 +311,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
        case SETTING_TRANSITION_PAGE:
        {
-               inputValue = 0 ;
+               inputValue = 0;
                __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
                                ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, inputValue);
                listView.UpdateList();
@@ -301,12 +320,12 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
        case SETTING_TRANSITION_DISSOLVE:
        {
-               inputValue = 1 ;
+               inputValue = 1;
                result r = __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
                                ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, inputValue);
                if (r == E_SUCCESS)
                {
-                       AppLogDebug(" Passed") ;
+                       AppLogDebug(" Passed");
                }
 
                listView.UpdateList();
@@ -315,7 +334,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
        case SETTING_TRANSITION_ZOOM:
        {
-               inputValue = 2 ;
+               inputValue = 2;
                 __pPresentationModel->SetValue(SECTION_NAME_IMAGE_VIEWER,
                                ENTRY_NAME_IMAGE_VIEWER_SLIDESHOW_TRANSITION_EFFECT, inputValue);
                listView.UpdateList();
@@ -324,7 +343,7 @@ SettingMainForm::OnGroupedListViewItemStateChanged(GroupedListView& listView, in
 
        case SETTING_REPEAT:
        {
-               int repeatValue = 0 ;
+               int repeatValue = 0;
 
                __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
                                ENTRY_NAME_IMAGE_VIEWER_REPEAT_VALUE, repeatValue);
@@ -388,7 +407,7 @@ SettingMainForm::CreateGroupItem(int groupIndex, int itemWidth)
        switch (groupIndex)
        {
        case 0:
-               text = ResourceManager::GetString(L"IDS_MEDIABR_BUTTON_SLIDE_SHOW");
+               text = ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW");
        break;
 
        default:
@@ -418,10 +437,51 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
        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;
+               itemHeight = defaultHeight;
+       }
+
+
        if (settingInfo[effectiveIndex].itemType == ITEM_TYPE_TOGGLE)
        {
                SettingToggleCustomItem* pItem = new (std::nothrow) SettingToggleCustomItem();
-               r = pItem->Construct(itemWidth, 112);
+               r = pItem->Construct(itemWidth, itemHeight);
 
                if (IsFailed(r))
                {
@@ -438,14 +498,14 @@ 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);
+               r = pItem->Construct(itemWidth,itemHeight);
                if (IsFailed(r))
                {
                        delete pItem;
@@ -466,7 +526,7 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                        pItem->SetCurState(DROP_DOWN_ITEM_STATE_CLOSED);
                }
 
-               r = pItem->Make();
+               r = pItem->Make(fontSize,itemHeight);
 
                if (IsFailed(r))
                {
@@ -490,12 +550,14 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                if (settingInfo[parentIndex].isOpen == false)
                {
                        r = pItem->Construct(itemWidth, 0);
+                       __pList->SetItemEnabled(groupIndex, itemIndex,false);
                        AppLogDebug("construct with height 0 %s", GetErrorMessage(r));
                        return pItem;
                }
                else
                {
-                       pItem->Construct(itemWidth, 112);
+                       pItem->Construct(itemWidth, itemHeight);
+                       __pList->SetItemEnabled(groupIndex, itemIndex, true);
                }
 
                pItem->SetBackgroundColor(LIST_ITEM_DRAWING_STATUS_NORMAL, ITEM_RADIO_ITEM_BACKGROUND_COLOR);
@@ -505,7 +567,7 @@ SettingMainForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
                AppLogDebug("effectiveIndex %d SettingInfo[effectiveIndex].isSelected %d", effectiveIndex, settingInfo[effectiveIndex].isSelected);
 
                pItem->SetSelected(settingInfo[effectiveIndex].isSelected);
-               pItem->Make();
+               pItem->Make(fontSize);
 
                return pItem;
        }
@@ -532,7 +594,7 @@ SettingMainForm::DeleteItem(int groupIndex, int itemIndex, ListItemBase* pItem,
 int
 SettingMainForm::GetGroupCount(void)
 {
-       int groupCount = 1 ;
+       int groupCount = 1;
 
        return groupCount;
 }
@@ -642,7 +704,7 @@ SettingMainForm::InitializeSettingValues(void)
        }
 
        settingInfo[SETTING_SLIDESHOW_INTERVAL_TITLE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_SLIDESHOW_INTERVAL");
-       settingInfo[SETTING_SLIDESHOW_INTERVAL_TITLE].subText = selectedInterval ;
+       settingInfo[SETTING_SLIDESHOW_INTERVAL_TITLE].subText = selectedInterval;
        settingInfo[SETTING_SLIDESHOW_INTERVAL_TITLE].itemType = ITEM_TYPE_DROPDOWN;
 
        settingInfo[SETTING_INTERVAL_2].titleText = ResourceManager::GetString(L"IDS_MEDIABR_OPT_2_SECONDS");
@@ -672,11 +734,11 @@ SettingMainForm::InitializeSettingValues(void)
 
        if (repeatValue == 0)
        {
-               settingInfo[SETTING_REPEAT].isSelected = false ;
+               settingInfo[SETTING_REPEAT].isSelected = false;
        }
        else
        {
-               settingInfo[SETTING_REPEAT].isSelected = true ;
+               settingInfo[SETTING_REPEAT].isSelected = true;
        }
 
        r = __pPresentationModel->GetValue(SECTION_NAME_IMAGE_VIEWER,
@@ -687,11 +749,11 @@ SettingMainForm::InitializeSettingValues(void)
 
        if (shuffletValue == 0)
        {
-               settingInfo[SETTING_SHUFFLE].isSelected = false ;
+               settingInfo[SETTING_SHUFFLE].isSelected = false;
        }
        else
        {
-               settingInfo[SETTING_SHUFFLE].isSelected = true ;
+               settingInfo[SETTING_SHUFFLE].isSelected = true;
        }
 
        settingInfo[SETTING_TRANSITION_EFFECT_TITLE].titleText = ResourceManager::GetString(L"IDS_MEDIABR_BODY_TRANSITION_EFFECT");
@@ -717,3 +779,15 @@ SettingMainForm::SettingItemInfo::SettingItemInfo(void)
        , isSelected(false)
 {
 }
+
+
+void
+SettingMainForm::OnSettingChanged(String& key)
+{
+       AppLogDebug("ENTER");
+       if (key == L"http://tizen.org/setting/font.size")
+       {
+               __pList->UpdateList();
+       }
+       AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
+}