summaryrefslogtreecommitdiff
path: root/core
authorschurig <schurig>2003-06-06 08:28:34 (UTC)
committer schurig <schurig>2003-06-06 08:28:34 (UTC)
commitbd0a37d78c1ba1f38b6fef144de584eff9dc2c1c (patch) (unidiff)
treeceb4ae77cb9d0a92f8738f3cd3b9a013b21cd148 /core
parentb02b57cc34fdba0b3d9058ed263e283f0660ffb7 (diff)
downloadopie-bd0a37d78c1ba1f38b6fef144de584eff9dc2c1c.zip
opie-bd0a37d78c1ba1f38b6fef144de584eff9dc2c1c.tar.gz
opie-bd0a37d78c1ba1f38b6fef144de584eff9dc2c1c.tar.bz2
added some doc-strings in an attempt to understand this beast
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
@@ -46,6 +46,9 @@ OpieScreenSaver::OpieScreenSaver ( )
46} 46}
47 47
48 48
49/**
50 * Stops the screen saver
51 */
49void OpieScreenSaver::restore() 52void OpieScreenSaver::restore()
50{ 53{
51 m_level = -1; 54 m_level = -1;
@@ -59,6 +62,13 @@ void OpieScreenSaver::restore()
59} 62}
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{
64 m_level = level; 74 m_level = level;
@@ -98,6 +108,8 @@ bool OpieScreenSaver::save( int level )
98 // We're going to suspend the whole machine 108 // We're going to suspend the whole machine
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;
103 } 115 }
@@ -108,46 +120,65 @@ bool OpieScreenSaver::save( int level )
108} 120}
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" );
114 config. setGroup ( m_on_ac ? "AC" : "Battery" ); 139 config. setGroup ( m_on_ac ? "AC" : "Battery" );
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
147 QWSServer::setScreenSaverIntervals( v ); 172 QWSServer::setScreenSaverIntervals( v );
148} 173}
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{
153 setIntervals ( -1, -1, interval ); 184 setIntervals ( -1, -1, interval );
@@ -162,13 +193,21 @@ void OpieScreenSaver::setMode ( int mode )
162} 193}
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{
167 // Read from config 207 // Read from config
168 Config config ( "apm" ); 208 Config config ( "apm" );
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
174 //qDebug ( "setBacklight: %d (norm: %d) (ls: %d)", bright, m_backlight_normal, m_use_light_sensor ? 1 : 0 ); 213 //qDebug ( "setBacklight: %d (norm: %d) (ls: %d)", bright, m_backlight_normal, m_use_light_sensor ? 1 : 0 );
@@ -199,6 +238,15 @@ void OpieScreenSaver::setBacklight ( int bright )
199} 238}
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{
204 if ( bright == -3 ) { 252 if ( bright == -3 ) {
@@ -223,6 +271,10 @@ void OpieScreenSaver::setBacklightInternal ( int bright )
223} 271}
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{
228 int s = ODevice::inst ( )-> readLightSensor ( ) * 256 / ODevice::inst ( )-> lightSensorResolution ( ); 280 int s = ODevice::inst ( )-> readLightSensor ( ) * 256 / ODevice::inst ( )-> lightSensorResolution ( );
@@ -247,6 +299,9 @@ void OpieScreenSaver::timerEvent ( QTimerEvent * )
247} 299}
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{
252 if ( m_lcd_status != on ) { 307 if ( m_lcd_status != on ) {
@@ -256,6 +311,9 @@ void OpieScreenSaver::setDisplayState ( bool on )
256} 311}
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{
261 bool newonac = ( ps. acStatus ( ) == PowerStatus::Online ); 319 bool newonac = ( ps. acStatus ( ) == PowerStatus::Online );
@@ -267,4 +325,3 @@ void OpieScreenSaver::powerStatusChanged ( PowerStatus ps )
267 restore ( ); 325 restore ( );
268 } 326 }
269} 327}
270