mirror of
				https://github.com/vdr-projects/vdr.git
				synced 2025-03-01 10:50:46 +00:00 
			
		
		
		
	'Now', 'Next' and 'Schedule' menus remember the current channel
This commit is contained in:
		
							
								
								
									
										2
									
								
								HISTORY
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								HISTORY
									
									
									
									
									
								
							@@ -384,3 +384,5 @@ Video Disk Recorder Revision History
 | 
				
			|||||||
- The 'Ca' parameter in the default 'channels.conf' has been changed from '2'
 | 
					- The 'Ca' parameter in the default 'channels.conf' has been changed from '2'
 | 
				
			||||||
  to '3' because the VDR prototype now has 3 DVB cards (and currently the CAM
 | 
					  to '3' because the VDR prototype now has 3 DVB cards (and currently the CAM
 | 
				
			||||||
  module only works if it is inserted into the last DVB card).
 | 
					  module only works if it is inserted into the last DVB card).
 | 
				
			||||||
 | 
					- The "Now", "Next" and "Schedule" menus now remember the current channel and
 | 
				
			||||||
 | 
					  restore the list when switching between them.
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										41
									
								
								menu.c
									
									
									
									
									
								
							
							
						
						
									
										41
									
								
								menu.c
									
									
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
				
			|||||||
 * See the main source file 'vdr.c' for copyright information and
 | 
					 * See the main source file 'vdr.c' for copyright information and
 | 
				
			||||||
 * how to reach the author.
 | 
					 * how to reach the author.
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * $Id: menu.c 1.63 2001/02/04 11:48:01 kls Exp $
 | 
					 * $Id: menu.c 1.64 2001/02/10 15:34:35 kls Exp $
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "menu.h"
 | 
					#include "menu.h"
 | 
				
			||||||
@@ -1192,13 +1192,17 @@ class cMenuWhatsOn : public cOsdMenu {
 | 
				
			|||||||
private:
 | 
					private:
 | 
				
			||||||
  eOSState Record(void);
 | 
					  eOSState Record(void);
 | 
				
			||||||
  eOSState Switch(void);
 | 
					  eOSState Switch(void);
 | 
				
			||||||
 | 
					  static int currentChannel;
 | 
				
			||||||
  static const cEventInfo *scheduleEventInfo;
 | 
					  static const cEventInfo *scheduleEventInfo;
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  cMenuWhatsOn(const cSchedules *Schedules, bool Now);
 | 
					  cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr);
 | 
				
			||||||
 | 
					  static int CurrentChannel(void) { return currentChannel; }
 | 
				
			||||||
 | 
					  static void SetCurrentChannel(int ChannelNr) { currentChannel = ChannelNr; }
 | 
				
			||||||
  static const cEventInfo *ScheduleEventInfo(void);
 | 
					  static const cEventInfo *ScheduleEventInfo(void);
 | 
				
			||||||
  virtual eOSState ProcessKey(eKeys Key);
 | 
					  virtual eOSState ProcessKey(eKeys Key);
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int cMenuWhatsOn::currentChannel = 0;
 | 
				
			||||||
const cEventInfo *cMenuWhatsOn::scheduleEventInfo = NULL;
 | 
					const cEventInfo *cMenuWhatsOn::scheduleEventInfo = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int CompareEventChannel(const void *p1, const void *p2)
 | 
					static int CompareEventChannel(const void *p1, const void *p2)
 | 
				
			||||||
@@ -1206,7 +1210,7 @@ static int CompareEventChannel(const void *p1, const void *p2)
 | 
				
			|||||||
  return (int)( (*(const cEventInfo **)p1)->GetChannelNumber() - (*(const cEventInfo **)p2)->GetChannelNumber());
 | 
					  return (int)( (*(const cEventInfo **)p1)->GetChannelNumber() - (*(const cEventInfo **)p2)->GetChannelNumber());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now)
 | 
					cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now, int CurrentChannelNr)
 | 
				
			||||||
