HW key changes
[apps/osp/Gallery.git] / src / GlFileListForm.cpp
index 714335e..1668f49 100644 (file)
@@ -23,6 +23,7 @@
 #include "GlAllListPanel.h"
 #include "GlFileListForm.h"
 #include "GlFileListPresentationModel.h"
+#include "GlGalleryApp.h"
 #include "GlResourceManager.h"
 #include "GlSlideSettingListener.h"
 #include "GlSlideShowPopUp.h"
@@ -38,7 +39,9 @@ using namespace Tizen::Ui::Scenes;
 using namespace Tizen::Content;
 
 FileListForm::FileListForm(void)
-       : __pContextMenuMore(null)
+       : __isHWBackButtonExist(false)
+       , __pContextMenuMore(null)
+       , __pOptionMenu(null)
        , __pPopUp(null)
        , __pPresentationModel(null)
 {
@@ -68,6 +71,13 @@ FileListForm::OnInitializing(void)
        Header* pHeader = GetHeader();
        TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
 
+        __isHWBackButtonExist = false;
+
+          SetFormMenuEventListener(this);
+          GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
+
+          __isHWBackButtonExist = pApp->IsHwKeySupported();
+
        __pPresentationModel = FileListPresentationModel::GetInstance();
        __pPresentationModel->ClearThumbnailRequests();
 
@@ -97,6 +107,13 @@ FileListForm::OnTerminating(void)
                delete __pContextMenuMore;
                __pContextMenuMore = null;
        }
+
+       if ( __pOptionMenu != null )
+       {
+               delete __pOptionMenu;
+               __pOptionMenu = null;
+       }
+
        AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
 
        return E_SUCCESS;
@@ -210,24 +227,27 @@ FileListForm::InitializeFooter(void)
        pFooter->RemoveAllItems();
        pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
 
-       ButtonItem footerMore;
-       footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
 
-       Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
-       Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
-       Bitmap* pBitmapMorePressed = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_PRESSED);
-
-       if (pBitmapMore != null && pBitmapMoreDim != null && pBitmapMorePressed != null)
+       if ( __isHWBackButtonExist == false )
        {
-               footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
-               footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
-               footerMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapMorePressed);
-       }
-       pFooter->SetButton(BUTTON_POSITION_LEFT, footerMore);
+               ButtonItem footerMore;
+               footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
+               Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
+               Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
+               Bitmap* pBitmapMorePressed = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_PRESSED);
 
-       delete pBitmapMore;
-       delete pBitmapMoreDim;
-       delete pBitmapMorePressed;
+               if (pBitmapMore != null && pBitmapMoreDim != null && pBitmapMorePressed != null)
+               {
+                       footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
+                       footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
+                       footerMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapMorePressed);
+               }
+               pFooter->SetButton(BUTTON_POSITION_LEFT, footerMore);
+
+               delete pBitmapMore;
+               delete pBitmapMoreDim;
+               delete pBitmapMorePressed;
+       }
 
        FooterItem itemCamera;
        itemCamera.Construct(IDA_FOOTER_CAMERA);
@@ -238,31 +258,61 @@ FileListForm::InitializeFooter(void)
        }
        pFooter->AddItem(itemCamera);
 
-       if (__pContextMenuMore != null)
+       if ( __isHWBackButtonExist == false )
        {
-               delete __pContextMenuMore;
-               __pContextMenuMore = null;
-       }
 
-       __pContextMenuMore = new (std::nothrow) ContextMenu();
-       __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
+               if (__pContextMenuMore != null)
+               {
+                       delete __pContextMenuMore;
+                       __pContextMenuMore = null;
+               }
 
-       if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
-       {
-               __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
-       }
+               __pContextMenuMore = new (std::nothrow) ContextMenu();
+               __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
 
-       if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
-       {
-               __pContextMenuMore->SetEnabled(false);
+               if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
+               {
+                       __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
+               }
+
+               if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
+               {
+                       __pContextMenuMore->SetEnabled(false);
+               }
+               else
+               {
+                       __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
+                       __pContextMenuMore->SetShowState(false);
+                       __pContextMenuMore->AddActionEventListener(*this);
+               }
        }
        else
        {
-               __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
-               __pContextMenuMore->SetShowState(false);
-               __pContextMenuMore->AddActionEventListener(*this);
-       }
+               if (__pOptionMenu != null)
+               {
+                       delete __pOptionMenu;
+                       __pOptionMenu = null;
+               }
+
+               __pOptionMenu = new (std::nothrow) OptionMenu();
+               __pOptionMenu->Construct();
+
+               if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
+               {
+                       __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
+               }
+
+               if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
+               {
+                       __pOptionMenu->SetEnabled(false);
+               }
+               else
+               {
+                       __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
+                       __pOptionMenu->AddActionEventListener(*this);
+               }
 
+       }
        pFooter->SetBackButton();
 
        pFooter->AddActionEventListener(*this);
@@ -334,3 +384,19 @@ FileListForm::SetFooterState(bool state)
        GetFooter()->SetButtonEnabled(BUTTON_POSITION_LEFT,state);
        GetFooter()->Invalidate(true);
 }
+
+void
+FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
+{
+
+       InitializeFooter();
+
+       if ( __pOptionMenu == null )
+       {
+               return ;
+       }
+
+       __pOptionMenu->Show();
+       __pOptionMenu->SetShowState(true);
+
+}