[video] fix selection after changing video or extra art
[xbmc.git] / xbmc / pvr / dialogs / GUIDialogPVRRecordingInfo.cpp
blob6019c3feb16baf62a89020826567e57851a4bd64
1 /*
2 * Copyright (C) 2012-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.
7 */
9 #include "GUIDialogPVRRecordingInfo.h"
11 #include "FileItem.h"
12 #include "ServiceBroker.h"
13 #include "guilib/GUIMessage.h"
14 #include "pvr/PVRManager.h"
15 #include "pvr/guilib/PVRGUIActionsEPG.h"
16 #include "pvr/guilib/PVRGUIRecordingsPlayActionProcessor.h"
18 using namespace PVR;
20 #define CONTROL_BTN_FIND 4
21 #define CONTROL_BTN_OK 7
22 #define CONTROL_BTN_PLAY_RECORDING 8
24 CGUIDialogPVRRecordingInfo::CGUIDialogPVRRecordingInfo()
25 : CGUIDialog(WINDOW_DIALOG_PVR_RECORDING_INFO, "DialogPVRInfo.xml"), m_recordItem(new CFileItem)
29 bool CGUIDialogPVRRecordingInfo::OnMessage(CGUIMessage& message)
31 switch (message.GetMessage())
33 case GUI_MSG_CLICKED:
34 return OnClickButtonOK(message) || OnClickButtonPlay(message) || OnClickButtonFind(message);
37 return CGUIDialog::OnMessage(message);
40 bool CGUIDialogPVRRecordingInfo::OnClickButtonOK(const CGUIMessage& message)
42 bool bReturn = false;
44 if (message.GetSenderId() == CONTROL_BTN_OK)
46 Close();
47 bReturn = true;
50 return bReturn;
53 bool CGUIDialogPVRRecordingInfo::OnClickButtonPlay(const CGUIMessage& message)
55 bool bReturn = false;
57 if (message.GetSenderId() == CONTROL_BTN_PLAY_RECORDING)
59 Close();
61 if (m_recordItem)
63 CGUIPVRRecordingsPlayActionProcessor proc{m_recordItem};
64 proc.ProcessDefaultAction();
65 if (proc.UserCancelled())
66 Open();
69 bReturn = true;
72 return bReturn;
75 bool CGUIDialogPVRRecordingInfo::OnClickButtonFind(const CGUIMessage& message)
77 bool bReturn = false;
79 if (message.GetSenderId() == CONTROL_BTN_FIND)
81 Close();
83 if (m_recordItem)
84 CServiceBroker::GetPVRManager().Get<PVR::GUI::EPG>().FindSimilar(*m_recordItem);
86 bReturn = true;
89 return bReturn;
92 bool CGUIDialogPVRRecordingInfo::OnInfo(int actionID)
94 Close();
95 return true;
98 void CGUIDialogPVRRecordingInfo::SetRecording(const CFileItem& item)
100 m_recordItem = std::make_shared<CFileItem>(item);
103 CFileItemPtr CGUIDialogPVRRecordingInfo::GetCurrentListItem(int offset)
105 return m_recordItem;