Skip to content

Commit

Permalink
Merge pull request #12823 from ksooo/pvr-fix-channel-osd-dialog-selec…
Browse files Browse the repository at this point in the history
…tion

[PVR] Fix channel OSD dialog channel preselection.
  • Loading branch information
ksooo committed Sep 24, 2017
2 parents 2a9cd9c + 38b7823 commit 1eac449
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
35 changes: 8 additions & 27 deletions xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,9 @@ void CGUIDialogPVRChannelsOSD::OnDeinitWindow(int nextWindowID)
{
if (m_group)
{
if (m_group != GetPlayingGroup())
{
CGUIWindowPVRBase::SetSelectedItemPath(CServiceBroker::GetPVRManager().IsPlayingRadio(), GetLastSelectedItemPath(m_group->GroupID()));
CServiceBroker::GetPVRManager().SetPlayingGroup(m_group);
}
else
{
CGUIWindowPVRBase::SetSelectedItemPath(CServiceBroker::GetPVRManager().IsPlayingRadio(), m_viewControl.GetSelectedItemPath());
}
CGUIWindowPVRBase::SetSelectedItemPath(m_group->IsRadio(), m_viewControl.GetSelectedItemPath());

// next OnInitWindow will set the group which is then selceted
m_group.reset();
}

Expand All @@ -152,9 +145,9 @@ bool CGUIDialogPVRChannelsOSD::OnAction(const CAction &action)
SaveControlStates();

// switch to next or previous group
CPVRChannelGroupPtr group = GetPlayingGroup();
CPVRChannelGroupPtr nextGroup = action.GetID() == ACTION_NEXT_CHANNELGROUP ? group->GetNextGroup() : group->GetPreviousGroup();
const CPVRChannelGroupPtr nextGroup = action.GetID() == ACTION_NEXT_CHANNELGROUP ? m_group->GetNextGroup() : m_group->GetPreviousGroup();
CServiceBroker::GetPVRManager().SetPlayingGroup(nextGroup);
m_group = nextGroup;
Update();

// restore control states and previously selected item of group
Expand All @@ -180,15 +173,6 @@ bool CGUIDialogPVRChannelsOSD::OnAction(const CAction &action)
return CGUIDialog::OnAction(action);
}

CPVRChannelGroupPtr CGUIDialogPVRChannelsOSD::GetPlayingGroup()
{
CPVRChannelPtr channel(CServiceBroker::GetPVRManager().GetCurrentChannel());
if (channel)
return CServiceBroker::GetPVRManager().GetPlayingGroup(channel->IsRadio());
else
return CPVRChannelGroupPtr();
}

void CGUIDialogPVRChannelsOSD::Update()
{
g_infoManager.RegisterObserver(this);
Expand Down Expand Up @@ -238,19 +222,17 @@ void CGUIDialogPVRChannelsOSD::SaveControlStates()
{
CGUIDialog::SaveControlStates();

CPVRChannelGroupPtr group = GetPlayingGroup();
if (group)
SaveSelectedItemPath(group->GroupID());
if (m_group)
SaveSelectedItemPath(m_group->GroupID());
}

void CGUIDialogPVRChannelsOSD::RestoreControlStates()
{
CGUIDialog::RestoreControlStates();

CPVRChannelGroupPtr group = GetPlayingGroup();
if (group)
if (m_group)
{
std::string path = GetLastSelectedItemPath(group->GroupID());
std::string path = GetLastSelectedItemPath(m_group->GroupID());
if (!path.empty())
m_viewControl.SetSelectedItem(path);
else
Expand All @@ -271,7 +253,6 @@ void CGUIDialogPVRChannelsOSD::GotoChannel(int item)

Close();
CServiceBroker::GetPVRManager().GUIActions()->SwitchToChannel(m_vecItems->Get(item), true /* bCheckResume */);
m_group = GetPlayingGroup();
}

void CGUIDialogPVRChannelsOSD::ShowInfo(int item)
Expand Down
5 changes: 2 additions & 3 deletions xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ namespace PVR
void ShowInfo(int item);
void Clear();
void Update();
CPVRChannelGroupPtr GetPlayingGroup();
void SaveSelectedItemPath(int iGroupID);
std::string GetLastSelectedItemPath(int iGroupID) const;

CFileItemList *m_vecItems;
CGUIViewControl m_viewControl;
CPVRChannelGroupPtr m_group;
std::map<int, std::string> m_groupSelectedItemPaths;
void SaveSelectedItemPath(int iGroupID);
std::string GetLastSelectedItemPath(int iGroupID) const;
XbmcThreads::EndTime m_refreshTimeout;
};
}
Expand Down

0 comments on commit 1eac449

Please sign in to comment.