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