[Kwintv] Patch to implement a sleep-timer TV function
Morten Brix Pedersen
kwintv@mail.kde.org
Thu, 17 Oct 2002 10:11:51 +0200
--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
* George Staikos <staikos@kde.org> [2002-10-17 05:38:20]:
> On October 16, 2002 16:57, Morten Brix Pedersen wrote:
>
> > I don't know how other people use kwintv, but I prefer to watch TV from
> > my bed with my remote control.
> >
> > I also like to fall asleep with the TV on, but I was missing the normal
> > TV sleep-function where the TV turns off after X minutes.
>
> It sounds like a great feature, but I think it should be put only in the
> MainWindow client, and no others. We dont' want it triggering in the panel
> applet or kpart in another app.
Fixed in this patch.
- Morten.
--IS0zKkzwUGydFO0o
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="kwintv_sleeptimer2.diff"
? changes.diff
? qtvision/.lirc.cpp.swp
? qtvision/.lirc.h.swp
? qtvision/.osdmanager.h.swp
? qtvision/.qtvision.cpp.swp
? qtvision/.qtvision.h.swp
? qtvision/.qtvisioniface.h.swp
? qtvision/.qtvisionviewiface.h.swp
? qtvision/.qtvisionwidget.cpp.swp
? qtvision/.qtvisionwidget.h.swp
? qtvision/clients/.mainwindow.cpp.swp
? qtvision/clients/.mainwindow.h.swp
? qtvision/clients/.q.swp
? qtvision/clients/.qtvisionactions.cpp.swp
? qtvision/clients/.qtvisionactions.h.swp
? qtvision/plugins/mixer/oss/.qtvision_oss.cpp.swp
? qtvision/teletext/Makefile
Index: qtvision/qtvision.h
===================================================================
RCS file: /home/kde/kdenonbeta/kwintv3/qtvision/qtvision.h,v
retrieving revision 1.52
diff -u -r1.52 qtvision.h
--- qtvision/qtvision.h 16 Oct 2002 05:21:01 -0000 1.52
+++ qtvision/qtvision.h 17 Oct 2002 08:14:53 -0000
@@ -100,6 +100,11 @@
ViewManager *views() const { return _viewmng; }
/**
+ * Returns the osd manager.
+ */
+ OSDManager *osd() const { return _osd; }
+
+ /**
* Returns current ChannelStore.
*/
ChannelStore *channels() { return _cs; }
@@ -351,7 +356,7 @@
bool _muted; // We have to keep track since some devices are broken
bool _quitting;
-
+
struct {
int left; // Left volume
int right; // Right volume
Index: qtvision/clients/mainwindow.cpp
===================================================================
RCS file: /home/kde/kdenonbeta/kwintv3/qtvision/clients/mainwindow.cpp,v
retrieving revision 1.48
diff -u -r1.48 mainwindow.cpp
--- qtvision/clients/mainwindow.cpp 4 Oct 2002 23:53:35 -0000 1.48
+++ qtvision/clients/mainwindow.cpp 17 Oct 2002 08:14:54 -0000
@@ -83,7 +83,8 @@
#include "mainwindow.moc"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f )
- :KMainWindow( parent, name ? name : "main_window", f ), systray(0L)
+ :KMainWindow( parent, name ? name : "main_window", f ), systray(0L),
+ _sleepdelay(0)
{
// Views
@@ -131,6 +132,11 @@
// Enable/disable actions
actions->deviceChanged( 0 );
+ _sleeptimer = new QTimer(parent);
+ connect(_sleeptimer, SIGNAL(timeout()), this, SLOT(slotSleepTimerTimeout()));
+
+ connect(this, SIGNAL(sleepTimerDelay(const QString &)), (const QObject *)screen->driver()->osd(), SLOT(displayCC(const QString &)));
+
setupInfraRed();
// Create the main window shell
@@ -232,6 +238,11 @@
actWebSite = new KAction( i18n("KWinTV Web Site..."), "html", 0,
this, SLOT( showWebSite() ),
actionCollection(), "help_view_website" );
+
+ sleepTime = new KToggleAction( i18n("Sleep Timer"), "ktv_sleeptimer", Key_T,
+ this, SLOT( sleepTimer() ), actionCollection(),
+ "sleep_timer" );
+
}
void MainWindow::setupInfraRed()
@@ -250,6 +261,7 @@
(*lircKeyMap)["MUTE"] = "volume_mute";
(*lircKeyMap)["QUIT"] = "file_quit";
(*lircKeyMap)["POWER"] = "file_quit";
+ (*lircKeyMap)["MINIMIZE"] = "sleep_timer";
//(*lircKeyMap)["FULL_SCREEN"] = "next_view_mode";
//(*lircKeyMap)["FULLSCREEN"] = "next_view_mode";
(*lircKeyMap)["FULL_SCREEN"] = "toggle_fullscreen";
@@ -502,6 +514,48 @@
void MainWindow::clearStatusBar() {
statusBar()->changeItem("", STATUSBAR_MAIN);
+}
+
+void MainWindow::slotSleepTimerTimeout()
+{
+ kdDebug() << "QtVision: sleepTimer timeout reached - quitting client." << endl;
+ QApplication::exit();
+}
+
+void MainWindow::sleepTimer()
+{
+ if (_sleeptimer->isActive())
+ _sleeptimer->stop();
+
+ kdDebug() << "sleepTimer() called.." << endl;
+
+ if (_sleepdelay == 0) {
+ // Change to 15 minutes.
+ _sleepdelay = 900000;
+
+ } else if (_sleepdelay == 900000) {
+ // Change to 30 minutes.
+ _sleepdelay = 1800000;
+
+ } else if (_sleepdelay == 1800000) {
+ // Change to 60 minutes.
+ _sleepdelay = 3600000;
+
+ } else if (_sleepdelay == 3600000) {
+ // Change to 120 minutes.
+ _sleepdelay = 7200000;
+
+ } else {
+ // Remove sleep-delay
+ _sleepdelay = 0;
+ }
+
+ if (_sleepdelay)
+ _sleeptimer->start(_sleepdelay, true); // start the count-down timer
+
+ // Display to the screen, how many minutes there are to the TV turns
+ // off.
+ emit sleepTimerDelay(QString::number(_sleepdelay / 1000 / 60));
}
Index: qtvision/clients/mainwindow.h
===================================================================
RCS file: /home/kde/kdenonbeta/kwintv3/qtvision/clients/mainwindow.h,v
retrieving revision 1.24
diff -u -r1.24 mainwindow.h
--- qtvision/clients/mainwindow.h 4 Oct 2002 02:41:00 -0000 1.24
+++ qtvision/clients/mainwindow.h 17 Oct 2002 08:14:54 -0000
@@ -23,6 +23,7 @@
#define MAINWINDOW_H
#include <kmainwindow.h>
+#include <kaction.h>
class QSplitter;
class QVBox;
@@ -68,10 +69,20 @@
void showCVSLog();
void showWebSite();
+ /**
+ * Activates/deactivates sleep timer.
+ */
+ virtual void sleepTimer();
+
signals:
/// Emits if a lirc number key was pressed
void numberKeyPressed(int);
+ /**
+ * Emitted when the "time to sleep before turning off" has been changed.
+ */
+ void sleepTimerDelay(const QString &);
+
protected slots:
void setShowTrayIcon( bool show );
void checkViewMode(int);
@@ -88,6 +99,10 @@
void saveWindowSize( KConfig * );
void restoreWindowSize( KConfig * );
+private slots:
+
+ void slotSleepTimerTimeout();
+
private:
QtVisionWidget *screen;
QtVisionActions *actions;
@@ -101,10 +116,15 @@
ToggleViewAction *actShowSidebar;
ToggleViewAction *actShowViewbar;
ToggleViewAction *actShowVolbar;
+ KToggleAction *sleepTime;
+
+ QTimer *_sleeptimer;
bool screenSaverWasEnabled;
bool dpmsWasEnabled;
bool activateVisibility;
+ int _sleepdelay;
+
};
#endif // MAINWINDOW_H
Index: qtvision/clients/qtvisionactions.h
===================================================================
RCS file: /home/kde/kdenonbeta/kwintv3/qtvision/clients/qtvisionactions.h,v
retrieving revision 1.19
diff -u -r1.19 qtvisionactions.h
--- qtvision/clients/qtvisionactions.h 29 Sep 2002 06:09:11 -0000 1.19
+++ qtvision/clients/qtvisionactions.h 17 Oct 2002 08:14:54 -0000
@@ -103,6 +103,7 @@
SliderAction *volSlider;
KToggleAction *volMute;
+ KToggleAction *sleepTime;
KAction *volUp;
KAction *volDown;
KAction *prevChannel;
--IS0zKkzwUGydFO0o--