-rw-r--r-- | core/launcher/desktop.cpp | 1367 |
1 files changed, 684 insertions, 683 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index bca95b2..4640a12 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,1034 +1,1035 @@ | |||
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 "mrulist.h" | 24 | //#include "mrulist.h" |
25 | #include "qcopbridge.h" | 25 | #include "qcopbridge.h" |
26 | #include "shutdownimpl.h" | 26 | #include "shutdownimpl.h" |
27 | #include "startmenu.h" | 27 | #include "startmenu.h" |
28 | #include "taskbar.h" | 28 | #include "taskbar.h" |
29 | #include "transferserver.h" | 29 | #include "transferserver.h" |
30 | #include "irserver.h" | 30 | #include "irserver.h" |
31 | #include "packageslave.h" | 31 | #include "packageslave.h" |
32 | 32 | ||
33 | #include <qpe/applnk.h> | 33 | #include <qpe/applnk.h> |
34 | #include <qpe/mimetype.h> | 34 | #include <qpe/mimetype.h> |
35 | #include <qpe/password.h> | 35 | #include <qpe/password.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/power.h> | 37 | #include <qpe/power.h> |
38 | #include <qpe/timeconversion.h> | 38 | #include <qpe/timeconversion.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/network.h> | 40 | #include <qpe/network.h> |
41 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
42 | 42 | ||
43 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 43 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
44 | #include <qpe/custom.h> | 44 | #include <qpe/custom.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include <opie/odevice.h> | 47 | #include <opie/odevice.h> |
48 | 48 | ||
49 | #include <qgfx_qws.h> | 49 | #include <qgfx_qws.h> |
50 | #include <qmainwindow.h> | 50 | #include <qmainwindow.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qwindowsystem_qws.h> | 53 | #include <qwindowsystem_qws.h> |
54 | 54 | ||
55 | #include <qvaluelist.h> | 55 | #include <qvaluelist.h> |
56 | 56 | ||
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #include <fcntl.h> | 59 | #include <fcntl.h> |
60 | 60 | ||
61 | class QCopKeyRegister | 61 | class QCopKeyRegister |
62 | { | 62 | { |
63 | public: | 63 | public: |
64 | QCopKeyRegister() : keyCode( 0 ) | 64 | QCopKeyRegister() : keyCode( 0 ) |
65 | { } | 65 | { } |
66 | QCopKeyRegister( int k, const QString &c, const QString &m ) | 66 | QCopKeyRegister( int k, const QString &c, const QString &m ) |
67 | : keyCode( k ), channel( c ), message( m ) | 67 | : keyCode( k ), channel( c ), message( m ) |
68 | { } | 68 | { } |
69 | 69 | ||
70 | int getKeyCode() const | 70 | int getKeyCode() const |
71 | { | 71 | { |
72 | return keyCode; | 72 | return keyCode; |
73 | } | 73 | } |
74 | QString getChannel() const | 74 | QString getChannel() const |
75 | { | 75 | { |
76 | return channel; | 76 | return channel; |
77 | } | 77 | } |
78 | QString getMessage() const | 78 | QString getMessage() const |
79 | { | 79 | { |
80 | return message; | 80 | return message; |
81 | } | 81 | } |
82 | 82 | ||
83 | private: | 83 | private: |
84 | int keyCode; | 84 | int keyCode; |
85 | QString channel, message; | 85 | QString channel, message; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 88 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
89 | KeyRegisterList keyRegisterList; | 89 | KeyRegisterList keyRegisterList; |
90 | 90 | ||
91 | static Desktop* qpedesktop = 0; | 91 | static Desktop* qpedesktop = 0; |
92 | static int loggedin = 0; | 92 | static int loggedin = 0; |
93 | static void login( bool at_poweron ) | 93 | static void login( bool at_poweron ) |
94 | { | 94 | { |
95 | if ( !loggedin ) { | 95 | if ( !loggedin ) { |
96 | Global::terminateBuiltin( "calibrate" ); | 96 | Global::terminateBuiltin( "calibrate" ); |
97 | Password::authenticate( at_poweron ); | 97 | Password::authenticate( at_poweron ); |
98 | loggedin = 1; | 98 | loggedin = 1; |
99 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 99 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | bool Desktop::screenLocked() | 103 | bool Desktop::screenLocked() |
104 | { | 104 | { |
105 | return loggedin == 0; | 105 | return loggedin == 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | /* | 108 | /* |
109 | Priority is number of alerts that are needed to pop up | 109 | Priority is number of alerts that are needed to pop up |
110 | alert. | 110 | alert. |
111 | */ | 111 | */ |
112 | class DesktopPowerAlerter : public QMessageBox | 112 | class DesktopPowerAlerter : public QMessageBox |
113 | { | 113 | { |
114 | public: | 114 | public: |
115 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 115 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
116 | : QMessageBox( tr( "Battery Status" ), "Low Battery", | 116 | : QMessageBox( tr( "Battery Status" ), "Low Battery", |
117 | QMessageBox::Critical, | 117 | QMessageBox::Critical, |
118 | QMessageBox::Ok | QMessageBox::Default, | 118 | QMessageBox::Ok | QMessageBox::Default, |
119 | QMessageBox::NoButton, QMessageBox::NoButton, | 119 | QMessageBox::NoButton, QMessageBox::NoButton, |
120 | parent, name, FALSE ) | 120 | parent, name, FALSE ) |
121 | { | 121 | { |
122 | currentPriority = INT_MAX; | 122 | currentPriority = INT_MAX; |
123 | alertCount = 0; | 123 | alertCount = 0; |
124 | } | 124 | } |
125 | 125 | ||
126 | void alert( const QString &text, int priority ); | 126 | void alert( const QString &text, int priority ); |
127 | void hideEvent( QHideEvent * ); | 127 | void hideEvent( QHideEvent * ); |
128 | private: | 128 | private: |
129 | int currentPriority; | 129 | int currentPriority; |
130 | int alertCount; | 130 | int alertCount; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 133 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
134 | { | 134 | { |
135 | alertCount++; | 135 | alertCount++; |
136 | if ( alertCount < priority ) | 136 | if ( alertCount < priority ) |
137 | return ; | 137 | return ; |
138 | if ( priority > currentPriority ) | 138 | if ( priority > currentPriority ) |
139 | return ; | 139 | return ; |
140 | currentPriority = priority; | 140 | currentPriority = priority; |
141 | setText( text ); | 141 | setText( text ); |
142 | show(); | 142 | show(); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 146 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
147 | { | 147 | { |
148 | QMessageBox::hideEvent( e ); | 148 | QMessageBox::hideEvent( e ); |
149 | alertCount = 0; | 149 | alertCount = 0; |
150 | currentPriority = INT_MAX; | 150 | currentPriority = INT_MAX; |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | class QPEScreenSaver : public QWSScreenSaver | 154 | class QPEScreenSaver : public QWSScreenSaver |
155 | { | 155 | { |
156 | private: | 156 | private: |
157 | int LcdOn; | 157 | int LcdOn; |
158 | 158 | ||
159 | public: | 159 | public: |
160 | QPEScreenSaver() | 160 | QPEScreenSaver() |
161 | { | 161 | { |
162 | m_disable_suspend = 100; | 162 | m_disable_suspend = 100; |
163 | m_enable_dim = false; | 163 | m_enable_dim = false; |
164 | m_enable_lightoff = false; | 164 | m_enable_lightoff = false; |
165 | m_enable_onlylcdoff = false; | 165 | m_enable_onlylcdoff = false; |
166 | 166 | ||
167 | m_lcd_status = true; | 167 | m_lcd_status = true; |
168 | 168 | ||
169 | m_backlight_bright = -1; | 169 | m_backlight_bright = -1; |
170 | m_backlight_forcedoff = false; | 170 | m_backlight_forcedoff = false; |
171 | 171 | ||
172 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 172 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
173 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 173 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
174 | } | 174 | } |
175 | void restore() | 175 | void restore() |
176 | { | 176 | { |
177 | if ( !m_lcd_status ) // We must have turned it off | 177 | if ( !m_lcd_status ) // We must have turned it off |
178 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 178 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
179 | 179 | ||
180 | setBacklight ( -1 ); | 180 | setBacklight ( -1 ); |
181 | } | 181 | } |
182 | bool save( int level ) | 182 | bool save( int level ) |
183 | { | 183 | { |
184 | switch ( level ) { | 184 | switch ( level ) { |
185 | case 0: | 185 | case 0: |
186 | if ( m_disable_suspend > 0 && m_enable_dim ) { | 186 | if ( m_disable_suspend > 0 && m_enable_dim ) { |
187 | if ( backlight() > 1 ) | 187 | if ( backlight() > 1 ) |
188 | setBacklight( 1 ); // lowest non-off | 188 | setBacklight( 1 ); // lowest non-off |
189 | } | 189 | } |
190 | return true; | 190 | return true; |
191 | break; | 191 | break; |
192 | case 1: | 192 | case 1: |
193 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { | 193 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { |
194 | setBacklight( 0 ); // off | 194 | setBacklight( 0 ); // off |
195 | } | 195 | } |
196 | return true; | 196 | return true; |
197 | break; | 197 | break; |
198 | case 2: | 198 | case 2: |
199 | if ( m_enable_onlylcdoff ) { | 199 | if ( m_enable_onlylcdoff ) { |
200 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 200 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
201 | m_lcd_status = false; | 201 | m_lcd_status = false; |
202 | return true; | 202 | return true; |
203 | } | 203 | } |
204 | else // We're going to suspend the whole machine | 204 | else // We're going to suspend the whole machine |
205 | { | 205 | { |
206 | if ( ( m_disable_suspend > 2 ) && | 206 | if ( ( m_disable_suspend > 2 ) && |
207 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && | 207 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && |
208 | ( !Network::networkOnline ( ) ) ) { | 208 | ( !Network::networkOnline ( ) ) ) { |
209 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 209 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
210 | return true; | 210 | return true; |
211 | } | 211 | } |
212 | } | 212 | } |
213 | break; | 213 | break; |
214 | } | 214 | } |
215 | return false; | 215 | return false; |
216 | } | 216 | } |
217 | 217 | ||
218 | private: | 218 | private: |
219 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) | 219 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) |
220 | { | 220 | { |
221 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) | 221 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) |
222 | return 0; | 222 | return 0; |
223 | 223 | ||
224 | if ( interval < 0 ) { | 224 | if ( interval < 0 ) { |
225 | // Restore screen blanking and power saving state | 225 | // Restore screen blanking and power saving state |
226 | interval = config.readNumEntry( value, def ); | 226 | interval = config.readNumEntry( value, def ); |
227 | } | 227 | } |
228 | return interval; | 228 | return interval; |
229 | } | 229 | } |
230 | 230 | ||
231 | public: | 231 | public: |
232 | void setIntervals( int i1, int i2, int i3 ) | 232 | void setIntervals( int i1, int i2, int i3 ) |
233 | { | 233 | { |
234 | Config config( "qpe" ); | 234 | Config config( "qpe" ); |
235 | config.setGroup( "Screensaver" ); | 235 | config.setGroup( "Screensaver" ); |
236 | 236 | ||
237 | int v[ 4 ]; | 237 | int v[ 4 ]; |
238 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); | 238 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); |
239 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); | 239 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); |
240 | i3 = ssi( i3, config, "", "Interval", 60 ); | 240 | i3 = ssi( i3, config, "", "Interval", 60 ); |
241 | 241 | ||
242 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | 242 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); |
243 | 243 | ||
244 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 244 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
245 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | 245 | v [ 1 ] = QMAX( 1000 * i2, 100 ); |
246 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | 246 | v [ 2 ] = QMAX( 1000 * i3, 100 ); |
247 | v [ 3 ] = 0; | 247 | v [ 3 ] = 0; |
248 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); | 248 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); |
249 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); | 249 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); |
250 | m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); | 250 | m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); |
251 | 251 | ||
252 | if ( !i1 && !i2 && !i3 ) | 252 | if ( !i1 && !i2 && !i3 ) |
253 | QWSServer::setScreenSaverInterval( 0 ); | 253 | QWSServer::setScreenSaverInterval( 0 ); |
254 | else | 254 | else |
255 | QWSServer::setScreenSaverIntervals( v ); | 255 | QWSServer::setScreenSaverIntervals( v ); |
256 | } | 256 | } |
257 | 257 | ||
258 | void setInterval ( int interval ) | 258 | void setInterval ( int interval ) |
259 | { | 259 | { |
260 | setIntervals ( -1, -1, interval ); | 260 | setIntervals ( -1, -1, interval ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void setMode ( int mode ) | 263 | void setMode ( int mode ) |
264 | { | 264 | { |
265 | if ( mode > m_disable_suspend ) | 265 | if ( mode > m_disable_suspend ) |
266 | setInterval( -1 ); | 266 | setInterval( -1 ); |
267 | m_disable_suspend = mode; | 267 | m_disable_suspend = mode; |
268 | } | 268 | } |
269 | 269 | ||
270 | int backlight ( ) | 270 | int backlight ( ) |
271 | { | 271 | { |
272 | if ( m_backlight_bright == -1 ) { | 272 | if ( m_backlight_bright == -1 ) { |
273 | // Read from config | 273 | // Read from config |
274 | Config config ( "qpe" ); | 274 | Config config ( "qpe" ); |
275 | config. setGroup ( "Screensaver" ); | 275 | config. setGroup ( "Screensaver" ); |
276 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); | 276 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); |
277 | } | 277 | } |
278 | return m_backlight_bright; | 278 | return m_backlight_bright; |
279 | } | 279 | } |
280 | 280 | ||
281 | void setBacklight ( int bright ) | 281 | void setBacklight ( int bright ) |
282 | { | 282 | { |
283 | if ( bright == -3 ) { | 283 | if ( bright == -3 ) { |
284 | // Forced on | 284 | // Forced on |
285 | m_backlight_forcedoff = false; | 285 | m_backlight_forcedoff = false; |
286 | bright = -1; | 286 | bright = -1; |
287 | } | 287 | } |
288 | if ( m_backlight_forcedoff && bright != -2 ) | 288 | if ( m_backlight_forcedoff && bright != -2 ) |
289 | return ; | 289 | return ; |
290 | if ( bright == -2 ) { | 290 | if ( bright == -2 ) { |
291 | // Toggle between off and on | 291 | // Toggle between off and on |
292 | bright = m_backlight_bright ? 0 : -1; | 292 | bright = m_backlight_bright ? 0 : -1; |
293 | m_backlight_forcedoff = !bright; | 293 | m_backlight_forcedoff = !bright; |
294 | } | 294 | } |
295 | 295 | ||
296 | m_backlight_bright = bright; | 296 | m_backlight_bright = bright; |
297 | 297 | ||
298 | bright = backlight ( ); | 298 | bright = backlight ( ); |
299 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 299 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); |
300 | 300 | ||
301 | m_backlight_bright = bright; | 301 | m_backlight_bright = bright; |
302 | } | 302 | } |
303 | 303 | ||
304 | private: | 304 | private: |
305 | int m_disable_suspend; | 305 | int m_disable_suspend; |
306 | bool m_enable_dim; | 306 | bool m_enable_dim; |
307 | bool m_enable_lightoff; | 307 | bool m_enable_lightoff; |
308 | bool m_enable_onlylcdoff; | 308 | bool m_enable_onlylcdoff; |
309 | 309 | ||
310 | bool m_lcd_status; | 310 | bool m_lcd_status; |
311 | 311 | ||
312 | int m_backlight_bright; | 312 | int m_backlight_bright; |
313 | bool m_backlight_forcedoff; | 313 | bool m_backlight_forcedoff; |
314 | }; | 314 | }; |
315 | 315 | ||
316 | 316 | ||
317 | void DesktopApplication::switchLCD ( bool on ) | 317 | void DesktopApplication::switchLCD ( bool on ) |
318 | { | 318 | { |
319 | if ( qApp ) { | 319 | if ( qApp ) { |
320 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 320 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
321 | 321 | ||
322 | if ( dapp-> m_screensaver ) | 322 | if ( dapp-> m_screensaver ) |
323 | dapp-> m_screensaver-> setBacklight ( on ? -3 : -1 ); | 323 | dapp-> m_screensaver-> setBacklight ( on ? -3 : -1 ); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 328 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
329 | : QPEApplication( argc, argv, appType ) | 329 | : QPEApplication( argc, argv, appType ) |
330 | { | 330 | { |
331 | 331 | ||
332 | QTimer * t = new QTimer( this ); | 332 | QTimer * t = new QTimer( this ); |
333 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); | 333 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); |
334 | t->start( 10000 ); | 334 | t->start( 10000 ); |
335 | ps = new PowerStatus; | 335 | ps = new PowerStatus; |
336 | pa = new DesktopPowerAlerter( 0 ); | 336 | pa = new DesktopPowerAlerter( 0 ); |
337 | 337 | ||
338 | channel = new QCopChannel( "QPE/Desktop", this ); | 338 | channel = new QCopChannel( "QPE/Desktop", this ); |
339 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 339 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
340 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 340 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
341 | 341 | ||
342 | channel = new QCopChannel( "QPE/System", this ); | 342 | channel = new QCopChannel( "QPE/System", this ); |
343 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 343 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
344 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 344 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
345 | 345 | ||
346 | m_screensaver = new QPEScreenSaver; | 346 | m_screensaver = new QPEScreenSaver; |
347 | 347 | ||
348 | m_screensaver-> setInterval ( -1 ); | 348 | m_screensaver-> setInterval ( -1 ); |
349 | QWSServer::setScreenSaver( m_screensaver ); | 349 | QWSServer::setScreenSaver( m_screensaver ); |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
353 | DesktopApplication::~DesktopApplication() | 353 | DesktopApplication::~DesktopApplication() |
354 | { | 354 | { |
355 | delete ps; | 355 | delete ps; |
356 | delete pa; | 356 | delete pa; |
357 | } | 357 | } |
358 | 358 | ||
359 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 359 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
360 | { | 360 | { |
361 | #ifdef Q_WS_QWS | 361 | #ifdef Q_WS_QWS |
362 | QDataStream stream( data, IO_ReadOnly ); | 362 | QDataStream stream( data, IO_ReadOnly ); |
363 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 363 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
364 | int k; | 364 | int k; |
365 | QString c, m; | 365 | QString c, m; |
366 | stream >> k; | 366 | stream >> k; |
367 | stream >> c; | 367 | stream >> c; |
368 | stream >> m; | 368 | stream >> m; |
369 | 369 | ||
370 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 370 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); |
371 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 371 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
372 | } | 372 | } |
373 | else if ( msg == "suspend()" ) { | 373 | else if ( msg == "suspend()" ) { |
374 | emit power(); | 374 | emit power(); |
375 | } | 375 | } |
376 | #endif | 376 | #endif |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 380 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
381 | { | 381 | { |
382 | #ifdef Q_WS_QWS | 382 | #ifdef Q_WS_QWS |
383 | QDataStream stream ( data, IO_ReadOnly ); | 383 | QDataStream stream ( data, IO_ReadOnly ); |
384 | 384 | ||
385 | if ( msg == "setScreenSaverInterval(int)" ) { | 385 | if ( msg == "setScreenSaverInterval(int)" ) { |
386 | int time; | 386 | int time; |
387 | stream >> time; | 387 | stream >> time; |
388 | m_screensaver-> setInterval( time ); | 388 | m_screensaver-> setInterval( time ); |
389 | } | 389 | } |
390 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 390 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
391 | int t1, t2, t3; | 391 | int t1, t2, t3; |
392 | stream >> t1 >> t2 >> t3; | 392 | stream >> t1 >> t2 >> t3; |
393 | m_screensaver-> setIntervals( t1, t2, t3 ); | 393 | m_screensaver-> setIntervals( t1, t2, t3 ); |
394 | } | 394 | } |
395 | else if ( msg == "setBacklight(int)" ) { | 395 | else if ( msg == "setBacklight(int)" ) { |
396 | int bright; | 396 | int bright; |
397 | stream >> bright; | 397 | stream >> bright; |
398 | m_screensaver-> setBacklight( bright ); | 398 | m_screensaver-> setBacklight( bright ); |
399 | } | 399 | } |
400 | else if ( msg == "setScreenSaverMode(int)" ) { | 400 | else if ( msg == "setScreenSaverMode(int)" ) { |
401 | int mode; | 401 | int mode; |
402 | stream >> mode; | 402 | stream >> mode; |
403 | m_screensaver-> setMode ( mode ); | 403 | m_screensaver-> setMode ( mode ); |
404 | } | 404 | } |
405 | #endif | 405 | #endif |
406 | } | 406 | } |
407 | 407 | ||
408 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 408 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
409 | 409 | ||
410 | #ifdef Q_WS_QWS | 410 | #ifdef Q_WS_QWS |
411 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 411 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
412 | { | 412 | { |
413 | qpedesktop->checkMemory(); | 413 | qpedesktop->checkMemory(); |
414 | 414 | ||
415 | if ( e->type == QWSEvent::Key ) { | 415 | if ( e->type == QWSEvent::Key ) { |
416 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 416 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
417 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 417 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
418 | return TRUE; | 418 | return TRUE; |
419 | bool press = ke->simpleData.is_press; | 419 | bool press = ke->simpleData.is_press; |
420 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 420 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
421 | 421 | ||
422 | /* | 422 | /* |
423 | app that registers key/message to be sent back to the app, when it doesn't have focus, | 423 | app that registers key/message to be sent back to the app, when it doesn't have focus, |
424 | when user presses key, unless keyboard has been requested from app. | 424 | when user presses key, unless keyboard has been requested from app. |
425 | will not send multiple repeats if user holds key | 425 | will not send multiple repeats if user holds key |
426 | i.e. one shot | 426 | i.e. one shot |
427 | */ | 427 | */ |
428 | if ( !keyRegisterList.isEmpty() ) { | 428 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { |
429 | KeyRegisterList::Iterator it; | 429 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); |
430 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 430 | KeyRegisterList::Iterator it; |
431 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press ) { | 431 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
432 | if ( press ) | 432 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { |
433 | qDebug( "press" ); | 433 | if ( press ) |
434 | else | 434 | qDebug( "press" ); |
435 | qDebug( "release" ); | 435 | else |
436 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); | 436 | qDebug( "release" ); |
437 | } | 437 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); |
438 | } | 438 | } |
439 | } | 439 | } |
440 | 440 | } | |
441 | if ( !keyboardGrabbed() ) { | 441 | |
442 | if ( ke->simpleData.keycode == Key_F9 ) { | 442 | if ( !keyboardGrabbed() ) { |
443 | if ( press ) | 443 | if ( ke->simpleData.keycode == Key_F9 ) { |
444 | emit datebook(); | 444 | if ( press ) |
445 | return TRUE; | 445 | emit datebook(); |
446 | } | 446 | return TRUE; |
447 | if ( ke->simpleData.keycode == Key_F10 ) { | 447 | } |
448 | if ( !press && cardSendTimer ) { | 448 | if ( ke->simpleData.keycode == Key_F10 ) { |
449 | emit contacts(); | 449 | if ( !press && cardSendTimer ) { |
450 | delete cardSendTimer; | 450 | emit contacts(); |
451 | } | 451 | delete cardSendTimer; |
452 | else if ( press ) { | 452 | } |
453 | cardSendTimer = new QTimer(); | 453 | else if ( press ) { |
454 | cardSendTimer->start( 2000, TRUE ); | 454 | cardSendTimer = new QTimer(); |
455 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 455 | cardSendTimer->start( 2000, TRUE ); |
456 | } | 456 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
457 | return TRUE; | 457 | } |
458 | } | 458 | return TRUE; |
459 | /* menu key now opens application menu/toolbar | 459 | } |
460 | if ( ke->simpleData.keycode == Key_F11 ) { | 460 | /* menu key now opens application menu/toolbar |
461 | if ( press ) emit menu(); | 461 | if ( ke->simpleData.keycode == Key_F11 ) { |
462 | return TRUE; | 462 | if ( press ) emit menu(); |
463 | } | 463 | return TRUE; |
464 | */ | 464 | } |
465 | if ( ke->simpleData.keycode == Key_F12 ) { | 465 | */ |
466 | while ( activePopupWidget() ) | 466 | if ( ke->simpleData.keycode == Key_F12 ) { |
467 | activePopupWidget() ->close(); | 467 | while ( activePopupWidget() ) |
468 | if ( press ) | 468 | activePopupWidget() ->close(); |
469 | emit launch(); | 469 | if ( press ) |
470 | return TRUE; | 470 | emit launch(); |
471 | } | 471 | return TRUE; |
472 | if ( ke->simpleData.keycode == Key_F13 ) { | 472 | } |
473 | if ( press ) | 473 | if ( ke->simpleData.keycode == Key_F13 ) { |
474 | emit email(); | 474 | if ( press ) |
475 | return TRUE; | 475 | emit email(); |
476 | } | 476 | return TRUE; |
477 | } | 477 | } |
478 | 478 | } | |
479 | if ( ke->simpleData.keycode == Key_F34 ) { | 479 | |
480 | if ( press ) | 480 | if ( ke->simpleData.keycode == Key_F34 ) { |
481 | emit power(); | 481 | if ( press ) |
482 | return TRUE; | 482 | emit power(); |
483 | } | 483 | return TRUE; |
484 | // This was used for the iPAQ PowerButton | 484 | } |
485 | // See main.cpp for new KeyboardFilter | 485 | // This was used for the iPAQ PowerButton |
486 | // | 486 | // See main.cpp for new KeyboardFilter |
487 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 487 | // |
488 | // if ( press ) emit power(); | 488 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
489 | // return TRUE; | 489 | // if ( press ) emit power(); |
490 | // } | 490 | // return TRUE; |
491 | if ( ke->simpleData.keycode == Key_F35 ) { | 491 | // } |
492 | if ( press ) | 492 | if ( ke->simpleData.keycode == Key_F35 ) { |
493 | emit backlight(); | 493 | if ( press ) |
494 | return TRUE; | 494 | emit backlight(); |
495 | } | 495 | return TRUE; |
496 | if ( ke->simpleData.keycode == Key_F32 ) { | 496 | } |
497 | if ( press ) | 497 | if ( ke->simpleData.keycode == Key_F32 ) { |
498 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 498 | if ( press ) |
499 | return TRUE; | 499 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
500 | } | 500 | return TRUE; |
501 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 501 | } |
502 | if ( press ) | 502 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
503 | emit symbol(); | 503 | if ( press ) |
504 | return TRUE; | 504 | emit symbol(); |
505 | } | 505 | return TRUE; |
506 | if ( ke->simpleData.keycode == Key_NumLock ) { | 506 | } |
507 | if ( press ) | 507 | if ( ke->simpleData.keycode == Key_NumLock ) { |
508 | emit numLockStateToggle(); | 508 | if ( press ) |
509 | } | 509 | emit numLockStateToggle(); |
510 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 510 | } |
511 | if ( press ) | 511 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
512 | emit capsLockStateToggle(); | 512 | if ( press ) |
513 | } | 513 | emit capsLockStateToggle(); |
514 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) | 514 | } |
515 | qpedesktop->keyClick(); | 515 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) |
516 | } | 516 | qpedesktop->keyClick(); |
517 | else { | 517 | } |
518 | if ( e->type == QWSEvent::Mouse ) { | 518 | else { |
519 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 519 | if ( e->type == QWSEvent::Mouse ) { |
520 | static bool up = TRUE; | 520 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
521 | if ( me->simpleData.state & LeftButton ) { | 521 | static bool up = TRUE; |
522 | if ( up ) { | 522 | if ( me->simpleData.state & LeftButton ) { |
523 | up = FALSE; | 523 | if ( up ) { |
524 | qpedesktop->screenClick(); | 524 | up = FALSE; |
525 | } | 525 | qpedesktop->screenClick(); |
526 | } | 526 | } |
527 | else { | 527 | } |
528 | up = TRUE; | 528 | else { |
529 | } | 529 | up = TRUE; |
530 | } | 530 | } |
531 | } | 531 | } |
532 | 532 | } | |
533 | return QPEApplication::qwsEventFilter( e ); | 533 | |
534 | return QPEApplication::qwsEventFilter( e ); | ||
534 | } | 535 | } |
535 | #endif | 536 | #endif |
536 | 537 | ||
537 | void DesktopApplication::psTimeout() | 538 | void DesktopApplication::psTimeout() |
538 | { | 539 | { |
539 | qpedesktop->checkMemory(); // in case no events are being generated | 540 | qpedesktop->checkMemory(); // in case no events are being generated |
540 | 541 | ||
541 | *ps = PowerStatusManager::readStatus(); | 542 | *ps = PowerStatusManager::readStatus(); |
542 | 543 | ||
543 | if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 544 | if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
544 | pa->alert( tr( "Battery is running very low." ), 6 ); | 545 | pa->alert( tr( "Battery is running very low." ), 6 ); |
545 | } | 546 | } |
546 | 547 | ||
547 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 548 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
548 | pa->alert( tr( "Battery level is critical!\n" | 549 | pa->alert( tr( "Battery level is critical!\n" |
549 | "Keep power off until power restored!" ), 1 ); | 550 | "Keep power off until power restored!" ), 1 ); |
550 | } | 551 | } |
551 | 552 | ||
552 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 553 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
553 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 554 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
554 | } | 555 | } |
555 | } | 556 | } |
556 | 557 | ||
557 | 558 | ||
558 | void DesktopApplication::sendCard() | 559 | void DesktopApplication::sendCard() |
559 | { | 560 | { |
560 | delete cardSendTimer; | 561 | delete cardSendTimer; |
561 | cardSendTimer = 0; | 562 | cardSendTimer = 0; |
562 | QString card = getenv( "HOME" ); | 563 | QString card = getenv( "HOME" ); |
563 | card += "/Applications/addressbook/businesscard.vcf"; | 564 | card += "/Applications/addressbook/businesscard.vcf"; |
564 | 565 | ||
565 | if ( QFile::exists( card ) ) { | 566 | if ( QFile::exists( card ) ) { |
566 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); | 567 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); |
567 | QString mimetype = "text/x-vCard"; | 568 | QString mimetype = "text/x-vCard"; |
568 | e << tr( "business card" ) << card << mimetype; | 569 | e << tr( "business card" ) << card << mimetype; |
569 | } | 570 | } |
570 | } | 571 | } |
571 | 572 | ||
572 | #if defined(QPE_HAVE_MEMALERTER) | 573 | #if defined(QPE_HAVE_MEMALERTER) |
573 | QPE_MEMALERTER_IMPL | 574 | QPE_MEMALERTER_IMPL |
574 | #endif | 575 | #endif |
575 | 576 | ||
576 | //=========================================================================== | 577 | //=========================================================================== |
577 | 578 | ||
578 | Desktop::Desktop() : | 579 | Desktop::Desktop() : |
579 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 580 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
580 | qcopBridge( 0 ), | 581 | qcopBridge( 0 ), |
581 | transferServer( 0 ), | 582 | transferServer( 0 ), |
582 | packageSlave( 0 ) | 583 | packageSlave( 0 ) |
583 | { | 584 | { |
584 | qpedesktop = this; | 585 | qpedesktop = this; |
585 | 586 | ||
586 | // bg = new Info( this ); | 587 | // bg = new Info( this ); |
587 | tb = new TaskBar; | 588 | tb = new TaskBar; |
588 | 589 | ||
589 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 590 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
590 | 591 | ||
591 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 592 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
592 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 593 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
593 | 594 | ||
594 | int displayw = qApp->desktop() ->width(); | 595 | int displayw = qApp->desktop() ->width(); |
595 | int displayh = qApp->desktop() ->height(); | 596 | int displayh = qApp->desktop() ->height(); |
596 | 597 | ||
597 | 598 | ||
598 | QSize sz = tb->sizeHint(); | 599 | QSize sz = tb->sizeHint(); |
599 | 600 | ||
600 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 601 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
601 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 602 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
602 | 603 | ||
603 | tb->show(); | 604 | tb->show(); |
604 | launcher->showMaximized(); | 605 | launcher->showMaximized(); |
605 | launcher->show(); | 606 | launcher->show(); |
606 | launcher->raise(); | 607 | launcher->raise(); |
607 | #if defined(QPE_HAVE_MEMALERTER) | 608 | #if defined(QPE_HAVE_MEMALERTER) |
608 | 609 | ||
609 | initMemalerter(); | 610 | initMemalerter(); |
610 | #endif | 611 | #endif |
611 | // start services | 612 | // start services |
612 | startTransferServer(); | 613 | startTransferServer(); |
613 | ( void ) new IrServer( this ); | 614 | ( void ) new IrServer( this ); |
614 | rereadVolumes(); | 615 | rereadVolumes(); |
615 | 616 | ||
616 | packageSlave = new PackageSlave( this ); | 617 | packageSlave = new PackageSlave( this ); |
617 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); | 618 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); |
618 | 619 | ||
619 | qApp->installEventFilter( this ); | 620 | qApp->installEventFilter( this ); |
620 | } | 621 | } |
621 | 622 | ||
622 | void Desktop::show() | 623 | void Desktop::show() |
623 | { | 624 | { |
624 | login( TRUE ); | 625 | login( TRUE ); |
625 | QWidget::show(); | 626 | QWidget::show(); |
626 | } | 627 | } |
627 | 628 | ||
628 | Desktop::~Desktop() | 629 | Desktop::~Desktop() |
629 | { | 630 | { |
630 | delete launcher; | 631 | delete launcher; |
631 | delete tb; | 632 | delete tb; |
632 | delete qcopBridge; | 633 | delete qcopBridge; |
633 | delete transferServer; | 634 | delete transferServer; |
634 | } | 635 | } |
635 | 636 | ||
636 | bool Desktop::recoverMemory() | 637 | bool Desktop::recoverMemory() |
637 | { | 638 | { |
638 | return tb->recoverMemory(); | 639 | return tb->recoverMemory(); |
639 | } | 640 | } |
640 | 641 | ||
641 | void Desktop::checkMemory() | 642 | void Desktop::checkMemory() |
642 | { | 643 | { |
643 | #if defined(QPE_HAVE_MEMALERTER) | 644 | #if defined(QPE_HAVE_MEMALERTER) |
644 | static bool ignoreNormal = FALSE; | 645 | static bool ignoreNormal = FALSE; |
645 | static bool existingMessage = FALSE; | 646 | static bool existingMessage = FALSE; |
646 | 647 | ||
647 | if ( existingMessage ) | 648 | if ( existingMessage ) |
648 | return ; // don't show a second message while still on first | 649 | return ; // don't show a second message while still on first |
649 | 650 | ||
650 | existingMessage = TRUE; | 651 | existingMessage = TRUE; |
651 | switch ( memstate ) { | 652 | switch ( memstate ) { |
652 | case Unknown: | 653 | case Unknown: |
653 | break; | 654 | break; |
654 | case Low: | 655 | case Low: |
655 | memstate = Unknown; | 656 | memstate = Unknown; |
656 | if ( recoverMemory() ) | 657 | if ( recoverMemory() ) |
657 | ignoreNormal = TRUE; | 658 | ignoreNormal = TRUE; |
658 | else | 659 | else |
659 | QMessageBox::warning( 0 , "Memory Status", | 660 | QMessageBox::warning( 0 , "Memory Status", |
660 | "The memory smacks of shortage. \n" | 661 | "The memory smacks of shortage. \n" |
661 | "Please save data. " ); | 662 | "Please save data. " ); |
662 | break; | 663 | break; |
663 | case Normal: | 664 | case Normal: |
664 | memstate = Unknown; | 665 | memstate = Unknown; |
665 | if ( ignoreNormal ) | 666 | if ( ignoreNormal ) |
666 | ignoreNormal = FALSE; | 667 | ignoreNormal = FALSE; |
667 | else | 668 | else |
668 | QMessageBox::information ( 0 , "Memory Status", | 669 | QMessageBox::information ( 0 , "Memory Status", |
669 | "There is enough memory again." ); | 670 | "There is enough memory again." ); |
670 | break; | 671 | break; |
671 | case VeryLow: | 672 | case VeryLow: |
672 | memstate = Unknown; | 673 | memstate = Unknown; |
673 | QMessageBox::critical( 0 , "Memory Status", | 674 | QMessageBox::critical( 0 , "Memory Status", |
674 | "The memory is very low. \n" | 675 | "The memory is very low. \n" |
675 | "Please end this application \n" | 676 | "Please end this application \n" |
676 | "immediately." ); | 677 | "immediately." ); |
677 | recoverMemory(); | 678 | recoverMemory(); |
678 | } | 679 | } |
679 | existingMessage = FALSE; | 680 | existingMessage = FALSE; |
680 | #endif | 681 | #endif |
681 | } | 682 | } |
682 | 683 | ||
683 | static bool isVisibleWindow( int wid ) | 684 | static bool isVisibleWindow( int wid ) |
684 | { | 685 | { |
685 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 686 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
686 | QWSWindow* w; | 687 | QWSWindow* w; |
687 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 688 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
688 | if ( w->winId() == wid ) | 689 | if ( w->winId() == wid ) |
689 | return !w->isFullyObscured(); | 690 | return !w->isFullyObscured(); |
690 | } | 691 | } |
691 | return FALSE; | 692 | return FALSE; |
692 | } | 693 | } |
693 | 694 | ||
694 | static bool hasVisibleWindow( const QString& clientname ) | 695 | static bool hasVisibleWindow( const QString& clientname ) |
695 | { | 696 | { |
696 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 697 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
697 | QWSWindow* w; | 698 | QWSWindow* w; |
698 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 699 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
699 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 700 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
700 | return TRUE; | 701 | return TRUE; |
701 | } | 702 | } |
702 | return FALSE; | 703 | return FALSE; |
703 | } | 704 | } |
704 | 705 | ||
705 | void Desktop::raiseLauncher() | 706 | void Desktop::raiseLauncher() |
706 | { | 707 | { |
707 | Config cfg( "qpe" ); //F12 'Home' | 708 | Config cfg( "qpe" ); //F12 'Home' |
708 | cfg.setGroup( "AppsKey" ); | 709 | cfg.setGroup( "AppsKey" ); |
709 | QString tempItem; | 710 | QString tempItem; |
710 | tempItem = cfg.readEntry( "Middle", "Home" ); | 711 | tempItem = cfg.readEntry( "Middle", "Home" ); |
711 | if ( tempItem == "Home" || tempItem.isEmpty() ) { | 712 | if ( tempItem == "Home" || tempItem.isEmpty() ) { |
712 | if ( isVisibleWindow( launcher->winId() ) ) | 713 | if ( isVisibleWindow( launcher->winId() ) ) |
713 | launcher->nextView(); | 714 | launcher->nextView(); |
714 | else | 715 | else |
715 | launcher->raise(); | 716 | launcher->raise(); |
716 | } | 717 | } |
717 | else { | 718 | else { |
718 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 719 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
719 | e << tempItem; | 720 | e << tempItem; |
720 | } | 721 | } |
721 | } | 722 | } |
722 | 723 | ||
723 | void Desktop::executeOrModify( const QString& appLnkFile ) | 724 | void Desktop::executeOrModify( const QString& appLnkFile ) |
724 | { | 725 | { |
725 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 726 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
726 | if ( lnk.isValid() ) { | 727 | if ( lnk.isValid() ) { |
727 | QCString app = lnk.exec().utf8(); | 728 | QCString app = lnk.exec().utf8(); |
728 | Global::terminateBuiltin( "calibrate" ); | 729 | Global::terminateBuiltin( "calibrate" ); |
729 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 730 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
730 | //MRUList::addTask( &lnk ); | 731 | // MRUList::addTask( &lnk ); |
731 | if ( hasVisibleWindow( app ) ) | 732 | if ( hasVisibleWindow( app ) ) |
732 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 733 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
733 | else | 734 | else |
734 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 735 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
735 | } | 736 | } |
736 | else { | 737 | else { |
737 | lnk.execute(); | 738 | lnk.execute(); |
738 | } | 739 | } |
739 | } | 740 | } |
740 | } | 741 | } |
741 | 742 | ||
742 | void Desktop::raiseDatebook() | 743 | void Desktop::raiseDatebook() |
743 | { | 744 | { |
744 | Config cfg( "qpe" ); //F9 'Activity' | 745 | Config cfg( "qpe" ); //F9 'Activity' |
745 | cfg.setGroup( "AppsKey" ); | 746 | cfg.setGroup( "AppsKey" ); |
746 | QString tempItem; | 747 | QString tempItem; |
747 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); | 748 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); |
748 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { | 749 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { |
749 | tempItem = "datebook"; | 750 | tempItem = "datebook"; |
750 | } | 751 | } |
751 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 752 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
752 | e << tempItem; | 753 | e << tempItem; |
753 | } | 754 | } |
754 | 755 | ||
755 | void Desktop::raiseContacts() | 756 | void Desktop::raiseContacts() |
756 | { | 757 | { |
757 | Config cfg( "qpe" ); //F10, 'Contacts' | 758 | Config cfg( "qpe" ); //F10, 'Contacts' |
758 | cfg.setGroup( "AppsKey" ); | 759 | cfg.setGroup( "AppsKey" ); |
759 | QString tempItem; | 760 | QString tempItem; |
760 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); | 761 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); |
761 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { | 762 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { |
762 | tempItem = "addressbook"; | 763 | tempItem = "addressbook"; |
763 | } | 764 | } |
764 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 765 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
765 | e << tempItem; | 766 | e << tempItem; |
766 | } | 767 | } |
767 | 768 | ||
768 | void Desktop::raiseMenu() | 769 | void Desktop::raiseMenu() |
769 | { | 770 | { |
770 | Config cfg( "qpe" ); //F11, 'Menu | 771 | Config cfg( "qpe" ); //F11, 'Menu |
771 | cfg.setGroup( "AppsKey" ); | 772 | cfg.setGroup( "AppsKey" ); |
772 | QString tempItem; | 773 | QString tempItem; |
773 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); | 774 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); |
774 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { | 775 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { |
775 | Global::terminateBuiltin( "calibrate" ); | 776 | Global::terminateBuiltin( "calibrate" ); |
776 | tb->startMenu() ->launch(); | 777 | tb->startMenu() ->launch(); |
777 | } | 778 | } |
778 | else { | 779 | else { |
779 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 780 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
780 | e << tempItem; | 781 | e << tempItem; |
781 | } | 782 | } |
782 | } | 783 | } |
783 | 784 | ||
784 | void Desktop::raiseEmail() | 785 | void Desktop::raiseEmail() |
785 | { | 786 | { |
786 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 | 787 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 |
787 | cfg.setGroup( "AppsKey" ); | 788 | cfg.setGroup( "AppsKey" ); |
788 | QString tempItem; | 789 | QString tempItem; |
789 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); | 790 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); |
790 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { | 791 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { |
791 | tempItem = "mail"; | 792 | tempItem = "mail"; |
792 | } | 793 | } |
793 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 794 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
794 | e << tempItem; | 795 | e << tempItem; |
795 | } | 796 | } |
796 | 797 | ||
797 | // autoStarts apps on resume and start | 798 | // autoStarts apps on resume and start |
798 | void Desktop::execAutoStart() | 799 | void Desktop::execAutoStart() |
799 | { | 800 | { |
800 | QString appName; | 801 | QString appName; |
801 | int delay; | 802 | int delay; |
802 | QDateTime now = QDateTime::currentDateTime(); | 803 | QDateTime now = QDateTime::currentDateTime(); |
803 | Config cfg( "autostart" ); | 804 | Config cfg( "autostart" ); |
804 | cfg.setGroup( "AutoStart" ); | 805 | cfg.setGroup( "AutoStart" ); |
805 | appName = cfg.readEntry( "Apps", "" ); | 806 | appName = cfg.readEntry( "Apps", "" ); |
806 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 807 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
807 | // If the time between suspend and resume was longer then the | 808 | // If the time between suspend and resume was longer then the |
808 | // value saved as delay, start the app | 809 | // value saved as delay, start the app |
809 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 810 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
810 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 811 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
811 | e << QString( appName ); | 812 | e << QString( appName ); |
812 | } | 813 | } |
813 | } | 814 | } |
814 | 815 | ||
815 | #if defined(QPE_HAVE_TOGGLELIGHT) | 816 | #if defined(QPE_HAVE_TOGGLELIGHT) |
816 | #include <qpe/config.h> | 817 | #include <qpe/config.h> |
817 | 818 | ||
818 | #include <sys/ioctl.h> | 819 | #include <sys/ioctl.h> |
819 | #include <sys/types.h> | 820 | #include <sys/types.h> |
820 | #include <fcntl.h> | 821 | #include <fcntl.h> |
821 | #include <unistd.h> | 822 | #include <unistd.h> |
822 | #include <errno.h> | 823 | #include <errno.h> |
823 | #include <linux/ioctl.h> | 824 | #include <linux/ioctl.h> |
824 | #include <time.h> | 825 | #include <time.h> |
825 | #endif | 826 | #endif |
826 | 827 | ||
827 | 828 | ||
828 | void Desktop::togglePower() | 829 | void Desktop::togglePower() |
829 | { | 830 | { |
830 | static bool excllock = false; | 831 | static bool excllock = false; |
831 | 832 | ||
832 | if ( excllock ) | 833 | if ( excllock ) |
833 | return ; | 834 | return ; |
834 | 835 | ||
835 | excllock = true; | 836 | excllock = true; |
836 | 837 | ||
837 | bool wasloggedin = loggedin; | 838 | bool wasloggedin = loggedin; |
838 | loggedin = 0; | 839 | loggedin = 0; |
839 | suspendTime = QDateTime::currentDateTime(); | 840 | suspendTime = QDateTime::currentDateTime(); |
840 | 841 | ||
841 | ODevice::inst ( ) -> suspend ( ); | 842 | ODevice::inst ( ) -> suspend ( ); |
842 | 843 | ||
843 | QWSServer::screenSaverActivate ( false ); | 844 | QWSServer::screenSaverActivate ( false ); |
844 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 845 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
845 | 846 | ||
846 | { | 847 | { |
847 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 848 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
848 | } | 849 | } |
849 | 850 | ||
850 | if ( wasloggedin ) | 851 | if ( wasloggedin ) |
851 | login( TRUE ); | 852 | login( TRUE ); |
852 | 853 | ||
853 | execAutoStart(); | 854 | execAutoStart(); |
854 | //qcopBridge->closeOpenConnections(); | 855 | //qcopBridge->closeOpenConnections(); |
855 | 856 | ||
856 | excllock = false; | 857 | excllock = false; |
857 | } | 858 | } |
858 | 859 | ||
859 | void Desktop::toggleLight() | 860 | void Desktop::toggleLight() |
860 | { | 861 | { |
861 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 862 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
862 | e << -2; // toggle | 863 | e << -2; // toggle |
863 | } | 864 | } |
864 | 865 | ||
865 | void Desktop::toggleSymbolInput() | 866 | void Desktop::toggleSymbolInput() |
866 | { | 867 | { |
867 | tb->toggleSymbolInput(); | 868 | tb->toggleSymbolInput(); |
868 | } | 869 | } |
869 | 870 | ||
870 | void Desktop::toggleNumLockState() | 871 | void Desktop::toggleNumLockState() |
871 | { | 872 | { |
872 | tb->toggleNumLockState(); | 873 | tb->toggleNumLockState(); |
873 | } | 874 | } |
874 | 875 | ||
875 | void Desktop::toggleCapsLockState() | 876 | void Desktop::toggleCapsLockState() |
876 | { | 877 | { |
877 | tb->toggleCapsLockState(); | 878 | tb->toggleCapsLockState(); |
878 | } | 879 | } |
879 | 880 | ||
880 | void Desktop::styleChange( QStyle &s ) | 881 | void Desktop::styleChange( QStyle &s ) |
881 | { | 882 | { |
882 | QWidget::styleChange( s ); | 883 | QWidget::styleChange( s ); |
883 | int displayw = qApp->desktop() ->width(); | 884 | int displayw = qApp->desktop() ->width(); |
884 | int displayh = qApp->desktop() ->height(); | 885 | int displayh = qApp->desktop() ->height(); |
885 | 886 | ||
886 | QSize sz = tb->sizeHint(); | 887 | QSize sz = tb->sizeHint(); |
887 | 888 | ||
888 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 889 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
889 | } | 890 | } |
890 | 891 | ||
891 | void DesktopApplication::shutdown() | 892 | void DesktopApplication::shutdown() |
892 | { | 893 | { |
893 | if ( type() != GuiServer ) | 894 | if ( type() != GuiServer ) |
894 | return ; | 895 | return ; |
895 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 896 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
896 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), | 897 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), |
897 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); | 898 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); |
898 | sd->showMaximized(); | 899 | sd->showMaximized(); |
899 | } | 900 | } |
900 | 901 | ||
901 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 902 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
902 | { | 903 | { |
903 | switch ( t ) { | 904 | switch ( t ) { |
904 | case ShutdownImpl::ShutdownSystem: | 905 | case ShutdownImpl::ShutdownSystem: |
905 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); | 906 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); |
906 | break; | 907 | break; |
907 | case ShutdownImpl::RebootSystem: | 908 | case ShutdownImpl::RebootSystem: |
908 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); | 909 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); |
909 | break; | 910 | break; |
910 | case ShutdownImpl::RestartDesktop: | 911 | case ShutdownImpl::RestartDesktop: |
911 | restart(); | 912 | restart(); |
912 | break; | 913 | break; |
913 | case ShutdownImpl::TerminateDesktop: | 914 | case ShutdownImpl::TerminateDesktop: |
914 | prepareForTermination( FALSE ); | 915 | prepareForTermination( FALSE ); |
915 | 916 | ||
916 | // This is a workaround for a Qt bug | 917 | // This is a workaround for a Qt bug |
917 | // clipboard applet has to stop its poll timer, or Qt/E | 918 | // clipboard applet has to stop its poll timer, or Qt/E |
918 | // will hang on quit() right before it emits aboutToQuit() | 919 | // will hang on quit() right before it emits aboutToQuit() |
919 | emit aboutToQuit ( ); | 920 | emit aboutToQuit ( ); |
920 | 921 | ||
921 | quit(); | 922 | quit(); |
922 | break; | 923 | break; |
923 | } | 924 | } |
924 | } | 925 | } |
925 | 926 | ||
926 | void DesktopApplication::restart() | 927 | void DesktopApplication::restart() |
927 | { | 928 | { |
928 | prepareForTermination( TRUE ); | 929 | prepareForTermination( TRUE ); |
929 | 930 | ||
930 | #ifdef Q_WS_QWS | 931 | #ifdef Q_WS_QWS |
931 | 932 | ||
932 | for ( int fd = 3; fd < 100; fd++ ) | 933 | for ( int fd = 3; fd < 100; fd++ ) |
933 | close( fd ); | 934 | close( fd ); |
934 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 935 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
935 | 936 | ||
936 | execl( "/sbin/init", "qpe", 0 ); | 937 | execl( "/sbin/init", "qpe", 0 ); |
937 | #elif defined(QT_QWS_CASSIOPEIA) | 938 | #elif defined(QT_QWS_CASSIOPEIA) |
938 | 939 | ||
939 | execl( "/bin/sh", "sh", 0 ); | 940 | execl( "/bin/sh", "sh", 0 ); |
940 | #else | 941 | #else |
941 | 942 | ||
942 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | 943 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); |
943 | #endif | 944 | #endif |
944 | 945 | ||
945 | exit( 1 ); | 946 | exit( 1 ); |
946 | #endif | 947 | #endif |
947 | } | 948 | } |
948 | 949 | ||
949 | void Desktop::startTransferServer() | 950 | void Desktop::startTransferServer() |
950 | { | 951 | { |
951 | // start qcop bridge server | 952 | // start qcop bridge server |
952 | qcopBridge = new QCopBridge( 4243 ); | 953 | qcopBridge = new QCopBridge( 4243 ); |
953 | if ( !qcopBridge->ok() ) { | 954 | if ( !qcopBridge->ok() ) { |
954 | delete qcopBridge; | 955 | delete qcopBridge; |
955 | qcopBridge = 0; | 956 | qcopBridge = 0; |
956 | } | 957 | } |
957 | // start transfer server | 958 | // start transfer server |
958 | transferServer = new TransferServer( 4242 ); | 959 | transferServer = new TransferServer( 4242 ); |
959 | if ( !transferServer->ok() ) { | 960 | if ( !transferServer->ok() ) { |
960 | delete transferServer; | 961 | delete transferServer; |
961 | transferServer = 0; | 962 | transferServer = 0; |
962 | } | 963 | } |
963 | if ( !transferServer || !qcopBridge ) | 964 | if ( !transferServer || !qcopBridge ) |
964 | startTimer( 2000 ); | 965 | startTimer( 2000 ); |
965 | } | 966 | } |
966 | 967 | ||
967 | void Desktop::timerEvent( QTimerEvent *e ) | 968 | void Desktop::timerEvent( QTimerEvent *e ) |
968 | { | 969 | { |
969 | killTimer( e->timerId() ); | 970 | killTimer( e->timerId() ); |
970 | startTransferServer(); | 971 | startTransferServer(); |
971 | } | 972 | } |
972 | 973 | ||
973 | void Desktop::terminateServers() | 974 | void Desktop::terminateServers() |
974 | { | 975 | { |
975 | delete transferServer; | 976 | delete transferServer; |
976 | delete qcopBridge; | 977 | delete qcopBridge; |
977 | transferServer = 0; | 978 | transferServer = 0; |
978 | qcopBridge = 0; | 979 | qcopBridge = 0; |
979 | } | 980 | } |
980 | 981 | ||
981 | void Desktop::rereadVolumes() | 982 | void Desktop::rereadVolumes() |
982 | { | 983 | { |
983 | Config cfg( "qpe" ); | 984 | Config cfg( "qpe" ); |
984 | cfg.setGroup( "Volume" ); | 985 | cfg.setGroup( "Volume" ); |
985 | touchclick = cfg.readBoolEntry( "TouchSound" ); | 986 | touchclick = cfg.readBoolEntry( "TouchSound" ); |
986 | keyclick = cfg.readBoolEntry( "KeySound" ); | 987 | keyclick = cfg.readBoolEntry( "KeySound" ); |
987 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); | 988 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); |
988 | } | 989 | } |
989 | 990 | ||
990 | void Desktop::keyClick() | 991 | void Desktop::keyClick() |
991 | { | 992 | { |
992 | if ( keyclick ) | 993 | if ( keyclick ) |
993 | ODevice::inst ( ) -> keySound ( ); | 994 | ODevice::inst ( ) -> keySound ( ); |
994 | } | 995 | } |
995 | 996 | ||
996 | void Desktop::screenClick() | 997 | void Desktop::screenClick() |
997 | { | 998 | { |
998 | if ( touchclick ) | 999 | if ( touchclick ) |
999 | ODevice::inst ( ) -> touchSound ( ); | 1000 | ODevice::inst ( ) -> touchSound ( ); |
1000 | } | 1001 | } |
1001 | 1002 | ||
1002 | void Desktop::soundAlarm() | 1003 | void Desktop::soundAlarm() |
1003 | { | 1004 | { |
1004 | if ( qpedesktop-> alarmsound ) | 1005 | if ( qpedesktop-> alarmsound ) |
1005 | ODevice::inst ( ) -> alarmSound ( ); | 1006 | ODevice::inst ( ) -> alarmSound ( ); |
1006 | } | 1007 | } |
1007 | 1008 | ||
1008 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | 1009 | bool Desktop::eventFilter( QObject *, QEvent *ev ) |
1009 | { | 1010 | { |
1010 | if ( ev-> type ( ) == QEvent::KeyPress ) { | 1011 | if ( ev-> type ( ) == QEvent::KeyPress ) { |
1011 | QKeyEvent * ke = ( QKeyEvent * ) ev; | 1012 | QKeyEvent * ke = ( QKeyEvent * ) ev; |
1012 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key | 1013 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key |
1013 | QWidget * active = qApp-> activeWindow ( ); | 1014 | QWidget * active = qApp-> activeWindow ( ); |
1014 | 1015 | ||
1015 | if ( active && active-> isPopup ( ) ) | 1016 | if ( active && active-> isPopup ( ) ) |
1016 | active->close(); | 1017 | active->close(); |
1017 | 1018 | ||
1018 | /* | 1019 | /* |
1019 | * On iPAQ 38xx that key is not the "menu key" but the mail key | 1020 | * On iPAQ 38xx that key is not the "menu key" but the mail key |
1020 | * To not confuse the users, make it launch the mail app on 38xx | 1021 | * To not confuse the users, make it launch the mail app on 38xx |
1021 | */ | 1022 | */ |
1022 | if ( ODevice::inst() ->model() == OMODEL_iPAQ_H38xx ) { | 1023 | if ( ODevice::inst() ->model() == OMODEL_iPAQ_H38xx ) { |
1023 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 1024 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
1024 | e << QString( "mail" ); | 1025 | e << QString( "mail" ); |
1025 | return true; | 1026 | return true; |
1026 | } | 1027 | } |
1027 | else { | 1028 | else { |
1028 | raiseMenu ( ); | 1029 | raiseMenu ( ); |
1029 | return true; | 1030 | return true; |
1030 | } | 1031 | } |
1031 | } | 1032 | } |
1032 | } | 1033 | } |
1033 | return false; | 1034 | return false; |
1034 | } | 1035 | } |