:cOsdMenu(Now ? tr("What's on now?") : tr("What's on next?"), 4, 7, 6)
 | 
					:cOsdMenu(Now ? tr("What's on now?") : tr("What's on next?"), 4, 7, 6)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const cSchedule *Schedule = Schedules->First();
 | 
					  const cSchedule *Schedule = Schedules->First();
 | 
				
			||||||
@@ -1230,8 +1234,9 @@ cMenuWhatsOn::cMenuWhatsOn(const cSchedules *Schedules, bool Now)
 | 
				
			|||||||
  qsort(pArray, num, sizeof(cEventInfo *), CompareEventChannel);
 | 
					  qsort(pArray, num, sizeof(cEventInfo *), CompareEventChannel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (int a = 0; a < num; a++)
 | 
					  for (int a = 0; a < num; a++)
 | 
				
			||||||
      Add(new cMenuWhatsOnItem(pArray[a]));
 | 
					      Add(new cMenuWhatsOnItem(pArray[a]), pArray[a]->GetChannelNumber() == CurrentChannelNr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  currentChannel = CurrentChannelNr;
 | 
				
			||||||
  delete pArray;
 | 
					  delete pArray;
 | 
				
			||||||
  SetHelp(tr("Record"), Now ? tr("Next") : tr("Now"), tr("Schedule"), tr("Switch"));
 | 
					  SetHelp(tr("Record"), Now ? tr("Next") : tr("Now"), tr("Schedule"), tr("Switch"));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -1282,12 +1287,16 @@ eOSState cMenuWhatsOn::ProcessKey(eKeys Key)
 | 
				
			|||||||
  if (state == osUnknown) {
 | 
					  if (state == osUnknown) {
 | 
				
			||||||
     switch (Key) {
 | 
					     switch (Key) {
 | 
				
			||||||
       case kRed:    return Record();
 | 
					       case kRed:    return Record();
 | 
				
			||||||
       case kYellow: {
 | 
					       case kYellow: state = osBack;
 | 
				
			||||||
 | 
					                     // continue with kGreen
 | 
				
			||||||
 | 
					       case kGreen:  {
 | 
				
			||||||
                       cMenuWhatsOnItem *mi = (cMenuWhatsOnItem *)Get(Current());
 | 
					                       cMenuWhatsOnItem *mi = (cMenuWhatsOnItem *)Get(Current());
 | 
				
			||||||
                       if (mi)
 | 
					                       if (mi) {
 | 
				
			||||||
                          scheduleEventInfo = mi->eventInfo;
 | 
					                          scheduleEventInfo = mi->eventInfo;
 | 
				
			||||||
 | 
					                          currentChannel = mi->eventInfo->GetChannelNumber();
 | 
				
			||||||
                          }
 | 
					                          }
 | 
				
			||||||
                     return osBack;
 | 
					                     }
 | 
				
			||||||
 | 
					                     break;
 | 
				
			||||||
       case kBlue:   return Switch();
 | 
					       case kBlue:   return Switch();
 | 
				
			||||||
       case kOk:     if (Count())
 | 
					       case kOk:     if (Count())
 | 
				
			||||||
                        return AddSubMenu(new cMenuEvent(((cMenuWhatsOnItem *)Get(Current()))->eventInfo, true));
 | 
					                        return AddSubMenu(new cMenuEvent(((cMenuWhatsOnItem *)Get(Current()))->eventInfo, true));
 | 
				
			||||||
@@ -1325,7 +1334,6 @@ private:
 | 
				
			|||||||
  eOSState Record(void);
 | 
					  eOSState Record(void);
 | 
				
			||||||
  eOSState Switch(void);
 | 
					  eOSState Switch(void);
 | 
				
			||||||
  void PrepareSchedule(cChannel *Channel);
 | 
					  void PrepareSchedule(cChannel *Channel);
 | 
				
			||||||
  void PrepareWhatsOnNext(bool On);
 | 
					 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  cMenuSchedule(void);
 | 
					  cMenuSchedule(void);
 | 
				
			||||||
  virtual eOSState ProcessKey(eKeys Key);
 | 
					  virtual eOSState ProcessKey(eKeys Key);
 | 
				
			||||||
@@ -1338,6 +1346,7 @@ cMenuSchedule::cMenuSchedule(void)
 | 
				
			|||||||
  otherChannel = 0;
 | 
					  otherChannel = 0;
 | 
				
			||||||
  cChannel *channel = Channels.GetByNumber(cDvbApi::CurrentChannel());
 | 
					  cChannel *channel = Channels.GetByNumber(cDvbApi::CurrentChannel());
 | 
				
			||||||
  if (channel) {
 | 
					  if (channel) {
 | 
				
			||||||
 | 
					     cMenuWhatsOn::SetCurrentChannel(channel->number);
 | 
				
			||||||
     schedules = cDvbApi::PrimaryDvbApi->Schedules(&threadLock);
 | 
					     schedules = cDvbApi::PrimaryDvbApi->Schedules(&threadLock);
 | 
				
			||||||
     PrepareSchedule(channel);
 | 
					     PrepareSchedule(channel);
 | 
				
			||||||
     SetHelp(tr("Record"), tr("Now"), tr("Next"));
 | 
					     SetHelp(tr("Record"), tr("Now"), tr("Next"));
 | 
				
			||||||
@@ -1414,14 +1423,22 @@ eOSState cMenuSchedule::ProcessKey(eKeys Key)
 | 
				
			|||||||
  if (state == osUnknown) {
 | 
					  if (state == osUnknown) {
 | 
				
			||||||
     switch (Key) {
 | 
					     switch (Key) {
 | 
				
			||||||
       case kRed:    return Record();
 | 
					       case kRed:    return Record();
 | 
				
			||||||
       case kGreen:  if (!now && !next) {
 | 
					       case kGreen:  {
 | 
				
			||||||
 | 
					                       if (!now && !next) {
 | 
				
			||||||
 | 
					                          int ChannelNr = 0;
 | 
				
			||||||
 | 
					                          if (Count()) {
 | 
				
			||||||
 | 
					                             cChannel *channel = Channels.GetByServiceID(((cMenuScheduleItem *)Get(Current()))->eventInfo->GetServiceID());
 | 
				
			||||||
 | 
					                             if (channel)
 | 
				
			||||||
 | 
					                                ChannelNr = channel->number;
 | 
				
			||||||
 | 
					                             }
 | 
				
			||||||
                          now = true;
 | 
					                          now = true;
 | 
				
			||||||
                        return AddSubMenu(new cMenuWhatsOn(schedules, true));
 | 
					                          return AddSubMenu(new cMenuWhatsOn(schedules, true, ChannelNr));
 | 
				
			||||||
                          }
 | 
					                          }
 | 
				
			||||||
                       now = !now;
 | 
					                       now = !now;
 | 
				
			||||||
                       next = !next;
 | 
					                       next = !next;
 | 
				
			||||||
                     return AddSubMenu(new cMenuWhatsOn(schedules, now));
 | 
					                       return AddSubMenu(new cMenuWhatsOn(schedules, now, cMenuWhatsOn::CurrentChannel()));
 | 
				
			||||||
       case kYellow: return AddSubMenu(new cMenuWhatsOn(schedules, false));
 | 
					                     }
 | 
				
			||||||
 | 
					       case kYellow: return AddSubMenu(new cMenuWhatsOn(schedules, false, cMenuWhatsOn::CurrentChannel()));
 | 
				
			||||||
       case kBlue:   return Switch();
 | 
					       case kBlue:   return Switch();
 | 
				
			||||||
       case kOk:     if (Count())
 | 
					       case kOk:     if (Count())
 | 
				
			||||||
                        return AddSubMenu(new cMenuEvent(((cMenuScheduleItem *)Get(Current()))->eventInfo, otherChannel));
 | 
					                        return AddSubMenu(new cMenuEvent(((cMenuScheduleItem *)Get(Current()))->eventInfo, otherChannel));
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user