author | sandman <sandman> | 2002-09-30 23:09:04 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-30 23:09:04 (UTC) |
commit | 61fdbd044d40cb3c93eab5a1ba262964a9413c66 (patch) (unidiff) | |
tree | db5cadc832dc402b53fc910b1d0ba3c7f26474ee | |
parent | 37a8266f4a32d07a27d453897febf1f25963a4d0 (diff) | |
download | opie-61fdbd044d40cb3c93eab5a1ba262964a9413c66.zip opie-61fdbd044d40cb3c93eab5a1ba262964a9413c66.tar.gz opie-61fdbd044d40cb3c93eab5a1ba262964a9413c66.tar.bz2 |
Removed the button mapping for H3800, since this is now handled in the
ODevice iPAQ keyfilter
-rw-r--r-- | core/launcher/desktop.cpp | 40 | ||||
-rw-r--r-- | core/launcher/desktop.h | 1 |
2 files changed, 10 insertions, 31 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 4640a12..68949e6 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,244 +1,246 @@ | |||
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 | using namespace Opie; | ||
62 | |||
61 | class QCopKeyRegister | 63 | class QCopKeyRegister |
62 | { | 64 | { |
63 | public: | 65 | public: |
64 | QCopKeyRegister() : keyCode( 0 ) | 66 | QCopKeyRegister() : keyCode( 0 ) |
65 | { } | 67 | { } |
66 | QCopKeyRegister( int k, const QString &c, const QString &m ) | 68 | QCopKeyRegister( int k, const QString &c, const QString &m ) |
67 | : keyCode( k ), channel( c ), message( m ) | 69 | : keyCode( k ), channel( c ), message( m ) |
68 | { } | 70 | { } |
69 | 71 | ||
70 | int getKeyCode() const | 72 | int getKeyCode() const |
71 | { | 73 | { |
72 | return keyCode; | 74 | return keyCode; |
73 | } | 75 | } |
74 | QString getChannel() const | 76 | QString getChannel() const |
75 | { | 77 | { |
76 | return channel; | 78 | return channel; |
77 | } | 79 | } |
78 | QString getMessage() const | 80 | QString getMessage() const |
79 | { | 81 | { |
80 | return message; | 82 | return message; |
81 | } | 83 | } |
82 | 84 | ||
83 | private: | 85 | private: |
84 | int keyCode; | 86 | int keyCode; |
85 | QString channel, message; | 87 | QString channel, message; |
86 | }; | 88 | }; |
87 | 89 | ||
88 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 90 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
89 | KeyRegisterList keyRegisterList; | 91 | KeyRegisterList keyRegisterList; |
90 | 92 | ||
91 | static Desktop* qpedesktop = 0; | 93 | static Desktop* qpedesktop = 0; |
92 | static int loggedin = 0; | 94 | static int loggedin = 0; |
93 | static void login( bool at_poweron ) | 95 | static void login( bool at_poweron ) |
94 | { | 96 | { |
95 | if ( !loggedin ) { | 97 | if ( !loggedin ) { |
96 | Global::terminateBuiltin( "calibrate" ); | 98 | Global::terminateBuiltin( "calibrate" ); |
97 | Password::authenticate( at_poweron ); | 99 | Password::authenticate( at_poweron ); |
98 | loggedin = 1; | 100 | loggedin = 1; |
99 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 101 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
100 | } | 102 | } |
101 | } | 103 | } |
102 | 104 | ||
103 | bool Desktop::screenLocked() | 105 | bool Desktop::screenLocked() |
104 | { | 106 | { |
105 | return loggedin == 0; | 107 | return loggedin == 0; |
106 | } | 108 | } |
107 | 109 | ||
108 | /* | 110 | /* |
109 | Priority is number of alerts that are needed to pop up | 111 | Priority is number of alerts that are needed to pop up |
110 | alert. | 112 | alert. |
111 | */ | 113 | */ |
112 | class DesktopPowerAlerter : public QMessageBox | 114 | class DesktopPowerAlerter : public QMessageBox |
113 | { | 115 | { |
114 | public: | 116 | public: |
115 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 117 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
116 | : QMessageBox( tr( "Battery Status" ), "Low Battery", | 118 | : QMessageBox( tr( "Battery Status" ), "Low Battery", |
117 | QMessageBox::Critical, | 119 | QMessageBox::Critical, |
118 | QMessageBox::Ok | QMessageBox::Default, | 120 | QMessageBox::Ok | QMessageBox::Default, |
119 | QMessageBox::NoButton, QMessageBox::NoButton, | 121 | QMessageBox::NoButton, QMessageBox::NoButton, |
120 | parent, name, FALSE ) | 122 | parent, name, FALSE ) |
121 | { | 123 | { |
122 | currentPriority = INT_MAX; | 124 | currentPriority = INT_MAX; |
123 | alertCount = 0; | 125 | alertCount = 0; |
124 | } | 126 | } |
125 | 127 | ||
126 | void alert( const QString &text, int priority ); | 128 | void alert( const QString &text, int priority ); |
127 | void hideEvent( QHideEvent * ); | 129 | void hideEvent( QHideEvent * ); |
128 | private: | 130 | private: |
129 | int currentPriority; | 131 | int currentPriority; |
130 | int alertCount; | 132 | int alertCount; |
131 | }; | 133 | }; |
132 | 134 | ||
133 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 135 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
134 | { | 136 | { |
135 | alertCount++; | 137 | alertCount++; |
136 | if ( alertCount < priority ) | 138 | if ( alertCount < priority ) |
137 | return ; | 139 | return ; |
138 | if ( priority > currentPriority ) | 140 | if ( priority > currentPriority ) |
139 | return ; | 141 | return ; |
140 | currentPriority = priority; | 142 | currentPriority = priority; |
141 | setText( text ); | 143 | setText( text ); |
142 | show(); | 144 | show(); |
143 | } | 145 | } |
144 | 146 | ||
145 | 147 | ||
146 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 148 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
147 | { | 149 | { |
148 | QMessageBox::hideEvent( e ); | 150 | QMessageBox::hideEvent( e ); |
149 | alertCount = 0; | 151 | alertCount = 0; |
150 | currentPriority = INT_MAX; | 152 | currentPriority = INT_MAX; |
151 | } | 153 | } |
152 | 154 | ||
153 | 155 | ||
154 | class QPEScreenSaver : public QWSScreenSaver | 156 | class QPEScreenSaver : public QWSScreenSaver |
155 | { | 157 | { |
156 | private: | 158 | private: |
157 | int LcdOn; | 159 | int LcdOn; |
158 | 160 | ||
159 | public: | 161 | public: |
160 | QPEScreenSaver() | 162 | QPEScreenSaver() |
161 | { | 163 | { |
162 | m_disable_suspend = 100; | 164 | m_disable_suspend = 100; |
163 | m_enable_dim = false; | 165 | m_enable_dim = false; |
164 | m_enable_lightoff = false; | 166 | m_enable_lightoff = false; |
165 | m_enable_onlylcdoff = false; | 167 | m_enable_onlylcdoff = false; |
166 | 168 | ||
167 | m_lcd_status = true; | 169 | m_lcd_status = true; |
168 | 170 | ||
169 | m_backlight_bright = -1; | 171 | m_backlight_bright = -1; |
170 | m_backlight_forcedoff = false; | 172 | m_backlight_forcedoff = false; |
171 | 173 | ||
172 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 174 | // 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 ); | 175 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
174 | } | 176 | } |
175 | void restore() | 177 | void restore() |
176 | { | 178 | { |
177 | if ( !m_lcd_status ) // We must have turned it off | 179 | if ( !m_lcd_status ) // We must have turned it off |
178 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 180 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
179 | 181 | ||
180 | setBacklight ( -1 ); | 182 | setBacklight ( -3 ); |
181 | } | 183 | } |
182 | bool save( int level ) | 184 | bool save( int level ) |
183 | { | 185 | { |
184 | switch ( level ) { | 186 | switch ( level ) { |
185 | case 0: | 187 | case 0: |
186 | if ( m_disable_suspend > 0 && m_enable_dim ) { | 188 | if ( m_disable_suspend > 0 && m_enable_dim ) { |
187 | if ( backlight() > 1 ) | 189 | if ( backlight() > 1 ) |
188 | setBacklight( 1 ); // lowest non-off | 190 | setBacklight( 1 ); // lowest non-off |
189 | } | 191 | } |
190 | return true; | 192 | return true; |
191 | break; | 193 | break; |
192 | case 1: | 194 | case 1: |
193 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { | 195 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { |
194 | setBacklight( 0 ); // off | 196 | setBacklight( 0 ); // off |
195 | } | 197 | } |
196 | return true; | 198 | return true; |
197 | break; | 199 | break; |
198 | case 2: | 200 | case 2: |
199 | if ( m_enable_onlylcdoff ) { | 201 | if ( m_enable_onlylcdoff ) { |
200 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 202 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
201 | m_lcd_status = false; | 203 | m_lcd_status = false; |
202 | return true; | 204 | return true; |
203 | } | 205 | } |
204 | else // We're going to suspend the whole machine | 206 | else // We're going to suspend the whole machine |
205 | { | 207 | { |
206 | if ( ( m_disable_suspend > 2 ) && | 208 | if ( ( m_disable_suspend > 2 ) && |
207 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && | 209 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && |
208 | ( !Network::networkOnline ( ) ) ) { | 210 | ( !Network::networkOnline ( ) ) ) { |
209 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 211 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
210 | return true; | 212 | return true; |
211 | } | 213 | } |
212 | } | 214 | } |
213 | break; | 215 | break; |
214 | } | 216 | } |
215 | return false; | 217 | return false; |
216 | } | 218 | } |
217 | 219 | ||
218 | private: | 220 | private: |
219 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) | 221 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) |
220 | { | 222 | { |
221 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) | 223 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) |
222 | return 0; | 224 | return 0; |
223 | 225 | ||
224 | if ( interval < 0 ) { | 226 | if ( interval < 0 ) { |
225 | // Restore screen blanking and power saving state | 227 | // Restore screen blanking and power saving state |
226 | interval = config.readNumEntry( value, def ); | 228 | interval = config.readNumEntry( value, def ); |
227 | } | 229 | } |
228 | return interval; | 230 | return interval; |
229 | } | 231 | } |
230 | 232 | ||
231 | public: | 233 | public: |
232 | void setIntervals( int i1, int i2, int i3 ) | 234 | void setIntervals( int i1, int i2, int i3 ) |
233 | { | 235 | { |
234 | Config config( "qpe" ); | 236 | Config config( "qpe" ); |
235 | config.setGroup( "Screensaver" ); | 237 | config.setGroup( "Screensaver" ); |
236 | 238 | ||
237 | int v[ 4 ]; | 239 | int v[ 4 ]; |
238 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); | 240 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); |
239 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); | 241 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); |
240 | i3 = ssi( i3, config, "", "Interval", 60 ); | 242 | i3 = ssi( i3, config, "", "Interval", 60 ); |
241 | 243 | ||
242 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | 244 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); |
243 | 245 | ||
244 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 246 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
@@ -258,130 +260,135 @@ public: | |||
258 | void setInterval ( int interval ) | 260 | void setInterval ( int interval ) |
259 | { | 261 | { |
260 | setIntervals ( -1, -1, interval ); | 262 | setIntervals ( -1, -1, interval ); |
261 | } | 263 | } |
262 | 264 | ||
263 | void setMode ( int mode ) | 265 | void setMode ( int mode ) |
264 | { | 266 | { |
265 | if ( mode > m_disable_suspend ) | 267 | if ( mode > m_disable_suspend ) |
266 | setInterval( -1 ); | 268 | setInterval( -1 ); |
267 | m_disable_suspend = mode; | 269 | m_disable_suspend = mode; |
268 | } | 270 | } |
269 | 271 | ||
270 | int backlight ( ) | 272 | int backlight ( ) |
271 | { | 273 | { |
272 | if ( m_backlight_bright == -1 ) { | 274 | if ( m_backlight_bright == -1 ) { |
273 | // Read from config | 275 | // Read from config |
274 | Config config ( "qpe" ); | 276 | Config config ( "qpe" ); |
275 | config. setGroup ( "Screensaver" ); | 277 | config. setGroup ( "Screensaver" ); |
276 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); | 278 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); |
277 | } | 279 | } |
278 | return m_backlight_bright; | 280 | return m_backlight_bright; |
279 | } | 281 | } |
280 | 282 | ||
281 | void setBacklight ( int bright ) | 283 | void setBacklight ( int bright ) |
282 | { | 284 | { |
283 | if ( bright == -3 ) { | 285 | if ( bright == -3 ) { |
284 | // Forced on | 286 | // Forced on |
285 | m_backlight_forcedoff = false; | 287 | m_backlight_forcedoff = false; |
286 | bright = -1; | 288 | bright = -1; |
287 | } | 289 | } |
288 | if ( m_backlight_forcedoff && bright != -2 ) | 290 | if ( m_backlight_forcedoff && bright != -2 ) |
289 | return ; | 291 | return ; |
290 | if ( bright == -2 ) { | 292 | if ( bright == -2 ) { |
291 | // Toggle between off and on | 293 | // Toggle between off and on |
292 | bright = m_backlight_bright ? 0 : -1; | 294 | bright = m_backlight_bright ? 0 : -1; |
293 | m_backlight_forcedoff = !bright; | 295 | m_backlight_forcedoff = !bright; |
294 | } | 296 | } |
295 | 297 | ||
296 | m_backlight_bright = bright; | 298 | m_backlight_bright = bright; |
297 | 299 | ||
298 | bright = backlight ( ); | 300 | bright = backlight ( ); |
299 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 301 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); |
300 | 302 | ||
301 | m_backlight_bright = bright; | 303 | m_backlight_bright = bright; |
302 | } | 304 | } |
303 | 305 | ||
304 | private: | 306 | private: |
305 | int m_disable_suspend; | 307 | int m_disable_suspend; |
306 | bool m_enable_dim; | 308 | bool m_enable_dim; |
307 | bool m_enable_lightoff; | 309 | bool m_enable_lightoff; |
308 | bool m_enable_onlylcdoff; | 310 | bool m_enable_onlylcdoff; |
309 | 311 | ||
310 | bool m_lcd_status; | 312 | bool m_lcd_status; |
311 | 313 | ||
312 | int m_backlight_bright; | 314 | int m_backlight_bright; |
313 | bool m_backlight_forcedoff; | 315 | bool m_backlight_forcedoff; |
314 | }; | 316 | }; |
315 | 317 | ||
316 | 318 | ||
317 | void DesktopApplication::switchLCD ( bool on ) | 319 | void DesktopApplication::switchLCD ( bool on ) |
318 | { | 320 | { |
319 | if ( qApp ) { | 321 | if ( qApp ) { |
320 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 322 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
321 | 323 | ||
322 | if ( dapp-> m_screensaver ) | 324 | if ( dapp-> m_screensaver ) { |
323 | dapp-> m_screensaver-> setBacklight ( on ? -3 : -1 ); | 325 | if ( on ) |
326 | dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 ); | ||
327 | else | ||
328 | dapp-> m_screensaver-> save ( 1 ); | ||
329 | |||
330 | } | ||
324 | } | 331 | } |
325 | } | 332 | } |
326 | 333 | ||
327 | 334 | ||
328 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 335 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
329 | : QPEApplication( argc, argv, appType ) | 336 | : QPEApplication( argc, argv, appType ) |
330 | { | 337 | { |
331 | 338 | ||
332 | QTimer * t = new QTimer( this ); | 339 | QTimer * t = new QTimer( this ); |
333 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); | 340 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); |
334 | t->start( 10000 ); | 341 | t->start( 10000 ); |
335 | ps = new PowerStatus; | 342 | ps = new PowerStatus; |
336 | pa = new DesktopPowerAlerter( 0 ); | 343 | pa = new DesktopPowerAlerter( 0 ); |
337 | 344 | ||
338 | channel = new QCopChannel( "QPE/Desktop", this ); | 345 | channel = new QCopChannel( "QPE/Desktop", this ); |
339 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 346 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
340 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 347 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
341 | 348 | ||
342 | channel = new QCopChannel( "QPE/System", this ); | 349 | channel = new QCopChannel( "QPE/System", this ); |
343 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 350 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
344 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 351 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
345 | 352 | ||
346 | m_screensaver = new QPEScreenSaver; | 353 | m_screensaver = new QPEScreenSaver; |
347 | 354 | ||
348 | m_screensaver-> setInterval ( -1 ); | 355 | m_screensaver-> setInterval ( -1 ); |
349 | QWSServer::setScreenSaver( m_screensaver ); | 356 | QWSServer::setScreenSaver( m_screensaver ); |
350 | } | 357 | } |
351 | 358 | ||
352 | 359 | ||
353 | DesktopApplication::~DesktopApplication() | 360 | DesktopApplication::~DesktopApplication() |
354 | { | 361 | { |
355 | delete ps; | 362 | delete ps; |
356 | delete pa; | 363 | delete pa; |
357 | } | 364 | } |
358 | 365 | ||
359 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 366 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
360 | { | 367 | { |
361 | #ifdef Q_WS_QWS | 368 | #ifdef Q_WS_QWS |
362 | QDataStream stream( data, IO_ReadOnly ); | 369 | QDataStream stream( data, IO_ReadOnly ); |
363 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 370 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
364 | int k; | 371 | int k; |
365 | QString c, m; | 372 | QString c, m; |
366 | stream >> k; | 373 | stream >> k; |
367 | stream >> c; | 374 | stream >> c; |
368 | stream >> m; | 375 | stream >> m; |
369 | 376 | ||
370 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 377 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); |
371 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 378 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
372 | } | 379 | } |
373 | else if ( msg == "suspend()" ) { | 380 | else if ( msg == "suspend()" ) { |
374 | emit power(); | 381 | emit power(); |
375 | } | 382 | } |
376 | #endif | 383 | #endif |
377 | } | 384 | } |
378 | 385 | ||
379 | 386 | ||
380 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 387 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
381 | { | 388 | { |
382 | #ifdef Q_WS_QWS | 389 | #ifdef Q_WS_QWS |
383 | QDataStream stream ( data, IO_ReadOnly ); | 390 | QDataStream stream ( data, IO_ReadOnly ); |
384 | 391 | ||
385 | if ( msg == "setScreenSaverInterval(int)" ) { | 392 | if ( msg == "setScreenSaverInterval(int)" ) { |
386 | int time; | 393 | int time; |
387 | stream >> time; | 394 | stream >> time; |
@@ -945,91 +952,64 @@ void DesktopApplication::restart() | |||
945 | 952 | ||
946 | exit( 1 ); | 953 | exit( 1 ); |
947 | #endif | 954 | #endif |
948 | } | 955 | } |
949 | 956 | ||
950 | void Desktop::startTransferServer() | 957 | void Desktop::startTransferServer() |
951 | { | 958 | { |
952 | // start qcop bridge server | 959 | // start qcop bridge server |
953 | qcopBridge = new QCopBridge( 4243 ); | 960 | qcopBridge = new QCopBridge( 4243 ); |
954 | if ( !qcopBridge->ok() ) { | 961 | if ( !qcopBridge->ok() ) { |
955 | delete qcopBridge; | 962 | delete qcopBridge; |
956 | qcopBridge = 0; | 963 | qcopBridge = 0; |
957 | } | 964 | } |
958 | // start transfer server | 965 | // start transfer server |
959 | transferServer = new TransferServer( 4242 ); | 966 | transferServer = new TransferServer( 4242 ); |
960 | if ( !transferServer->ok() ) { | 967 | if ( !transferServer->ok() ) { |
961 | delete transferServer; | 968 | delete transferServer; |
962 | transferServer = 0; | 969 | transferServer = 0; |
963 | } | 970 | } |
964 | if ( !transferServer || !qcopBridge ) | 971 | if ( !transferServer || !qcopBridge ) |
965 | startTimer( 2000 ); | 972 | startTimer( 2000 ); |
966 | } | 973 | } |
967 | 974 | ||
968 | void Desktop::timerEvent( QTimerEvent *e ) | 975 | void Desktop::timerEvent( QTimerEvent *e ) |
969 | { | 976 | { |
970 | killTimer( e->timerId() ); | 977 | killTimer( e->timerId() ); |
971 | startTransferServer(); | 978 | startTransferServer(); |
972 | } | 979 | } |
973 | 980 | ||
974 | void Desktop::terminateServers() | 981 | void Desktop::terminateServers() |
975 | { | 982 | { |
976 | delete transferServer; | 983 | delete transferServer; |
977 | delete qcopBridge; | 984 | delete qcopBridge; |
978 | transferServer = 0; | 985 | transferServer = 0; |
979 | qcopBridge = 0; | 986 | qcopBridge = 0; |
980 | } | 987 | } |
981 | 988 | ||
982 | void Desktop::rereadVolumes() | 989 | void Desktop::rereadVolumes() |
983 | { | 990 | { |
984 | Config cfg( "qpe" ); | 991 | Config cfg( "qpe" ); |
985 | cfg.setGroup( "Volume" ); | 992 | cfg.setGroup( "Volume" ); |
986 | touchclick = cfg.readBoolEntry( "TouchSound" ); | 993 | touchclick = cfg.readBoolEntry( "TouchSound" ); |
987 | keyclick = cfg.readBoolEntry( "KeySound" ); | 994 | keyclick = cfg.readBoolEntry( "KeySound" ); |
988 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); | 995 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); |
989 | } | 996 | } |
990 | 997 | ||
991 | void Desktop::keyClick() | 998 | void Desktop::keyClick() |
992 | { | 999 | { |
993 | if ( keyclick ) | 1000 | if ( keyclick ) |
994 | ODevice::inst ( ) -> keySound ( ); | 1001 | ODevice::inst ( ) -> keySound ( ); |
995 | } | 1002 | } |
996 | 1003 | ||
997 | void Desktop::screenClick() | 1004 | void Desktop::screenClick() |
998 | { | 1005 | { |
999 | if ( touchclick ) | 1006 | if ( touchclick ) |
1000 | ODevice::inst ( ) -> touchSound ( ); | 1007 | ODevice::inst ( ) -> touchSound ( ); |
1001 | } | 1008 | } |
1002 | 1009 | ||
1003 | void Desktop::soundAlarm() | 1010 | void Desktop::soundAlarm() |
1004 | { | 1011 | { |
1005 | if ( qpedesktop-> alarmsound ) | 1012 | if ( qpedesktop-> alarmsound ) |
1006 | ODevice::inst ( ) -> alarmSound ( ); | 1013 | ODevice::inst ( ) -> alarmSound ( ); |
1007 | } | 1014 | } |
1008 | 1015 | ||
1009 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | ||
1010 | { | ||
1011 | if ( ev-> type ( ) == QEvent::KeyPress ) { | ||
1012 | QKeyEvent * ke = ( QKeyEvent * ) ev; | ||
1013 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key | ||
1014 | QWidget * active = qApp-> activeWindow ( ); | ||
1015 | |||
1016 | if ( active && active-> isPopup ( ) ) | ||
1017 | active->close(); | ||
1018 | |||
1019 | /* | ||
1020 | * On iPAQ 38xx that key is not the "menu key" but the mail key | ||
1021 | * To not confuse the users, make it launch the mail app on 38xx | ||
1022 | */ | ||
1023 | if ( ODevice::inst() ->model() == OMODEL_iPAQ_H38xx ) { | ||
1024 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | ||
1025 | e << QString( "mail" ); | ||
1026 | return true; | ||
1027 | } | ||
1028 | else { | ||
1029 | raiseMenu ( ); | ||
1030 | return true; | ||
1031 | } | ||
1032 | } | ||
1033 | } | ||
1034 | return false; | ||
1035 | } | ||
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index b9ff39f..f7c3e3f 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -61,85 +61,84 @@ signals: | |||
61 | void capsLockStateToggle(); | 61 | void capsLockStateToggle(); |
62 | void prepareForRestart(); | 62 | void prepareForRestart(); |
63 | 63 | ||
64 | protected: | 64 | protected: |
65 | #ifdef Q_WS_QWS | 65 | #ifdef Q_WS_QWS |
66 | 66 | ||
67 | bool qwsEventFilter( QWSEvent * ); | 67 | bool qwsEventFilter( QWSEvent * ); |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | void shutdown(); | 70 | void shutdown(); |
71 | void restart(); | 71 | void restart(); |
72 | 72 | ||
73 | public slots: | 73 | public slots: |
74 | virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); | 74 | virtual void desktopMessage ( const QCString &msg, const QByteArray &data ); |
75 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); | 75 | virtual void systemMessage ( const QCString &msg, const QByteArray &data ); |
76 | 76 | ||
77 | protected slots: | 77 | protected slots: |
78 | void shutdown( ShutdownImpl::Type ); | 78 | void shutdown( ShutdownImpl::Type ); |
79 | void psTimeout(); | 79 | void psTimeout(); |
80 | void sendCard(); | 80 | void sendCard(); |
81 | private: | 81 | private: |
82 | DesktopPowerAlerter *pa; | 82 | DesktopPowerAlerter *pa; |
83 | PowerStatus *ps; | 83 | PowerStatus *ps; |
84 | QTimer *cardSendTimer; | 84 | QTimer *cardSendTimer; |
85 | QCopChannel *channel; | 85 | QCopChannel *channel; |
86 | QPEScreenSaver *m_screensaver; | 86 | QPEScreenSaver *m_screensaver; |
87 | }; | 87 | }; |
88 | 88 | ||
89 | 89 | ||
90 | class Desktop : public QWidget | 90 | class Desktop : public QWidget |
91 | { | 91 | { |
92 | Q_OBJECT | 92 | Q_OBJECT |
93 | public: | 93 | public: |
94 | Desktop(); | 94 | Desktop(); |
95 | ~Desktop(); | 95 | ~Desktop(); |
96 | 96 | ||
97 | static bool screenLocked(); | 97 | static bool screenLocked(); |
98 | 98 | ||
99 | void show(); | 99 | void show(); |
100 | void checkMemory(); | 100 | void checkMemory(); |
101 | 101 | ||
102 | void keyClick(); | 102 | void keyClick(); |
103 | void screenClick(); | 103 | void screenClick(); |
104 | static void soundAlarm(); | 104 | static void soundAlarm(); |
105 | 105 | ||
106 | public slots: | 106 | public slots: |
107 | void raiseDatebook(); | 107 | void raiseDatebook(); |
108 | void raiseContacts(); | 108 | void raiseContacts(); |
109 | void raiseMenu(); | 109 | void raiseMenu(); |
110 | void raiseLauncher(); | 110 | void raiseLauncher(); |
111 | void raiseEmail(); | 111 | void raiseEmail(); |
112 | void execAutoStart(); | 112 | void execAutoStart(); |
113 | void togglePower(); | 113 | void togglePower(); |
114 | void toggleLight(); | 114 | void toggleLight(); |
115 | void toggleNumLockState(); | 115 | void toggleNumLockState(); |
116 | void toggleCapsLockState(); | 116 | void toggleCapsLockState(); |
117 | void toggleSymbolInput(); | 117 | void toggleSymbolInput(); |
118 | void terminateServers(); | 118 | void terminateServers(); |
119 | void rereadVolumes(); | 119 | void rereadVolumes(); |
120 | 120 | ||
121 | protected: | 121 | protected: |
122 | void executeOrModify( const QString& appLnkFile ); | 122 | void executeOrModify( const QString& appLnkFile ); |
123 | void styleChange( QStyle & ); | 123 | void styleChange( QStyle & ); |
124 | void timerEvent( QTimerEvent *e ); | 124 | void timerEvent( QTimerEvent *e ); |
125 | bool eventFilter( QObject *, QEvent * ); | ||
126 | 125 | ||
127 | QWidget *bg; | 126 | QWidget *bg; |
128 | Launcher *launcher; | 127 | Launcher *launcher; |
129 | TaskBar *tb; | 128 | TaskBar *tb; |
130 | 129 | ||
131 | private: | 130 | private: |
132 | void startTransferServer(); | 131 | void startTransferServer(); |
133 | bool recoverMemory(); | 132 | bool recoverMemory(); |
134 | 133 | ||
135 | QCopBridge *qcopBridge; | 134 | QCopBridge *qcopBridge; |
136 | TransferServer *transferServer; | 135 | TransferServer *transferServer; |
137 | PackageSlave *packageSlave; | 136 | PackageSlave *packageSlave; |
138 | 137 | ||
139 | QDateTime suspendTime; | 138 | QDateTime suspendTime; |
140 | bool keyclick, touchclick, alarmsound; | 139 | bool keyclick, touchclick, alarmsound; |
141 | }; | 140 | }; |
142 | 141 | ||
143 | 142 | ||
144 | #endif // __DESKTOP_H__ | 143 | #endif // __DESKTOP_H__ |
145 | 144 | ||