Skip to content

Commit

Permalink
Merge pull request xbmc#13611 from ksooo/pvr-directchannelinput-ok
Browse files Browse the repository at this point in the history
[PVR] Direct channel number input improvement
  • Loading branch information
ksooo authored Mar 4, 2018
2 parents 89a53e4 + b8d070c commit 2ed79a4
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ CGUITextLayout* COverlayText::GetFontLayout(const std::string &font, int color,
, style
, true, 1.0f, 1.0f, &pal, true);
if (!subtitle_font || !border_font)
CLog::Log(LOGERROR, "CGUIWindowFullScreen::OnMessage(WINDOW_INIT) - Unable to load subtitle font");
CLog::Log(LOGERROR, "COverlayText::GetFontLayout - Unable to load subtitle font");
else
return new CGUITextLayout(subtitle_font, true, 0, border_font);
}
Expand Down
13 changes: 2 additions & 11 deletions xbmc/music/windows/GUIWindowVisualisation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "GUIUserMessages.h"
#include "GUIInfoManager.h"
#include "guilib/GUIWindowManager.h"
#include "input/InputManager.h"
#include "input/Key.h"
#include "pvr/PVRGUIActions.h"
#include "pvr/PVRManager.h"
Expand All @@ -50,17 +49,9 @@ CGUIWindowVisualisation::CGUIWindowVisualisation(void)

bool CGUIWindowVisualisation::OnAction(const CAction &action)
{
if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRPLAYBACK_CONFIRMCHANNELSWITCH) &&
CServiceBroker::GetPVRManager().GUIActions()->GetChannelNavigator().IsPreview() &&
(action.GetID() == ACTION_SELECT_ITEM ||
CServiceBroker::GetInputManager().GetGlobalAction(action.GetButtonCode()).GetID() == ACTION_SELECT_ITEM))
{
// If confirm channel switch is active, channel preview is currently shown
// and the button that caused this action matches (global) action "Select" (OK)
// switch to the channel currently displayed within the preview.
CServiceBroker::GetPVRManager().GUIActions()->GetChannelNavigator().SwitchToCurrentChannel();
// Handle some actions "overloaded" by PVR (e.g. channel preview, direct channel number input).
if (CServiceBroker::GetPVRManager().GUIActions()->OnAction(action))
return true;
}

bool passToVis = false;
switch (action.GetID())
Expand Down
12 changes: 12 additions & 0 deletions xbmc/pvr/PVRChannelNumberInputHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ void CPVRChannelNumberInputHandler::OnTimeout()
m_inputBuffer.erase();
}

bool CPVRChannelNumberInputHandler::CheckInputAndExecuteAction()
{
const CPVRChannelNumber channelNumber = GetChannelNumber();
if (channelNumber.IsValid())
{
// we have a valid channel number; execute the associated action now.
OnTimeout();
return true;
}
return false;
}

