summaryrefslogtreecommitdiff
authorsandman <sandman>2002-06-09 23:40:20 (UTC)
committer sandman <sandman>2002-06-09 23:40:20 (UTC)
commit4f04ef71be8f36e6251f4e6e7fafbfc36fba415c (patch) (unidiff)
treefd4d907f36fc5291ff9d91237bebaf872313f18d
parent65b1a790493272a38b0ac44e219d5186168fabac (diff)
downloadopie-4f04ef71be8f36e6251f4e6e7fafbfc36fba415c.zip
opie-4f04ef71be8f36e6251f4e6e7fafbfc36fba415c.tar.gz
opie-4f04ef71be8f36e6251f4e6e7fafbfc36fba415c.tar.bz2
Fixed Alarm sound handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 6771a66..693e77f 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,792 +1,790 @@
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/global.h> 40#include <qpe/global.h>
41#ifdef QT_QWS_CUSTOM 41#include <qpe/custom.h>
42#include "qpe/custom.h"
43#endif
44 42
45#include <qgfx_qws.h> 43#include <qgfx_qws.h>
46#include <qmainwindow.h> 44#include <qmainwindow.h>
47#include <qmessagebox.h> 45#include <qmessagebox.h>
48#include <qtimer.h> 46#include <qtimer.h>
49#include <qwindowsystem_qws.h> 47#include <qwindowsystem_qws.h>
50 48
51#include <qvaluelist.h> 49#include <qvaluelist.h>
52 50
53#include <stdlib.h> 51#include <stdlib.h>
54#include <unistd.h> 52#include <unistd.h>
55 53
56class QCopKeyRegister 54class QCopKeyRegister
57{ 55{
58public: 56public:
59 QCopKeyRegister() : keyCode(0) { } 57 QCopKeyRegister() : keyCode(0) { }
60 QCopKeyRegister(int k, const QString &c, const QString &m) 58 QCopKeyRegister(int k, const QString &c, const QString &m)
61 : keyCode(k), channel(c), message(m) { } 59 : keyCode(k), channel(c), message(m) { }
62 60
63 int getKeyCode() const { return keyCode; } 61 int getKeyCode() const { return keyCode; }
64 QString getChannel() const { return channel; } 62 QString getChannel() const { return channel; }
65 QString getMessage() const { return message; } 63 QString getMessage() const { return message; }
66 64
67private: 65private:
68 int keyCode; 66 int keyCode;
69 QString channel, message; 67 QString channel, message;
70}; 68};
71 69
72typedef QValueList<QCopKeyRegister> KeyRegisterList; 70typedef QValueList<QCopKeyRegister> KeyRegisterList;
73KeyRegisterList keyRegisterList; 71KeyRegisterList keyRegisterList;
74 72
75static Desktop* qpedesktop = 0; 73static Desktop* qpedesktop = 0;
76static int loggedin=0; 74static int loggedin=0;
77static void login(bool at_poweron) 75static void login(bool at_poweron)
78{ 76{
79 if ( !loggedin ) { 77 if ( !loggedin ) {
80 Global::terminateBuiltin("calibrate"); 78 Global::terminateBuiltin("calibrate");
81 Password::authenticate(at_poweron); 79 Password::authenticate(at_poweron);
82 loggedin=1; 80 loggedin=1;
83 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 81 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
84 } 82 }
85} 83}
86 84
87bool Desktop::screenLocked() 85bool Desktop::screenLocked()
88{ 86{
89 return loggedin == 0; 87 return loggedin == 0;
90} 88}
91 89
92/* 90/*
93 Priority is number of alerts that are needed to pop up 91 Priority is number of alerts that are needed to pop up
94 alert. 92 alert.
95 */ 93 */
96class DesktopPowerAlerter : public QMessageBox 94class DesktopPowerAlerter : public QMessageBox
97{ 95{
98public: 96public:
99 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 97 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
100 : QMessageBox( tr("Battery Status"), "Low Battery", 98 : QMessageBox( tr("Battery Status"), "Low Battery",
101 QMessageBox::Critical, 99 QMessageBox::Critical,
102 QMessageBox::Ok | QMessageBox::Default, 100 QMessageBox::Ok | QMessageBox::Default,
103 QMessageBox::NoButton, QMessageBox::NoButton, 101 QMessageBox::NoButton, QMessageBox::NoButton,
104 parent, name, FALSE ) 102 parent, name, FALSE )
105 { 103 {
106 currentPriority = INT_MAX; 104 currentPriority = INT_MAX;
107 alertCount = 0; 105 alertCount = 0;
108 } 106 }
109 107
110 void alert( const QString &text, int priority ); 108 void alert( const QString &text, int priority );
111 void hideEvent( QHideEvent * ); 109 void hideEvent( QHideEvent * );
112private: 110private:
113 int currentPriority; 111 int currentPriority;
114 int alertCount; 112 int alertCount;
115}; 113};
116 114
117void DesktopPowerAlerter::alert( const QString &text, int priority ) 115void DesktopPowerAlerter::alert( const QString &text, int priority )
118{ 116{
119 alertCount++; 117 alertCount++;
120 if ( alertCount < priority ) 118 if ( alertCount < priority )
121 return; 119 return;
122 if ( priority > currentPriority ) 120 if ( priority > currentPriority )
123 return; 121 return;
124 currentPriority = priority; 122 currentPriority = priority;
125 setText( text ); 123 setText( text );
126 show(); 124 show();
127} 125}
128 126
129 127
130void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 128void DesktopPowerAlerter::hideEvent( QHideEvent *e )
131{ 129{
132 QMessageBox::hideEvent( e ); 130 QMessageBox::hideEvent( e );
133 alertCount = 0; 131 alertCount = 0;
134 currentPriority = INT_MAX; 132 currentPriority = INT_MAX;
135} 133}
136 134
137 135
138 136
139DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 137DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
140 : QPEApplication( argc, argv, appType ) 138 : QPEApplication( argc, argv, appType )
141{ 139{
142 140
143 QTimer *t = new QTimer( this ); 141 QTimer *t = new QTimer( this );
144 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 142 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
145 t->start( 10000 ); 143 t->start( 10000 );
146 ps = new PowerStatus; 144 ps = new PowerStatus;
147 pa = new DesktopPowerAlerter( 0 ); 145 pa = new DesktopPowerAlerter( 0 );
148 146
149 channel = new QCopChannel( "QPE/Desktop", this ); 147 channel = new QCopChannel( "QPE/Desktop", this );
150 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 148 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
151 this, SLOT(receive(const QCString&, const QByteArray&)) ); 149 this, SLOT(receive(const QCString&, const QByteArray&)) );
152} 150}
153 151
154 152
155DesktopApplication::~DesktopApplication() 153DesktopApplication::~DesktopApplication()
156{ 154{
157 delete ps; 155 delete ps;
158 delete pa; 156 delete pa;
159} 157}
160 158
161void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 159void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
162{ 160{
163 QDataStream stream( data, IO_ReadOnly ); 161 QDataStream stream( data, IO_ReadOnly );
164 if (msg == "keyRegister(int key, QString channel, QString message)") 162 if (msg == "keyRegister(int key, QString channel, QString message)")
165 { 163 {
166 int k; 164 int k;
167 QString c, m; 165 QString c, m;
168 stream >> k; 166 stream >> k;
169 stream >> c; 167 stream >> c;
170 stream >> m; 168 stream >> m;
171 169
172 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); 170 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m );
173 keyRegisterList.append(QCopKeyRegister(k,c,m)); 171 keyRegisterList.append(QCopKeyRegister(k,c,m));
174 } 172 }
175 else if (msg == "suspend()"){ 173 else if (msg == "suspend()"){
176 emit power(); 174 emit power();
177 } 175 }
178 176
179} 177}
180 178
181enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 179enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
182 180
183#ifdef Q_WS_QWS 181#ifdef Q_WS_QWS
184bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 182bool DesktopApplication::qwsEventFilter( QWSEvent *e )
185{ 183{
186 qpedesktop->checkMemory(); 184 qpedesktop->checkMemory();
187 185
188 if ( e->type == QWSEvent::Key ) { 186 if ( e->type == QWSEvent::Key ) {
189 QWSKeyEvent *ke = (QWSKeyEvent *)e; 187 QWSKeyEvent *ke = (QWSKeyEvent *)e;
190 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 188 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
191 return TRUE; 189 return TRUE;
192 bool press = ke->simpleData.is_press; 190 bool press = ke->simpleData.is_press;
193 bool autoRepeat= ke->simpleData.is_auto_repeat; 191 bool autoRepeat= ke->simpleData.is_auto_repeat;
194 if (!keyRegisterList.isEmpty()) 192 if (!keyRegisterList.isEmpty())
195 { 193 {
196 KeyRegisterList::Iterator it; 194 KeyRegisterList::Iterator it;
197 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) 195 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
198 { 196 {
199 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) { 197 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat) {
200 if(press) qDebug("press"); else qDebug("release"); 198 if(press) qDebug("press"); else qDebug("release");
201 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 199 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
202 } 200 }
203 } 201 }
204 } 202 }
205 203
206 if ( !keyboardGrabbed() ) { 204 if ( !keyboardGrabbed() ) {
207 if ( ke->simpleData.keycode == Key_F9 ) { 205 if ( ke->simpleData.keycode == Key_F9 ) {
208 if ( press ) emit datebook(); 206 if ( press ) emit datebook();
209 return TRUE; 207 return TRUE;
210 } 208 }
211 if ( ke->simpleData.keycode == Key_F10 ) { 209 if ( ke->simpleData.keycode == Key_F10 ) {
212 if ( !press && cardSendTimer ) { 210 if ( !press && cardSendTimer ) {
213 emit contacts(); 211 emit contacts();
214 delete cardSendTimer; 212 delete cardSendTimer;
215 } else if ( press ) { 213 } else if ( press ) {
216 cardSendTimer = new QTimer(); 214 cardSendTimer = new QTimer();
217 cardSendTimer->start( 2000, TRUE ); 215 cardSendTimer->start( 2000, TRUE );
218 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 216 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
219 } 217 }
220 return TRUE; 218 return TRUE;
221 } 219 }
222 /* menu key now opens application menu/toolbar 220 /* menu key now opens application menu/toolbar
223 if ( ke->simpleData.keycode == Key_F11 ) { 221 if ( ke->simpleData.keycode == Key_F11 ) {
224 if ( press ) emit menu(); 222 if ( press ) emit menu();
225 return TRUE; 223 return TRUE;
226 } 224 }
227 */ 225 */
228 if ( ke->simpleData.keycode == Key_F12 ) { 226 if ( ke->simpleData.keycode == Key_F12 ) {
229 while( activePopupWidget() ) 227 while( activePopupWidget() )
230 activePopupWidget()->close(); 228 activePopupWidget()->close();
231 if ( press ) emit launch(); 229 if ( press ) emit launch();
232 return TRUE; 230 return TRUE;
233 } 231 }
234 if ( ke->simpleData.keycode == Key_F13 ) { 232 if ( ke->simpleData.keycode == Key_F13 ) {
235 if ( press ) emit email(); 233 if ( press ) emit email();
236 return TRUE; 234 return TRUE;
237 } 235 }
238 } 236 }
239 237
240 if ( ke->simpleData.keycode == Key_F34 ) { 238 if ( ke->simpleData.keycode == Key_F34 ) {
241 if ( press ) emit power(); 239 if ( press ) emit power();
242 return TRUE; 240 return TRUE;
243 } 241 }
244 if ( ke->simpleData.keycode == Key_SysReq ) { 242 if ( ke->simpleData.keycode == Key_SysReq ) {
245 if ( press ) emit power(); 243 if ( press ) emit power();
246 return TRUE; 244 return TRUE;
247 } 245 }
248 if ( ke->simpleData.keycode == Key_F35 ) { 246 if ( ke->simpleData.keycode == Key_F35 ) {
249 if ( press ) emit backlight(); 247 if ( press ) emit backlight();
250 return TRUE; 248 return TRUE;
251 } 249 }
252 if ( ke->simpleData.keycode == Key_F32 ) { 250 if ( ke->simpleData.keycode == Key_F32 ) {
253 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 251 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
254 return TRUE; 252 return TRUE;
255 } 253 }
256 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 254 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
257 if ( press ) emit symbol(); 255 if ( press ) emit symbol();
258 return TRUE; 256 return TRUE;
259 } 257 }
260 if ( ke->simpleData.keycode == Key_NumLock ) { 258 if ( ke->simpleData.keycode == Key_NumLock ) {
261 if ( press ) emit numLockStateToggle(); 259 if ( press ) emit numLockStateToggle();
262 } 260 }
263 if ( ke->simpleData.keycode == Key_CapsLock ) { 261 if ( ke->simpleData.keycode == Key_CapsLock ) {
264 if ( press ) emit capsLockStateToggle(); 262 if ( press ) emit capsLockStateToggle();
265 } 263 }
266 if ( press ) 264 if ( press )
267 qpedesktop->keyClick(); 265 qpedesktop->keyClick();
268 } else { 266 } else {
269 if ( e->type == QWSEvent::Mouse ) { 267 if ( e->type == QWSEvent::Mouse ) {
270 QWSMouseEvent *me = (QWSMouseEvent *)e; 268 QWSMouseEvent *me = (QWSMouseEvent *)e;
271 static bool up = TRUE; 269 static bool up = TRUE;
272 if ( me->simpleData.state&LeftButton ) { 270 if ( me->simpleData.state&LeftButton ) {
273 if ( up ) { 271 if ( up ) {
274 up = FALSE; 272 up = FALSE;
275 qpedesktop->screenClick(); 273 qpedesktop->screenClick();
276 } 274 }
277 } else { 275 } else {
278 up = TRUE; 276 up = TRUE;
279 } 277 }
280 } 278 }
281 } 279 }
282 280
283 return QPEApplication::qwsEventFilter( e ); 281 return QPEApplication::qwsEventFilter( e );
284} 282}
285#endif 283#endif
286 284
287void DesktopApplication::psTimeout() 285void DesktopApplication::psTimeout()
288{ 286{
289 qpedesktop->checkMemory(); // in case no events are being generated 287 qpedesktop->checkMemory(); // in case no events are being generated
290 288
291 *ps = PowerStatusManager::readStatus(); 289 *ps = PowerStatusManager::readStatus();
292 290
293 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 291 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
294 pa->alert( tr( "Battery is running very low." ), 6 ); 292 pa->alert( tr( "Battery is running very low." ), 6 );
295 } 293 }
296 294
297 if ( ps->batteryStatus() == PowerStatus::Critical ) { 295 if ( ps->batteryStatus() == PowerStatus::Critical ) {
298 pa->alert( tr( "Battery level is critical!\n" 296 pa->alert( tr( "Battery level is critical!\n"
299 "Keep power off until power restored!" ), 1 ); 297 "Keep power off until power restored!" ), 1 );
300 } 298 }
301 299
302 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 300 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
303 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 301 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
304 } 302 }
305} 303}
306 304
307 305
308void DesktopApplication::sendCard() 306void DesktopApplication::sendCard()
309{ 307{
310 delete cardSendTimer; 308 delete cardSendTimer;
311 cardSendTimer = 0; 309 cardSendTimer = 0;
312 QString card = getenv("HOME"); 310 QString card = getenv("HOME");
313 card += "/Applications/addressbook/businesscard.vcf"; 311 card += "/Applications/addressbook/businesscard.vcf";
314 312
315 if ( QFile::exists( card ) ) { 313 if ( QFile::exists( card ) ) {
316 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 314 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
317 QString mimetype = "text/x-vCard"; 315 QString mimetype = "text/x-vCard";
318 e << tr("business card") << card << mimetype; 316 e << tr("business card") << card << mimetype;
319 } 317 }
320} 318}
321 319
322#if defined(QPE_HAVE_MEMALERTER) 320#if defined(QPE_HAVE_MEMALERTER)
323QPE_MEMALERTER_IMPL 321QPE_MEMALERTER_IMPL
324#endif 322#endif
325 323
326#if defined(CUSTOM_SOUND_IMPL) 324#if defined(CUSTOM_SOUND_IMPL)
327CUSTOM_SOUND_IMPL 325CUSTOM_SOUND_IMPL
328#endif 326#endif
329 327
330//=========================================================================== 328//===========================================================================
331 329
332Desktop::Desktop() : 330Desktop::Desktop() :
333 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 331 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
334 qcopBridge( 0 ), 332 qcopBridge( 0 ),
335 transferServer( 0 ), 333 transferServer( 0 ),
336 packageSlave( 0 ) 334 packageSlave( 0 )
337{ 335{
338#ifdef CUSTOM_SOUND_INIT 336#ifdef CUSTOM_SOUND_INIT
339 CUSTOM_SOUND_INIT; 337 CUSTOM_SOUND_INIT;
340#endif 338#endif
341 339
342 qpedesktop = this; 340 qpedesktop = this;
343 341
344// bg = new Info( this ); 342// bg = new Info( this );
345 tb = new TaskBar; 343 tb = new TaskBar;
346 344
347 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 345 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
348 346
349 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 347 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
350 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 348 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
351 349
352 int displayw = qApp->desktop()->width(); 350 int displayw = qApp->desktop()->width();
353 int displayh = qApp->desktop()->height(); 351 int displayh = qApp->desktop()->height();
354 352
355 353
356 QSize sz = tb->sizeHint(); 354 QSize sz = tb->sizeHint();
357 355
358 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 356 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
359 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 357 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
360 358
361 tb->show(); 359 tb->show();
362 launcher->showMaximized(); 360 launcher->showMaximized();
363 launcher->show(); 361 launcher->show();
364 launcher->raise(); 362 launcher->raise();
365#if defined(QPE_HAVE_MEMALERTER) 363#if defined(QPE_HAVE_MEMALERTER)
366 initMemalerter(); 364 initMemalerter();
367#endif 365#endif
368 // start services 366 // start services
369 startTransferServer(); 367 startTransferServer();
370 (void) new IrServer( this ); 368 (void) new IrServer( this );
371 rereadVolumes(); 369 rereadVolumes();
372 370
373 packageSlave = new PackageSlave( this ); 371 packageSlave = new PackageSlave( this );
374 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 372 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
375 373
376 qApp->installEventFilter( this ); 374 qApp->installEventFilter( this );
377} 375}
378 376
379void Desktop::show() 377void Desktop::show()
380{ 378{
381 login(TRUE); 379 login(TRUE);
382 QWidget::show(); 380 QWidget::show();
383} 381}
384 382
385Desktop::~Desktop() 383Desktop::~Desktop()
386{ 384{
387 delete launcher; 385 delete launcher;
388 delete tb; 386 delete tb;
389 delete qcopBridge; 387 delete qcopBridge;
390 delete transferServer; 388 delete transferServer;
391} 389}
392 390
393bool Desktop::recoverMemory() 391bool Desktop::recoverMemory()
394{ 392{
395 return tb->recoverMemory(); 393 return tb->recoverMemory();
396} 394}
397 395
398void Desktop::checkMemory() 396void Desktop::checkMemory()
399{ 397{
400#if defined(QPE_HAVE_MEMALERTER) 398#if defined(QPE_HAVE_MEMALERTER)
401 static bool ignoreNormal=FALSE; 399 static bool ignoreNormal=FALSE;
402 static bool existingMessage=FALSE; 400 static bool existingMessage=FALSE;
403 401
404 if(existingMessage) 402 if(existingMessage)
405 return; // don't show a second message while still on first 403 return; // don't show a second message while still on first
406 404
407 existingMessage = TRUE; 405 existingMessage = TRUE;
408 switch ( memstate ) { 406 switch ( memstate ) {
409 case Unknown: 407 case Unknown:
410 break; 408 break;
411 case Low: 409 case Low:
412 memstate = Unknown; 410 memstate = Unknown;
413 if ( recoverMemory() ) 411 if ( recoverMemory() )
414 ignoreNormal = TRUE; 412 ignoreNormal = TRUE;
415 else 413 else
416 QMessageBox::warning( 0 , "Memory Status", 414 QMessageBox::warning( 0 , "Memory Status",
417 "The memory smacks of shortage. \n" 415 "The memory smacks of shortage. \n"
418 "Please save data. " ); 416 "Please save data. " );
419 break; 417 break;
420 case Normal: 418 case Normal:
421 memstate = Unknown; 419 memstate = Unknown;
422 if ( ignoreNormal ) 420 if ( ignoreNormal )
423 ignoreNormal = FALSE; 421 ignoreNormal = FALSE;
424 else 422 else
425 QMessageBox::information ( 0 , "Memory Status", 423 QMessageBox::information ( 0 , "Memory Status",
426 "There is enough memory again." ); 424 "There is enough memory again." );
427 break; 425 break;
428 case VeryLow: 426 case VeryLow:
429 memstate = Unknown; 427 memstate = Unknown;
430 QMessageBox::critical( 0 , "Memory Status", 428 QMessageBox::critical( 0 , "Memory Status",
431 "The memory is very low. \n" 429 "The memory is very low. \n"
432 "Please end this application \n" 430 "Please end this application \n"
433 "immediately." ); 431 "immediately." );
434 recoverMemory(); 432 recoverMemory();
435 } 433 }
436 existingMessage = FALSE; 434 existingMessage = FALSE;
437#endif 435#endif
438} 436}
439 437
440static bool isVisibleWindow(int wid) 438static bool isVisibleWindow(int wid)
441{ 439{
442 const QList<QWSWindow> &list = qwsServer->clientWindows(); 440 const QList<QWSWindow> &list = qwsServer->clientWindows();
443 QWSWindow* w; 441 QWSWindow* w;
444 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 442 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
445 if ( w->winId() == wid ) 443 if ( w->winId() == wid )
446 return !w->isFullyObscured(); 444 return !w->isFullyObscured();
447 } 445 }
448 return FALSE; 446 return FALSE;
449} 447}
450 448
451static bool hasVisibleWindow(const QString& clientname) 449static bool hasVisibleWindow(const QString& clientname)
452{ 450{
453 const QList<QWSWindow> &list = qwsServer->clientWindows(); 451 const QList<QWSWindow> &list = qwsServer->clientWindows();
454 QWSWindow* w; 452 QWSWindow* w;
455 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 453 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
456 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 454 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
457 return TRUE; 455 return TRUE;
458 } 456 }
459 return FALSE; 457 return FALSE;
460} 458}
461 459
462void Desktop::raiseLauncher() 460void Desktop::raiseLauncher()
463{ 461{
464 Config cfg("qpe"); //F12 'Home' 462 Config cfg("qpe"); //F12 'Home'
465 cfg.setGroup("AppsKey"); 463 cfg.setGroup("AppsKey");
466 QString tempItem; 464 QString tempItem;
467 tempItem = cfg.readEntry("Middle","Home"); 465 tempItem = cfg.readEntry("Middle","Home");
468 if(tempItem == "Home" || tempItem.isEmpty()) { 466 if(tempItem == "Home" || tempItem.isEmpty()) {
469 if ( isVisibleWindow(launcher->winId()) ) 467 if ( isVisibleWindow(launcher->winId()) )
470 launcher->nextView(); 468 launcher->nextView();
471 else 469 else
472 launcher->raise(); 470 launcher->raise();
473 } else { 471 } else {
474 QCopEnvelope e("QPE/System","execute(QString)"); 472 QCopEnvelope e("QPE/System","execute(QString)");
475 e << tempItem; 473 e << tempItem;
476 } 474 }
477} 475}
478 476
479void Desktop::executeOrModify(const QString& appLnkFile) 477void Desktop::executeOrModify(const QString& appLnkFile)
480{ 478{
481 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 479 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
482 if ( lnk.isValid() ) { 480 if ( lnk.isValid() ) {
483 QCString app = lnk.exec().utf8(); 481 QCString app = lnk.exec().utf8();
484 Global::terminateBuiltin("calibrate"); 482 Global::terminateBuiltin("calibrate");
485 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 483 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
486 MRUList::addTask(&lnk); 484 MRUList::addTask(&lnk);
487 if ( hasVisibleWindow(app) ) 485 if ( hasVisibleWindow(app) )
488 QCopChannel::send("QPE/Application/" + app, "nextView()"); 486 QCopChannel::send("QPE/Application/" + app, "nextView()");
489 else 487 else
490 QCopChannel::send("QPE/Application/" + app, "raise()"); 488 QCopChannel::send("QPE/Application/" + app, "raise()");
491 } else { 489 } else {
492 lnk.execute(); 490 lnk.execute();
493 } 491 }
494 } 492 }
495} 493}
496 494
497void Desktop::raiseDatebook() 495void Desktop::raiseDatebook()
498{ 496{
499 Config cfg("qpe"); //F9 'Activity' 497 Config cfg("qpe"); //F9 'Activity'
500 cfg.setGroup("AppsKey"); 498 cfg.setGroup("AppsKey");
501 QString tempItem; 499 QString tempItem;
502 tempItem = cfg.readEntry("LeftEnd","Calender"); 500 tempItem = cfg.readEntry("LeftEnd","Calender");
503 if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); 501 if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop");
504 else { 502 else {
505 QCopEnvelope e("QPE/System","execute(QString)"); 503 QCopEnvelope e("QPE/System","execute(QString)");
506 e << tempItem; 504 e << tempItem;
507 } 505 }
508} 506}
509 507
510void Desktop::raiseContacts() 508void Desktop::raiseContacts()
511{ 509{
512 Config cfg("qpe"); //F10, 'Contacts' 510 Config cfg("qpe"); //F10, 'Contacts'
513 cfg.setGroup("AppsKey"); 511 cfg.setGroup("AppsKey");
514 QString tempItem; 512 QString tempItem;
515 tempItem = cfg.readEntry("Left2nd","Address Book"); 513 tempItem = cfg.readEntry("Left2nd","Address Book");
516 if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); 514 if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop");
517 else { 515 else {
518 QCopEnvelope e("QPE/System","execute(QString)"); 516 QCopEnvelope e("QPE/System","execute(QString)");
519 e << tempItem; 517 e << tempItem;
520 } 518 }
521} 519}
522 520
523void Desktop::raiseMenu() 521void Desktop::raiseMenu()
524{ 522{
525 Config cfg("qpe"); //F11, 'Menu' 523 Config cfg("qpe"); //F11, 'Menu'
526 cfg.setGroup("AppsKey"); 524 cfg.setGroup("AppsKey");
527 QString tempItem; 525 QString tempItem;
528 tempItem = cfg.readEntry("Right2nd","Popup Menu"); 526 tempItem = cfg.readEntry("Right2nd","Popup Menu");
529 if(tempItem == "Popup Menu" || tempItem.isEmpty()) { 527 if(tempItem == "Popup Menu" || tempItem.isEmpty()) {
530 Global::terminateBuiltin("calibrate"); 528 Global::terminateBuiltin("calibrate");
531 tb->startMenu()->launch(); 529 tb->startMenu()->launch();
532 } else { 530 } else {
533 QCopEnvelope e("QPE/System","execute(QString)"); 531 QCopEnvelope e("QPE/System","execute(QString)");
534 e << tempItem; 532 e << tempItem;
535 } 533 }
536} 534}
537 535
538void Desktop::raiseEmail() 536void Desktop::raiseEmail()
539{ 537{
540 Config cfg("qpe"); //F13, 'Mail' 538 Config cfg("qpe"); //F13, 'Mail'
541 cfg.setGroup("AppsKey"); 539 cfg.setGroup("AppsKey");
542 QString tempItem; 540 QString tempItem;
543 tempItem = cfg.readEntry("RightEnd","Mail"); 541 tempItem = cfg.readEntry("RightEnd","Mail");
544 if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); 542 if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop");
545 else { 543 else {
546 QCopEnvelope e("QPE/System","execute(QString)"); 544 QCopEnvelope e("QPE/System","execute(QString)");
547 e << tempItem; 545 e << tempItem;
548 } 546 }
549} 547}
550 548
551// autoStarts apps on resume and start 549// autoStarts apps on resume and start
552void Desktop::execAutoStart() { 550void Desktop::execAutoStart() {
553 QString appName; 551 QString appName;
554 int delay; 552 int delay;
555 QDateTime now = QDateTime::currentDateTime(); 553 QDateTime now = QDateTime::currentDateTime();
556 Config cfg( "autostart" ); 554 Config cfg( "autostart" );
557 cfg.setGroup( "AutoStart" ); 555 cfg.setGroup( "AutoStart" );
558 appName = cfg.readEntry("Apps", ""); 556 appName = cfg.readEntry("Apps", "");
559 delay = (cfg.readEntry("Delay", "0" )).toInt(); 557 delay = (cfg.readEntry("Delay", "0" )).toInt();
560 // If the time between suspend and resume was longer then the 558 // If the time between suspend and resume was longer then the
561 // value saved as delay, start the app 559 // value saved as delay, start the app
562 if ( suspendTime.secsTo(now) >= (delay*60) ) { 560 if ( suspendTime.secsTo(now) >= (delay*60) ) {
563 QCopEnvelope e("QPE/System", "execute(QString)"); 561 QCopEnvelope e("QPE/System", "execute(QString)");
564 e << QString(appName); 562 e << QString(appName);
565 } else { 563 } else {
566 } 564 }
567} 565}
568 566
569#if defined(QPE_HAVE_TOGGLELIGHT) 567#if defined(QPE_HAVE_TOGGLELIGHT)
570#include <qpe/config.h> 568#include <qpe/config.h>
571 569
572#include <sys/ioctl.h> 570#include <sys/ioctl.h>
573#include <sys/types.h> 571#include <sys/types.h>
574#include <fcntl.h> 572#include <fcntl.h>
575#include <unistd.h> 573#include <unistd.h>
576#include <errno.h> 574#include <errno.h>
577#include <linux/ioctl.h> 575#include <linux/ioctl.h>
578#include <time.h> 576#include <time.h>
579#endif 577#endif
580 578
581static bool blanked=FALSE; 579static bool blanked=FALSE;
582 580
583static void blankScreen() 581static void blankScreen()
584{ 582{
585 if ( !qt_screen ) return; 583 if ( !qt_screen ) return;
586 /* Should use a big black window instead. 584 /* Should use a big black window instead.
587 QGfx* g = qt_screen->screenGfx(); 585 QGfx* g = qt_screen->screenGfx();
588 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 586 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
589 delete g; 587 delete g;
590 */ 588 */
591 blanked = TRUE; 589 blanked = TRUE;
592} 590}
593 591
594static void darkScreen() 592static void darkScreen()
595{ 593{
596 extern void qpe_setBacklight(int); 594 extern void qpe_setBacklight(int);
597 qpe_setBacklight(0); // force off 595 qpe_setBacklight(0); // force off
598} 596}
599 597
600 598
601void Desktop::togglePower() 599void Desktop::togglePower()
602{ 600{
603 bool wasloggedin = loggedin; 601 bool wasloggedin = loggedin;
604 loggedin=0; 602 loggedin=0;
605 suspendTime = QDateTime::currentDateTime(); 603 suspendTime = QDateTime::currentDateTime();
606 darkScreen(); 604 darkScreen();
607 if ( wasloggedin ) 605 if ( wasloggedin )
608 blankScreen(); 606 blankScreen();
609 607
610 system("apm --suspend"); 608 system("apm --suspend");
611 609
612 610
613 611
614 QWSServer::screenSaverActivate( FALSE ); 612 QWSServer::screenSaverActivate( FALSE );
615 { 613 {
616 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 614 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
617 QCopEnvelope e("QPE/System", "setBacklight(int)"); 615 QCopEnvelope e("QPE/System", "setBacklight(int)");
618 e << -3; // Force on 616 e << -3; // Force on
619 } 617 }
620 if ( wasloggedin ) { 618 if ( wasloggedin ) {
621 login(TRUE); 619 login(TRUE);
622 } 620 }
623 sleep(1); 621 sleep(1);
624 execAutoStart(); 622 execAutoStart();
625 //qcopBridge->closeOpenConnections(); 623 //qcopBridge->closeOpenConnections();
626 //qDebug("called togglePower()!!!!!!"); 624 //qDebug("called togglePower()!!!!!!");
627} 625}
628 626
629void Desktop::toggleLight() 627void Desktop::toggleLight()
630{ 628{
631 QCopEnvelope e("QPE/System", "setBacklight(int)"); 629 QCopEnvelope e("QPE/System", "setBacklight(int)");
632 e << -2; // toggle 630 e << -2; // toggle
633} 631}
634 632
635void Desktop::toggleSymbolInput() 633void Desktop::toggleSymbolInput()
636{ 634{
637 tb->toggleSymbolInput(); 635 tb->toggleSymbolInput();
638} 636}
639 637
640void Desktop::toggleNumLockState() 638void Desktop::toggleNumLockState()
641{ 639{
642 tb->toggleNumLockState(); 640 tb->toggleNumLockState();
643} 641}
644 642
645void Desktop::toggleCapsLockState() 643void Desktop::toggleCapsLockState()
646{ 644{
647 tb->toggleCapsLockState(); 645 tb->toggleCapsLockState();
648} 646}
649 647
650void Desktop::styleChange( QStyle &s ) 648void Desktop::styleChange( QStyle &s )
651{ 649{
652 QWidget::styleChange( s ); 650 QWidget::styleChange( s );
653 int displayw = qApp->desktop()->width(); 651 int displayw = qApp->desktop()->width();
654 int displayh = qApp->desktop()->height(); 652 int displayh = qApp->desktop()->height();
655 653
656 QSize sz = tb->sizeHint(); 654 QSize sz = tb->sizeHint();
657 655
658 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 656 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
659} 657}
660 658
661void DesktopApplication::shutdown() 659void DesktopApplication::shutdown()
662{ 660{
663 if ( type() != GuiServer ) 661 if ( type() != GuiServer )
664 return; 662 return;
665 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 663 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
666 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 664 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
667 this, SLOT(shutdown(ShutdownImpl::Type)) ); 665 this, SLOT(shutdown(ShutdownImpl::Type)) );
668 sd->showMaximized(); 666 sd->showMaximized();
669} 667}
670 668
671void DesktopApplication::shutdown( ShutdownImpl::Type t ) 669void DesktopApplication::shutdown( ShutdownImpl::Type t )
672{ 670{
673 switch ( t ) { 671 switch ( t ) {
674 case ShutdownImpl::ShutdownSystem: 672 case ShutdownImpl::ShutdownSystem:
675 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 673 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
676 break; 674 break;
677 case ShutdownImpl::RebootSystem: 675 case ShutdownImpl::RebootSystem:
678 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 676 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
679 break; 677 break;
680 case ShutdownImpl::RestartDesktop: 678 case ShutdownImpl::RestartDesktop:
681 restart(); 679 restart();
682 break; 680 break;
683 case ShutdownImpl::TerminateDesktop: 681 case ShutdownImpl::TerminateDesktop:
684 prepareForTermination(FALSE); 682 prepareForTermination(FALSE);
685 quit(); 683 quit();
686 break; 684 break;
687 } 685 }
688} 686}
689 687
690void DesktopApplication::restart() 688void DesktopApplication::restart()
691{ 689{
692 prepareForTermination(TRUE); 690 prepareForTermination(TRUE);
693 691
694#ifdef Q_WS_QWS 692#ifdef Q_WS_QWS
695 for ( int fd = 3; fd < 100; fd++ ) 693 for ( int fd = 3; fd < 100; fd++ )
696 close( fd ); 694 close( fd );
697#if defined(QT_DEMO_SINGLE_FLOPPY) 695#if defined(QT_DEMO_SINGLE_FLOPPY)
698 execl( "/sbin/init", "qpe", 0 ); 696 execl( "/sbin/init", "qpe", 0 );
699#elif defined(QT_QWS_CASSIOPEIA) 697#elif defined(QT_QWS_CASSIOPEIA)
700 execl( "/bin/sh", "sh", 0 ); 698 execl( "/bin/sh", "sh", 0 );
701#else 699#else
702 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 700 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
703#endif 701#endif
704 exit(1); 702 exit(1);
705#endif 703#endif
706} 704}
707 705
708void Desktop::startTransferServer() 706void Desktop::startTransferServer()
709{ 707{
710 // start qcop bridge server 708 // start qcop bridge server
711 qcopBridge = new QCopBridge( 4243 ); 709 qcopBridge = new QCopBridge( 4243 );
712 if ( !qcopBridge->ok() ) { 710 if ( !qcopBridge->ok() ) {
713 delete qcopBridge; 711 delete qcopBridge;
714 qcopBridge = 0; 712 qcopBridge = 0;
715 } 713 }
716 // start transfer server 714 // start transfer server
717 transferServer = new TransferServer( 4242 ); 715 transferServer = new TransferServer( 4242 );
718 if ( !transferServer->ok() ) { 716 if ( !transferServer->ok() ) {
719 delete transferServer; 717 delete transferServer;
720 transferServer = 0; 718 transferServer = 0;
721 } 719 }
722 if ( !transferServer || !qcopBridge ) 720 if ( !transferServer || !qcopBridge )
723 startTimer( 2000 ); 721 startTimer( 2000 );
724} 722}
725 723
726void Desktop::timerEvent( QTimerEvent *e ) 724void Desktop::timerEvent( QTimerEvent *e )
727{ 725{
728 killTimer( e->timerId() ); 726 killTimer( e->timerId() );
729 startTransferServer(); 727 startTransferServer();
730} 728}
731 729
732void Desktop::terminateServers() 730void Desktop::terminateServers()
733{ 731{
734 delete transferServer; 732 delete transferServer;
735 delete qcopBridge; 733 delete qcopBridge;
736 transferServer = 0; 734 transferServer = 0;
737 qcopBridge = 0; 735 qcopBridge = 0;
738} 736}
739 737
740void Desktop::rereadVolumes() 738void Desktop::rereadVolumes()
741{ 739{
742 Config cfg("qpe"); 740 Config cfg("qpe");
743 cfg.setGroup("Volume"); 741 cfg.setGroup("Volume");
744 touchclick = cfg.readBoolEntry("TouchSound"); 742 touchclick = cfg.readBoolEntry("TouchSound");
745 keyclick = cfg.readBoolEntry("KeySound"); 743 keyclick = cfg.readBoolEntry("KeySound");
746 alarmsound = cfg.readBoolEntry("AlarmSound"); 744 alarmsound = cfg.readBoolEntry("AlarmSound");
747// Config cfg("Sound"); 745// Config cfg("Sound");
748// cfg.setGroup("System"); 746// cfg.setGroup("System");
749// touchclick = cfg.readBoolEntry("Touch"); 747// touchclick = cfg.readBoolEntry("Touch");
750// keyclick = cfg.readBoolEntry("Key"); 748// keyclick = cfg.readBoolEntry("Key");
751} 749}
752 750
753void Desktop::keyClick() 751void Desktop::keyClick()
754{ 752{
755#ifdef CUSTOM_SOUND_KEYCLICK 753#ifdef CUSTOM_SOUND_KEYCLICK
756 if ( keyclick ) 754 if ( keyclick )
757 CUSTOM_SOUND_KEYCLICK; 755 CUSTOM_SOUND_KEYCLICK;
758#endif 756#endif
759} 757}
760 758
761void Desktop::screenClick() 759void Desktop::screenClick()
762{ 760{
763#ifdef CUSTOM_SOUND_TOUCH 761#ifdef CUSTOM_SOUND_TOUCH
764 if ( touchclick ) 762 if ( touchclick )
765 CUSTOM_SOUND_TOUCH; 763 CUSTOM_SOUND_TOUCH;
766#endif 764#endif
767} 765}
768 766
769void Desktop::soundAlarm() 767void Desktop::soundAlarm()
770{ 768{
771#ifdef CUSTOM_SOUND_ALARM 769#ifdef CUSTOM_SOUND_ALARM
772 if (alarmsound) 770 if (qpedesktop->alarmsound)
773 CUSTOM_SOUND_ALARM; 771 CUSTOM_SOUND_ALARM;
774#endif 772#endif
775} 773}
776 774
777bool Desktop::eventFilter( QObject *w, QEvent *ev ) 775bool Desktop::eventFilter( QObject *w, QEvent *ev )
778{ 776{
779 if ( ev->type() == QEvent::KeyPress ) { 777 if ( ev->type() == QEvent::KeyPress ) {
780 QKeyEvent *ke = (QKeyEvent *)ev; 778 QKeyEvent *ke = (QKeyEvent *)ev;
781 if ( ke->key() == Qt::Key_F11 ) { // menu key 779 if ( ke->key() == Qt::Key_F11 ) { // menu key
782 QWidget *active = qApp->activeWindow(); 780 QWidget *active = qApp->activeWindow();
783 if ( active && active->isPopup() ) { 781 if ( active && active->isPopup() ) {
784 active->close(); 782 active->close();
785 } 783 }
786 raiseMenu(); 784 raiseMenu();
787 return TRUE; 785 return TRUE;
788 } 786 }
789 } 787 }
790 return FALSE; 788 return FALSE;
791} 789}
792 790