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