-rw-r--r-- | core/launcher/desktop.cpp | 345 | ||||
-rw-r--r-- | core/launcher/desktop.h | 7 | ||||
-rw-r--r-- | core/launcher/launcher.pro | 2 | ||||
-rw-r--r-- | core/launcher/screensaver.cpp | 237 | ||||
-rw-r--r-- | core/launcher/screensaver.h | 61 |
5 files changed, 354 insertions, 298 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 2ea6d27..bc43475 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,78 +1,79 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "desktop.h" | 21 | #include "desktop.h" |
22 | #include "info.h" | 22 | #include "info.h" |
23 | #include "launcher.h" | 23 | #include "launcher.h" |
24 | #include "qcopbridge.h" | 24 | #include "qcopbridge.h" |
25 | #include "shutdownimpl.h" | 25 | #include "shutdownimpl.h" |
26 | #include "startmenu.h" | 26 | #include "startmenu.h" |
27 | #include "taskbar.h" | 27 | #include "taskbar.h" |
28 | #include "transferserver.h" | 28 | #include "transferserver.h" |
29 | #include "irserver.h" | 29 | #include "irserver.h" |
30 | #include "packageslave.h" | 30 | #include "packageslave.h" |
31 | #include "screensaver.h" | ||
31 | 32 | ||
32 | #include <qpe/applnk.h> | 33 | #include <qpe/applnk.h> |
33 | #include <qpe/mimetype.h> | 34 | #include <qpe/mimetype.h> |
34 | #include <qpe/password.h> | 35 | #include <qpe/password.h> |
35 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
36 | #include <qpe/power.h> | 37 | #include <qpe/power.h> |
37 | #include <qpe/timeconversion.h> | 38 | #include <qpe/timeconversion.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
39 | #include <qpe/network.h> | 40 | #include <qpe/network.h> |
40 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
41 | 42 | ||
42 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 43 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
43 | #include <qpe/custom.h> | 44 | #include <qpe/custom.h> |
44 | #endif | 45 | #endif |
45 | 46 | ||
46 | #include <opie/odevice.h> | 47 | #include <opie/odevice.h> |
47 | 48 | ||
48 | #include <qgfx_qws.h> | 49 | #include <qgfx_qws.h> |
49 | #include <qmainwindow.h> | 50 | #include <qmainwindow.h> |
50 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
51 | #include <qtimer.h> | 52 | #include <qtimer.h> |
52 | #include <qwindowsystem_qws.h> | 53 | #include <qwindowsystem_qws.h> |
53 | 54 | ||
54 | #include <qvaluelist.h> | 55 | #include <qvaluelist.h> |
55 | 56 | ||
56 | #include <stdlib.h> | 57 | #include <stdlib.h> |
57 | #include <unistd.h> | 58 | #include <unistd.h> |
58 | #include <fcntl.h> | 59 | #include <fcntl.h> |
59 | 60 | ||
60 | using namespace Opie; | 61 | using namespace Opie; |
61 | 62 | ||
62 | class QCopKeyRegister | 63 | class QCopKeyRegister |
63 | { | 64 | { |
64 | public: | 65 | public: |
65 | QCopKeyRegister() : keyCode( 0 ) | 66 | QCopKeyRegister() : keyCode( 0 ) |
66 | { } | 67 | { } |
67 | QCopKeyRegister( int k, const QString &c, const QString &m ) | 68 | QCopKeyRegister( int k, const QString &c, const QString &m ) |
68 | : keyCode( k ), channel( c ), message( m ) | 69 | : keyCode( k ), channel( c ), message( m ) |
69 | { } | 70 | { } |
70 | 71 | ||
71 | int getKeyCode() const | 72 | int getKeyCode() const |
72 | { | 73 | { |
73 | return keyCode; | 74 | return keyCode; |
74 | } | 75 | } |
75 | QString getChannel() const | 76 | QString getChannel() const |
76 | { | 77 | { |
77 | return channel; | 78 | return channel; |
78 | } | 79 | } |
@@ -106,421 +107,210 @@ bool Desktop::screenLocked() | |||
106 | return loggedin == 0; | 107 | return loggedin == 0; |
107 | } | 108 | } |
108 | 109 | ||
109 | /* | 110 | /* |
110 | Priority is number of alerts that are needed to pop up | 111 | Priority is number of alerts that are needed to pop up |
111 | alert. | 112 | alert. |
112 | */ | 113 | */ |
113 | class DesktopPowerAlerter : public QMessageBox | 114 | class DesktopPowerAlerter : public QMessageBox |
114 | { | 115 | { |
115 | public: | 116 | public: |
116 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 117 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
117 | : QMessageBox( tr( "Battery Status" ), "Low Battery", | 118 | : QMessageBox( tr( "Battery Status" ), "Low Battery", |
118 | QMessageBox::Critical, | 119 | QMessageBox::Critical, |
119 | QMessageBox::Ok | QMessageBox::Default, | 120 | QMessageBox::Ok | QMessageBox::Default, |
120 | QMessageBox::NoButton, QMessageBox::NoButton, | 121 | QMessageBox::NoButton, QMessageBox::NoButton, |
121 | parent, name, FALSE ) | 122 | parent, name, FALSE ) |
122 | { | 123 | { |
123 | currentPriority = INT_MAX; | 124 | currentPriority = INT_MAX; |
124 | alertCount = 0; | 125 | alertCount = 0; |
125 | } | 126 | } |
126 | 127 | ||
127 | void alert( const QString &text, int priority ); | 128 | void alert( const QString &text, int priority ); |
128 | void hideEvent( QHideEvent * ); | 129 | void hideEvent( QHideEvent * ); |
129 | private: | 130 | private: |
130 | int currentPriority; | 131 | int currentPriority; |
131 | int alertCount; | 132 | int alertCount; |
132 | }; | 133 | }; |
133 | 134 | ||
134 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 135 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
135 | { | 136 | { |
136 | alertCount++; | 137 | alertCount++; |
137 | if ( alertCount < priority ) | 138 | if ( alertCount < priority ) |
138 | return ; | 139 | return ; |
139 | if ( priority > currentPriority ) | 140 | if ( priority > currentPriority ) |
140 | return ; | 141 | return ; |
141 | currentPriority = priority; | 142 | currentPriority = priority; |
142 | setText( text ); | 143 | setText( text ); |
143 | show(); | 144 | show(); |
144 | } | 145 | } |
145 | 146 | ||
146 | 147 | ||
147 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 148 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
148 | { | 149 | { |
149 | QMessageBox::hideEvent( e ); | 150 | QMessageBox::hideEvent( e ); |
150 | alertCount = 0; | 151 | alertCount = 0; |
151 | currentPriority = INT_MAX; | 152 | currentPriority = INT_MAX; |
152 | } | 153 | } |
153 | 154 | ||
154 | class QPEScreenSaver : public QWSScreenSaver | ||
155 | { | ||
156 | private: | ||
157 | int LcdOn; | ||
158 | |||
159 | public: | ||
160 | QPEScreenSaver() | ||
161 | { | ||
162 | m_disable_suspend = 100; | ||
163 | m_enable_dim = false; | ||
164 | m_enable_lightoff = false; | ||
165 | m_enable_onlylcdoff = false; | ||
166 | |||
167 | m_disable_suspend_ac = 100; | ||
168 | m_enable_dim_ac = false; | ||
169 | m_enable_lightoff_ac = false; | ||
170 | m_enable_onlylcdoff_ac = false; | ||
171 | m_disable_apm_ac = false; | ||
172 | |||
173 | m_lcd_status = true; | ||
174 | |||
175 | m_backlight_normal = -1; | ||
176 | m_backlight_current = -1; | ||
177 | m_backlight_forcedoff = false; | ||
178 | |||
179 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | ||
180 | ODevice::inst ( )-> setDisplayStatus ( true ); | ||
181 | setBacklight ( -1 ); | ||
182 | } | ||
183 | void restore() | ||
184 | { | ||
185 | if ( !m_lcd_status ) { // We must have turned it off | ||
186 | ODevice::inst ( ) -> setDisplayStatus ( true ); | ||
187 | m_lcd_status = true; | ||
188 | } | ||
189 | |||
190 | setBacklightInternal ( -1 ); | ||
191 | } | ||
192 | bool save( int level ) | ||
193 | { | ||
194 | bool onAC = ( PowerStatusManager::readStatus().acStatus() == PowerStatus::Online ); | ||
195 | |||
196 | switch ( level ) { | ||
197 | case 0: | ||
198 | |||
199 | if ( m_disable_suspend_ac > 0 && m_enable_dim_ac && onAC ) { | ||
200 | if ( m_backlight_current > 1 ) | ||
201 | setBacklight( 1 ); // lowest non-off | ||
202 | } else if ( !onAC && m_disable_suspend > 0 && m_enable_dim ) { | ||
203 | if ( m_backlight_current > 1 ) | ||
204 | setBacklightInternal( 1 ); // lowest non-off | ||
205 | } | ||
206 | return true; | ||
207 | break; | ||
208 | case 1: | ||
209 | |||
210 | if ( m_disable_suspend_ac > 1 && m_enable_lightoff_ac && onAC ) { | ||
211 | setBacklightInternal( 0 ); // off | ||
212 | } else if ( !onAC && m_disable_suspend > 1 && m_enable_lightoff ) { | ||
213 | setBacklightInternal( 0 ); // off | ||
214 | } | ||
215 | return true; | ||
216 | break; | ||
217 | case 2: | ||
218 | if ( m_disable_apm_ac && onAC ) { | ||
219 | return true; | ||
220 | } | ||
221 | |||
222 | if ( m_enable_onlylcdoff_ac && onAC ) { | ||
223 | ODevice::inst ( ) -> setDisplayStatus ( false ); | ||
224 | m_lcd_status = false; | ||
225 | return true; | ||
226 | } | ||
227 | else if ( !onAC && m_enable_onlylcdoff ) { | ||
228 | ODevice::inst ( ) -> setDisplayStatus ( false ); | ||
229 | m_lcd_status = false; | ||
230 | return true; | ||
231 | } | ||
232 | else // We're going to suspend the whole machine | ||
233 | { | ||
234 | if ( ( m_disable_suspend_ac > 2 && onAC ) && ( !Network::networkOnline ( ) ) ) { | ||
235 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | ||
236 | return true; | ||
237 | } | ||
238 | if ( !onAC && ( m_disable_suspend > 2 ) && ( !Network::networkOnline ( ) ) ) { | ||
239 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | ||
240 | return true; | ||
241 | } | ||
242 | } | ||
243 | break; | ||
244 | } | ||
245 | return false; | ||
246 | } | ||
247 | |||
248 | private: | ||
249 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) | ||
250 | { | ||
251 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) | ||
252 | return 0; | ||
253 | |||
254 | if ( interval < 0 ) { | ||
255 | // Restore screen blanking and power saving state | ||
256 | interval = config.readNumEntry( value, def ); | ||
257 | } | ||
258 | return interval; | ||
259 | } | ||
260 | |||
261 | public: | ||
262 | void setIntervals( int i1, int i2, int i3 ) | ||
263 | { | ||
264 | Config config( "qpe" ); | ||
265 | config.setGroup( "Screensaver" ); | ||
266 | |||
267 | int v[ 4 ]; | ||
268 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); | ||
269 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); | ||
270 | i3 = ssi( i3, config, "", "Interval", 60 ); | ||
271 | |||
272 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | ||
273 | |||
274 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | ||
275 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | ||
276 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | ||
277 | v [ 3 ] = 0; | ||
278 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); | ||
279 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); | ||
280 | m_enable_onlylcdoff = config.readNumEntry ( "LcdOffOnly", 0 ); | ||
281 | |||
282 | if ( !i1 && !i2 && !i3 ) | ||
283 | QWSServer::setScreenSaverInterval( 0 ); | ||
284 | else | ||
285 | QWSServer::setScreenSaverIntervals( v ); | ||
286 | } | ||
287 | |||
288 | void setIntervalsAC( int i1, int i2, int i3 ) | ||
289 | { | ||
290 | Config config( "qpe" ); | ||
291 | config.setGroup( "Screensaver" ); | ||
292 | |||
293 | int v[ 4 ]; | ||
294 | i1 = ssi( i1, config, "DimAC", "Interval_DimAC", 30 ); | ||
295 | i2 = ssi( i2, config, "LightOffAC", "Interval_LightOffAC", 20 ); | ||
296 | i3 = ssi( i3, config, "", "IntervalAC", 60 ); | ||
297 | |||
298 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | ||
299 | |||
300 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | ||
301 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | ||
302 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | ||
303 | v [ 3 ] = 0; | ||
304 | m_enable_dim_ac = ( ( i1 != 0 ) ? config.readNumEntry ( "DimAC", 1 ) : false ); | ||
305 | m_enable_lightoff_ac = ( ( i2 != 0 ) ? config.readNumEntry ( "LightOffAC", 1 ) : false ); | ||
306 | m_enable_onlylcdoff_ac = config.readNumEntry ( "LcdOffOnlyAC", 0 ); | ||
307 | m_disable_apm_ac = config.readNumEntry ( "NoApmAC", 0 ); | ||
308 | |||
309 | if ( !i1 && !i2 && !i3 ) | ||
310 | QWSServer::setScreenSaverInterval( 0 ); | ||
311 | else | ||
312 | QWSServer::setScreenSaverIntervals( v ); | ||
313 | } | ||
314 | |||
315 | void setInterval ( int interval ) | ||
316 | { | ||
317 | setIntervals ( -1, -1, interval ); | ||
318 | setIntervalsAC ( -1, -1, interval ); | ||
319 | } | ||
320 | |||
321 | void setMode ( int mode ) | ||
322 | { | ||
323 | if ( mode > m_disable_suspend ) | ||
324 | setInterval( -1 ); | ||
325 | m_disable_suspend = mode; | ||
326 | } | ||
327 | |||
328 | void setBacklight ( int bright ) | ||
329 | { | ||
330 | // Read from config | ||
331 | Config config ( "qpe" ); | ||
332 | config. setGroup ( "Screensaver" ); | ||
333 | m_backlight_normal = config. readNumEntry ( "Brightness", 255 ); | ||
334 | |||
335 | setBacklightInternal ( bright ); | ||
336 | } | ||
337 | |||
338 | private: | ||
339 | void setBacklightInternal ( int bright ) | ||
340 | { | ||
341 | if ( bright == -3 ) { | ||
342 | // Forced on | ||
343 | m_backlight_forcedoff = false; | ||
344 | bright = -1; | ||
345 | } | ||
346 | if ( m_backlight_forcedoff && bright != -2 ) | ||
347 | return ; | ||
348 | if ( bright == -2 ) { | ||
349 | // Toggle between off and on | ||
350 | bright = m_backlight_current ? 0 : -1; | ||
351 | m_backlight_forcedoff = !bright; | ||
352 | } | ||
353 | if ( bright == -1 ) | ||
354 | bright = m_backlight_normal; | ||
355 | |||
356 | if ( bright != m_backlight_current ) { | ||
357 | ODevice::inst ( )-> setDisplayBrightness ( bright ); | ||
358 | m_backlight_current = bright; | ||
359 | } | ||
360 | } | ||
361 | |||
362 | public: | ||
363 | void setDisplayState ( bool on ) | ||
364 | { | ||
365 | if ( m_lcd_status != on ) { | ||
366 | ODevice::inst ( ) -> setDisplayStatus ( on ); | ||
367 | m_lcd_status = on; | ||
368 | } | ||
369 | } | ||
370 | |||
371 | private: | ||
372 | int m_disable_suspend; | ||
373 | bool m_enable_dim; | ||
374 | bool m_enable_lightoff; | ||
375 | bool m_enable_onlylcdoff; | ||
376 | |||
377 | int m_disable_suspend_ac; | ||
378 | bool m_enable_dim_ac; | ||
379 | bool m_enable_lightoff_ac; | ||
380 | bool m_enable_onlylcdoff_ac; | ||
381 | bool m_disable_apm_ac; | ||
382 | |||
383 | bool m_lcd_status; | ||
384 | |||
385 | int m_backlight_normal; | ||
386 | int m_backlight_current; | ||
387 | bool m_backlight_forcedoff; | ||
388 | }; | ||
389 | 155 | ||
390 | void DesktopApplication::switchLCD ( bool on ) | 156 | void DesktopApplication::switchLCD ( bool on ) |
391 | { | 157 | { |
392 | if ( qApp ) { | 158 | if ( qApp ) { |
393 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 159 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
394 | 160 | ||
395 | if ( dapp-> m_screensaver ) { | 161 | if ( dapp-> m_screensaver ) { |
396 | if ( on ) { | 162 | if ( on ) { |
397 | dapp-> m_screensaver-> setDisplayState ( true ); | 163 | dapp-> m_screensaver-> setDisplayState ( true ); |
398 | dapp-> m_screensaver-> setBacklight ( -3 ); | 164 | dapp-> m_screensaver-> setBacklight ( -3 ); |
399 | } | 165 | } |
400 | else { | 166 | else { |
401 | dapp-> m_screensaver-> setDisplayState ( false ); | 167 | dapp-> m_screensaver-> setDisplayState ( false ); |
402 | } | 168 | } |
403 | } | 169 | } |
404 | } | 170 | } |
405 | } | 171 | } |
406 | 172 | ||
407 | 173 | ||
408 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 174 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
409 | : QPEApplication( argc, argv, appType ) | 175 | : QPEApplication( argc, argv, appType ) |
410 | { | 176 | { |
411 | 177 | ||
412 | m_timer = new QTimer( this ); | 178 | Config cfg( "apm" ); |
413 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); | 179 | cfg.setGroup( "Warnings" ); |
414 | Config cfg( "apm" ); | ||
415 | cfg.setGroup( "Warnings" ); | ||
416 | m_timer->start( 5000 ); | ||
417 | //cfg.readNumEntry( "checkinterval", 10000 ) | 180 | //cfg.readNumEntry( "checkinterval", 10000 ) |
418 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 181 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
419 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); | 182 | m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); |
420 | ps = new PowerStatus; | 183 | |
421 | pa = new DesktopPowerAlerter( 0 ); | 184 | m_ps = new PowerStatus; |
185 | m_ps_last = new PowerStatus; | ||
186 | pa = new DesktopPowerAlerter( 0 ); | ||
422 | 187 | ||
423 | channel = new QCopChannel( "QPE/Desktop", this ); | 188 | m_timer = new QTimer( this ); |
424 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 189 | connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); |
425 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 190 | m_timer->start( 5000 ); |
191 | |||
192 | channel = new QCopChannel( "QPE/Desktop", this ); | ||
193 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | ||
194 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | ||
426 | 195 | ||
427 | channel = new QCopChannel( "QPE/System", this ); | 196 | channel = new QCopChannel( "QPE/System", this ); |
428 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 197 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
429 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 198 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
430 | 199 | ||
431 | m_screensaver = new QPEScreenSaver; | 200 | m_screensaver = new OpieScreenSaver ( ); |
432 | 201 | m_screensaver-> setInterval ( -1 ); | |
433 | m_screensaver-> setInterval ( -1 ); | 202 | QWSServer::setScreenSaver( m_screensaver ); |
434 | QWSServer::setScreenSaver( m_screensaver ); | 203 | |
204 | apmTimeout ( ); | ||
435 | } | 205 | } |
436 | 206 | ||
437 | 207 | ||
438 | DesktopApplication::~DesktopApplication() | 208 | DesktopApplication::~DesktopApplication() |
439 | { | 209 | { |
440 | delete ps; | 210 | delete m_ps; |
441 | delete pa; | 211 | delete m_ps_last; |
212 | delete pa; | ||
213 | } | ||
214 | |||
215 | void DesktopApplication::apmTimeout() | ||
216 | { | ||
217 | qpedesktop->checkMemory(); // in case no events are being generated | ||
218 | |||
219 | *m_ps_last = *m_ps; | ||
220 | *m_ps = PowerStatusManager::readStatus(); | ||
221 | |||
222 | if ( m_ps-> acStatus ( ) != m_ps_last-> acStatus ( )) | ||
223 | m_screensaver-> powerStatusChanged ( *m_ps ); | ||
224 | |||
225 | int bat = m_ps-> batteryPercentRemaining ( ); | ||
226 | |||
227 | if ( m_ps_last-> batteryPercentRemaining ( ) != bat ) { | ||
228 | if ( bat <= m_powerCritical ) | ||
229 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); | ||
230 | else if ( bat <= m_powerVeryLow ) | ||
231 | pa->alert( tr( "Battery is running very low." ), 2 ); | ||
232 | |||
233 | |||
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 ); | ||
236 | } | ||
442 | } | 237 | } |
443 | 238 | ||
444 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 239 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
445 | { | 240 | { |
446 | QDataStream stream( data, IO_ReadOnly ); | 241 | QDataStream stream( data, IO_ReadOnly ); |
447 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 242 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
448 | int k; | 243 | int k; |
449 | QString c, m; | 244 | QString c, m; |
450 | stream >> k; | 245 | stream >> k; |
451 | stream >> c; | 246 | stream >> c; |
452 | stream >> m; | 247 | stream >> m; |
453 | 248 | ||
454 | 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 ); |
455 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 250 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
456 | } | 251 | } |
457 | } | 252 | } |
458 | 253 | ||
459 | 254 | ||
460 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 255 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
461 | { | 256 | { |
462 | QDataStream stream ( data, IO_ReadOnly ); | 257 | QDataStream stream ( data, IO_ReadOnly ); |
463 | 258 | ||
464 | if ( msg == "setScreenSaverInterval(int)" ) { | 259 | if ( msg == "setScreenSaverInterval(int)" ) { |
465 | int time; | 260 | int time; |
466 | stream >> time; | 261 | stream >> time; |
467 | m_screensaver-> setInterval( time ); | 262 | m_screensaver-> setInterval( time ); |
468 | } | 263 | } |
469 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 264 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
470 | int t1, t2, t3; | 265 | int t1, t2, t3; |
471 | stream >> t1 >> t2 >> t3; | 266 | stream >> t1 >> t2 >> t3; |
472 | m_screensaver-> setIntervals( t1, t2, t3 ); | 267 | m_screensaver-> setIntervals( t1, t2, t3 ); |
473 | } | 268 | } |
474 | else if ( msg == "setScreenSaverIntervalsAC(int,int,int)" ) { | ||
475 | int t1, t2, t3; | ||
476 | stream >> t1 >> t2 >> t3; | ||
477 | m_screensaver-> setIntervalsAC( t1, t2, t3 ); | ||
478 | } | ||
479 | else if ( msg == "setBacklight(int)" ) { | 269 | else if ( msg == "setBacklight(int)" ) { |
480 | int bright; | 270 | int bright; |
481 | stream >> bright; | 271 | stream >> bright; |
482 | m_screensaver-> setBacklight( bright ); | 272 | m_screensaver-> setBacklight( bright ); |
483 | } | 273 | } |
484 | else if ( msg == "setScreenSaverMode(int)" ) { | 274 | else if ( msg == "setScreenSaverMode(int)" ) { |
485 | int mode; | 275 | int mode; |
486 | stream >> mode; | 276 | stream >> mode; |
487 | m_screensaver-> setMode ( mode ); | 277 | m_screensaver-> setMode ( mode ); |
488 | } | 278 | } |
489 | else if ( msg == "reloadPowerWarnSettings()" ) { | 279 | else if ( msg == "reloadPowerWarnSettings()" ) { |
490 | reloadPowerWarnSettings(); | 280 | reloadPowerWarnSettings(); |
491 | } | 281 | } |
492 | else if ( msg == "setDisplayState(int)" ) { | 282 | else if ( msg == "setDisplayState(int)" ) { |
493 | int state; | 283 | int state; |
494 | stream >> state; | 284 | stream >> state; |
495 | m_screensaver-> setDisplayState ( state != 0 ); | 285 | m_screensaver-> setDisplayState ( state != 0 ); |
496 | } | 286 | } |
497 | else if ( msg == "suspend()" ) { | 287 | else if ( msg == "suspend()" ) { |
498 | emit power(); | 288 | emit power(); |
499 | } | 289 | } |
500 | } | 290 | } |
501 | 291 | ||
502 | void DesktopApplication::reloadPowerWarnSettings() { | 292 | void DesktopApplication::reloadPowerWarnSettings() { |
503 | Config cfg( "apm" ); | 293 | Config cfg( "apm" ); |
504 | cfg.setGroup( "Warnings" ); | 294 | cfg.setGroup( "Warnings" ); |
505 | 295 | ||
506 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); | 296 | // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); |
507 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); | 297 | m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); |
508 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); | 298 | m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); |
509 | } | 299 | } |
510 | 300 | ||
511 | 301 | ||
512 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 302 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
513 | 303 | ||
514 | #ifdef Q_WS_QWS | 304 | #ifdef Q_WS_QWS |
515 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 305 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
516 | { | 306 | { |
517 | qpedesktop->checkMemory(); | 307 | qpedesktop->checkMemory(); |
518 | 308 | ||
519 | if ( e->type == QWSEvent::Key ) { | 309 | if ( e->type == QWSEvent::Key ) { |
520 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 310 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
521 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 311 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
522 | return TRUE; | 312 | return TRUE; |
523 | bool press = ke->simpleData.is_press; | 313 | bool press = ke->simpleData.is_press; |
524 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 314 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
525 | 315 | ||
526 | /* | 316 | /* |
@@ -594,129 +384,96 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
594 | // return TRUE; | 384 | // return TRUE; |
595 | // } | 385 | // } |
596 | if ( ke->simpleData.keycode == Key_F35 ) { | 386 | if ( ke->simpleData.keycode == Key_F35 ) { |
597 | if ( press ) | 387 | if ( press ) |
598 | emit backlight(); | 388 | emit backlight(); |
599 | return TRUE; | 389 | return TRUE; |
600 | } | 390 | } |
601 | if ( ke->simpleData.keycode == Key_F32 ) { | 391 | if ( ke->simpleData.keycode == Key_F32 ) { |
602 | if ( press ) | 392 | if ( press ) |
603 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 393 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
604 | return TRUE; | 394 | return TRUE; |
605 | } | 395 | } |
606 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 396 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
607 | if ( press ) | 397 | if ( press ) |
608 | emit symbol(); | 398 | emit symbol(); |
609 | return TRUE; | 399 | return TRUE; |
610 | } | 400 | } |
611 | if ( ke->simpleData.keycode == Key_NumLock ) { | 401 | if ( ke->simpleData.keycode == Key_NumLock ) { |
612 | if ( press ) | 402 | if ( press ) |
613 | emit numLockStateToggle(); | 403 | emit numLockStateToggle(); |
614 | } | 404 | } |
615 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 405 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
616 | if ( press ) | 406 | if ( press ) |
617 | emit capsLockStateToggle(); | 407 | emit capsLockStateToggle(); |
618 | } | 408 | } |
619 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) | 409 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) |
620 | qpedesktop->keyClick(); | 410 | qpedesktop->keyClick(); |
621 | } | 411 | } |
622 | else { | 412 | else { |
623 | if ( e->type == QWSEvent::Mouse ) { | 413 | if ( e->type == QWSEvent::Mouse ) { |
624 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 414 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
625 | static bool up = TRUE; | 415 | static bool up = TRUE; |
626 | if ( me->simpleData.state & LeftButton ) { | 416 | if ( me->simpleData.state & LeftButton ) { |
627 | if ( up ) { | 417 | if ( up ) { |
628 | up = FALSE; | 418 | up = FALSE; |
629 | qpedesktop->screenClick(); | 419 | qpedesktop->screenClick(); |
630 | } | 420 | } |
631 | } | 421 | } |
632 | else { | 422 | else { |
633 | up = TRUE; | 423 | up = TRUE; |
634 | } | 424 | } |
635 | } | 425 | } |
636 | } | 426 | } |
637 | 427 | ||
638 | return QPEApplication::qwsEventFilter( e ); | 428 | return QPEApplication::qwsEventFilter( e ); |
639 | } | 429 | } |
640 | #endif | 430 | #endif |
641 | 431 | ||
642 | void DesktopApplication::psTimeout( int batRemaining ) | ||
643 | { | ||
644 | *ps = PowerStatusManager::readStatus(); | ||
645 | |||
646 | // maybe now since its triggered by apm change there might be to few warnings | ||
647 | // if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { | ||
648 | if ( ( batRemaining == m_powerVeryLow ) ) { | ||
649 | pa->alert( tr( "Battery is running very low." ), 2 ); | ||
650 | } | ||
651 | |||
652 | // if ( ps->batteryStatus() == PowerStatus::Critical ) { | ||
653 | if ( batRemaining == m_powerCritical ) { | ||
654 | pa->alert( tr( "Battery level is critical!\n" | ||
655 | "Keep power off until power restored!" ), 1 ); | ||
656 | } | ||
657 | |||
658 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | ||
659 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); | ||
660 | } | ||
661 | } | ||
662 | |||
663 | void DesktopApplication::apmTimeout() | ||
664 | { | ||
665 | qpedesktop->checkMemory(); // in case no events are being generated | ||
666 | |||
667 | *ps = PowerStatusManager::readStatus(); | ||
668 | |||
669 | if ( m_currentPowerLevel != ps->batteryPercentRemaining() ) { | ||
670 | // not very nice, since psTimeout parses the again | ||
671 | m_currentPowerLevel = ps->batteryPercentRemaining(); | ||
672 | psTimeout( m_currentPowerLevel ); | ||
673 | } | ||
674 | } | ||
675 | 432 | ||
676 | void DesktopApplication::sendCard() | 433 | void DesktopApplication::sendCard() |
677 | { | 434 | { |
678 | delete cardSendTimer; | 435 | delete cardSendTimer; |
679 | cardSendTimer = 0; | 436 | cardSendTimer = 0; |
680 | QString card = getenv( "HOME" ); | 437 | QString card = getenv( "HOME" ); |
681 | card += "/Applications/addressbook/businesscard.vcf"; | 438 | card += "/Applications/addressbook/businesscard.vcf"; |
682 | 439 | ||
683 | if ( QFile::exists( card ) ) { | 440 | if ( QFile::exists( card ) ) { |
684 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); | 441 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); |
685 | QString mimetype = "text/x-vCard"; | 442 | QString mimetype = "text/x-vCard"; |
686 | e << tr( "business card" ) << card << mimetype; | 443 | e << tr( "business card" ) << card << mimetype; |
687 | } | 444 | } |
688 | } | 445 | } |
689 | 446 | ||
690 | #if defined(QPE_HAVE_MEMALERTER) | 447 | #if defined(QPE_HAVE_MEMALERTER) |
691 | QPE_MEMALERTER_IMPL | 448 | QPE_MEMALERTER_IMPL |
692 | #endif | 449 | #endif |
693 | 450 | ||
694 | //=========================================================================== | 451 | //=========================================================================== |
695 | 452 | ||
696 | Desktop::Desktop() : | 453 | Desktop::Desktop() : |
697 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 454 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
698 | qcopBridge( 0 ), | 455 | qcopBridge( 0 ), |
699 | transferServer( 0 ), | 456 | transferServer( 0 ), |
700 | packageSlave( 0 ) | 457 | packageSlave( 0 ) |
701 | { | 458 | { |
702 | qpedesktop = this; | 459 | qpedesktop = this; |
703 | 460 | ||
704 | // bg = new Info( this ); | 461 | // bg = new Info( this ); |
705 | tb = new TaskBar; | 462 | tb = new TaskBar; |
706 | 463 | ||
707 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 464 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
708 | 465 | ||
709 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 466 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
710 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 467 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
711 | 468 | ||
712 | int displayw = qApp->desktop() ->width(); | 469 | int displayw = qApp->desktop() ->width(); |
713 | int displayh = qApp->desktop() ->height(); | 470 | int displayh = qApp->desktop() ->height(); |
714 | 471 | ||
715 | 472 | ||
716 | QSize sz = tb->sizeHint(); | 473 | QSize sz = tb->sizeHint(); |
717 | 474 | ||
718 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 475 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
719 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 476 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
720 | 477 | ||
721 | tb->show(); | 478 | tb->show(); |
722 | launcher->showMaximized(); | 479 | launcher->showMaximized(); |
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index 8308811..f6059b8 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -1,137 +1,136 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __DESKTOP_H__ | 21 | #ifndef __DESKTOP_H__ |
22 | #define __DESKTOP_H__ | 22 | #define __DESKTOP_H__ |
23 | 23 | ||
24 | 24 | ||
25 | #include "shutdownimpl.h" | 25 | #include "shutdownimpl.h" |
26 | 26 | ||
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | 28 | ||
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qdatetime.h> | 30 | #include <qdatetime.h> |
31 | 31 | ||
32 | class Background; | 32 | class Background; |
33 | class Launcher; | 33 | class Launcher; |
34 | class TaskBar; | 34 | class TaskBar; |
35 | class PowerStatus; | 35 | class PowerStatus; |
36 | class QCopBridge; | 36 | class QCopBridge; |
37 | class TransferServer; | 37 | class TransferServer; |
38 | class DesktopPowerAlerter; | 38 | class DesktopPowerAlerter; |
39 | class PackageSlave; | 39 | class PackageSlave; |
40 | class QPEScreenSaver; | 40 | class OpieScreenSaver; |
41 | 41 | ||
42 | class DesktopApplication : public QPEApplication | 42 | class DesktopApplication : public QPEApplication |
43 | { | 43 | { |
44 | Q_OBJECT | 44 | Q_OBJECT |
45 | public: | 45 | public: |
46 | DesktopApplication( int& argc, char **argv, Type t ); | 46 | DesktopApplication( int& argc, char **argv, Type t ); |
47 | ~DesktopApplication(); | 47 | ~DesktopApplication(); |
48 | 48 | ||
49 | static void switchLCD ( bool on ); // only for togglePower in Desktop | 49 | static void switchLCD ( bool on ); // only for togglePower in Desktop |
50 | 50 | ||
51 | signals: | 51 | signals: |
52 | void menu(); | 52 | void menu(); |
53 | void home(); | 53 | void home(); |
54 | void datebook(); | 54 | void datebook(); |
55 | void contacts(); | 55 | void contacts(); |
56 | void launch(); | 56 | void launch(); |
57 | void email(); | 57 | void email(); |
58 | void backlight(); | 58 | void backlight(); |
59 | void power(); | 59 | void power(); |
60 | void symbol(); | 60 | void symbol(); |
61 | void numLockStateToggle(); | 61 | void numLockStateToggle(); |
62 | void capsLockStateToggle(); | 62 | void capsLockStateToggle(); |
63 | void prepareForRestart(); | 63 | void prepareForRestart(); |
64 | 64 | ||
65 | protected: | 65 | protected: |
66 | #ifdef Q_WS_QWS | 66 | #ifdef Q_WS_QWS |
67 | 67 | ||
68 | bool qwsEventFilter( QWSEvent * ); | 68 | bool qwsEventFilter( QWSEvent * ); |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | void shutdown(); | 71 | void shutdown(); |
72 | void restart(); | 72 | void restart(); |
73 | 73 | ||
74 | public slots: | 74 | public slots: |
75 | virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); | 75 | virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); |
76 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); | 76 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); |
77 | 77 | ||
78 | protected slots: | 78 | protected slots: |
79 | void shutdown( ShutdownImpl::Type ); | 79 | void shutdown( ShutdownImpl::Type ); |
80 | void psTimeout( int ); | ||
81 | void apmTimeout(); | 80 | void apmTimeout(); |
82 | void sendCard(); | 81 | void sendCard(); |
83 | private: | 82 | private: |
84 | void reloadPowerWarnSettings(); | 83 | void reloadPowerWarnSettings(); |
85 | DesktopPowerAlerter *pa; | 84 | DesktopPowerAlerter *pa; |
86 | PowerStatus *ps; | 85 | PowerStatus *m_ps, *m_ps_last; |
87 | QTimer *cardSendTimer; | 86 | QTimer *cardSendTimer; |
88 | QCopChannel *channel; | 87 | QCopChannel *channel; |
89 | QPEScreenSaver *m_screensaver; | 88 | OpieScreenSaver *m_screensaver; |
90 | QTimer * m_timer; | 89 | QTimer * m_timer; |
91 | int m_powerVeryLow; | 90 | int m_powerVeryLow; |
92 | int m_powerCritical; | 91 | int m_powerCritical; |
93 | int m_currentPowerLevel; | 92 | int m_currentPowerLevel; |
94 | }; | 93 | }; |
95 | 94 | ||
96 | 95 | ||
97 | class Desktop : public QWidget | 96 | class Desktop : public QWidget |
98 | { | 97 | { |
99 | Q_OBJECT | 98 | Q_OBJECT |
100 | public: | 99 | public: |
101 | Desktop(); | 100 | Desktop(); |
102 | ~Desktop(); | 101 | ~Desktop(); |
103 | 102 | ||
104 | static bool screenLocked(); | 103 | static bool screenLocked(); |
105 | 104 | ||
106 | void show(); | 105 | void show(); |
107 | void checkMemory(); | 106 | void checkMemory(); |
108 | 107 | ||
109 | void keyClick(); | 108 | void keyClick(); |
110 | void screenClick(); | 109 | void screenClick(); |
111 | static void soundAlarm(); | 110 | static void soundAlarm(); |
112 | 111 | ||
113 | public slots: | 112 | public slots: |
114 | void raiseDatebook(); | 113 | void raiseDatebook(); |
115 | void raiseContacts(); | 114 | void raiseContacts(); |
116 | void raiseMenu(); | 115 | void raiseMenu(); |
117 | void raiseLauncher(); | 116 | void raiseLauncher(); |
118 | void raiseEmail(); | 117 | void raiseEmail(); |
119 | void execAutoStart(); | 118 | void execAutoStart(); |
120 | void togglePower(); | 119 | void togglePower(); |
121 | void toggleLight(); | 120 | void toggleLight(); |
122 | void toggleNumLockState(); | 121 | void toggleNumLockState(); |
123 | void toggleCapsLockState(); | 122 | void toggleCapsLockState(); |
124 | void toggleSymbolInput(); | 123 | void toggleSymbolInput(); |
125 | void terminateServers(); | 124 | void terminateServers(); |
126 | void rereadVolumes(); | 125 | void rereadVolumes(); |
127 | 126 | ||
128 | void home ( ); | 127 | void home ( ); |
129 | 128 | ||
130 | protected: | 129 | protected: |
131 | void executeOrModify( const QString& appLnkFile ); | 130 | void executeOrModify( const QString& appLnkFile ); |
132 | void styleChange( QStyle & ); | 131 | void styleChange( QStyle & ); |
133 | void timerEvent( QTimerEvent *e ); | 132 | void timerEvent( QTimerEvent *e ); |
134 | bool eventFilter( QObject *, QEvent * ); | 133 | bool eventFilter( QObject *, QEvent * ); |
135 | 134 | ||
136 | QWidget *bg; | 135 | QWidget *bg; |
137 | Launcher *launcher; | 136 | Launcher *launcher; |
diff --git a/core/launcher/launcher.pro b/core/launcher/launcher.pro index 95642af..83f8b5c 100644 --- a/core/launcher/launcher.pro +++ b/core/launcher/launcher.pro | |||
@@ -1,94 +1,96 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = ../../bin | 3 | DESTDIR = ../../bin |
4 | HEADERS = background.h \ | 4 | HEADERS = background.h \ |
5 | desktop.h \ | 5 | desktop.h \ |
6 | screensaver.h \ | ||
6 | qprocess.h \ | 7 | qprocess.h \ |
7 | mediummountgui.h \ | 8 | mediummountgui.h \ |
8 | info.h \ | 9 | info.h \ |
9 | appicons.h \ | 10 | appicons.h \ |
10 | taskbar.h \ | 11 | taskbar.h \ |
11 | sidething.h \ | 12 | sidething.h \ |
12 | runningappbar.h \ | 13 | runningappbar.h \ |
13 | stabmon.h \ | 14 | stabmon.h \ |
14 | inputmethods.h \ | 15 | inputmethods.h \ |
15 | systray.h \ | 16 | systray.h \ |
16 | wait.h \ | 17 | wait.h \ |
17 | shutdownimpl.h \ | 18 | shutdownimpl.h \ |
18 | launcher.h \ | 19 | launcher.h \ |
19 | launcherview.h \ | 20 | launcherview.h \ |
20 | ../../core/apps/calibrate/calibrate.h \ | 21 | ../../core/apps/calibrate/calibrate.h \ |
21 | startmenu.h \ | 22 | startmenu.h \ |
22 | transferserver.h \ | 23 | transferserver.h \ |
23 | qcopbridge.h \ | 24 | qcopbridge.h \ |
24 | packageslave.h \ | 25 | packageslave.h \ |
25 | irserver.h \ | 26 | irserver.h \ |
26 | ../../rsync/buf.h \ | 27 | ../../rsync/buf.h \ |
27 | ../../rsync/checksum.h \ | 28 | ../../rsync/checksum.h \ |
28 | ../../rsync/command.h \ | 29 | ../../rsync/command.h \ |
29 | ../../rsync/emit.h \ | 30 | ../../rsync/emit.h \ |
30 | ../../rsync/job.h \ | 31 | ../../rsync/job.h \ |
31 | ../../rsync/netint.h \ | 32 | ../../rsync/netint.h \ |
32 | ../../rsync/protocol.h \ | 33 | ../../rsync/protocol.h \ |
33 | ../../rsync/prototab.h \ | 34 | ../../rsync/prototab.h \ |
34 | ../../rsync/rsync.h \ | 35 | ../../rsync/rsync.h \ |
35 | ../../rsync/search.h \ | 36 | ../../rsync/search.h \ |
36 | ../../rsync/stream.h \ | 37 | ../../rsync/stream.h \ |
37 | ../../rsync/sumset.h \ | 38 | ../../rsync/sumset.h \ |
38 | ../../rsync/trace.h \ | 39 | ../../rsync/trace.h \ |
39 | ../../rsync/types.h \ | 40 | ../../rsync/types.h \ |
40 | ../../rsync/util.h \ | 41 | ../../rsync/util.h \ |
41 | ../../rsync/whole.h \ | 42 | ../../rsync/whole.h \ |
42 | ../../rsync/config_rsync.h \ | 43 | ../../rsync/config_rsync.h \ |
43 | ../../rsync/qrsync.h \ | 44 | ../../rsync/qrsync.h \ |
44 | quicklauncher.h | 45 | quicklauncher.h |
45 | SOURCES = background.cpp \ | 46 | SOURCES = background.cpp \ |
46 | desktop.cpp \ | 47 | desktop.cpp \ |
48 | screensaver.cpp \ | ||
47 | mediummountgui.cpp \ | 49 | mediummountgui.cpp \ |
48 | qprocess.cpp qprocess_unix.cpp \ | 50 | qprocess.cpp qprocess_unix.cpp \ |
49 | info.cpp \ | 51 | info.cpp \ |
50 | appicons.cpp \ | 52 | appicons.cpp \ |
51 | taskbar.cpp \ | 53 | taskbar.cpp \ |
52 | sidething.cpp \ | 54 | sidething.cpp \ |
53 | runningappbar.cpp \ | 55 | runningappbar.cpp \ |
54 | stabmon.cpp \ | 56 | stabmon.cpp \ |
55 | inputmethods.cpp \ | 57 | inputmethods.cpp \ |
56 | systray.cpp \ | 58 | systray.cpp \ |
57 | wait.cpp \ | 59 | wait.cpp \ |
58 | shutdownimpl.cpp \ | 60 | shutdownimpl.cpp \ |
59 | launcher.cpp \ | 61 | launcher.cpp \ |
60 | launcherview.cpp \ | 62 | launcherview.cpp \ |
61 | ../../core/apps/calibrate/calibrate.cpp \ | 63 | ../../core/apps/calibrate/calibrate.cpp \ |
62 | transferserver.cpp \ | 64 | transferserver.cpp \ |
63 | packageslave.cpp \ | 65 | packageslave.cpp \ |
64 | irserver.cpp \ | 66 | irserver.cpp \ |
65 | qcopbridge.cpp \ | 67 | qcopbridge.cpp \ |
66 | startmenu.cpp \ | 68 | startmenu.cpp \ |
67 | main.cpp \ | 69 | main.cpp \ |
68 | ../../rsync/base64.c \ | 70 | ../../rsync/base64.c \ |
69 | ../../rsync/buf.c \ | 71 | ../../rsync/buf.c \ |
70 | ../../rsync/checksum.c \ | 72 | ../../rsync/checksum.c \ |
71 | ../../rsync/command.c \ | 73 | ../../rsync/command.c \ |
72 | ../../rsync/delta.c \ | 74 | ../../rsync/delta.c \ |
73 | ../../rsync/emit.c \ | 75 | ../../rsync/emit.c \ |
74 | ../../rsync/hex.c \ | 76 | ../../rsync/hex.c \ |
75 | ../../rsync/job.c \ | 77 | ../../rsync/job.c \ |
76 | ../../rsync/mdfour.c \ | 78 | ../../rsync/mdfour.c \ |
77 | ../../rsync/mksum.c \ | 79 | ../../rsync/mksum.c \ |
78 | ../../rsync/msg.c \ | 80 | ../../rsync/msg.c \ |
79 | ../../rsync/netint.c \ | 81 | ../../rsync/netint.c \ |
80 | ../../rsync/patch.c \ | 82 | ../../rsync/patch.c \ |
81 | ../../rsync/prototab.c \ | 83 | ../../rsync/prototab.c \ |
82 | ../../rsync/readsums.c \ | 84 | ../../rsync/readsums.c \ |
83 | ../../rsync/scoop.c \ | 85 | ../../rsync/scoop.c \ |
84 | ../../rsync/search.c \ | 86 | ../../rsync/search.c \ |
85 | ../../rsync/stats.c \ | 87 | ../../rsync/stats.c \ |
86 | ../../rsync/stream.c \ | 88 | ../../rsync/stream.c \ |
87 | ../../rsync/sumset.c \ | 89 | ../../rsync/sumset.c \ |
88 | ../../rsync/trace.c \ | 90 | ../../rsync/trace.c \ |
89 | ../../rsync/tube.c \ | 91 | ../../rsync/tube.c \ |
90 | ../../rsync/util.c \ | 92 | ../../rsync/util.c \ |
91 | ../../rsync/version.c \ | 93 | ../../rsync/version.c \ |
92 | ../../rsync/whole.c \ | 94 | ../../rsync/whole.c \ |
93 | ../../rsync/qrsync.cpp | 95 | ../../rsync/qrsync.cpp |
94 | INTERFACES= syncdialog.ui | 96 | INTERFACES= syncdialog.ui |
diff --git a/core/launcher/screensaver.cpp b/core/launcher/screensaver.cpp new file mode 100644 index 0000000..9e823ff --- a/dev/null +++ b/core/launcher/screensaver.cpp | |||
@@ -0,0 +1,237 @@ | |||
1 | |||
2 | #include "screensaver.h" | ||
3 | |||
4 | #include <qpe/config.h> | ||
5 | #include <qpe/power.h> | ||
6 | #include <qpe/network.h> | ||
7 | |||
8 | #include <opie/odevice.h> | ||
9 | |||
10 | |||
11 | using namespace Opie; | ||
12 | |||
13 | |||
14 | OpieScreenSaver::OpieScreenSaver ( ) | ||
15 | : QObject ( 0, "screensaver" ), QWSScreenSaver ( ) | ||
16 | { | ||
17 | m_disable_suspend = 100; | ||
18 | m_enable_dim = false; | ||
19 | m_enable_lightoff = false; | ||
20 | m_enable_suspend = false; | ||
21 | m_onlylcdoff = false; | ||
22 | |||
23 | m_enable_dim_ac = false; | ||
24 | m_enable_lightoff_ac = false; | ||
25 | m_enable_suspend_ac = false; | ||
26 | m_onlylcdoff_ac = false; | ||
27 | |||
28 | m_use_light_sensor = false; | ||
29 | m_backlight_sensor = -1; | ||
30 | |||
31 | m_lcd_status = true; | ||
32 | |||
33 | m_backlight_normal = -1; | ||
34 | m_backlight_current = -1; | ||
35 | m_backlight_forcedoff = false; | ||
36 | |||
37 | m_on_ac = false; | ||
38 | |||
39 | m_level = -1; | ||
40 | |||
41 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | ||
42 | ODevice::inst ( )-> setDisplayStatus ( true ); | ||
43 | setBacklight ( -1 ); | ||
44 | } | ||
45 | |||
46 | |||
47 | void OpieScreenSaver::restore() | ||
48 | { | ||
49 | m_level = -1; | ||
50 | |||
51 | if ( !m_lcd_status ) { // We must have turned it off | ||
52 | ODevice::inst ( ) -> setDisplayStatus ( true ); | ||
53 | m_lcd_status = true; | ||
54 | } | ||
55 | |||
56 | setBacklightInternal ( -1 ); | ||
57 | } | ||
58 | |||
59 | |||
60 | bool OpieScreenSaver::save( int level ) | ||
61 | { | ||
62 | m_level = level; | ||
63 | |||
64 | switch ( level ) { | ||
65 | case 0: | ||
66 | if (( m_on_ac && m_enable_dim_ac ) || | ||
67 | ( !m_on_ac && m_enable_dim )) { | ||
68 | if (( m_disable_suspend > 0 ) && ( m_backlight_current > 1 ) && !m_use_light_sensor ) | ||
69 | setBacklightInternal ( 1 ); // lowest non-off | ||
70 | } | ||
71 | return true; | ||
72 | break; | ||
73 | |||
74 | case 1: | ||
75 | if (( m_on_ac && m_enable_lightoff_ac ) || | ||
76 | ( !m_on_ac && m_enable_lightoff )) { | ||
77 | if ( m_disable_suspend > 1 ) | ||
78 | setBacklightInternal ( 0 ); // off | ||
79 | } | ||
80 | return true; | ||
81 | break; | ||
82 | |||
83 | case 2: | ||
84 | if (( m_on_ac && !m_enable_suspend_ac ) || | ||
85 | ( !m_on_ac && !m_enable_suspend )) { | ||
86 | return true; | ||
87 | } | ||
88 | |||
89 | if (( m_on_ac && m_onlylcdoff_ac ) || | ||
90 | ( !m_on_ac && m_onlylcdoff )) { | ||
91 | ODevice::inst ( ) -> setDisplayStatus ( false ); | ||
92 | m_lcd_status = false; | ||
93 | return true; | ||
94 | } | ||
95 | |||
96 | // We're going to suspend the whole machine | ||
97 | |||
98 | if (( m_disable_suspend > 2 ) && !Network::networkOnline ( )) { | ||
99 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | ||
100 | return true; | ||
101 | } | ||
102 | |||
103 | break; | ||
104 | } | ||
105 | return false; | ||
106 | } | ||
107 | |||
108 | |||
109 | void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 ) | ||
110 | { | ||
111 | Config config ( "apm" ); | ||
112 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); | ||
113 | |||
114 | int v[ 4 ]; | ||
115 | if ( i1 < 0 ) | ||
116 | i1 = config. readNumEntry ( "Dim", 30 ); | ||
117 | if ( i2 < 0 ) | ||
118 | i2 = config. readNumEntry ( "LightOff", 20 ); | ||
119 | if ( i3 < 0 ) | ||
120 | i3 = config. readNumEntry ( "Suspend", 60 ); | ||
121 | |||
122 | if ( m_on_ac ) { | ||
123 | m_enable_dim_ac = ( i1 > 0 ); | ||
124 | m_enable_lightoff_ac = ( i2 > 0 ); | ||
125 | m_enable_suspend_ac = ( i3 > 0 ); | ||
126 | m_onlylcdoff_ac = config.readNumEntry ( "LcdOffOnly", 0 ); | ||
127 | } | ||
128 | else { | ||
129 | m_enable_dim = ( i1 > 0 ); | ||
130 | m_enable_lightoff = ( i2 > 0 ); | ||
131 | m_enable_suspend = ( i3 > 0 ); | ||
132 | m_onlylcdoff = config.readNumEntry ( "LcdOffOnly", 0 ); | ||
133 | } | ||
134 | |||
135 | qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | ||
136 | |||
137 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | ||
138 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | ||
139 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | ||
140 | v [ 3 ] = 0; | ||
141 | |||
142 | if ( !i1 && !i2 && !i3 ) | ||
143 | QWSServer::setScreenSaverInterval( 0 ); | ||
144 | else | ||
145 | QWSServer::setScreenSaverIntervals( v ); | ||
146 | } | ||
147 | |||
148 | |||
149 | void OpieScreenSaver::setInterval ( int interval ) | ||
150 | { | ||
151 | setIntervals ( -1, -1, interval ); | ||
152 | } | ||
153 | |||
154 | |||
155 | void OpieScreenSaver::setMode ( int mode ) | ||
156 | { | ||
157 | if ( mode > m_disable_suspend ) | ||
158 | setInterval ( -1 ); | ||
159 | m_disable_suspend = mode; | ||
160 | } | ||
161 | |||
162 | |||
163 | void OpieScreenSaver::setBacklight ( int bright ) | ||
164 | { | ||
165 | // Read from config | ||
166 | Config config ( "apm" ); | ||
167 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); | ||
168 | m_backlight_normal = config. readNumEntry ( "Brightness", 255 ); | ||
169 | |||
170 | m_use_light_sensor = config. readBoolEntry ( "LightSensor", false ); | ||
171 | |||
172 | qDebug ( "setBacklight: %d (ls: %d)", m_backlight_normal, m_use_light_sensor ? 1 : 0 ); | ||
173 | |||
174 | killTimers ( ); | ||
175 | if ( m_use_light_sensor ) { | ||
176 | timerEvent ( 0 ); | ||
177 | startTimer ( 2000 ); | ||
178 | } | ||
179 | |||
180 | setBacklightInternal ( bright ); | ||
181 | } | ||
182 | |||
183 | |||
184 | void OpieScreenSaver::setBacklightInternal ( int bright ) | ||
185 | { | ||
186 | if ( bright == -3 ) { | ||
187 | // Forced on | ||
188 | m_backlight_forcedoff = false; | ||
189 | bright = -1; | ||
190 | } | ||
191 | if ( m_backlight_forcedoff && bright != -2 ) | ||
192 | return ; | ||
193 | if ( bright == -2 ) { | ||
194 | // Toggle between off and on | ||
195 | bright = m_backlight_current ? 0 : -1; | ||
196 | m_backlight_forcedoff = !bright; | ||
197 | } | ||
198 | if ( bright == -1 ) | ||
199 | bright = m_use_light_sensor ? m_backlight_sensor : m_backlight_normal; | ||
200 | |||
201 | if ( bright != m_backlight_current ) { | ||
202 | ODevice::inst ( )-> setDisplayBrightness ( bright ); | ||
203 | m_backlight_current = bright; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | |||
208 | void OpieScreenSaver::timerEvent ( QTimerEvent * ) | ||
209 | { | ||
210 | m_backlight_sensor = (( 255 - ODevice::inst ( )-> readLightSensor ( )) * m_backlight_normal ) / 255; | ||
211 | |||
212 | if ( m_level <= 0 ) | ||
213 | setBacklightInternal ( -1 ); | ||
214 | } | ||
215 | |||
216 | |||
217 | void OpieScreenSaver::setDisplayState ( bool on ) | ||
218 | { | ||
219 | if ( m_lcd_status != on ) { | ||
220 | ODevice::inst ( ) -> setDisplayStatus ( on ); | ||
221 | m_lcd_status = on; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | |||
226 | void OpieScreenSaver::powerStatusChanged ( PowerStatus ps ) | ||
227 | { | ||
228 | bool newonac = ( ps. acStatus ( ) == PowerStatus::Online ); | ||
229 | |||
230 | if ( newonac != m_on_ac ) { | ||
231 | m_on_ac = newonac; | ||
232 | setInterval ( -1 ); | ||
233 | setBacklight ( -1 ); | ||
234 | restore ( ); | ||
235 | } | ||
236 | } | ||
237 | |||
diff --git a/core/launcher/screensaver.h b/core/launcher/screensaver.h new file mode 100644 index 0000000..9126f33 --- a/dev/null +++ b/core/launcher/screensaver.h | |||
@@ -0,0 +1,61 @@ | |||
1 | #ifndef __LAUNCHER_SCREENSAVER_H__ | ||
2 | #define __LAUNCHER_SCREENSAVER_H__ | ||
3 | |||
4 | #include <qwindowsystem_qws.h> | ||
5 | #include <qobject.h> | ||
6 | |||
7 | #include <qpe/power.h> | ||
8 | |||
9 | class OpieScreenSaver : public QObject, public QWSScreenSaver | ||
10 | { | ||
11 | public: | ||
12 | OpieScreenSaver ( ); | ||
13 | |||
14 | void restore ( ); | ||
15 | bool save ( int level ); | ||
16 | |||
17 | void setIntervals( int i1, int i2, int i3 ); | ||
18 | void setIntervalsAC( int i1, int i2, int i3 ); | ||
19 | |||
20 | void setInterval ( int interval ); | ||
21 | |||
22 | void setMode ( int mode ); | ||
23 | |||
24 | void setBacklight ( int bright ); | ||
25 | void setDisplayState ( bool on ); | ||
26 | |||
27 | void powerStatusChanged ( PowerStatus ps ); | ||
28 | |||
29 | private: | ||
30 | void setBacklightInternal ( int bright ); | ||
31 | |||
32 | protected: | ||
33 | virtual void timerEvent ( QTimerEvent * ); | ||
34 | |||
35 | private: | ||
36 | int m_disable_suspend; | ||
37 | bool m_enable_dim; | ||
38 | bool m_enable_lightoff; | ||
39 | bool m_enable_suspend; | ||
40 | bool m_onlylcdoff; | ||
41 | |||
42 | bool m_enable_dim_ac; | ||
43 | bool m_enable_lightoff_ac; | ||
44 | bool m_enable_suspend_ac; | ||
45 | bool m_onlylcdoff_ac; | ||
46 | |||
47 | bool m_use_light_sensor; | ||
48 | int m_backlight_sensor; | ||
49 | |||
50 | bool m_lcd_status; | ||
51 | |||
52 | int m_backlight_normal; | ||
53 | int m_backlight_current; | ||
54 | bool m_backlight_forcedoff; | ||
55 | |||
56 | bool m_on_ac; | ||
57 | |||
58 | int m_level; | ||
59 | }; | ||
60 | |||
61 | #endif | ||