summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -47,4 +47,7 @@ OpieScreenSaver::OpieScreenSaver ( )
47 47
48 48
49/**
50 * Stops the screen saver
51 */
49void OpieScreenSaver::restore() 52void OpieScreenSaver::restore()
50{ 53{
@@ -60,4 +63,11 @@ void OpieScreenSaver::restore()
60 63
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 )
63{ 73{
@@ -99,4 +109,6 @@ bool OpieScreenSaver::save( int level )
99 109
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 );
102 return true; 114 return true;
@@ -109,5 +121,18 @@ bool OpieScreenSaver::save( int level )
109 121
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{
113 Config config ( "apm" ); 138 Config config ( "apm" );
@@ -115,32 +140,32 @@ void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 )
115 140
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 );
129 } 154 }
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 );
135 } 160 }
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 );
146 else 171 else
@@ -149,4 +174,10 @@ void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 )
149 174
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 )
152{ 183{
@@ -163,4 +194,13 @@ void OpieScreenSaver::setMode ( int mode )
163 194
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 )
166{ 206{
@@ -169,5 +209,4 @@ void OpieScreenSaver::setBacklight ( int bright )
169 config. setGroup ( m_on_ac ? "AC" : "Battery" ); 209 config. setGroup ( m_on_ac ? "AC" : "Battery" );
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 );
173 212
@@ -200,4 +239,13 @@ void OpieScreenSaver::setBacklight ( int bright )
200 239
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 )
203{ 251{
@@ -224,4 +272,8 @@ void OpieScreenSaver::setBacklightInternal ( int bright )
224 272
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 * )
227{ 279{
@@ -248,4 +300,7 @@ void OpieScreenSaver::timerEvent ( QTimerEvent * )
248 300
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 )
251{ 306{
@@ -257,4 +312,7 @@ void OpieScreenSaver::setDisplayState ( bool on )
257 312
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 )
260{ 318{
@@ -268,3 +326,2 @@ void OpieScreenSaver::powerStatusChanged ( PowerStatus ps )
268 } 326 }
269} 327}
270