2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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 GlFileListForm.cpp
19 * @brief This is the implementation file for FileListForm class.
22 #include "GlAlbumInfo.h"
23 #include "GlAllListPanel.h"
24 #include "GlFileListForm.h"
25 #include "GlFileListPresentationModel.h"
26 #include "GlGalleryApp.h"
27 #include "GlResourceManager.h"
28 #include "GlSlideSettingListener.h"
29 #include "GlSlideShowPopUp.h"
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Graphics;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
39 using namespace Tizen::Content;
41 FileListForm::FileListForm(void)
42 : __isHWBackButtonExist(false)
43 , __pContextMenuMore(null)
46 , __pPresentationModel(null)
49 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
52 FileListForm::~FileListForm(void)
55 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
59 FileListForm::Initialize(void)
62 result r = Form::Construct(IDL_FORM_FILE_LIST);
63 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
68 FileListForm::OnInitializing(void)
71 Header* pHeader = GetHeader();
72 TryReturn(pHeader != null, E_FAILURE, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
74 __isHWBackButtonExist = false;
76 SetFormMenuEventListener(this);
77 GalleryApp* pApp = static_cast<GalleryApp*>(GalleryApp::GetInstance());
79 __isHWBackButtonExist = pApp->IsHwKeySupported();
81 __pPresentationModel = FileListPresentationModel::GetInstance();
82 __pPresentationModel->ClearThumbnailRequests();
84 __pPopUp = new (std::nothrow) SlideShowPopUp();
88 __pPopUp->Initialize();
89 __pPopUp->SetEventListner(this);
94 SetFormBackEventListener(this);
95 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
101 FileListForm::OnTerminating(void)
103 AppLogDebug("ENTER");
105 if (__pContextMenuMore != null)
107 delete __pContextMenuMore;
108 __pContextMenuMore = null;
111 if ( __pOptionMenu != null )
113 delete __pOptionMenu;
114 __pOptionMenu = null;
117 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
123 FileListForm::OnContentUpdated()
125 AppLogDebug("ENTER");
126 SceneManager* pSceneManager = SceneManager::GetInstance();
127 static_cast<AllListPanel*>(pSceneManager->GetCurrentScene()->GetPanel())->Refresh();
128 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
132 FileListForm::OnActionPerformed(const Control& source, int actionId)
134 AppLogDebug("ENTER");
135 SceneManager* pSceneManager = SceneManager::GetInstance();
136 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
140 case IDA_FOOTER_MORE:
142 AppLogDebug("ITEMCOUNT(%d)", __pPresentationModel->GetCurrentAlbumContentInfoCount());
146 if (__pContextMenuMore->GetShowState() == false)
148 Rectangle rect = source.GetBounds();
149 __pContextMenuMore->SetAnchorPosition(Point(rect.width / 10, rect.y));
150 __pContextMenuMore->SetShowState(true);
151 __pContextMenuMore->Show();
155 __pContextMenuMore->SetShowState(false);
160 case IDA_FOOTER_EDIT:
162 if (pSceneManager->GetCurrentSceneId() == IDSCN_ALL_LIST)
164 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
166 else if (pSceneManager->GetCurrentSceneId() == IDSCN_IMAGE_LIST)
168 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_IMAGE_LIST_EDITOR));
170 else if (pSceneManager->GetCurrentSceneId() == IDSCN_VIDEO_LIST)
172 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_VIDEO_LIST_EDITOR));
176 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_ALL_LIST_EDITOR));
181 case IDA_FOOTER_SLIDESHOW:
184 if (__pPopUp != null)
186 __pPopUp->SetShowState(true);
192 case IDA_FOOTER_CAMERA:
194 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
195 pDataList->Construct();
196 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_CAMERA_ALLOW_SWITCH), new (std::nothrow) String(APPCONTROL_DATA_TRUE));
197 __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_CAMERA, APPCONTROL_OPERATION_ID_CREATE_CONTENT,
198 null, new (std::nothrow) String(APPCONTROL_MIME_IMAGE_JPG), pDataList, null);
205 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
209 FileListForm::OnFormBackRequested(Form& source)
211 AppLogDebug("ENTER");
212 SceneManager* pSceneManager = SceneManager::GetInstance();
213 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
215 pSceneManager->GoBackward(BackwardSceneTransition(IDSCN_ALBUM_LIST));
216 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
220 FileListForm::InitializeFooter(void)
222 AppLogDebug("ENTER");
223 result r = E_SUCCESS;
224 Footer* pFooter = GetFooter();
225 TryReturn(pFooter != null, E_FAILURE, "[%s] fail to get the Footer.", GetErrorMessage(GetLastResult()));
227 pFooter->RemoveAllItems();
228 pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON);
231 if ( __isHWBackButtonExist == false )
233 ButtonItem footerMore;
234 footerMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_MORE);
235 Bitmap* pBitmapMore = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE);
236 Bitmap* pBitmapMoreDim = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_DISABLED);
237 Bitmap* pBitmapMorePressed = ResourceManager::GetBitmapN(IDB_CONTROLBAR_MORE_PRESSED);
239 if (pBitmapMore != null && pBitmapMoreDim != null && pBitmapMorePressed != null)
241 footerMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBitmapMore);
242 footerMore.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pBitmapMoreDim);
243 footerMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pBitmapMorePressed);
245 pFooter->SetButton(BUTTON_POSITION_LEFT, footerMore);
248 delete pBitmapMoreDim;
249 delete pBitmapMorePressed;
252 FooterItem itemCamera;
253 itemCamera.Construct(IDA_FOOTER_CAMERA);
254 Bitmap* pBitmapCamera = ResourceManager::GetBitmapN(IDB_CONTROLBAR_CAMERA);
255 if (pBitmapCamera != null)
257 itemCamera.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pBitmapCamera);
259 pFooter->AddItem(itemCamera);
261 if ( __isHWBackButtonExist == false )
264 if (__pContextMenuMore != null)
266 delete __pContextMenuMore;
267 __pContextMenuMore = null;
270 __pContextMenuMore = new (std::nothrow) ContextMenu();
271 __pContextMenuMore->Construct(Point(0, 0), CONTEXT_MENU_STYLE_LIST);
273 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
275 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
278 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
280 __pContextMenuMore->SetEnabled(false);
284 __pContextMenuMore->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
285 __pContextMenuMore->SetShowState(false);
286 __pContextMenuMore->AddActionEventListener(*this);
291 if (__pOptionMenu != null)
293 delete __pOptionMenu;
294 __pOptionMenu = null;
297 __pOptionMenu = new (std::nothrow) OptionMenu();
298 __pOptionMenu->Construct();
300 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() > 1)
302 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_MEDIABR_OPT_SLIDESHOW"), IDA_FOOTER_SLIDESHOW);
305 if (__pPresentationModel->GetCurrentAlbumContentInfoCount() == 0)
307 __pOptionMenu->SetEnabled(false);
311 __pOptionMenu->AddItem(ResourceManager::GetString(L"IDS_COM_HEADER_EDIT"), IDA_FOOTER_EDIT);
312 __pOptionMenu->AddActionEventListener(*this);
316 pFooter->SetBackButton();
318 pFooter->AddActionEventListener(*this);
319 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
325 FileListForm::SetTitleText(const String& titleText)
327 AppLogDebug("ENTER");
328 Header* pHeader = GetHeader();
329 TryReturnVoid(pHeader != null, "[%s] fail to get the Header.", GetErrorMessage(GetLastResult()));
330 pHeader->SetTitleText(titleText);
332 AppLogDebug("EXIT(%s)", GetErrorMessage(GetLastResult()));
336 FileListForm::OnSlideSettingPopUpItemSelected(int index)
338 if (__pPopUp != NULL)
340 __pPopUp->SetShowState(false);
345 result r = E_SUCCESS;
346 ArrayList* pArrayList = new (std::nothrow) ArrayList(SingleObjectDeleter);
347 pArrayList->Construct();
348 int loopCount = __pPresentationModel->GetCurrentAlbumContentInfoCount();
350 for (int i = 0; i < loopCount; ++i)
352 pArrayList->Add(new (std::nothrow) String(__pPresentationModel->GetContentFilePath(i)));
355 HashMap* pDataList = new (std::nothrow) HashMap(SingleObjectDeleter);
356 pDataList->Construct();
357 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_TYPE), new (std::nothrow) String(APPCONTROL_DATA_SLIDE_SHOW));
358 pDataList->Add(new (std::nothrow) String(APPCONTROL_KEY_PATH), (Object*)pArrayList);
360 r = __pPresentationModel->StartAppControl(APPCONTROL_PROVIDER_ID_IMAGE, APPCONTROL_OPERATION_ID_VIEW, null,
361 new (std::nothrow) String(APPCONTROL_MIME_IMAGE_ALL), pDataList, null);
363 if (r == E_MAX_EXCEEDED)
365 MessageBox messageBox;
366 messageBox.Construct(L"", ResourceManager::GetString(L"IDS_RCS_BODY_MAXIMUM_NUMBER_OF_FILES_EXCEEDED"),
367 MSGBOX_STYLE_NONE, 3000);
369 messageBox.ShowAndWait(modalResult);
374 SceneManager* pSceneManager = SceneManager::GetInstance();
375 TryReturnVoid(pSceneManager != null, "[%s] fail to get SceneManager", GetErrorMessage(GetLastResult()));
377 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SETTING_MAIN));
382 FileListForm::SetFooterState(bool state)
384 GetFooter()->SetButtonEnabled(BUTTON_POSITION_LEFT,state);
385 GetFooter()->Invalidate(true);
389 FileListForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
394 if ( __pOptionMenu == null )
399 __pOptionMenu->Show();
400 __pOptionMenu->SetShowState(true);