Permalink
Browse files

Merge pull request #4646 from xhaggi/channel-selection

[pvr] numeric input to select a channel within pvr views
  • Loading branch information...
2 parents 1a2cf73 + d26a659 commit 619880f5ce65c10b7c40ea872c4fd07b090a7b5d @xhaggi xhaggi committed May 7, 2014
@@ -7726,7 +7726,11 @@ msgctxt "#19102"
msgid "Please switch to another channel."
msgstr ""
-#empty string with id 19103
+#. Title of numeric dialog for choosing a channel by entering a number
+#: xbmc/pvr/windows/GUIWindowPVRCommon.cpp
+msgctxt "#19103"
+msgid "Go to channel"
+msgstr ""
msgctxt "#19104"
msgid "Enter the name of the folder for the recording"
@@ -1069,8 +1069,7 @@ void CGUIEPGGridContainer::SetChannel(const CStdString &channel)
}
}
- if (iChannelIndex >= 0)
- ScrollToChannelOffset(iChannelIndex);
+ SetSelectedChannel(iChannelIndex);
}
void CGUIEPGGridContainer::SetChannel(const CPVRChannel &channel)
@@ -1086,8 +1085,7 @@ void CGUIEPGGridContainer::SetChannel(const CPVRChannel &channel)
}
}
- if (iChannelIndex >= 0)
- ScrollToChannelOffset(iChannelIndex);
+ SetSelectedChannel(iChannelIndex);
}
void CGUIEPGGridContainer::SetChannel(int channel)
@@ -1266,6 +1264,27 @@ bool CGUIEPGGridContainer::OnMouseWheel(char wheel, const CPoint &point)
return true;
}
+void CGUIEPGGridContainer::SetSelectedChannel(int channelIndex)
+{
+ if (channelIndex < 0)
+ return;
+
+ if (channelIndex - m_channelOffset < m_channelsPerPage && channelIndex - m_channelOffset >= 0)
+ {
+ SetChannel(channelIndex - m_channelOffset);
+ }
+ else if(channelIndex < m_channels - m_channelsPerPage)
+ {
+ ScrollToChannelOffset(channelIndex - m_channelsPerPage + 1);
+ SetChannel(m_channelsPerPage - 1);
+ }
+ else
+ {
+ ScrollToChannelOffset(m_channels - m_channelsPerPage);
+ SetChannel(channelIndex - (m_channels - m_channelsPerPage));
+ }
+}
+
int CGUIEPGGridContainer::GetSelectedItem() const
{
if (m_gridIndex.empty() ||
@@ -65,6 +65,7 @@ namespace EPG
const int GetNumChannels() { return m_channels; };
virtual int GetSelectedItem() const;
const int GetSelectedChannel() { return m_channelCursor + m_channelOffset; }
+ void SetSelectedChannel(int channelIndex);
virtual EVENT_RESULT OnMouseEvent(const CPoint &point, const CMouseEvent &event);
virtual void Process(unsigned int currentTime, CDirtyRegionList &dirtyregions);
@@ -264,6 +264,26 @@ void CGUIWindowPVRChannels::UpdateData(bool bUpdateSelectedFile /* = true */)
m_parent->SetLabel(CONTROL_LABELGROUP, currentGroup->GroupName());
}
+bool CGUIWindowPVRChannels::OnAction(const CAction &action)
+{
+ switch (action.GetID())
+ {
+ case REMOTE_0:
+ case REMOTE_1:
+ case REMOTE_2:
+ case REMOTE_3:
+ case REMOTE_4:
+ case REMOTE_5:
+ case REMOTE_6:
+ case REMOTE_7:
+ case REMOTE_8:
+ case REMOTE_9:
+ return ActionInputChannelNumber(action.GetID() - REMOTE_0);
+ }
+
+ return false;
+}
+
bool CGUIWindowPVRChannels::OnClickButton(CGUIMessage &message)
{
bool bReturn = false;
@@ -45,6 +45,7 @@ namespace PVR
void Notify(const Observable &obs, const ObservableMessage msg);
void ResetObservers(void);
void UnregisterObservers(void);
+ bool OnAction(const CAction &action);
private:
bool OnClickButton(CGUIMessage &message);
@@ -22,6 +22,7 @@
#include "Application.h"
#include "ApplicationMessenger.h"
+#include "dialogs/GUIDialogNumeric.h"
#include "dialogs/GUIDialogKaiToast.h"
#include "dialogs/GUIDialogOK.h"
#include "dialogs/GUIDialogYesNo.h"
@@ -566,6 +567,36 @@ bool CGUIWindowPVRCommon::ActionDeleteChannel(CFileItem *item)
return true;
}
+bool CGUIWindowPVRCommon::ActionInputChannelNumber(int input, bool bGuideGrid)
+{
+ CStdString strInput = StringUtils::Format("%i", input);
+ if (CGUIDialogNumeric::ShowAndGetNumber(strInput, g_localizeStrings.Get(19103)))
+ {
+ int iChannelNumber = atoi(strInput.c_str());
+ if (iChannelNumber > 0)
+ {
+ int itemIndex = 0;
+ VECFILEITEMS items = m_parent->m_vecItems->GetList();
+ for(VECFILEITEMS::iterator it = items.begin(); it != items.end(); ++it)
+ {
+ if(((*it)->HasPVRChannelInfoTag() && (*it)->GetPVRChannelInfoTag()->ChannelNumber() == iChannelNumber) ||
+ ((*it)->HasEPGInfoTag() && (*it)->GetEPGInfoTag()->HasPVRChannel() && (*it)->GetEPGInfoTag()->PVRChannelNumber() == iChannelNumber))
+ {
+ // different handling for guide grid
+ if (bGuideGrid && m_parent->m_guideGrid)
+ m_parent->m_guideGrid->SetChannel((*(*it)->GetEPGInfoTag()->ChannelTag()));
+ else
+ m_parent->m_viewControl.SetSelectedItem(itemIndex);
+ return true;
+ }
+ itemIndex++;
+ }
+ }
+ }
+
+ return false;
+}
+
bool CGUIWindowPVRCommon::UpdateEpgForChannel(CFileItem *item)
{
CPVRChannel *channel = item->GetPVRChannelInfoTag();
@@ -602,7 +633,6 @@ bool CGUIWindowPVRCommon::ShowTimerSettings(CFileItem *item)
return pDlgInfo->GetOK();
}
-
bool CGUIWindowPVRCommon::PlayRecording(CFileItem *item, bool bPlayMinimized /* = false */)
{
if (!item->HasPVRRecordingInfoTag())
@@ -117,6 +117,7 @@ namespace PVR
virtual bool ActionPlayChannel(CFileItem *item);
virtual bool ActionPlayEpg(CFileItem *item);
virtual bool ActionDeleteChannel(CFileItem *item);
+ virtual bool ActionInputChannelNumber(int input, bool bGuideGrid = false);
virtual bool PlayRecording(CFileItem *item, bool bPlayMinimized = false);
virtual bool PlayFile(CFileItem *item, bool bPlayMinimized = false);
@@ -120,6 +120,27 @@ void CGUIWindowPVRGuide::GetContextButtons(int itemNumber, CContextButtons &butt
buttons.Add(CONTEXT_BUTTON_MENU_HOOKS, 19195); /* PVR client specific action */
}
+bool CGUIWindowPVRGuide::OnAction(const CAction &action)
+{
+ switch (action.GetID())
+ {
+ case REMOTE_0:
+ case REMOTE_1:
+ case REMOTE_2:
+ case REMOTE_3:
+ case REMOTE_4:
+ case REMOTE_5:
+ case REMOTE_6:
+ case REMOTE_7:
+ case REMOTE_8:
+ case REMOTE_9:
+ if (m_iGuideView != GUIDE_VIEW_CHANNEL)
+ return ActionInputChannelNumber(action.GetID() - REMOTE_0, (m_iGuideView == GUIDE_VIEW_TIMELINE));
+ break;
+ }
+
+ return false;
+}
bool CGUIWindowPVRGuide::OnContextButton(int itemNumber, CONTEXT_BUTTON button)
{
@@ -48,6 +48,7 @@ namespace PVR
CGUIWindowPVRGuide(CGUIWindowPVR *parent);
virtual ~CGUIWindowPVRGuide(void);
+ bool OnAction(const CAction &action);
void GetContextButtons(int itemNumber, CContextButtons &buttons) const;
bool OnContextButton(int itemNumber, CONTEXT_BUTTON button);
void UpdateData(bool bUpdateSelectedFile = true);

0 comments on commit 619880f

Please sign in to comment.