Fix keymap.
[vuplus_xbmc] / xbmc / pictures / GUIDialogPictureInfo.cpp
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://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/Key.h"
26 #include "guilib/LocalizeStrings.h"
27 #include "PictureInfoTag.h"
28
29 #define CONTROL_PICTURE_INFO 5
30
31 #define SLIDE_STRING_BASE 21800 - SLIDE_INFO_START
32
33 CGUIDialogPictureInfo::CGUIDialogPictureInfo(void)
34     : CGUIDialog(WINDOW_DIALOG_PICTURE_INFO, "DialogPictureInfo.xml")
35 {
36   m_pictureInfo = new CFileItemList;
37   m_loadType = KEEP_IN_MEMORY;
38 }
39
40 CGUIDialogPictureInfo::~CGUIDialogPictureInfo(void)
41 {
42   delete m_pictureInfo;
43 }
44
45 void CGUIDialogPictureInfo::SetPicture(CFileItem *item)
46 {
47   g_infoManager.SetCurrentSlide(*item);
48 }
49
50 void CGUIDialogPictureInfo::OnInitWindow()
51 {
52   UpdatePictureInfo();
53   CGUIDialog::OnInitWindow();
54 }
55
56 bool CGUIDialogPictureInfo::OnAction(const CAction& action)
57 {
58   switch (action.GetID())
59   {
60     // if we're running from slideshow mode, drop the "next picture" and "previous picture" actions through.
61     case ACTION_NEXT_PICTURE:
62     case ACTION_PREV_PICTURE:
63     case ACTION_PLAYER_PLAY:
64     case ACTION_PAUSE:
65       if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW)
66       {
67         CGUIWindow* pWindow = g_windowManager.GetWindow(WINDOW_SLIDESHOW);
68         return pWindow->OnAction(action);
69       }
70       break;
71
72     case ACTION_SHOW_INFO:
73       Close();
74       return true;
75   };
76   return CGUIDialog::OnAction(action);
77 }
78
79 void CGUIDialogPictureInfo::FrameMove()
80 {
81   if (g_infoManager.GetCurrentSlide().GetPath() != m_currentPicture)
82   {
83     UpdatePictureInfo();
84     m_currentPicture = g_infoManager.GetCurrentSlide().GetPath();
85   }
86   CGUIDialog::FrameMove();
87 }
88
89 void CGUIDialogPictureInfo::UpdatePictureInfo()
90 {
91   // add stuff from the current slide to the list
92   CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_PICTURE_INFO);
93   OnMessage(msgReset);
94   m_pictureInfo->Clear();
95   for (int info = SLIDE_INFO_START; info <= SLIDE_INFO_END; ++info)
96   {
97     // we only want to add SLIDE_EXIF_DATE_TIME
98     // so we skip the other date formats
99     if (info == SLIDE_EXIF_DATE || info == SLIDE_EXIF_LONG_DATE || info == SLIDE_EXIF_LONG_DATE_TIME )
100       continue;
101
102     CStdString picInfo = g_infoManager.GetLabel(info);
103     if (!picInfo.empty())
104     {
105       CFileItemPtr item(new CFileItem(g_localizeStrings.Get(SLIDE_STRING_BASE + info)));
106       item->SetLabel2(picInfo);
107       m_pictureInfo->Add(item);
108     }
109   }
110   CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_PICTURE_INFO, 0, 0, m_pictureInfo);
111   OnMessage(msg);
112 }
113
114 void CGUIDialogPictureInfo::OnDeinitWindow(int nextWindowID)
115 {
116   CGUIDialog::OnDeinitWindow(nextWindowID);
117   CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_PICTURE_INFO);
118   OnMessage(msgReset);
119   m_pictureInfo->Clear();
120   m_currentPicture.clear();
121 }