summaryrefslogtreecommitdiff
path: root/core
Unidiff
Diffstat (limited to 'core') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/screensaver.cpp97
1 files changed, 77 insertions, 20 deletions
diff --git a/core/launcher/screensaver.cpp b/core/launcher/screensaver.cpp
index b9bb64c..182084d 100644
--- a/core/launcher/screensaver.cpp
+++ b/core/launcher/screensaver.cpp
@@ -48,2 +48,5 @@ OpieScreenSaver::OpieScreenSaver ( )
48 48
49/**
50 * Stops the screen saver
51 */
49void OpieScreenSaver::restore() 52void OpieScreenSaver::restore()
@@ -61,2 +64,9 @@ void OpieScreenSaver::restore()
61 64
65/**
66 * Starts the screen saver
67 *
68 * @param level what level of screen saving should happen (0=lowest non-off, 1=off,
69 * 2=suspend whole machine)
70 * @returns true on success
71 */
62bool OpieScreenSaver::save( int level ) 72bool OpieScreenSaver::save( int level )
@@ -100,2 +110,4 @@ bool OpieScreenSaver::save( int level )
100 if (( m_disable_suspend > 2 ) && !Network::networkOnline ( )) { 110 if (( m_disable_suspend > 2 ) && !Network::networkOnline ( )) {
111 // TODO: why is this key F34 hard coded? -- schurig
112 // Does this now only work an devices with a ODevice::filter?
101 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 113 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
@@ -110,3 +122,16 @@ bool OpieScreenSaver::save( int level )
110 122
111void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 ) 123/**
124 * Set intervals in seconds for automatic dimming, light off and suspend
125 *
126 * This function also sets the member variables m_m_enable_dim[_ac],
127 * m_enable_lightoff[_ac], m_enable_suspend[_ac], m_onlylcdoff[_ac]
128 *
129 * @param dim time in seconds to dim, -1 to read value from config file,
130 * 0 to disable
131 * @param lightoff time in seconds to turn LCD backlight off, -1 to
132 * read value from config file, 0 to disable
133 * @param suspend time in seconds to do an APM suspend, -1 to
134 * read value from config file, 0 to disable
135 */
136void OpieScreenSaver::setIntervals ( int dim, int lightoff, int suspend )
112{ 137{
@@ -116,13 +141,13 @@ void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 )
116 int v[ 4 ]; 141 int v[ 4 ];
117 if ( i1 < 0 ) 142 if ( dim < 0 )
118 i1 = config. readNumEntry ( "Dim", m_on_ac ? 60 : 30 ); 143 dim = config. readNumEntry ( "Dim", m_on_ac ? 60 : 30 );
119 if ( i2 < 0 ) 144 if ( lightoff < 0 )
120 i2 = config. readNumEntry ( "LightOff", m_on_ac ? 120 : 20 ); 145 lightoff = config. readNumEntry ( "LightOff", m_on_ac ? 120 : 20 );
121 if ( i3 < 0 ) 146 if ( suspend < 0 )
122 i3 = config. readNumEntry ( "Suspend", m_on_ac ? 0 : 60 ); 147 suspend = config. readNumEntry ( "Suspend", m_on_ac ? 0 : 60 );
123 148
124 if ( m_on_ac ) { 149 if ( m_on_ac ) {
125 m_enable_dim_ac = ( i1 > 0 ); 150 m_enable_dim_ac = ( dim > 0 );
126 m_enable_lightoff_ac = ( i2 > 0 ); 151 m_enable_lightoff_ac = ( lightoff > 0 );
127 m_enable_suspend_ac = ( i3 > 0 ); 152 m_enable_suspend_ac = ( suspend > 0 );
128 m_onlylcdoff_ac = config.readBoolEntry ( "LcdOffOnly", false ); 153 m_onlylcdoff_ac = config.readBoolEntry ( "LcdOffOnly", false );
@@ -130,5 +155,5 @@ void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 )
130 else { 155 else {
131 m_enable_dim = ( i1 > 0 ); 156 m_enable_dim = ( dim > 0 );
132 m_enable_lightoff = ( i2 > 0 ); 157 m_enable_lightoff = ( lightoff > 0 );
133 m_enable_suspend = ( i3 > 0 ); 158 m_enable_suspend = ( suspend > 0 );
134 m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false ); 159 m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false );
@@ -136,10 +161,10 @@ void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 )
136 161
137 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 162 //qDebug("screen saver intervals: %d %d %d", dim, lightoff, suspend);
138 163
139 v [ 0 ] = QMAX( 1000 * i1, 100 ); 164 v [ 0 ] = QMAX( 1000 * dim, 100 );
140 v [ 1 ] = QMAX( 1000 * i2, 100 ); 165 v [ 1 ] = QMAX( 1000 * lightoff, 100 );
141 v [ 2 ] = QMAX( 1000 * i3, 100 ); 166 v [ 2 ] = QMAX( 1000 * suspend, 100 );
142 v [ 3 ] = 0; 167 v [ 3 ] = 0;
143 168
144 if ( !i1 && !i2 && !i3 ) 169 if ( !dim && !lightoff && !suspend )
145 QWSServer::setScreenSaverInterval( 0 ); 170 QWSServer::setScreenSaverInterval( 0 );
@@ -150,2 +175,8 @@ void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 )
150 175
176/**
177 * Set suspend time. Will read the dim and lcd-off times from the config file.
178 *
179 * @param suspend time in seconds to go into APM suspend, -1 to
180 * read value from config file, 0 to disable
181 */
151void OpieScreenSaver::setInterval ( int interval ) 182void OpieScreenSaver::setInterval ( int interval )
@@ -164,2 +195,11 @@ void OpieScreenSaver::setMode ( int mode )
164 195
196/**
197 * Set display brightness
198 *
199 * Get's default values for backlight and light sensor from config file.
200 *
201 * @param bright desired brighness (-1 to use automatic sensor data or value
202 * from config file, -2 to toggle backlight on and off, -3 to
203 * force backlight off)
204 */
165void OpieScreenSaver::setBacklight ( int bright ) 205void OpieScreenSaver::setBacklight ( int bright )
@@ -170,3 +210,2 @@ void OpieScreenSaver::setBacklight ( int bright )
170 m_backlight_normal = config. readNumEntry ( "Brightness", m_on_ac ? 255 : 127 ); 210 m_backlight_normal = config. readNumEntry ( "Brightness", m_on_ac ? 255 : 127 );
171
172 m_use_light_sensor = config. readBoolEntry ( "LightSensor", false ); 211 m_use_light_sensor = config. readBoolEntry ( "LightSensor", false );
@@ -201,2 +240,11 @@ void OpieScreenSaver::setBacklight ( int bright )
201 240
241/**
242 * Internal brightness setting method
243 *
244 * Get's default values for backlight and light sensor from config file.
245 *
246 * @param bright desired brighness (-1 to use automatic sensor data or value
247 * from config file, -2 to toggle backlight on and off, -3 to
248 * force backlight off)
249 */
202void OpieScreenSaver::setBacklightInternal ( int bright ) 250void OpieScreenSaver::setBacklightInternal ( int bright )
@@ -225,2 +273,6 @@ void OpieScreenSaver::setBacklightInternal ( int bright )
225 273
274/**
275 * Timer event used for automatic setting the backlight according to a light sensor
276 * and to set the default brightness
277 */
226void OpieScreenSaver::timerEvent ( QTimerEvent * ) 278void OpieScreenSaver::timerEvent ( QTimerEvent * )
@@ -249,2 +301,5 @@ void OpieScreenSaver::timerEvent ( QTimerEvent * )
249 301
302/**
303 * Like ODevice::setDisplayStatus(), but keep current state in m_lcd_status.
304 */
250void OpieScreenSaver::setDisplayState ( bool on ) 305void OpieScreenSaver::setDisplayState ( bool on )
@@ -258,2 +313,5 @@ void OpieScreenSaver::setDisplayState ( bool on )
258 313
314/**
315 * Set display to default ac/battery settings when power status changed.
316 */
259void OpieScreenSaver::powerStatusChanged ( PowerStatus ps ) 317void OpieScreenSaver::powerStatusChanged ( PowerStatus ps )
@@ -269,2 +327 @@ void OpieScreenSaver::powerStatusChanged ( PowerStatus ps )
269} }
270