void CPVRChannelNumberInputHandler::AppendChannelNumberCharacter(char cCharacter)
{
if (cCharacter != CPVRChannelNumber::SEPARATOR && (cCharacter < '0' || cCharacter > '9'))
Expand Down
6 changes: 6 additions & 0 deletions xbmc/pvr/PVRChannelNumberInputHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ class CPVRChannelNumberInputHandler : private ITimerCallback
*/
std::string GetChannelNumberAsString() const;

/*!
* @brief If a number was entered, execute the associated action.
* @return True, if the action was executed, false otherwise.
*/
bool CheckInputAndExecuteAction();

protected:
/*!
* @brief Get the currently entered channel number.
Expand Down
34 changes: 27 additions & 7 deletions xbmc/pvr/PVRGUIActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "guilib/GUIKeyboardFactory.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/LocalizeStrings.h"
#include "input/InputManager.h"
#include "input/Key.h"
#include "messaging/ApplicationMessenger.h"
#include "network/Network.h"
Expand Down Expand Up @@ -157,6 +158,7 @@ namespace PVR
CSettings::SETTING_PVRMANAGER_PRESELECTPLAYINGCHANNEL,
CSettings::SETTING_PVRRECORD_INSTANTRECORDTIME,
CSettings::SETTING_PVRRECORD_INSTANTRECORDACTION,
CSettings::SETTING_PVRPLAYBACK_CONFIRMCHANNELSWITCH,
CSettings::SETTING_PVRPLAYBACK_SWITCHTOFULLSCREEN,
CSettings::SETTING_PVRPARENTAL_PIN,
CSettings::SETTING_PVRPARENTAL_ENABLED,
Expand Down Expand Up @@ -1120,11 +1122,6 @@ namespace PVR
}

bool CPVRGUIActions::SwitchToChannel(const CFileItemPtr &item, bool bCheckResume) const
{
return SwitchToChannel(item, bCheckResume, m_settings.GetBoolValue(CSettings::SETTING_PVRPLAYBACK_SWITCHTOFULLSCREEN));
}

bool CPVRGUIActions::SwitchToChannel(const CFileItemPtr &item, bool bCheckResume, bool bFullscreen) const
{
if (item->m_bIsFolder)
return false;
Expand Down Expand Up @@ -1163,7 +1160,7 @@ namespace PVR
}
}

StartPlayback(new CFileItem(channel), bFullscreen);
StartPlayback(new CFileItem(channel), m_settings.GetBoolValue(CSettings::SETTING_PVRPLAYBACK_SWITCHTOFULLSCREEN));
return true;
}

Expand Down Expand Up @@ -1266,7 +1263,7 @@ namespace PVR

CLog::Log(LOGNOTICE, "PVRGUIActions - %s - start playback of channel '%s'", __FUNCTION__, item->GetPVRChannelInfoTag()->ChannelName().c_str());
CServiceBroker::GetPVRManager().SetPlayingGroup(group);
return SwitchToChannel(item, true, m_settings.GetBoolValue(CSettings::SETTING_PVRPLAYBACK_SWITCHTOFULLSCREEN));
return SwitchToChannel(item, true);
}

bool CPVRGUIActions::PlayMedia(const CFileItemPtr &item) const
Expand Down Expand Up @@ -1834,6 +1831,29 @@ namespace PVR
return m_channelNavigator;
}

bool CPVRGUIActions::OnAction(const CAction &action)
{
// If the button that caused this action matches (global) action "Select" (OK)...
if (action.GetID() == ACTION_SELECT_ITEM ||
CServiceBroker::GetInputManager().GetGlobalAction(action.GetButtonCode()).GetID() == ACTION_SELECT_ITEM)
{
if (m_settings.GetBoolValue(CSettings::SETTING_PVRPLAYBACK_CONFIRMCHANNELSWITCH) &&
GetChannelNavigator().IsPreview())
{
// ... and if "confirm channel switch" setting is active and a channel
// preview is currently shown, switch to the currently previewed channel.
GetChannelNavigator().SwitchToCurrentChannel();
return true;
}
else if (GetChannelNumberInputHandler().CheckInputAndExecuteAction())
{
// ... and action was processed by direct channel number input, we're done.
return true;
}
}
return false;
}

void CPVRGUIActions::OnPlaybackStarted(const CFileItemPtr &item)
{
if (item->HasPVRChannelInfoTag())
Expand Down
16 changes: 7 additions & 9 deletions xbmc/pvr/PVRGUIActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "pvr/PVRSettings.h"
#include "pvr/PVRTypes.h"

class CAction;
class CFileItem;
typedef std::shared_ptr<CFileItem> CFileItemPtr;

Expand Down Expand Up @@ -372,6 +373,12 @@ namespace PVR
*/
CPVRGUIChannelNavigator &GetChannelNavigator();

/*!
* @brief Process an action.
* @return True if the action was processed, false otherwise.
*/
bool OnAction(const CAction &action);

/*!
* @brief Inform GUI actions that playback of an item just started.
* @param item The item that started to play.
Expand Down Expand Up @@ -473,15 +480,6 @@ namespace PVR
*/
void CheckAndSwitchToFullscreen(bool bFullscreen) const;

/*!
* @brief Switch channel.
* @param item containing a channel or an epg tag.
* @param bCheckResume controls resume check in case a recording for the current epg event is present.
* @param bFullscreen start playback fullscreen or not.
* @return true on success, false otherwise.
*/
bool SwitchToChannel(const CFileItemPtr &item, bool bCheckResume, bool bFullscreen) const;

/*!
* @brief Start playback of the given item.
* @param bFullscreen start playback fullscreen or not.
Expand Down
4 changes: 4 additions & 0 deletions xbmc/pvr/dialogs/GUIDialogPVRChannelsOSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ bool CGUIDialogPVRChannelsOSD::OnMessage(CGUIMessage& message)

if (iAction == ACTION_SELECT_ITEM || iAction == ACTION_MOUSE_LEFT_CLICK)
{
// If direct channel number input is active, select the entered channel.
if (CServiceBroker::GetPVRManager().GUIActions()->GetChannelNumberInputHandler().CheckInputAndExecuteAction())
return true;

/* Switch to channel */
GotoChannel(iItem);
return true;
Expand Down
11 changes: 11 additions & 0 deletions xbmc/pvr/windows/GUIWindowPVRChannels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,17 @@ bool CGUIWindowPVRChannelsBase::OnMessage(CGUIMessage& message)
case GUI_MSG_CLICKED:
if (message.GetSenderId() == m_viewControl.GetCurrentControl())
{
if (message.GetParam1() == ACTION_SELECT_ITEM ||
message.GetParam1() == ACTION_MOUSE_LEFT_CLICK)
{
// If direct channel number input is active, select the entered channel.
if (CServiceBroker::GetPVRManager().GUIActions()->GetChannelNumberInputHandler().CheckInputAndExecuteAction())
{
bReturn = true;
break;
}
}

int iItem = m_viewControl.GetSelectedItem();
if (iItem >= 0 && iItem < m_vecItems->Size())
{
Expand Down
11 changes: 11 additions & 0 deletions xbmc/pvr/windows/GUIWindowPVRGuide.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,17 @@ bool CGUIWindowPVRGuideBase::OnMessage(CGUIMessage& message)
{
if (message.GetSenderId() == m_viewControl.GetCurrentControl())
{
if (message.GetParam1() == ACTION_SELECT_ITEM ||
message.GetParam1() == ACTION_MOUSE_LEFT_CLICK)
{
// If direct channel number input is active, select the entered channel.
if (CServiceBroker::GetPVRManager().GUIActions()->GetChannelNumberInputHandler().CheckInputAndExecuteAction())
{
bReturn = true;
break;
}
}

int iItem = m_viewControl.GetSelectedItem();
if (iItem >= 0 && iItem < m_vecItems->Size())
{
Expand Down
13 changes: 2 additions & 11 deletions xbmc/video/windows/GUIWindowFullScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "threads/SingleLock.h"
#include "utils/StringUtils.h"
#include "XBDateTime.h"
#include "input/InputManager.h"
#include "windowing/WinSystem.h"
#include "cores/IPlayer.h"
#include "guiinfo/GUIInfoLabels.h"
Expand Down Expand Up @@ -95,17 +94,9 @@ CGUIWindowFullScreen::~CGUIWindowFullScreen(void)

bool CGUIWindowFullScreen::OnAction(const CAction &action)
{
if (CServiceBroker::GetSettings().GetBool(CSettings::SETTING_PVRPLAYBACK_CONFIRMCHANNELSWITCH) &&
CServiceBroker::GetPVRManager().GUIActions()->GetChannelNavigator().IsPreview() &&
(action.GetID() == ACTION_SELECT_ITEM ||
CServiceBroker::GetInputManager().GetGlobalAction(action.GetButtonCode()).GetID() == ACTION_SELECT_ITEM))
{
// If confirm channel switch is active, channel preview is currently shown
// and the button that caused this action matches (global) action "Select" (OK)
// switch to the channel currently displayed within the preview.
CServiceBroker::GetPVRManager().GUIActions()->GetChannelNavigator().SwitchToCurrentChannel();
// Handle some actions "overloaded" by PVR (e.g. channel preview, direct channel number input).
if (CServiceBroker::GetPVRManager().GUIActions()->OnAction(action))
return true;
}

switch (action.GetID())
{
Expand Down

0 comments on commit 2ed79a4

Please sign in to comment.