[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / pictures / GUIDialogPictureInfo.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #include "GUIDialogPictureInfo.h"
22 #include "GUIInfoManager.h"
23 #include "guilib/GUIWindowManager.h"
24 #include "FileItem.h"
25 #include "guilib/LocalizeStrings.h"
26 #include "PictureInfoTag.h"
27
28 #define CONTROL_PICTURE_INFO 5
29
30 #define SLIDE_STRING_BASE 21800 - SLIDE_INFO_START
31
32 CGUIDialogPictureInfo::CGUIDialogPictureInfo(void)
33     : CGUIDialog(WINDOW_DIALOG_PICTURE_INFO, "DialogPictureInfo.xml")
34 {
35   m_pictureInfo = new CFileItemList;
36   m_loadType = KEEP_IN_MEMORY;
37 }
38
39 CGUIDialogPictureInfo::~CGUIDialogPictureInfo(void)
40 {
41   delete m_pictureInfo;
42 }
43
44 void CGUIDialogPictureInfo::SetPicture(CFileItem *item)
45 {
46   g_infoManager.SetCurrentSlide(*item);
47 }
48
49 void CGUIDialogPictureInfo::OnInitWindow()
50 {
51   UpdatePictureInfo();
52   CGUIDialog::OnInitWindow();
53 }
54
55 bool CGUIDialogPictureInfo::OnAction(const CAction& action)
56 {
57   switch (action.GetID())
58   {
59     // if we're running from slideshow mode, drop the "next picture" and "previous picture" actions through.
60     case ACTION_NEXT_PICTURE:
61     case ACTION_PREV_PICTURE:
62     case ACTION_PLAYER_PLAY:
63     case ACTION_PAUSE:
64       if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW)
65       {
66         CGUIWindow* pWindow = g_windowManager.GetWindow(WINDOW_SLIDESHOW);
67         return pWindow->OnAction(action);
68       }
69       break;
70
71     case ACTION_SHOW_INFO:
72       Close();
73       return true;
74   };
75   return CGUIDialog::OnAction(action);
76 }
77
78 void CGUIDialogPictureInfo::FrameMove()
79 {
80   if (g_infoManager.GetCurrentSlide().GetPath() != m_currentPicture)
81   {
82     UpdatePictureInfo();
83     m_currentPicture = g_infoManager.GetCurrentSlide().GetPath();
84   }
85   CGUIDialog::FrameMove();
86 }
87
88 void CGUIDialogPictureInfo::UpdatePictureInfo()
89 {
90   // add stuff from the current slide to the list
91   CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_PICTURE_INFO);
92   OnMessage(msgReset);
93   m_pictureInfo->Clear();
94   for (int info = SLIDE_INFO_START; info <= SLIDE_INFO_END; ++info)
95   {
96     // we don't need want to add both SLIDE_EXIF_DATE_TIME and SLIDE_EXIF_DATE
97     // so we skip one without time
98     if (info == SLIDE_EXIF_DATE)
99       continue;
100
101     CStdString picInfo = g_infoManager.GetLabel(info);
102     if (!picInfo.IsEmpty())
103     {
104       CFileItemPtr item(new CFileItem(g_localizeStrings.Get(SLIDE_STRING_BASE + info)));
105       item->SetLabel2(picInfo);
106       m_pictureInfo->Add(item);
107     }
108   }
109   CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_PICTURE_INFO, 0, 0, m_pictureInfo);
110   OnMessage(msg);
111 }
112
113 void CGUIDialogPictureInfo::OnDeinitWindow(int nextWindowID)
114 {
115   CGUIDialog::OnDeinitWindow(nextWindowID);
116   CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_PICTURE_INFO);
117   OnMessage(msgReset);
118   m_pictureInfo->Clear();
119   m_currentPicture.Empty();
120 }