| 1 |
/* |
| 2 |
* Copyright (C) 2005-2018 Team Kodi |
| 3 |
* This file is part of Kodi - https://kodi.tv |
| 4 |
* |
| 5 |
* SPDX-License-Identifier: GPL-2.0-or-later |
| 6 |
* See LICENSES/README.md for more information. |
| 7 |
*/ |
| 8 |
|
| 9 |
#include "GUIDialogPictureInfo.h" |
| 10 |
|
| 11 |
#include "FileItem.h" |
| 12 |
#include "GUIInfoManager.h" |
| 13 |
#include "ServiceBroker.h" |
| 14 |
#include "guilib/GUIComponent.h" |
| 15 |
#include "guilib/GUIWindowManager.h" |
| 16 |
#include "guilib/LocalizeStrings.h" |
| 17 |
#include "guilib/guiinfo/GUIInfoLabels.h" |
| 18 |
#include "input/actions/Action.h" |
| 19 |
#include "input/actions/ActionIDs.h" |
| 20 |
|
| 21 |
#define CONTROL_PICTURE_INFO 5 |
| 22 |
|
| 23 |
#define SLIDESHOW_STRING_BASE 21800 - SLIDESHOW_LABELS_START |
| 24 |
|
| 25 |
CGUIDialogPictureInfo::CGUIDialogPictureInfo(void) |
| 26 |
: CGUIDialog(WINDOW_DIALOG_PICTURE_INFO, "DialogPictureInfo.xml") |
| 27 |
{ |
| 28 |
m_pictureInfo = new CFileItemList; |
| 29 |
m_loadType = KEEP_IN_MEMORY; |
| 30 |
} |
| 31 |
|
| 32 |
CGUIDialogPictureInfo::~CGUIDialogPictureInfo(void) |
| 33 |
{ |
| 34 |
delete m_pictureInfo; |
| 35 |
} |
| 36 |
|
| 37 |
void CGUIDialogPictureInfo::SetPicture(CFileItem *item) |
| 38 |
{ |
| 39 |
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPicturesInfoProvider().SetCurrentSlide(item); |
| 40 |
} |
| 41 |
|
| 42 |
void CGUIDialogPictureInfo::OnInitWindow() |
| 43 |
{ |
| 44 |
UpdatePictureInfo(); |
| 45 |
CGUIDialog::OnInitWindow(); |
| 46 |
} |
| 47 |
|
| 48 |
bool CGUIDialogPictureInfo::OnAction(const CAction& action) |
| 49 |
{ |
| 50 |
switch (action.GetID()) |
| 51 |
{ |
| 52 |
// if we're running from slideshow mode, drop the "next picture" and "previous picture" actions through. |
| 53 |
case ACTION_NEXT_PICTURE: |
| 54 |
case ACTION_PREV_PICTURE: |
| 55 |
case ACTION_PLAYER_PLAY: |
| 56 |
case ACTION_PAUSE: |
| 57 |
if (CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WINDOW_SLIDESHOW) |
| 58 |
{ |
| 59 |
CGUIWindow* pWindow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(WINDOW_SLIDESHOW); |
| 60 |
return pWindow->OnAction(action); |
| 61 |
} |
| 62 |
break; |
| 63 |
|
| 64 |
case ACTION_SHOW_INFO: |
| 65 |
Close(); |
| 66 |
return true; |
| 67 |
}; |
| 68 |
return CGUIDialog::OnAction(action); |
| 69 |
} |
| 70 |
|
| 71 |
void CGUIDialogPictureInfo::FrameMove() |
| 72 |
{ |
| 73 |
const CFileItem* item = CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPicturesInfoProvider().GetCurrentSlide(); |
| 74 |
if (item && item->GetPath() != m_currentPicture) |
| 75 |
{ |
| 76 |
UpdatePictureInfo(); |
| 77 |
m_currentPicture = item->GetPath(); |
| 78 |
} |
| 79 |
CGUIDialog::FrameMove(); |
| 80 |
} |
| 81 |
|
| 82 |
void CGUIDialogPictureInfo::UpdatePictureInfo() |
| 83 |
{ |
| 84 |
// add stuff from the current slide to the list |
| 85 |
CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_PICTURE_INFO); |
| 86 |
OnMessage(msgReset); |
| 87 |
m_pictureInfo->Clear(); |
| 88 |
for (int info = SLIDESHOW_LABELS_START; info <= SLIDESHOW_LABELS_END; ++info) |
| 89 |
{ |
| 90 |
// we only want to add SLIDESHOW_EXIF_DATE_TIME |
| 91 |
// so we skip the other date formats |
| 92 |
if (info == SLIDESHOW_EXIF_DATE || info == SLIDESHOW_EXIF_LONG_DATE || info == SLIDESHOW_EXIF_LONG_DATE_TIME ) |
| 93 |
continue; |
| 94 |
|
| 95 |
std::string picInfo = |
| 96 |
CServiceBroker::GetGUI()->GetInfoManager().GetLabel(info, INFO::DEFAULT_CONTEXT); |
| 97 |
if (!picInfo.empty()) |
| 98 |
{ |
| 99 |
CFileItemPtr item(new CFileItem(g_localizeStrings.Get(SLIDESHOW_STRING_BASE + info))); |
| 100 |
item->SetLabel2(picInfo); |
| 101 |
m_pictureInfo->Add(item); |
| 102 |
} |
| 103 |
} |
| 104 |
CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_PICTURE_INFO, 0, 0, m_pictureInfo); |
| 105 |
OnMessage(msg); |
| 106 |
} |
| 107 |
|
| 108 |
void CGUIDialogPictureInfo::OnDeinitWindow(int nextWindowID) |
| 109 |
{ |
| 110 |
CGUIDialog::OnDeinitWindow(nextWindowID); |
| 111 |
CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_PICTURE_INFO); |
| 112 |
OnMessage(msgReset); |
| 113 |
m_pictureInfo->Clear(); |
| 114 |
m_currentPicture.clear(); |
| 115 |
} |