PageRenderTime 20ms CodeModel.GetById 8ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/xbmc/pictures/GUIDialogPictureInfo.cpp

http://github.com/xbmc/xbmc
C++ | 113 lines | 88 code | 14 blank | 11 comment | 14 complexity | a3b4cbdb1ebe19dc0dbd9334a4a70f5c MD5 | raw file
  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/Key.h"
 19
 20#define CONTROL_PICTURE_INFO 5
 21
 22#define SLIDESHOW_STRING_BASE 21800 - SLIDESHOW_LABELS_START
 23
 24CGUIDialogPictureInfo::CGUIDialogPictureInfo(void)
 25    : CGUIDialog(WINDOW_DIALOG_PICTURE_INFO, "DialogPictureInfo.xml")
 26{
 27  m_pictureInfo = new CFileItemList;
 28  m_loadType = KEEP_IN_MEMORY;
 29}
 30
 31CGUIDialogPictureInfo::~CGUIDialogPictureInfo(void)
 32{
 33  delete m_pictureInfo;
 34}
 35
 36void CGUIDialogPictureInfo::SetPicture(CFileItem *item)
 37{
 38  CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPicturesInfoProvider().SetCurrentSlide(item);
 39}
 40
 41void CGUIDialogPictureInfo::OnInitWindow()
 42{
 43  UpdatePictureInfo();
 44  CGUIDialog::OnInitWindow();
 45}
 46
 47bool CGUIDialogPictureInfo::OnAction(const CAction& action)
 48{
 49  switch (action.GetID())
 50  {
 51    // if we're running from slideshow mode, drop the "next picture" and "previous picture" actions through.
 52    case ACTION_NEXT_PICTURE:
 53    case ACTION_PREV_PICTURE:
 54    case ACTION_PLAYER_PLAY:
 55    case ACTION_PAUSE:
 56      if (CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow() == WINDOW_SLIDESHOW)
 57      {
 58        CGUIWindow* pWindow = CServiceBroker::GetGUI()->GetWindowManager().GetWindow(WINDOW_SLIDESHOW);
 59        return pWindow->OnAction(action);
 60      }
 61      break;
 62
 63    case ACTION_SHOW_INFO:
 64      Close();
 65      return true;
 66  };
 67  return CGUIDialog::OnAction(action);
 68}
 69
 70void CGUIDialogPictureInfo::FrameMove()
 71{
 72  const CFileItem* item = CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPicturesInfoProvider().GetCurrentSlide();
 73  if (item && item->GetPath() != m_currentPicture)
 74  {
 75    UpdatePictureInfo();
 76    m_currentPicture = item->GetPath();
 77  }
 78  CGUIDialog::FrameMove();
 79}
 80
 81void CGUIDialogPictureInfo::UpdatePictureInfo()
 82{
 83  // add stuff from the current slide to the list
 84  CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_PICTURE_INFO);
 85  OnMessage(msgReset);
 86  m_pictureInfo->Clear();
 87  for (int info = SLIDESHOW_LABELS_START; info <= SLIDESHOW_LABELS_END; ++info)
 88  {
 89    // we only want to add SLIDESHOW_EXIF_DATE_TIME
 90    // so we skip the other date formats
 91    if (info == SLIDESHOW_EXIF_DATE || info == SLIDESHOW_EXIF_LONG_DATE || info == SLIDESHOW_EXIF_LONG_DATE_TIME )
 92      continue;
 93
 94    std::string picInfo = CServiceBroker::GetGUI()->GetInfoManager().GetLabel(info);
 95    if (!picInfo.empty())
 96    {
 97      CFileItemPtr item(new CFileItem(g_localizeStrings.Get(SLIDESHOW_STRING_BASE + info)));
 98      item->SetLabel2(picInfo);
 99      m_pictureInfo->Add(item);
100    }
101  }
102  CGUIMessage msg(GUI_MSG_LABEL_BIND, GetID(), CONTROL_PICTURE_INFO, 0, 0, m_pictureInfo);
103  OnMessage(msg);
104}
105
106void CGUIDialogPictureInfo::OnDeinitWindow(int nextWindowID)
107{
108  CGUIDialog::OnDeinitWindow(nextWindowID);
109  CGUIMessage msgReset(GUI_MSG_LABEL_RESET, GetID(), CONTROL_PICTURE_INFO);
110  OnMessage(msgReset);
111  m_pictureInfo->Clear();
112  m_currentPicture.clear();
113}