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