2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "GUIDialogPictureInfo.h"
12 #include "FileItemList.h"
13 #include "GUIInfoManager.h"
14 #include "ServiceBroker.h"
15 #include "guilib/GUIComponent.h"
16 #include "guilib/GUIWindowManager.h"
17 #include "guilib/LocalizeStrings.h"
18 #include "guilib/guiinfo/GUIInfoLabels.h"
19 #include "input/actions/Action.h"
20 #include "input/actions/ActionIDs.h"
26 constexpr unsigned int CONTROL_PICTURE_INFO
= 5;
28 constexpr std::array slideShowInfoTranslationList
{std::pair
{SLIDESHOW_FILE_NAME
, 21800},
29 std::pair
{SLIDESHOW_FILE_PATH
, 21801},
30 std::pair
{SLIDESHOW_FILE_SIZE
, 21802},
31 std::pair
{SLIDESHOW_FILE_DATE
, 21803},
32 std::pair
{SLIDESHOW_COLOUR
, 21807},
33 std::pair
{SLIDESHOW_PROCESS
, 21808},
34 std::pair
{SLIDESHOW_INDEX
, 21804},
35 std::pair
{SLIDESHOW_RESOLUTION
, 21805},
36 std::pair
{SLIDESHOW_COMMENT
, 21806},
37 std::pair
{SLIDESHOW_EXIF_DATE_TIME
, 21820},
38 std::pair
{SLIDESHOW_EXIF_DESCRIPTION
, 21821},
39 std::pair
{SLIDESHOW_EXIF_CAMERA_MAKE
, 21822},
40 std::pair
{SLIDESHOW_EXIF_CAMERA_MODEL
, 21823},
41 std::pair
{SLIDESHOW_EXIF_COMMENT
, 21824},
42 std::pair
{SLIDESHOW_EXIF_APERTURE
, 21826},
43 std::pair
{SLIDESHOW_EXIF_FOCAL_LENGTH
, 21827},
44 std::pair
{SLIDESHOW_EXIF_FOCUS_DIST
, 21828},
45 std::pair
{SLIDESHOW_EXIF_EXPOSURE
, 21829},
46 std::pair
{SLIDESHOW_EXIF_EXPOSURE_TIME
, 21830},
47 std::pair
{SLIDESHOW_EXIF_EXPOSURE_BIAS
, 21831},
48 std::pair
{SLIDESHOW_EXIF_EXPOSURE_MODE
, 21832},
49 std::pair
{SLIDESHOW_EXIF_FLASH_USED
, 21833},
50 std::pair
{SLIDESHOW_EXIF_WHITE_BALANCE
, 21834},
51 std::pair
{SLIDESHOW_EXIF_LIGHT_SOURCE
, 21835},
52 std::pair
{SLIDESHOW_EXIF_METERING_MODE
, 21836},
53 std::pair
{SLIDESHOW_EXIF_ISO_EQUIV
, 21837},
54 std::pair
{SLIDESHOW_EXIF_DIGITAL_ZOOM
, 21838},
55 std::pair
{SLIDESHOW_EXIF_CCD_WIDTH
, 21839},
56 std::pair
{SLIDESHOW_EXIF_GPS_LATITUDE
, 21840},
57 std::pair
{SLIDESHOW_EXIF_GPS_LONGITUDE
, 21841},
58 std::pair
{SLIDESHOW_EXIF_GPS_ALTITUDE
, 21842},
59 std::pair
{SLIDESHOW_EXIF_ORIENTATION
, 21843},
60 std::pair
{SLIDESHOW_EXIF_XPCOMMENT
, 21844},
61 std::pair
{SLIDESHOW_IPTC_SUBLOCATION
, 21857},
62 std::pair
{SLIDESHOW_IPTC_IMAGETYPE
, 21858},
63 std::pair
{SLIDESHOW_IPTC_TIMECREATED
, 21859},
64 std::pair
{SLIDESHOW_IPTC_SUP_CATEGORIES
, 21860},
65 std::pair
{SLIDESHOW_IPTC_KEYWORDS
, 21861},
66 std::pair
{SLIDESHOW_IPTC_CAPTION
, 21862},
67 std::pair
{SLIDESHOW_IPTC_AUTHOR
, 21863},
68 std::pair
{SLIDESHOW_IPTC_HEADLINE
, 21864},
69 std::pair
{SLIDESHOW_IPTC_SPEC_INSTR
, 21865},
70 std::pair
{SLIDESHOW_IPTC_CATEGORY
, 21866},
71 std::pair
{SLIDESHOW_IPTC_BYLINE
, 21867},
72 std::pair
{SLIDESHOW_IPTC_BYLINE_TITLE
, 21868},
73 std::pair
{SLIDESHOW_IPTC_CREDIT
, 21869},
74 std::pair
{SLIDESHOW_IPTC_SOURCE
, 21870},
75 std::pair
{SLIDESHOW_IPTC_COPYRIGHT_NOTICE
, 21871},
76 std::pair
{SLIDESHOW_IPTC_OBJECT_NAME
, 21872},
77 std::pair
{SLIDESHOW_IPTC_CITY
, 21873},
78 std::pair
{SLIDESHOW_IPTC_STATE
, 21874},
79 std::pair
{SLIDESHOW_IPTC_COUNTRY
, 21875},
80 std::pair
{SLIDESHOW_IPTC_TX_REFERENCE
, 21876},
81 std::pair
{SLIDESHOW_IPTC_DATE
, 21877},
82 std::pair
{SLIDESHOW_IPTC_URGENCY
, 21878},
83 std::pair
{SLIDESHOW_IPTC_COUNTRY_CODE
, 21879},
84 std::pair
{SLIDESHOW_IPTC_REF_SERVICE
, 21880}};
87 CGUIDialogPictureInfo::CGUIDialogPictureInfo(void)
88 : CGUIDialog(WINDOW_DIALOG_PICTURE_INFO
, "DialogPictureInfo.xml"),
89 m_pictureInfo
{std::make_unique
<CFileItemList
>()}
91 m_loadType
= KEEP_IN_MEMORY
;
94 void CGUIDialogPictureInfo::SetPicture(CFileItem
*item
)
96 CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPicturesInfoProvider().SetCurrentSlide(item
);
99 void CGUIDialogPictureInfo::OnInitWindow()
102 CGUIDialog::OnInitWindow();
105 bool CGUIDialogPictureInfo::OnAction(const CAction
& action
)
107 switch (action
.GetID())
109 // if we're running from slideshow mode, drop the "next picture" and "previous picture" actions through.
110 case ACTION_NEXT_PICTURE
:
111 case ACTION_PREV_PICTURE
:
112 case ACTION_PLAYER_PLAY
:
114 if (CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WINDOW_SLIDESHOW
)
116 CGUIWindow
* pWindow
= CServiceBroker::GetGUI()->GetWindowManager().GetWindow(WINDOW_SLIDESHOW
);
117 return pWindow
->OnAction(action
);
121 case ACTION_SHOW_INFO
:
125 return CGUIDialog::OnAction(action
);
128 void CGUIDialogPictureInfo::FrameMove()
130 const CFileItem
* item
= CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPicturesInfoProvider().GetCurrentSlide();
131 if (item
&& item
->GetPath() != m_currentPicture
)
134 m_currentPicture
= item
->GetPath();
136 CGUIDialog::FrameMove();
139 void CGUIDialogPictureInfo::UpdatePictureInfo()
141 // add stuff from the current slide to the list
142 CGUIMessage
msgReset(GUI_MSG_LABEL_RESET
, GetID(), CONTROL_PICTURE_INFO
);
144 m_pictureInfo
->Clear();
145 for (const auto& [info
, code
] : slideShowInfoTranslationList
)
147 const std::string picInfo
=
148 CServiceBroker::GetGUI()->GetInfoManager().GetLabel(info
, INFO::DEFAULT_CONTEXT
);
149 if (!picInfo
.empty())
151 auto item
{std::make_shared
<CFileItem
>(g_localizeStrings
.Get(code
))};
152 item
->SetLabel2(picInfo
);
153 m_pictureInfo
->Add(item
);
156 CGUIMessage
msg(GUI_MSG_LABEL_BIND
, GetID(), CONTROL_PICTURE_INFO
, 0, 0, m_pictureInfo
.get());
160 void CGUIDialogPictureInfo::OnDeinitWindow(int nextWindowID
)
162 CGUIDialog::OnDeinitWindow(nextWindowID
);
163 CGUIMessage
msgReset(GUI_MSG_LABEL_RESET
, GetID(), CONTROL_PICTURE_INFO
);
165 m_pictureInfo
->Clear();
166 m_currentPicture
.clear();