[mythtv] [patch] sleep timer
mian
mythtv at mian.net.au
Wed Feb 18 23:51:17 EST 2004
This patch adds a simple sleep timer to the LiveTV much like those found
on TV sets. It currently supports increments of 30 minutes, upto 2 hours
though that is easily changeable at the top of tv_play.cpp. Current keys
are *,F8. All the function will do is exit LiveTV, it will not shut down
the frontend or backend boxes at this time.
--
Damian
-------------- next part --------------
--- work/mythtv/libs/libmythtv/tv_play.cpp 2004-02-19 15:15:51.528336696 +1030
+++ work-sleeptimer/mythtv/libs/libmythtv/tv_play.cpp 2004-02-19 15:13:59.475371336 +1030
@@ -47,6 +47,22 @@
{"16X", 16.72, 132.00, 84.00}
};
+struct SleepTimer {
+ QString dispString;
+ unsigned long seconds;
+};
+
+SleepTimer sleep_timer_array[] =
+{
+ {"Off", 0},
+ {"30m", 30*60},
+ {"1h", 60*60},
+ {"1h30m", 90*60},
+ {"2h", 120*60},
+};
+
+const int SSLEEP_MAX = sizeof sleep_timer_array / sizeof sleep_timer_array[0];
+
const int SSPEED_NORMAL = 3;
const int SSPEED_MAX = sizeof seek_speed_array / sizeof seek_speed_array[0];
@@ -93,6 +109,7 @@
"while paused", ",,<");
REG_KEY("TV Playback", "TOGGLEINPUTS", "Toggle Inputs", "C");
REG_KEY("TV Playback", "SWITCHCARDS", "Switch Capture Cards", "Y");
+ REG_KEY("TV Playback", "TOGGLESLEEP", "Toggle Sleep Timer", "*,F8");
REG_KEY("TV Playback", "SKIPCOMMERCIAL", "Skip Commercial", "Z,End");
REG_KEY("TV Playback", "SKIPCOMMBACK", "Skip Commercial (Reverse)",
"Q,Home");
@@ -192,6 +209,9 @@
browseTimer = new QTimer(this);
connect(browseTimer, SIGNAL(timeout()), SLOT(BrowseEndTimer()));
+
+ sleepTimer = new QTimer(this);
+ connect(sleepTimer, SIGNAL(timeout()), SLOT(SleepEndTimer()));
}
void TV::Init(bool createWindow)
@@ -813,6 +833,7 @@
doing_ff_rew = 0;
ff_rew_index = SSPEED_NORMAL;
speed_index = 0;
+ sleep_index = 0;
nvp = NULL;
osd = NULL;
@@ -869,6 +890,7 @@
doing_ff_rew = 0;
ff_rew_index = SSPEED_NORMAL;
speed_index = 0;
+ sleep_index = 0;
int updatecheck = 0;
update_osd_pos = false;
@@ -1479,6 +1501,8 @@
ToggleInputs();
else if (action == "SWITCHCARDS")
SwitchCards();
+ else if (action == "TOGGLESLEEP")
+ ToggleSleepTimer();
else if (action == "SELECT")
ChannelCommit();
else if (action == "MENU")
@@ -2758,6 +2782,32 @@
osd->SetSettingsText(text, 5);
}
+void TV::ToggleSleepTimer(void)
+{
+ QString text;
+
+ // increment sleep index, cycle through
+ if (++sleep_index == SSLEEP_MAX) sleep_index = 0;
+
+ // turn sleep timer off
+ if (sleep_timer_array[sleep_index].seconds == 0) {
+ sleepTimer->stop();
+ } else {
+ if (sleepTimer->isActive())
+ // sleep timer is active, adjust interval
+ sleepTimer->changeInterval(sleep_timer_array[sleep_index].seconds*1000);
+ else
+ // sleep timer is not active, start it
+ sleepTimer->start(sleep_timer_array[sleep_index].seconds*1000, TRUE);
+ }
+
+ text = tr("Sleep ") + sleep_timer_array[sleep_index].dispString;
+
+ // display OSD
+ if (osd && !browsemode)
+ osd->SetSettingsText(text, 3);
+}
+
void TV::ToggleLetterbox(void)
{
nvp->ToggleLetterbox();
--- work/mythtv/libs/libmythtv/tv_play.h 2004-02-19 15:15:51.536335480 +1030
+++ work-sleeptimer/mythtv/libs/libmythtv/tv_play.h 2004-02-19 13:52:32.000000000 +1030
@@ -94,6 +94,7 @@
void UnMute(void);
void KeyRepeatOK(void);
void BrowseEndTimer(void) { BrowseEnd(false); }
+ void SleepEndTimer(void) { exitPlayer = true; wantsToQuit = true; }
protected:
void doLoadMenu(void);
@@ -128,8 +129,8 @@
void ChannelCommit(void);
void ToggleInputs(void);
-
void SwitchCards(void);
+ void ToggleSleepTimer(void);
void DoInfo(void);
void DoPause(void);
@@ -217,6 +218,9 @@
int ff_rew_index;
int speed_index;
+ int sleep_index;
+ QTimer *sleepTimer;
+
OSD *osd;
bool update_osd_pos;
More information about the mythtv-dev
mailing list