summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp20
-rw-r--r--core/launcher/screensaver.cpp14
2 files changed, 17 insertions, 17 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index bc43475..f2e00d8 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -201,60 +201,60 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
201 m_screensaver-> setInterval ( -1 ); 201 m_screensaver-> setInterval ( -1 );
202 QWSServer::setScreenSaver( m_screensaver ); 202 QWSServer::setScreenSaver( m_screensaver );
203 203
204 apmTimeout ( ); 204 apmTimeout ( );
205} 205}
206 206
207 207
208DesktopApplication::~DesktopApplication() 208DesktopApplication::~DesktopApplication()
209{ 209{
210 delete m_ps; 210 delete m_ps;
211 delete m_ps_last; 211 delete m_ps_last;
212 delete pa; 212 delete pa;
213} 213}
214 214
215void DesktopApplication::apmTimeout() 215void DesktopApplication::apmTimeout()
216{ 216{
217 qpedesktop->checkMemory(); // in case no events are being generated 217 qpedesktop->checkMemory(); // in case no events are being generated
218 218
219 *m_ps_last = *m_ps; 219 *m_ps_last = *m_ps;
220 *m_ps = PowerStatusManager::readStatus(); 220 *m_ps = PowerStatusManager::readStatus();
221 221
222 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) 222 if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( ))
223 m_screensaver-> powerStatusChanged ( *m_ps ); 223 m_screensaver-> powerStatusChanged ( *m_ps );
224 224
225 int bat = m_ps-> batteryPercentRemaining ( ); 225 if ( m_ps-> acStatus ( ) != PowerStatus::Online ) {
226 226 int bat = m_ps-> batteryPercentRemaining ( );
227 if ( m_ps_last-> batteryPercentRemaining ( ) != bat ) { 227
228 if ( bat <= m_powerCritical ) 228 if ( bat < m_ps_last-> batteryPercentRemaining ( )) {
229 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); 229 if ( bat <= m_powerCritical )
230 else if ( bat <= m_powerVeryLow ) 230 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 );
231 pa->alert( tr( "Battery is running very low." ), 2 ); 231 else if ( bat <= m_powerVeryLow )
232 232 pa->alert( tr( "Battery is running very low." ), 2 );
233 233 }
234 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow ) 234 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow )
235 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); 235 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 );
236 } 236 }
237} 237}
238 238
239void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) 239void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data )
240{ 240{
241 QDataStream stream( data, IO_ReadOnly ); 241 QDataStream stream( data, IO_ReadOnly );
242 if ( msg == "keyRegister(int key, QString channel, QString message)" ) { 242 if ( msg == "keyRegister(int key, QString channel, QString message)" ) {
243 int k; 243 int k;
244 QString c, m; 244 QString c, m;
245 stream >> k; 245 stream >> k;
246 stream >> c; 246 stream >> c;
247 stream >> m; 247 stream >> m;
248 248
249 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); 249 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m );
250 keyRegisterList.append( QCopKeyRegister( k, c, m ) ); 250 keyRegisterList.append( QCopKeyRegister( k, c, m ) );
251 } 251 }
252} 252}
253 253
254 254
255void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 255void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
256{ 256{
257 QDataStream stream ( data, IO_ReadOnly ); 257 QDataStream stream ( data, IO_ReadOnly );
258 258
259 if ( msg == "setScreenSaverInterval(int)" ) { 259 if ( msg == "setScreenSaverInterval(int)" ) {
260 int time; 260 int time;
diff --git a/core/launcher/screensaver.cpp b/core/launcher/screensaver.cpp
index 741591e..45da9ed 100644
--- a/core/launcher/screensaver.cpp
+++ b/core/launcher/screensaver.cpp
@@ -94,105 +94,105 @@ bool OpieScreenSaver::save( int level )
94 m_lcd_status = false; 94 m_lcd_status = false;
95 return true; 95 return true;
96 } 96 }
97 97
98 // We're going to suspend the whole machine 98 // We're going to suspend the whole machine
99 99
100 if (( m_disable_suspend > 2 ) && !Network::networkOnline ( )) { 100 if (( m_disable_suspend > 2 ) && !Network::networkOnline ( )) {
101 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 101 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
102 return true; 102 return true;
103 } 103 }
104 104
105 break; 105 break;
106 } 106 }
107 return false; 107 return false;
108} 108}
109 109
110 110
111void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 ) 111void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 )
112{ 112{
113 Config config ( "apm" ); 113 Config config ( "apm" );
114 config. setGroup ( m_on_ac ? "AC" : "Battery" ); 114 config. setGroup ( m_on_ac ? "AC" : "Battery" );
115 115
116 int v[ 4 ]; 116 int v[ 4 ];
117 if ( i1 < 0 ) 117 if ( i1 < 0 )
118 i1 = config. readNumEntry ( "Dim", 30 ); 118 i1 = config. readNumEntry ( "Dim", m_on_ac ? 60 : 30 );
119 if ( i2 < 0 ) 119 if ( i2 < 0 )
120 i2 = config. readNumEntry ( "LightOff", 20 ); 120 i2 = config. readNumEntry ( "LightOff", m_on_ac ? 120 : 20 );
121 if ( i3 < 0 ) 121 if ( i3 < 0 )
122 i3 = config. readNumEntry ( "Suspend", 60 ); 122 i3 = config. readNumEntry ( "Suspend", m_on_ac ? 0 : 60 );
123 123
124 if ( m_on_ac ) { 124 if ( m_on_ac ) {
125 m_enable_dim_ac = ( i1 > 0 ); 125 m_enable_dim_ac = ( i1 > 0 );
126 m_enable_lightoff_ac = ( i2 > 0 ); 126 m_enable_lightoff_ac = ( i2 > 0 );
127 m_enable_suspend_ac = ( i3 > 0 ); 127 m_enable_suspend_ac = ( i3 > 0 );
128 m_onlylcdoff_ac = config.readNumEntry ( "LcdOffOnly", 0 ); 128 m_onlylcdoff_ac = config.readBoolEntry ( "LcdOffOnly", false );
129 } 129 }
130 else { 130 else {
131 m_enable_dim = ( i1 > 0 ); 131 m_enable_dim = ( i1 > 0 );
132 m_enable_lightoff = ( i2 > 0 ); 132 m_enable_lightoff = ( i2 > 0 );
133 m_enable_suspend = ( i3 > 0 ); 133 m_enable_suspend = ( i3 > 0 );
134 m_onlylcdoff = config.readNumEntry ( "LcdOffOnly", 0 ); 134 m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false );
135 } 135 }
136 136
137 qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 137 qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
138 138
139 v [ 0 ] = QMAX( 1000 * i1, 100 ); 139 v [ 0 ] = QMAX( 1000 * i1, 100 );
140 v [ 1 ] = QMAX( 1000 * i2, 100 ); 140 v [ 1 ] = QMAX( 1000 * i2, 100 );
141 v [ 2 ] = QMAX( 1000 * i3, 100 ); 141 v [ 2 ] = QMAX( 1000 * i3, 100 );
142 v [ 3 ] = 0; 142 v [ 3 ] = 0;
143 143
144 if ( !i1 && !i2 && !i3 ) 144 if ( !i1 && !i2 && !i3 )
145 QWSServer::setScreenSaverInterval( 0 ); 145 QWSServer::setScreenSaverInterval( 0 );
146 else 146 else
147 QWSServer::setScreenSaverIntervals( v ); 147 QWSServer::setScreenSaverIntervals( v );
148} 148}
149 149
150 150
151void OpieScreenSaver::setInterval ( int interval ) 151void OpieScreenSaver::setInterval ( int interval )
152{ 152{
153 setIntervals ( -1, -1, interval ); 153 setIntervals ( -1, -1, interval );
154} 154}
155 155
156 156
157void OpieScreenSaver::setMode ( int mode ) 157void OpieScreenSaver::setMode ( int mode )
158{ 158{
159 if ( mode > m_disable_suspend ) 159 if ( mode > m_disable_suspend )
160 setInterval ( -1 ); 160 setInterval ( -1 );
161 m_disable_suspend = mode; 161 m_disable_suspend = mode;
162} 162}
163 163
164 164
165void OpieScreenSaver::setBacklight ( int bright ) 165void OpieScreenSaver::setBacklight ( int bright )
166{ 166{
167 // Read from config 167 // Read from config
168 Config config ( "apm" ); 168 Config config ( "apm" );
169 config. setGroup ( m_on_ac ? "AC" : "Battery" ); 169 config. setGroup ( m_on_ac ? "AC" : "Battery" );
170 m_backlight_normal = config. readNumEntry ( "Brightness", 255 ); 170 m_backlight_normal = config. readNumEntry ( "Brightness", m_on_ac ? 255 : 127 );
171 171
172 m_use_light_sensor = config. readBoolEntry ( "LightSensor", false ); 172 m_use_light_sensor = config. readBoolEntry ( "LightSensor", false );
173 173
174 qDebug ( "setBacklight: %d (ls: %d)", m_backlight_normal, m_use_light_sensor ? 1 : 0 ); 174 //qDebug ( "setBacklight: %d (ls: %d)", m_backlight_normal, m_use_light_sensor ? 1 : 0 );
175 175
176 killTimers ( ); 176 killTimers ( );
177 if ( m_use_light_sensor ) { 177 if ( m_use_light_sensor ) {
178 QStringList sl = config. readListEntry ( "LightSensorData", ';' ); 178 QStringList sl = config. readListEntry ( "LightSensorData", ';' );
179 179
180 m_sensordata [LS_SensorMin] = 40; 180 m_sensordata [LS_SensorMin] = 40;
181 m_sensordata [LS_SensorMax] = 215; 181 m_sensordata [LS_SensorMax] = 215;
182 m_sensordata [LS_LightMin] = 1; 182 m_sensordata [LS_LightMin] = 1;
183 m_sensordata [LS_LightMax] = 255; 183 m_sensordata [LS_LightMax] = 255;
184 m_sensordata [LS_Steps] = 12; 184 m_sensordata [LS_Steps] = 12;
185 m_sensordata [LS_Interval] = 2000; 185 m_sensordata [LS_Interval] = 2000;
186 186
187 for ( uint i = 0; i < LS_Count; i++ ) { 187 for ( uint i = 0; i < LS_Count; i++ ) {
188 if ( i < sl. count ( )) 188 if ( i < sl. count ( ))
189 m_sensordata [i] = sl [i]. toInt ( ); 189 m_sensordata [i] = sl [i]. toInt ( );
190 } 190 }
191 191
192 timerEvent ( 0 ); 192 timerEvent ( 0 );
193 startTimer ( m_sensordata [LS_Interval] ); 193 startTimer ( m_sensordata [LS_Interval] );
194 } 194 }
195 195
196 setBacklightInternal ( bright ); 196 setBacklightInternal ( bright );
197} 197}
198 198