-rw-r--r-- | core/launcher/desktop.cpp | 41 | ||||
-rw-r--r-- | core/launcher/desktop.h | 2 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 82 | ||||
-rw-r--r-- | core/pim/today/today.cpp | 27 | ||||
-rw-r--r-- | core/pim/today/todayconfig.cpp | 57 | ||||
-rw-r--r-- | core/pim/today/todayconfig.h | 39 |
6 files changed, 150 insertions, 98 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index cf33011..43006f1 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,776 +1,785 @@ | |||
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/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
39 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
40 | #ifdef QT_QWS_CUSTOM | 41 | #ifdef QT_QWS_CUSTOM |
41 | #include "qpe/custom.h" | 42 | #include "qpe/custom.h" |
42 | #endif | 43 | #endif |
43 | 44 | ||
44 | #include <qgfx_qws.h> | 45 | #include <qgfx_qws.h> |
45 | #include <qmainwindow.h> | 46 | #include <qmainwindow.h> |
46 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
47 | #include <qtimer.h> | 48 | #include <qtimer.h> |
48 | #include <qwindowsystem_qws.h> | 49 | #include <qwindowsystem_qws.h> |
49 | 50 | ||
50 | #include <qvaluelist.h> | 51 | #include <qvaluelist.h> |
51 | 52 | ||
52 | #include <stdlib.h> | 53 | #include <stdlib.h> |
53 | #include <unistd.h> | 54 | #include <unistd.h> |
54 | 55 | ||
55 | class QCopKeyRegister | 56 | class QCopKeyRegister |
56 | { | 57 | { |
57 | public: | 58 | public: |
58 | QCopKeyRegister() : keyCode(0) { } | 59 | QCopKeyRegister() : keyCode(0) { } |
59 | QCopKeyRegister(int k, const QString &c, const QString &m) | 60 | QCopKeyRegister(int k, const QString &c, const QString &m) |
60 | : keyCode(k), channel(c), message(m) { } | 61 | : keyCode(k), channel(c), message(m) { } |
61 | 62 | ||
62 | int getKeyCode() const { return keyCode; } | 63 | int getKeyCode() const { return keyCode; } |
63 | QString getChannel() const { return channel; } | 64 | QString getChannel() const { return channel; } |
64 | QString getMessage() const { return message; } | 65 | QString getMessage() const { return message; } |
65 | 66 | ||
66 | private: | 67 | private: |
67 | int keyCode; | 68 | int keyCode; |
68 | QString channel, message; | 69 | QString channel, message; |
69 | }; | 70 | }; |
70 | 71 | ||
71 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 72 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
72 | KeyRegisterList keyRegisterList; | 73 | KeyRegisterList keyRegisterList; |
73 | 74 | ||
74 | static Desktop* qpedesktop = 0; | 75 | static Desktop* qpedesktop = 0; |
75 | static int loggedin=0; | 76 | static int loggedin=0; |
76 | static void login(bool at_poweron) | 77 | static void login(bool at_poweron) |
77 | { | 78 | { |
78 | if ( !loggedin ) { | 79 | if ( !loggedin ) { |
79 | Global::terminateBuiltin("calibrate"); | 80 | Global::terminateBuiltin("calibrate"); |
80 | Password::authenticate(at_poweron); | 81 | Password::authenticate(at_poweron); |
81 | loggedin=1; | 82 | loggedin=1; |
82 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 83 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
83 | } | 84 | } |
84 | } | 85 | } |
85 | 86 | ||
86 | bool Desktop::screenLocked() | 87 | bool Desktop::screenLocked() |
87 | { | 88 | { |
88 | return loggedin == 0; | 89 | return loggedin == 0; |
89 | } | 90 | } |
90 | 91 | ||
91 | /* | 92 | /* |
92 | Priority is number of alerts that are needed to pop up | 93 | Priority is number of alerts that are needed to pop up |
93 | alert. | 94 | alert. |
94 | */ | 95 | */ |
95 | class DesktopPowerAlerter : public QMessageBox | 96 | class DesktopPowerAlerter : public QMessageBox |
96 | { | 97 | { |
97 | public: | 98 | public: |
98 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 99 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
99 | : QMessageBox( tr("Battery Status"), "Low Battery", | 100 | : QMessageBox( tr("Battery Status"), "Low Battery", |
100 | QMessageBox::Critical, | 101 | QMessageBox::Critical, |
101 | QMessageBox::Ok | QMessageBox::Default, | 102 | QMessageBox::Ok | QMessageBox::Default, |
102 | QMessageBox::NoButton, QMessageBox::NoButton, | 103 | QMessageBox::NoButton, QMessageBox::NoButton, |
103 | parent, name, FALSE ) | 104 | parent, name, FALSE ) |
104 | { | 105 | { |
105 | currentPriority = INT_MAX; | 106 | currentPriority = INT_MAX; |
106 | alertCount = 0; | 107 | alertCount = 0; |
107 | } | 108 | } |
108 | 109 | ||
109 | void alert( const QString &text, int priority ); | 110 | void alert( const QString &text, int priority ); |
110 | void hideEvent( QHideEvent * ); | 111 | void hideEvent( QHideEvent * ); |
111 | private: | 112 | private: |
112 | int currentPriority; | 113 | int currentPriority; |
113 | int alertCount; | 114 | int alertCount; |
114 | }; | 115 | }; |
115 | 116 | ||
116 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 117 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
117 | { | 118 | { |
118 | alertCount++; | 119 | alertCount++; |
119 | if ( alertCount < priority ) | 120 | if ( alertCount < priority ) |
120 | return; | 121 | return; |
121 | if ( priority > currentPriority ) | 122 | if ( priority > currentPriority ) |
122 | return; | 123 | return; |
123 | currentPriority = priority; | 124 | currentPriority = priority; |
124 | setText( text ); | 125 | setText( text ); |
125 | show(); | 126 | show(); |
126 | } | 127 | } |
127 | 128 | ||
128 | 129 | ||
129 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 130 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
130 | { | 131 | { |
131 | QMessageBox::hideEvent( e ); | 132 | QMessageBox::hideEvent( e ); |
132 | alertCount = 0; | 133 | alertCount = 0; |
133 | currentPriority = INT_MAX; | 134 | currentPriority = INT_MAX; |
134 | } | 135 | } |
135 | 136 | ||
136 | 137 | ||
137 | 138 | ||
138 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) | 139 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) |
139 | : QPEApplication( argc, argv, t ) | 140 | : QPEApplication( argc, argv, t ) |
140 | { | 141 | { |
141 | 142 | ||
142 | QTimer *t = new QTimer( this ); | 143 | QTimer *t = new QTimer( this ); |
143 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); | 144 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); |
144 | t->start( 10000 ); | 145 | t->start( 10000 ); |
145 | ps = new PowerStatus; | 146 | ps = new PowerStatus; |
146 | pa = new DesktopPowerAlerter( 0 ); | 147 | pa = new DesktopPowerAlerter( 0 ); |
147 | 148 | ||
148 | channel = new QCopChannel( "QPE/Desktop", this ); | 149 | channel = new QCopChannel( "QPE/Desktop", this ); |
149 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 150 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
150 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 151 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
151 | } | 152 | } |
152 | 153 | ||
153 | 154 | ||
154 | DesktopApplication::~DesktopApplication() | 155 | DesktopApplication::~DesktopApplication() |
155 | { | 156 | { |
156 | delete ps; | 157 | delete ps; |
157 | delete pa; | 158 | delete pa; |
158 | } | 159 | } |
159 | 160 | ||
160 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | 161 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) |
161 | { | 162 | { |
162 | QDataStream stream( data, IO_ReadOnly ); | 163 | QDataStream stream( data, IO_ReadOnly ); |
163 | if (msg == "keyRegister(int key, QString channel, QString message)") | 164 | if (msg == "keyRegister(int key, QString channel, QString message)") |
164 | { | 165 | { |
165 | int k; | 166 | int k; |
166 | QString c, m; | 167 | QString c, m; |
167 | 168 | ||
168 | stream >> k; | 169 | stream >> k; |
169 | stream >> c; | 170 | stream >> c; |
170 | stream >> m; | 171 | stream >> m; |
171 | 172 | ||
172 | qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); | 173 | qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); |
173 | keyRegisterList.append(QCopKeyRegister(k,c,m)); | 174 | keyRegisterList.append(QCopKeyRegister(k,c,m)); |
174 | } | 175 | } |
175 | else if (msg == "suspend()"){ | 176 | else if (msg == "suspend()"){ |
176 | emit power(); | 177 | emit power(); |
177 | } | 178 | } |
178 | 179 | ||
179 | } | 180 | } |
180 | 181 | ||
181 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 182 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
182 | 183 | ||
183 | #ifdef Q_WS_QWS | 184 | #ifdef Q_WS_QWS |
184 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 185 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
185 | { | 186 | { |
186 | qpedesktop->checkMemory(); | 187 | qpedesktop->checkMemory(); |
187 | 188 | ||
188 | if ( e->type == QWSEvent::Key ) { | 189 | if ( e->type == QWSEvent::Key ) { |
189 | QWSKeyEvent *ke = (QWSKeyEvent *)e; | 190 | QWSKeyEvent *ke = (QWSKeyEvent *)e; |
190 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 191 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
191 | return TRUE; | 192 | return TRUE; |
192 | bool press = ke->simpleData.is_press; | 193 | bool press = ke->simpleData.is_press; |
193 | 194 | ||
194 | if (!keyRegisterList.isEmpty()) | 195 | if (!keyRegisterList.isEmpty()) |
195 | { | 196 | { |
196 | KeyRegisterList::Iterator it; | 197 | KeyRegisterList::Iterator it; |
197 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) | 198 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) |
198 | { | 199 | { |
199 | if ((*it).getKeyCode() == ke->simpleData.keycode) | 200 | if ((*it).getKeyCode() == ke->simpleData.keycode) |
200 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | 201 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); |
201 | } | 202 | } |
202 | } | 203 | } |
203 | 204 | ||
204 | if ( !keyboardGrabbed() ) { | 205 | if ( !keyboardGrabbed() ) { |
205 | if ( ke->simpleData.keycode == Key_F9 ) { | 206 | if ( ke->simpleData.keycode == Key_F9 ) { |
206 | if ( press ) emit datebook(); | 207 | if ( press ) emit datebook(); |
207 | return TRUE; | 208 | return TRUE; |
208 | } | 209 | } |
209 | if ( ke->simpleData.keycode == Key_F10 ) { | 210 | if ( ke->simpleData.keycode == Key_F10 ) { |
210 | if ( !press && cardSendTimer ) { | 211 | if ( !press && cardSendTimer ) { |
211 | emit contacts(); | 212 | emit contacts(); |
212 | delete cardSendTimer; | 213 | delete cardSendTimer; |
213 | } else if ( press ) { | 214 | } else if ( press ) { |
214 | cardSendTimer = new QTimer(); | 215 | cardSendTimer = new QTimer(); |
215 | cardSendTimer->start( 2000, TRUE ); | 216 | cardSendTimer->start( 2000, TRUE ); |
216 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 217 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
217 | } | 218 | } |
218 | return TRUE; | 219 | return TRUE; |
219 | } | 220 | } |
220 | /* menu key now opens application menu/toolbar | 221 | /* menu key now opens application menu/toolbar |
221 | if ( ke->simpleData.keycode == Key_F11 ) { | 222 | if ( ke->simpleData.keycode == Key_F11 ) { |
222 | if ( press ) emit menu(); | 223 | if ( press ) emit menu(); |
223 | return TRUE; | 224 | return TRUE; |
224 | } | 225 | } |
225 | */ | 226 | */ |
226 | if ( ke->simpleData.keycode == Key_F12 ) { | 227 | if ( ke->simpleData.keycode == Key_F12 ) { |
227 | while( activePopupWidget() ) | 228 | while( activePopupWidget() ) |
228 | activePopupWidget()->close(); | 229 | activePopupWidget()->close(); |
229 | if ( press ) emit launch(); | 230 | if ( press ) emit launch(); |
230 | return TRUE; | 231 | return TRUE; |
231 | } | 232 | } |
232 | if ( ke->simpleData.keycode == Key_F13 ) { | 233 | if ( ke->simpleData.keycode == Key_F13 ) { |
233 | if ( press ) emit email(); | 234 | if ( press ) emit email(); |
234 | return TRUE; | 235 | return TRUE; |
235 | } | 236 | } |
236 | } | 237 | } |
237 | 238 | ||
238 | if ( ke->simpleData.keycode == Key_F34 ) { | 239 | if ( ke->simpleData.keycode == Key_F34 ) { |
239 | if ( press ) emit power(); | 240 | if ( press ) emit power(); |
240 | return TRUE; | 241 | return TRUE; |
241 | } | 242 | } |
242 | if ( ke->simpleData.keycode == Key_SysReq ) { | 243 | if ( ke->simpleData.keycode == Key_SysReq ) { |
243 | if ( press ) emit power(); | 244 | if ( press ) emit power(); |
244 | return TRUE; | 245 | return TRUE; |
245 | } | 246 | } |
246 | if ( ke->simpleData.keycode == Key_F35 ) { | 247 | if ( ke->simpleData.keycode == Key_F35 ) { |
247 | if ( press ) emit backlight(); | 248 | if ( press ) emit backlight(); |
248 | return TRUE; | 249 | return TRUE; |
249 | } | 250 | } |
250 | if ( ke->simpleData.keycode == Key_F32 ) { | 251 | if ( ke->simpleData.keycode == Key_F32 ) { |
251 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 252 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
252 | return TRUE; | 253 | return TRUE; |
253 | } | 254 | } |
254 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 255 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
255 | if ( press ) emit symbol(); | 256 | if ( press ) emit symbol(); |
256 | return TRUE; | 257 | return TRUE; |
257 | } | 258 | } |
258 | if ( ke->simpleData.keycode == Key_NumLock ) { | 259 | if ( ke->simpleData.keycode == Key_NumLock ) { |
259 | if ( press ) emit numLockStateToggle(); | 260 | if ( press ) emit numLockStateToggle(); |
260 | } | 261 | } |
261 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 262 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
262 | if ( press ) emit capsLockStateToggle(); | 263 | if ( press ) emit capsLockStateToggle(); |
263 | } | 264 | } |
264 | if ( press ) | 265 | if ( press ) |
265 | qpedesktop->keyClick(); | 266 | qpedesktop->keyClick(); |
266 | } else { | 267 | } else { |
267 | if ( e->type == QWSEvent::Mouse ) { | 268 | if ( e->type == QWSEvent::Mouse ) { |
268 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 269 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
269 | static bool up = TRUE; | 270 | static bool up = TRUE; |
270 | if ( me->simpleData.state&LeftButton ) { | 271 | if ( me->simpleData.state&LeftButton ) { |
271 | if ( up ) { | 272 | if ( up ) { |
272 | up = FALSE; | 273 | up = FALSE; |
273 | qpedesktop->screenClick(); | 274 | qpedesktop->screenClick(); |
274 | } | 275 | } |
275 | } else { | 276 | } else { |
276 | up = TRUE; | 277 | up = TRUE; |
277 | } | 278 | } |
278 | } | 279 | } |
279 | } | 280 | } |
280 | 281 | ||
281 | return QPEApplication::qwsEventFilter( e ); | 282 | return QPEApplication::qwsEventFilter( e ); |
282 | } | 283 | } |
283 | #endif | 284 | #endif |
284 | 285 | ||
285 | void DesktopApplication::psTimeout() | 286 | void DesktopApplication::psTimeout() |
286 | { | 287 | { |
287 | qpedesktop->checkMemory(); // in case no events are being generated | 288 | qpedesktop->checkMemory(); // in case no events are being generated |
288 | 289 | ||
289 | *ps = PowerStatusManager::readStatus(); | 290 | *ps = PowerStatusManager::readStatus(); |
290 | 291 | ||
291 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 292 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
292 | pa->alert( tr( "Battery is running very low." ), 6 ); | 293 | pa->alert( tr( "Battery is running very low." ), 6 ); |
293 | } | 294 | } |
294 | 295 | ||
295 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 296 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
296 | pa->alert( tr( "Battery level is critical!\n" | 297 | pa->alert( tr( "Battery level is critical!\n" |
297 | "Keep power off until power restored!" ), 1 ); | 298 | "Keep power off until power restored!" ), 1 ); |
298 | } | 299 | } |
299 | 300 | ||
300 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 301 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
301 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 302 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
302 | } | 303 | } |
303 | } | 304 | } |
304 | 305 | ||
305 | 306 | ||
306 | void DesktopApplication::sendCard() | 307 | void DesktopApplication::sendCard() |
307 | { | 308 | { |
308 | delete cardSendTimer; | 309 | delete cardSendTimer; |
309 | cardSendTimer = 0; | 310 | cardSendTimer = 0; |
310 | QString card = getenv("HOME"); | 311 | QString card = getenv("HOME"); |
311 | card += "/Applications/addressbook/businesscard.vcf"; | 312 | card += "/Applications/addressbook/businesscard.vcf"; |
312 | 313 | ||
313 | if ( QFile::exists( card ) ) { | 314 | if ( QFile::exists( card ) ) { |
314 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); | 315 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); |
315 | QString mimetype = "text/x-vCard"; | 316 | QString mimetype = "text/x-vCard"; |
316 | e << tr("business card") << card << mimetype; | 317 | e << tr("business card") << card << mimetype; |
317 | } | 318 | } |
318 | } | 319 | } |
319 | 320 | ||
320 | #if defined(QPE_HAVE_MEMALERTER) | 321 | #if defined(QPE_HAVE_MEMALERTER) |
321 | QPE_MEMALERTER_IMPL | 322 | QPE_MEMALERTER_IMPL |
322 | #endif | 323 | #endif |
323 | 324 | ||
324 | #if defined(CUSTOM_SOUND_IMPL) | 325 | #if defined(CUSTOM_SOUND_IMPL) |
325 | CUSTOM_SOUND_IMPL | 326 | CUSTOM_SOUND_IMPL |
326 | #endif | 327 | #endif |
327 | 328 | ||
328 | //=========================================================================== | 329 | //=========================================================================== |
329 | 330 | ||
330 | Desktop::Desktop() : | 331 | Desktop::Desktop() : |
331 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 332 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
332 | qcopBridge( 0 ), | 333 | qcopBridge( 0 ), |
333 | transferServer( 0 ), | 334 | transferServer( 0 ), |
334 | packageSlave( 0 ) | 335 | packageSlave( 0 ) |
335 | { | 336 | { |
336 | #ifdef CUSTOM_SOUND_INIT | 337 | #ifdef CUSTOM_SOUND_INIT |
337 | CUSTOM_SOUND_INIT; | 338 | CUSTOM_SOUND_INIT; |
338 | #endif | 339 | #endif |
339 | 340 | ||
340 | qpedesktop = this; | 341 | qpedesktop = this; |
341 | 342 | ||
342 | // bg = new Info( this ); | 343 | // bg = new Info( this ); |
343 | tb = new TaskBar; | 344 | tb = new TaskBar; |
344 | 345 | ||
345 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 346 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
346 | 347 | ||
347 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); | 348 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); |
348 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); | 349 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); |
349 | 350 | ||
350 | int displayw = qApp->desktop()->width(); | 351 | int displayw = qApp->desktop()->width(); |
351 | int displayh = qApp->desktop()->height(); | 352 | int displayh = qApp->desktop()->height(); |
352 | 353 | ||
353 | 354 | ||
354 | QSize sz = tb->sizeHint(); | 355 | QSize sz = tb->sizeHint(); |
355 | 356 | ||
356 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 357 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
357 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 358 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
358 | 359 | ||
359 | tb->show(); | 360 | tb->show(); |
360 | launcher->showMaximized(); | 361 | launcher->showMaximized(); |
361 | launcher->show(); | 362 | launcher->show(); |
362 | launcher->raise(); | 363 | launcher->raise(); |
363 | #if defined(QPE_HAVE_MEMALERTER) | 364 | #if defined(QPE_HAVE_MEMALERTER) |
364 | initMemalerter(); | 365 | initMemalerter(); |
365 | #endif | 366 | #endif |
366 | // start services | 367 | // start services |
367 | startTransferServer(); | 368 | startTransferServer(); |
368 | (void) new IrServer( this ); | 369 | (void) new IrServer( this ); |
369 | rereadVolumes(); | 370 | rereadVolumes(); |
370 | 371 | ||
371 | packageSlave = new PackageSlave( this ); | 372 | packageSlave = new PackageSlave( this ); |
372 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); | 373 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); |
373 | 374 | ||
374 | qApp->installEventFilter( this ); | 375 | qApp->installEventFilter( this ); |
375 | } | 376 | } |
376 | 377 | ||
377 | void Desktop::show() | 378 | void Desktop::show() |
378 | { | 379 | { |
379 | login(TRUE); | 380 | login(TRUE); |
380 | QWidget::show(); | 381 | QWidget::show(); |
381 | } | 382 | } |
382 | 383 | ||
383 | Desktop::~Desktop() | 384 | Desktop::~Desktop() |
384 | { | 385 | { |
385 | delete launcher; | 386 | delete launcher; |
386 | delete tb; | 387 | delete tb; |
387 | delete qcopBridge; | 388 | delete qcopBridge; |
388 | delete transferServer; | 389 | delete transferServer; |
389 | } | 390 | } |
390 | 391 | ||
391 | bool Desktop::recoverMemory() | 392 | bool Desktop::recoverMemory() |
392 | { | 393 | { |
393 | return tb->recoverMemory(); | 394 | return tb->recoverMemory(); |
394 | } | 395 | } |
395 | 396 | ||
396 | void Desktop::checkMemory() | 397 | void Desktop::checkMemory() |
397 | { | 398 | { |
398 | #if defined(QPE_HAVE_MEMALERTER) | 399 | #if defined(QPE_HAVE_MEMALERTER) |
399 | static bool ignoreNormal=FALSE; | 400 | static bool ignoreNormal=FALSE; |
400 | static bool existingMessage=FALSE; | 401 | static bool existingMessage=FALSE; |
401 | 402 | ||
402 | if(existingMessage) | 403 | if(existingMessage) |
403 | return; // don't show a second message while still on first | 404 | return; // don't show a second message while still on first |
404 | 405 | ||
405 | existingMessage = TRUE; | 406 | existingMessage = TRUE; |
406 | switch ( memstate ) { | 407 | switch ( memstate ) { |
407 | case Unknown: | 408 | case Unknown: |
408 | break; | 409 | break; |
409 | case Low: | 410 | case Low: |
410 | memstate = Unknown; | 411 | memstate = Unknown; |
411 | if ( recoverMemory() ) | 412 | if ( recoverMemory() ) |
412 | ignoreNormal = TRUE; | 413 | ignoreNormal = TRUE; |
413 | else | 414 | else |
414 | QMessageBox::warning( 0 , "Memory Status", | 415 | QMessageBox::warning( 0 , "Memory Status", |
415 | "The memory smacks of shortage. \n" | 416 | "The memory smacks of shortage. \n" |
416 | "Please save data. " ); | 417 | "Please save data. " ); |
417 | break; | 418 | break; |
418 | case Normal: | 419 | case Normal: |
419 | memstate = Unknown; | 420 | memstate = Unknown; |
420 | if ( ignoreNormal ) | 421 | if ( ignoreNormal ) |
421 | ignoreNormal = FALSE; | 422 | ignoreNormal = FALSE; |
422 | else | 423 | else |
423 | QMessageBox::information ( 0 , "Memory Status", | 424 | QMessageBox::information ( 0 , "Memory Status", |
424 | "There is enough memory again." ); | 425 | "There is enough memory again." ); |
425 | break; | 426 | break; |
426 | case VeryLow: | 427 | case VeryLow: |
427 | memstate = Unknown; | 428 | memstate = Unknown; |
428 | QMessageBox::critical( 0 , "Memory Status", | 429 | QMessageBox::critical( 0 , "Memory Status", |
429 | "The memory is very low. \n" | 430 | "The memory is very low. \n" |
430 | "Please end this application \n" | 431 | "Please end this application \n" |
431 | "immediately." ); | 432 | "immediately." ); |
432 | recoverMemory(); | 433 | recoverMemory(); |
433 | } | 434 | } |
434 | existingMessage = FALSE; | 435 | existingMessage = FALSE; |
435 | #endif | 436 | #endif |
436 | } | 437 | } |
437 | 438 | ||
438 | static bool isVisibleWindow(int wid) | 439 | static bool isVisibleWindow(int wid) |
439 | { | 440 | { |
440 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 441 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
441 | QWSWindow* w; | 442 | QWSWindow* w; |
442 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 443 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
443 | if ( w->winId() == wid ) | 444 | if ( w->winId() == wid ) |
444 | return !w->isFullyObscured(); | 445 | return !w->isFullyObscured(); |
445 | } | 446 | } |
446 | return FALSE; | 447 | return FALSE; |
447 | } | 448 | } |
448 | 449 | ||
449 | static bool hasVisibleWindow(const QString& clientname) | 450 | static bool hasVisibleWindow(const QString& clientname) |
450 | { | 451 | { |
451 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 452 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
452 | QWSWindow* w; | 453 | QWSWindow* w; |
453 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 454 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
454 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) | 455 | if ( w->client()->identity() == clientname && !w->isFullyObscured() ) |
455 | return TRUE; | 456 | return TRUE; |
456 | } | 457 | } |
457 | return FALSE; | 458 | return FALSE; |
458 | } | 459 | } |
459 | 460 | ||
460 | void Desktop::raiseLauncher() | 461 | void Desktop::raiseLauncher() |
461 | { | 462 | { |
462 | Config cfg("qpe"); //F12 'Home' | 463 | Config cfg("qpe"); //F12 'Home' |
463 | cfg.setGroup("AppsKey"); | 464 | cfg.setGroup("AppsKey"); |
464 | QString tempItem; | 465 | QString tempItem; |
465 | tempItem = cfg.readEntry("Middle","Home"); | 466 | tempItem = cfg.readEntry("Middle","Home"); |
466 | if(tempItem == "Home" || tempItem.isEmpty()) { | 467 | if(tempItem == "Home" || tempItem.isEmpty()) { |
467 | if ( isVisibleWindow(launcher->winId()) ) | 468 | if ( isVisibleWindow(launcher->winId()) ) |
468 | launcher->nextView(); | 469 | launcher->nextView(); |
469 | else | 470 | else |
470 | launcher->raise(); | 471 | launcher->raise(); |
471 | } else { | 472 | } else { |
472 | QCopEnvelope e("QPE/System","execute(QString)"); | 473 | QCopEnvelope e("QPE/System","execute(QString)"); |
473 | e << tempItem; | 474 | e << tempItem; |
474 | } | 475 | } |
475 | } | 476 | } |
476 | 477 | ||
477 | void Desktop::executeOrModify(const QString& appLnkFile) | 478 | void Desktop::executeOrModify(const QString& appLnkFile) |
478 | { | 479 | { |
479 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); | 480 | AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); |
480 | if ( lnk.isValid() ) { | 481 | if ( lnk.isValid() ) { |
481 | QCString app = lnk.exec().utf8(); | 482 | QCString app = lnk.exec().utf8(); |
482 | Global::terminateBuiltin("calibrate"); | 483 | Global::terminateBuiltin("calibrate"); |
483 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { | 484 | if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { |
484 | MRUList::addTask(&lnk); | 485 | MRUList::addTask(&lnk); |
485 | if ( hasVisibleWindow(app) ) | 486 | if ( hasVisibleWindow(app) ) |
486 | QCopChannel::send("QPE/Application/" + app, "nextView()"); | 487 | QCopChannel::send("QPE/Application/" + app, "nextView()"); |
487 | else | 488 | else |
488 | QCopChannel::send("QPE/Application/" + app, "raise()"); | 489 | QCopChannel::send("QPE/Application/" + app, "raise()"); |
489 | } else { | 490 | } else { |
490 | lnk.execute(); | 491 | lnk.execute(); |
491 | } | 492 | } |
492 | } | 493 | } |
493 | } | 494 | } |
494 | 495 | ||
495 | void Desktop::raiseDatebook() | 496 | void Desktop::raiseDatebook() |
496 | { | 497 | { |
497 | Config cfg("qpe"); //F9 'Activity' | 498 | Config cfg("qpe"); //F9 'Activity' |
498 | cfg.setGroup("AppsKey"); | 499 | cfg.setGroup("AppsKey"); |
499 | QString tempItem; | 500 | QString tempItem; |
500 | tempItem = cfg.readEntry("LeftEnd","Calender"); | 501 | tempItem = cfg.readEntry("LeftEnd","Calender"); |
501 | if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); | 502 | if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop"); |
502 | else { | 503 | else { |
503 | QCopEnvelope e("QPE/System","execute(QString)"); | 504 | QCopEnvelope e("QPE/System","execute(QString)"); |
504 | e << tempItem; | 505 | e << tempItem; |
505 | } | 506 | } |
506 | } | 507 | } |
507 | 508 | ||
508 | void Desktop::raiseContacts() | 509 | void Desktop::raiseContacts() |
509 | { | 510 | { |
510 | Config cfg("qpe"); //F10, 'Contacts' | 511 | Config cfg("qpe"); //F10, 'Contacts' |
511 | cfg.setGroup("AppsKey"); | 512 | cfg.setGroup("AppsKey"); |
512 | QString tempItem; | 513 | QString tempItem; |
513 | tempItem = cfg.readEntry("Left2nd","Address Book"); | 514 | tempItem = cfg.readEntry("Left2nd","Address Book"); |
514 | if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); | 515 | if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop"); |
515 | else { | 516 | else { |
516 | QCopEnvelope e("QPE/System","execute(QString)"); | 517 | QCopEnvelope e("QPE/System","execute(QString)"); |
517 | e << tempItem; | 518 | e << tempItem; |
518 | } | 519 | } |
519 | } | 520 | } |
520 | 521 | ||
521 | void Desktop::raiseMenu() | 522 | void Desktop::raiseMenu() |
522 | { | 523 | { |
523 | Config cfg("qpe"); //F11, 'Menu' | 524 | Config cfg("qpe"); //F11, 'Menu' |
524 | cfg.setGroup("AppsKey"); | 525 | cfg.setGroup("AppsKey"); |
525 | QString tempItem; | 526 | QString tempItem; |
526 | tempItem = cfg.readEntry("Right2nd","Popup Menu"); | 527 | tempItem = cfg.readEntry("Right2nd","Popup Menu"); |
527 | if(tempItem == "Popup Menu" || tempItem.isEmpty()) { | 528 | if(tempItem == "Popup Menu" || tempItem.isEmpty()) { |
528 | Global::terminateBuiltin("calibrate"); | 529 | Global::terminateBuiltin("calibrate"); |
529 | tb->startMenu()->launch(); | 530 | tb->startMenu()->launch(); |
530 | } else { | 531 | } else { |
531 | QCopEnvelope e("QPE/System","execute(QString)"); | 532 | QCopEnvelope e("QPE/System","execute(QString)"); |
532 | e << tempItem; | 533 | e << tempItem; |
533 | } | 534 | } |
534 | } | 535 | } |
535 | 536 | ||
536 | void Desktop::raiseEmail() | 537 | void Desktop::raiseEmail() |
537 | { | 538 | { |
538 | Config cfg("qpe"); //F13, 'Mail' | 539 | Config cfg("qpe"); //F13, 'Mail' |
539 | cfg.setGroup("AppsKey"); | 540 | cfg.setGroup("AppsKey"); |
540 | QString tempItem; | 541 | QString tempItem; |
541 | tempItem = cfg.readEntry("RightEnd","Mail"); | 542 | tempItem = cfg.readEntry("RightEnd","Mail"); |
542 | if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); | 543 | if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop"); |
543 | else { | 544 | else { |
544 | QCopEnvelope e("QPE/System","execute(QString)"); | 545 | QCopEnvelope e("QPE/System","execute(QString)"); |
545 | e << tempItem; | 546 | e << tempItem; |
546 | } | 547 | } |
547 | } | 548 | } |
548 | 549 | ||
549 | // autoStarts apps on resume and start | 550 | // autoStarts apps on resume and start |
550 | void Desktop::execAutoStart() | 551 | void Desktop::execAutoStart() { |
551 | { | 552 | QString appName; |
552 | QString appName; | 553 | int delay; |
553 | Config cfg( "autostart" ); | 554 | QDateTime now = QDateTime::currentDateTime(); |
554 | cfg.setGroup( "AutoStart" ); | 555 | Config cfg( "autostart" ); |
555 | appName = cfg.readEntry("Apps", ""); | 556 | cfg.setGroup( "AutoStart" ); |
556 | QCopEnvelope e("QPE/System", "execute(QString)"); | 557 | appName = cfg.readEntry("Apps", ""); |
557 | e << QString(appName); | 558 | delay = (cfg.readEntry("Delay", "0" )).toInt(); |
559 | // If the time between suspend and resume was longer then the | ||
560 | // value saved as delay, start the app | ||
561 | if ( suspendTime.secsTo(now) >= (delay*60) ) { | ||
562 | QCopEnvelope e("QPE/System", "execute(QString)"); | ||
563 | e << QString(appName); | ||
564 | } else { | ||
565 | } | ||
558 | } | 566 | } |
559 | 567 | ||
560 | #if defined(QPE_HAVE_TOGGLELIGHT) | 568 | #if defined(QPE_HAVE_TOGGLELIGHT) |
561 | #include <qpe/config.h> | 569 | #include <qpe/config.h> |
562 | 570 | ||
563 | #include <sys/ioctl.h> | 571 | #include <sys/ioctl.h> |
564 | #include <sys/types.h> | 572 | #include <sys/types.h> |
565 | #include <fcntl.h> | 573 | #include <fcntl.h> |
566 | #include <unistd.h> | 574 | #include <unistd.h> |
567 | #include <errno.h> | 575 | #include <errno.h> |
568 | #include <linux/ioctl.h> | 576 | #include <linux/ioctl.h> |
569 | #include <time.h> | 577 | #include <time.h> |
570 | #endif | 578 | #endif |
571 | 579 | ||
572 | static bool blanked=FALSE; | 580 | static bool blanked=FALSE; |
573 | 581 | ||
574 | static void blankScreen() | 582 | static void blankScreen() |
575 | { | 583 | { |
576 | if ( !qt_screen ) return; | 584 | if ( !qt_screen ) return; |
577 | /* Should use a big black window instead. | 585 | /* Should use a big black window instead. |
578 | QGfx* g = qt_screen->screenGfx(); | 586 | QGfx* g = qt_screen->screenGfx(); |
579 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); | 587 | g->fillRect(0,0,qt_screen->width(),qt_screen->height()); |
580 | delete g; | 588 | delete g; |
581 | */ | 589 | */ |
582 | blanked = TRUE; | 590 | blanked = TRUE; |
583 | } | 591 | } |
584 | 592 | ||
585 | static void darkScreen() | 593 | static void darkScreen() |
586 | { | 594 | { |
587 | extern void qpe_setBacklight(int); | 595 | extern void qpe_setBacklight(int); |
588 | qpe_setBacklight(0); // force off | 596 | qpe_setBacklight(0); // force off |
589 | } | 597 | } |
590 | 598 | ||
591 | 599 | ||
592 | void Desktop::togglePower() | 600 | void Desktop::togglePower() |
593 | { | 601 | { |
594 | bool wasloggedin = loggedin; | 602 | bool wasloggedin = loggedin; |
595 | loggedin=0; | 603 | loggedin=0; |
604 | suspendTime = QDateTime::currentDateTime(); | ||
596 | darkScreen(); | 605 | darkScreen(); |
597 | if ( wasloggedin ) | 606 | if ( wasloggedin ) |
598 | blankScreen(); | 607 | blankScreen(); |
599 | 608 | ||
600 | system("apm --suspend"); | 609 | system("apm --suspend"); |
601 | 610 | ||
602 | 611 | ||
603 | 612 | ||
604 | QWSServer::screenSaverActivate( FALSE ); | 613 | QWSServer::screenSaverActivate( FALSE ); |
605 | { | 614 | { |
606 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep | 615 | QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep |
607 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 616 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
608 | e << -3; // Force on | 617 | e << -3; // Force on |
609 | } | 618 | } |
610 | if ( wasloggedin ) { | 619 | if ( wasloggedin ) { |
611 | login(TRUE); | 620 | login(TRUE); |
612 | } | 621 | } |
613 | sleep(1); | 622 | sleep(1); |
614 | execAutoStart(); | 623 | execAutoStart(); |
615 | //qcopBridge->closeOpenConnections(); | 624 | //qcopBridge->closeOpenConnections(); |
616 | //qDebug("called togglePower()!!!!!!"); | 625 | //qDebug("called togglePower()!!!!!!"); |
617 | } | 626 | } |
618 | 627 | ||
619 | void Desktop::toggleLight() | 628 | void Desktop::toggleLight() |
620 | { | 629 | { |
621 | QCopEnvelope e("QPE/System", "setBacklight(int)"); | 630 | QCopEnvelope e("QPE/System", "setBacklight(int)"); |
622 | e << -2; // toggle | 631 | e << -2; // toggle |
623 | } | 632 | } |
624 | 633 | ||
625 | void Desktop::toggleSymbolInput() | 634 | void Desktop::toggleSymbolInput() |
626 | { | 635 | { |
627 | tb->toggleSymbolInput(); | 636 | tb->toggleSymbolInput(); |
628 | } | 637 | } |
629 | 638 | ||
630 | void Desktop::toggleNumLockState() | 639 | void Desktop::toggleNumLockState() |
631 | { | 640 | { |
632 | tb->toggleNumLockState(); | 641 | tb->toggleNumLockState(); |
633 | } | 642 | } |
634 | 643 | ||
635 | void Desktop::toggleCapsLockState() | 644 | void Desktop::toggleCapsLockState() |
636 | { | 645 | { |
637 | tb->toggleCapsLockState(); | 646 | tb->toggleCapsLockState(); |
638 | } | 647 | } |
639 | 648 | ||
640 | void Desktop::styleChange( QStyle &s ) | 649 | void Desktop::styleChange( QStyle &s ) |
641 | { | 650 | { |
642 | QWidget::styleChange( s ); | 651 | QWidget::styleChange( s ); |
643 | int displayw = qApp->desktop()->width(); | 652 | int displayw = qApp->desktop()->width(); |
644 | int displayh = qApp->desktop()->height(); | 653 | int displayh = qApp->desktop()->height(); |
645 | 654 | ||
646 | QSize sz = tb->sizeHint(); | 655 | QSize sz = tb->sizeHint(); |
647 | 656 | ||
648 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 657 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
649 | } | 658 | } |
650 | 659 | ||
651 | void DesktopApplication::shutdown() | 660 | void DesktopApplication::shutdown() |
652 | { | 661 | { |
653 | if ( type() != GuiServer ) | 662 | if ( type() != GuiServer ) |
654 | return; | 663 | return; |
655 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 664 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
656 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), | 665 | connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), |
657 | this, SLOT(shutdown(ShutdownImpl::Type)) ); | 666 | this, SLOT(shutdown(ShutdownImpl::Type)) ); |
658 | sd->showMaximized(); | 667 | sd->showMaximized(); |
659 | } | 668 | } |
660 | 669 | ||
661 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 670 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
662 | { | 671 | { |
663 | switch ( t ) { | 672 | switch ( t ) { |
664 | case ShutdownImpl::ShutdownSystem: | 673 | case ShutdownImpl::ShutdownSystem: |
665 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); | 674 | execlp("shutdown", "shutdown", "-h", "now", (void*)0); |
666 | break; | 675 | break; |
667 | case ShutdownImpl::RebootSystem: | 676 | case ShutdownImpl::RebootSystem: |
668 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); | 677 | execlp("shutdown", "shutdown", "-r", "now", (void*)0); |
669 | break; | 678 | break; |
670 | case ShutdownImpl::RestartDesktop: | 679 | case ShutdownImpl::RestartDesktop: |
671 | restart(); | 680 | restart(); |
672 | break; | 681 | break; |
673 | case ShutdownImpl::TerminateDesktop: | 682 | case ShutdownImpl::TerminateDesktop: |
674 | prepareForTermination(FALSE); | 683 | prepareForTermination(FALSE); |
675 | quit(); | 684 | quit(); |
676 | break; | 685 | break; |
677 | } | 686 | } |
678 | } | 687 | } |
679 | 688 | ||
680 | void DesktopApplication::restart() | 689 | void DesktopApplication::restart() |
681 | { | 690 | { |
682 | prepareForTermination(TRUE); | 691 | prepareForTermination(TRUE); |
683 | 692 | ||
684 | #ifdef Q_WS_QWS | 693 | #ifdef Q_WS_QWS |
685 | for ( int fd = 3; fd < 100; fd++ ) | 694 | for ( int fd = 3; fd < 100; fd++ ) |
686 | close( fd ); | 695 | close( fd ); |
687 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 696 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
688 | execl( "/sbin/init", "qpe", 0 ); | 697 | execl( "/sbin/init", "qpe", 0 ); |
689 | #elif defined(QT_QWS_CASSIOPEIA) | 698 | #elif defined(QT_QWS_CASSIOPEIA) |
690 | execl( "/bin/sh", "sh", 0 ); | 699 | execl( "/bin/sh", "sh", 0 ); |
691 | #else | 700 | #else |
692 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); | 701 | execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); |
693 | #endif | 702 | #endif |
694 | exit(1); | 703 | exit(1); |
695 | #endif | 704 | #endif |
696 | } | 705 | } |
697 | 706 | ||
698 | void Desktop::startTransferServer() | 707 | void Desktop::startTransferServer() |
699 | { | 708 | { |
700 | // start qcop bridge server | 709 | // start qcop bridge server |
701 | qcopBridge = new QCopBridge( 4243 ); | 710 | qcopBridge = new QCopBridge( 4243 ); |
702 | if ( !qcopBridge->ok() ) { | 711 | if ( !qcopBridge->ok() ) { |
703 | delete qcopBridge; | 712 | delete qcopBridge; |
704 | qcopBridge = 0; | 713 | qcopBridge = 0; |
705 | } | 714 | } |
706 | // start transfer server | 715 | // start transfer server |
707 | transferServer = new TransferServer( 4242 ); | 716 | transferServer = new TransferServer( 4242 ); |
708 | if ( !transferServer->ok() ) { | 717 | if ( !transferServer->ok() ) { |
709 | delete transferServer; | 718 | delete transferServer; |
710 | transferServer = 0; | 719 | transferServer = 0; |
711 | } | 720 | } |
712 | if ( !transferServer || !qcopBridge ) | 721 | if ( !transferServer || !qcopBridge ) |
713 | startTimer( 2000 ); | 722 | startTimer( 2000 ); |
714 | } | 723 | } |
715 | 724 | ||
716 | void Desktop::timerEvent( QTimerEvent *e ) | 725 | void Desktop::timerEvent( QTimerEvent *e ) |
717 | { | 726 | { |
718 | killTimer( e->timerId() ); | 727 | killTimer( e->timerId() ); |
719 | startTransferServer(); | 728 | startTransferServer(); |
720 | } | 729 | } |
721 | 730 | ||
722 | void Desktop::terminateServers() | 731 | void Desktop::terminateServers() |
723 | { | 732 | { |
724 | delete transferServer; | 733 | delete transferServer; |
725 | delete qcopBridge; | 734 | delete qcopBridge; |
726 | transferServer = 0; | 735 | transferServer = 0; |
727 | qcopBridge = 0; | 736 | qcopBridge = 0; |
728 | } | 737 | } |
729 | 738 | ||
730 | void Desktop::rereadVolumes() | 739 | void Desktop::rereadVolumes() |
731 | { | 740 | { |
732 | Config cfg("Sound"); | 741 | Config cfg("Sound"); |
733 | cfg.setGroup("System"); | 742 | cfg.setGroup("System"); |
734 | touchclick = cfg.readBoolEntry("Touch"); | 743 | touchclick = cfg.readBoolEntry("Touch"); |
735 | keyclick = cfg.readBoolEntry("Key"); | 744 | keyclick = cfg.readBoolEntry("Key"); |
736 | } | 745 | } |
737 | 746 | ||
738 | void Desktop::keyClick() | 747 | void Desktop::keyClick() |
739 | { | 748 | { |
740 | #ifdef CUSTOM_SOUND_KEYCLICK | 749 | #ifdef CUSTOM_SOUND_KEYCLICK |
741 | if ( keyclick ) | 750 | if ( keyclick ) |
742 | CUSTOM_SOUND_KEYCLICK; | 751 | CUSTOM_SOUND_KEYCLICK; |
743 | #endif | 752 | #endif |
744 | } | 753 | } |
745 | 754 | ||
746 | void Desktop::screenClick() | 755 | void Desktop::screenClick() |
747 | { | 756 | { |
748 | #ifdef CUSTOM_SOUND_TOUCH | 757 | #ifdef CUSTOM_SOUND_TOUCH |
749 | if ( touchclick ) | 758 | if ( touchclick ) |
750 | CUSTOM_SOUND_TOUCH; | 759 | CUSTOM_SOUND_TOUCH; |
751 | #endif | 760 | #endif |
752 | } | 761 | } |
753 | 762 | ||
754 | void Desktop::soundAlarm() | 763 | void Desktop::soundAlarm() |
755 | { | 764 | { |
756 | #ifdef CUSTOM_SOUND_ALARM | 765 | #ifdef CUSTOM_SOUND_ALARM |
757 | CUSTOM_SOUND_ALARM; | 766 | CUSTOM_SOUND_ALARM; |
758 | #endif | 767 | #endif |
759 | } | 768 | } |
760 | 769 | ||
761 | bool Desktop::eventFilter( QObject *w, QEvent *ev ) | 770 | bool Desktop::eventFilter( QObject *w, QEvent *ev ) |
762 | { | 771 | { |
763 | if ( ev->type() == QEvent::KeyPress ) { | 772 | if ( ev->type() == QEvent::KeyPress ) { |
764 | QKeyEvent *ke = (QKeyEvent *)ev; | 773 | QKeyEvent *ke = (QKeyEvent *)ev; |
765 | if ( ke->key() == Qt::Key_F11 ) { // menu key | 774 | if ( ke->key() == Qt::Key_F11 ) { // menu key |
766 | QWidget *active = qApp->activeWindow(); | 775 | QWidget *active = qApp->activeWindow(); |
767 | if ( active && active->isPopup() ) { | 776 | if ( active && active->isPopup() ) { |
768 | active->close(); | 777 | active->close(); |
769 | } | 778 | } |
770 | raiseMenu(); | 779 | raiseMenu(); |
771 | return TRUE; | 780 | return TRUE; |
772 | } | 781 | } |
773 | } | 782 | } |
774 | return FALSE; | 783 | return FALSE; |
775 | } | 784 | } |
776 | 785 | ||
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h index de0dbf0..e094dc0 100644 --- a/core/launcher/desktop.h +++ b/core/launcher/desktop.h | |||
@@ -1,134 +1,136 @@ | |||
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 | #ifndef __DESKTOP_H__ | 21 | #ifndef __DESKTOP_H__ |
22 | #define __DESKTOP_H__ | 22 | #define __DESKTOP_H__ |
23 | 23 | ||
24 | 24 | ||
25 | #include "shutdownimpl.h" | 25 | #include "shutdownimpl.h" |
26 | 26 | ||
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | 28 | ||
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #include <qdatetime.h> | ||
30 | 31 | ||
31 | class Background; | 32 | class Background; |
32 | class Launcher; | 33 | class Launcher; |
33 | class TaskBar; | 34 | class TaskBar; |
34 | class PowerStatus; | 35 | class PowerStatus; |
35 | class QCopBridge; | 36 | class QCopBridge; |
36 | class TransferServer; | 37 | class TransferServer; |
37 | class DesktopPowerAlerter; | 38 | class DesktopPowerAlerter; |
38 | class PackageSlave; | 39 | class PackageSlave; |
39 | 40 | ||
40 | class DesktopApplication : public QPEApplication | 41 | class DesktopApplication : public QPEApplication |
41 | { | 42 | { |
42 | Q_OBJECT | 43 | Q_OBJECT |
43 | public: | 44 | public: |
44 | DesktopApplication( int& argc, char **argv, Type t ); | 45 | DesktopApplication( int& argc, char **argv, Type t ); |
45 | ~DesktopApplication(); | 46 | ~DesktopApplication(); |
46 | signals: | 47 | signals: |
47 | void home(); | 48 | void home(); |
48 | void datebook(); | 49 | void datebook(); |
49 | void contacts(); | 50 | void contacts(); |
50 | void launch(); | 51 | void launch(); |
51 | void email(); | 52 | void email(); |
52 | void backlight(); | 53 | void backlight(); |
53 | void power(); | 54 | void power(); |
54 | void symbol(); | 55 | void symbol(); |
55 | void numLockStateToggle(); | 56 | void numLockStateToggle(); |
56 | void capsLockStateToggle(); | 57 | void capsLockStateToggle(); |
57 | void prepareForRestart(); | 58 | void prepareForRestart(); |
58 | 59 | ||
59 | protected: | 60 | protected: |
60 | #ifdef Q_WS_QWS | 61 | #ifdef Q_WS_QWS |
61 | bool qwsEventFilter( QWSEvent * ); | 62 | bool qwsEventFilter( QWSEvent * ); |
62 | #endif | 63 | #endif |
63 | void shutdown(); | 64 | void shutdown(); |
64 | void restart(); | 65 | void restart(); |
65 | 66 | ||
66 | public slots: | 67 | public slots: |
67 | void receive( const QCString &msg, const QByteArray &data ); | 68 | void receive( const QCString &msg, const QByteArray &data ); |
68 | 69 | ||
69 | protected slots: | 70 | protected slots: |
70 | void shutdown(ShutdownImpl::Type); | 71 | void shutdown(ShutdownImpl::Type); |
71 | void psTimeout(); | 72 | void psTimeout(); |
72 | void sendCard(); | 73 | void sendCard(); |
73 | private: | 74 | private: |
74 | DesktopPowerAlerter *pa; | 75 | DesktopPowerAlerter *pa; |
75 | PowerStatus *ps; | 76 | PowerStatus *ps; |
76 | QTimer *cardSendTimer; | 77 | QTimer *cardSendTimer; |
77 | QCopChannel *channel; | 78 | QCopChannel *channel; |
78 | }; | 79 | }; |
79 | 80 | ||
80 | 81 | ||
81 | class Desktop : public QWidget { | 82 | class Desktop : public QWidget { |
82 | Q_OBJECT | 83 | Q_OBJECT |
83 | public: | 84 | public: |
84 | Desktop(); | 85 | Desktop(); |
85 | ~Desktop(); | 86 | ~Desktop(); |
86 | 87 | ||
87 | static bool screenLocked(); | 88 | static bool screenLocked(); |
88 | 89 | ||
89 | void show(); | 90 | void show(); |
90 | void checkMemory(); | 91 | void checkMemory(); |
91 | 92 | ||
92 | void keyClick(); | 93 | void keyClick(); |
93 | void screenClick(); | 94 | void screenClick(); |
94 | static void soundAlarm(); | 95 | static void soundAlarm(); |
95 | 96 | ||
96 | public slots: | 97 | public slots: |
97 | void raiseDatebook(); | 98 | void raiseDatebook(); |
98 | void raiseContacts(); | 99 | void raiseContacts(); |
99 | void raiseMenu(); | 100 | void raiseMenu(); |
100 | void raiseLauncher(); | 101 | void raiseLauncher(); |
101 | void raiseEmail(); | 102 | void raiseEmail(); |
102 | void execAutoStart(); | 103 | void execAutoStart(); |
103 | void togglePower(); | 104 | void togglePower(); |
104 | void toggleLight(); | 105 | void toggleLight(); |
105 | void toggleNumLockState(); | 106 | void toggleNumLockState(); |
106 | void toggleCapsLockState(); | 107 | void toggleCapsLockState(); |
107 | void toggleSymbolInput(); | 108 | void toggleSymbolInput(); |
108 | void terminateServers(); | 109 | void terminateServers(); |
109 | void rereadVolumes(); | 110 | void rereadVolumes(); |
110 | 111 | ||
111 | protected: | 112 | protected: |
112 | void executeOrModify(const QString& appLnkFile); | 113 | void executeOrModify(const QString& appLnkFile); |
113 | void styleChange( QStyle & ); | 114 | void styleChange( QStyle & ); |
114 | void timerEvent( QTimerEvent *e ); | 115 | void timerEvent( QTimerEvent *e ); |
115 | bool eventFilter( QObject *, QEvent * ); | 116 | bool eventFilter( QObject *, QEvent * ); |
116 | 117 | ||
117 | QWidget *bg; | 118 | QWidget *bg; |
118 | Launcher *launcher; | 119 | Launcher *launcher; |
119 | TaskBar *tb; | 120 | TaskBar *tb; |
120 | 121 | ||
121 | private: | 122 | private: |
122 | void startTransferServer(); | 123 | void startTransferServer(); |
123 | bool recoverMemory(); | 124 | bool recoverMemory(); |
124 | 125 | ||
125 | QCopBridge *qcopBridge; | 126 | QCopBridge *qcopBridge; |
126 | TransferServer *transferServer; | 127 | TransferServer *transferServer; |
127 | PackageSlave *packageSlave; | 128 | PackageSlave *packageSlave; |
128 | 129 | ||
130 | QDateTime suspendTime; | ||
129 | bool keyclick,touchclick; | 131 | bool keyclick,touchclick; |
130 | }; | 132 | }; |
131 | 133 | ||
132 | 134 | ||
133 | #endif // __DESKTOP_H__ | 135 | #endif // __DESKTOP_H__ |
134 | 136 | ||
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 1449269..979eee6 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,943 +1,957 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (c) 2002 Holger zecke Freyther | 2 | ** Copyright (c) 2002 Holger zecke Freyther |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Qtopia Environment. | 5 | ** This file is part of Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | 22 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT |
23 | // have this class. | 23 | // have this class. |
24 | #define QTOPIA_INTERNAL_FSLP | 24 | #define QTOPIA_INTERNAL_FSLP |
25 | 25 | ||
26 | #include <opie/oconfig.h> | 26 | #include <opie/oconfig.h> |
27 | #include <qpe/qcopenvelope_qws.h> | 27 | #include <qpe/qcopenvelope_qws.h> |
28 | #include <qpe/resource.h> | 28 | #include <qpe/resource.h> |
29 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
30 | #include <qpe/config.h> | 30 | #include <qpe/config.h> |
31 | #include <qpe/global.h> | 31 | #include <qpe/global.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/mimetype.h> | 33 | #include <qpe/mimetype.h> |
34 | #include <qpe/storage.h> | 34 | #include <qpe/storage.h> |
35 | #include <qpe/palmtoprecord.h> | 35 | #include <qpe/palmtoprecord.h> |
36 | 36 | ||
37 | #include <qdatetime.h> | 37 | #include <qdatetime.h> |
38 | #include <qdir.h> | 38 | #include <qdir.h> |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #include <qtimer.h> | 40 | #include <qtimer.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qvbox.h> | 42 | #include <qvbox.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qstyle.h> | 44 | #include <qstyle.h> |
45 | #include <qpushbutton.h> | 45 | #include <qpushbutton.h> |
46 | #include <qtabbar.h> | 46 | #include <qtabbar.h> |
47 | #include <qwidgetstack.h> | 47 | #include <qwidgetstack.h> |
48 | #include <qlayout.h> | 48 | #include <qlayout.h> |
49 | #include <qregexp.h> | 49 | #include <qregexp.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qframe.h> | 51 | #include <qframe.h> |
52 | #include <qpainter.h> | 52 | #include <qpainter.h> |
53 | #include <qlabel.h> | 53 | #include <qlabel.h> |
54 | #include <qtextstream.h> | 54 | #include <qtextstream.h> |
55 | 55 | ||
56 | #include "launcherview.h" | 56 | #include "launcherview.h" |
57 | #include "launcher.h" | 57 | #include "launcher.h" |
58 | #include "syncdialog.h" | 58 | #include "syncdialog.h" |
59 | #include "desktop.h" | 59 | #include "desktop.h" |
60 | #include <qpe/lnkproperties.h> | 60 | #include <qpe/lnkproperties.h> |
61 | #include "mrulist.h" | 61 | #include "mrulist.h" |
62 | #include "qrsync.h" | 62 | #include "qrsync.h" |
63 | #include <stdlib.h> | 63 | #include <stdlib.h> |
64 | #include <unistd.h> | 64 | #include <unistd.h> |
65 | 65 | ||
66 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 66 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
67 | #include <stdio.h> | 67 | #include <stdio.h> |
68 | #include <sys/vfs.h> | 68 | #include <sys/vfs.h> |
69 | #include <mntent.h> | 69 | #include <mntent.h> |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #include <qpe/storage.h> | 72 | #include <qpe/storage.h> |
73 | #include "mediummountgui.h" | 73 | #include "mediummountgui.h" |
74 | //#define SHOW_ALL | 74 | //#define SHOW_ALL |
75 | 75 | ||
76 | // uidGen | 76 | // uidGen |
77 | 77 | ||
78 | // uidGen | 78 | // uidGen |
79 | namespace { | 79 | namespace { |
80 | QStringList configToMime( Config *cfg ){ | 80 | QStringList configToMime( Config *cfg ){ |
81 | QStringList mimes; | 81 | QStringList mimes; |
82 | bool tmpMime; | 82 | bool tmpMime; |
83 | cfg->setGroup("mimetypes" ); | 83 | cfg->setGroup("mimetypes" ); |
84 | tmpMime = cfg->readBoolEntry("all" ,false); | 84 | tmpMime = cfg->readBoolEntry("all" ,false); |
85 | if( tmpMime ){ | 85 | if( tmpMime ){ |
86 | mimes << QString::null; | 86 | mimes << QString::null; |
87 | return mimes; | 87 | return mimes; |
88 | }else{ | 88 | }else{ |
89 | tmpMime = cfg->readBoolEntry("audio", true ); | 89 | tmpMime = cfg->readBoolEntry("audio", true ); |
90 | if(tmpMime ) | 90 | if(tmpMime ) |
91 | mimes.append("audio//*" ); | 91 | mimes.append("audio//*" ); |
92 | 92 | ||
93 | tmpMime = cfg->readBoolEntry("image", true ); | 93 | tmpMime = cfg->readBoolEntry("image", true ); |
94 | if(tmpMime ) | 94 | if(tmpMime ) |
95 | mimes.append("image//*" ); | 95 | mimes.append("image//*" ); |
96 | 96 | ||
97 | tmpMime = cfg->readBoolEntry("text", true ); | 97 | tmpMime = cfg->readBoolEntry("text", true ); |
98 | if(tmpMime ) | 98 | if(tmpMime ) |
99 | mimes.append("text//*"); | 99 | mimes.append("text//*"); |
100 | 100 | ||
101 | tmpMime = cfg->readBoolEntry("video", true ); | 101 | tmpMime = cfg->readBoolEntry("video", true ); |
102 | if(tmpMime ) | 102 | if(tmpMime ) |
103 | mimes.append("video//*" ); | 103 | mimes.append("video//*" ); |
104 | } | 104 | } |
105 | return mimes; | 105 | return mimes; |
106 | } | 106 | } |
107 | 107 | ||
108 | } | 108 | } |
109 | 109 | ||
110 | 110 | ||
111 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | 111 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : |
112 | QVBox( parent ) | 112 | QVBox( parent ) |
113 | { | 113 | { |
114 | categoryBar = 0; | 114 | categoryBar = 0; |
115 | stack = 0; | 115 | stack = 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | void CategoryTabWidget::prevTab() | 118 | void CategoryTabWidget::prevTab() |
119 | { | 119 | { |
120 | if ( categoryBar ) { | 120 | if ( categoryBar ) { |
121 | int n = categoryBar->count(); | 121 | int n = categoryBar->count(); |
122 | int tab = categoryBar->currentTab(); | 122 | int tab = categoryBar->currentTab(); |
123 | if ( tab >= 0 ) | 123 | if ( tab >= 0 ) |
124 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); | 124 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); |
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | void CategoryTabWidget::nextTab() | 128 | void CategoryTabWidget::nextTab() |
129 | { | 129 | { |
130 | if ( categoryBar ) { | 130 | if ( categoryBar ) { |
131 | int n = categoryBar->count(); | 131 | int n = categoryBar->count(); |
132 | int tab = categoryBar->currentTab(); | 132 | int tab = categoryBar->currentTab(); |
133 | categoryBar->setCurrentTab( (tab + 1)%n ); | 133 | categoryBar->setCurrentTab( (tab + 1)%n ); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | 136 | ||
137 | void CategoryTabWidget::addItem( const QString& linkfile ) | 137 | void CategoryTabWidget::addItem( const QString& linkfile ) |
138 | { | 138 | { |
139 | int i=0; | 139 | int i=0; |
140 | AppLnk *app = new AppLnk(linkfile); | 140 | AppLnk *app = new AppLnk(linkfile); |
141 | if ( !app->isValid() ) { | 141 | if ( !app->isValid() ) { |
142 | delete app; | 142 | delete app; |
143 | return; | 143 | return; |
144 | } | 144 | } |
145 | if ( !app->file().isEmpty() ) { | 145 | if ( !app->file().isEmpty() ) { |
146 | // A document | 146 | // A document |
147 | delete app; | 147 | delete app; |
148 | app = new DocLnk(linkfile); | 148 | app = new DocLnk(linkfile); |
149 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 149 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 152 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
153 | if ( !(*it).isEmpty() ) { | 153 | if ( !(*it).isEmpty() ) { |
154 | QRegExp tf(*it,FALSE,TRUE); | 154 | QRegExp tf(*it,FALSE,TRUE); |
155 | if ( tf.match(app->type()) >= 0 ) { | 155 | if ( tf.match(app->type()) >= 0 ) { |
156 | ((LauncherView*)stack->widget(i))->addItem(app); | 156 | ((LauncherView*)stack->widget(i))->addItem(app); |
157 | return; | 157 | return; |
158 | } | 158 | } |
159 | i++; | 159 | i++; |
160 | } | 160 | } |
161 | } | 161 | } |
162 | } | 162 | } |
163 | 163 | ||
164 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 164 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
165 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 165 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
166 | { | 166 | { |
167 | delete categoryBar; | 167 | delete categoryBar; |
168 | categoryBar = new CategoryTabBar( this ); | 168 | categoryBar = new CategoryTabBar( this ); |
169 | QPalette pal = categoryBar->palette(); | 169 | QPalette pal = categoryBar->palette(); |
170 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 170 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
171 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 171 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
172 | categoryBar->setPalette( pal ); | 172 | categoryBar->setPalette( pal ); |
173 | 173 | ||
174 | delete stack; | 174 | delete stack; |
175 | stack = new QWidgetStack(this); | 175 | stack = new QWidgetStack(this); |
176 | tabs=0; | 176 | tabs=0; |
177 | 177 | ||
178 | ids.clear(); | 178 | ids.clear(); |
179 | 179 | ||
180 | QStringList types = rootFolder->types(); | 180 | QStringList types = rootFolder->types(); |
181 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 181 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
182 | if ( !(*it).isEmpty() ) { | 182 | if ( !(*it).isEmpty() ) { |
183 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 183 | newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
184 | } | 184 | } |
185 | } | 185 | } |
186 | QListIterator<AppLnk> it( rootFolder->children() ); | 186 | QListIterator<AppLnk> it( rootFolder->children() ); |
187 | AppLnk* l; | 187 | AppLnk* l; |
188 | while ( (l=it.current()) ) { | 188 | while ( (l=it.current()) ) { |
189 | if ( l->type() == "Separator" ) { | 189 | if ( l->type() == "Separator" ) { |
190 | rootFolder->remove(l); | 190 | rootFolder->remove(l); |
191 | delete l; | 191 | delete l; |
192 | } else { | 192 | } else { |
193 | int i=0; | 193 | int i=0; |
194 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 194 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
195 | if ( *it == l->type() ) | 195 | if ( *it == l->type() ) |
196 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); | 196 | ((LauncherView*)stack->widget(i))->addItem(l,FALSE); |
197 | i++; | 197 | i++; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | ++it; | 200 | ++it; |
201 | } | 201 | } |
202 | rootFolder->detachChildren(); | 202 | rootFolder->detachChildren(); |
203 | for (int i=0; i<tabs; i++) | 203 | for (int i=0; i<tabs; i++) |
204 | ((LauncherView*)stack->widget(i))->sort(); | 204 | ((LauncherView*)stack->widget(i))->sort(); |
205 | 205 | ||
206 | // all documents | 206 | // all documents |
207 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); | 207 | docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); |
208 | docview->populate( docFolder, QString::null ); | 208 | docview->populate( docFolder, QString::null ); |
209 | docFolder->detachChildren(); | 209 | docFolder->detachChildren(); |
210 | docview->setFileSystems(fs); | 210 | docview->setFileSystems(fs); |
211 | docview->setToolsEnabled(TRUE); | 211 | docview->setToolsEnabled(TRUE); |
212 | 212 | ||
213 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); | 213 | connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); |
214 | 214 | ||
215 | ((LauncherView*)stack->widget(0))->setFocus(); | 215 | ((LauncherView*)stack->widget(0))->setFocus(); |
216 | 216 | ||
217 | categoryBar->show(); | 217 | categoryBar->show(); |
218 | stack->show(); | 218 | stack->show(); |
219 | } | 219 | } |
220 | 220 | ||
221 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) | 221 | void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) |
222 | { | 222 | { |
223 | docview->populate( docFolder, QString::null ); | 223 | docview->populate( docFolder, QString::null ); |
224 | docFolder->detachChildren(); | 224 | docFolder->detachChildren(); |
225 | docview->setFileSystems(fs); | 225 | docview->setFileSystems(fs); |
226 | docview->updateTools(); | 226 | docview->updateTools(); |
227 | } | 227 | } |
228 | 228 | ||
229 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) | 229 | LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) |
230 | { | 230 | { |
231 | LauncherView* view = new LauncherView( stack ); | 231 | LauncherView* view = new LauncherView( stack ); |
232 | connect( view, SIGNAL(clicked(const AppLnk*)), | 232 | connect( view, SIGNAL(clicked(const AppLnk*)), |
233 | this, SIGNAL(clicked(const AppLnk*))); | 233 | this, SIGNAL(clicked(const AppLnk*))); |
234 | connect( view, SIGNAL(rightPressed(AppLnk*)), | 234 | connect( view, SIGNAL(rightPressed(AppLnk*)), |
235 | this, SIGNAL(rightPressed(AppLnk*))); | 235 | this, SIGNAL(rightPressed(AppLnk*))); |
236 | ids.append(id); | 236 | ids.append(id); |
237 | categoryBar->addTab( new QTab( pm, label ) ); | 237 | categoryBar->addTab( new QTab( pm, label ) ); |
238 | stack->addWidget( view, tabs++ ); | 238 | stack->addWidget( view, tabs++ ); |
239 | return view; | 239 | return view; |
240 | } | 240 | } |
241 | 241 | ||
242 | void CategoryTabWidget::updateLink(const QString& linkfile) | 242 | void CategoryTabWidget::updateLink(const QString& linkfile) |
243 | { | 243 | { |
244 | int i=0; | 244 | int i=0; |
245 | LauncherView* view; | 245 | LauncherView* view; |
246 | while ((view = (LauncherView*)stack->widget(i++))) { | 246 | while ((view = (LauncherView*)stack->widget(i++))) { |
247 | if ( view->removeLink(linkfile) ) | 247 | if ( view->removeLink(linkfile) ) |
248 | break; | 248 | break; |
249 | } | 249 | } |
250 | addItem(linkfile); | 250 | addItem(linkfile); |
251 | docview->updateTools(); | 251 | docview->updateTools(); |
252 | } | 252 | } |
253 | 253 | ||
254 | void CategoryTabWidget::paletteChange( const QPalette &p ) | 254 | void CategoryTabWidget::paletteChange( const QPalette &p ) |
255 | { | 255 | { |
256 | QVBox::paletteChange( p ); | 256 | QVBox::paletteChange( p ); |
257 | QPalette pal = palette(); | 257 | QPalette pal = palette(); |
258 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 258 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
259 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 259 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
260 | categoryBar->setPalette( pal ); | 260 | categoryBar->setPalette( pal ); |
261 | categoryBar->update(); | 261 | categoryBar->update(); |
262 | } | 262 | } |
263 | 263 | ||
264 | void CategoryTabWidget::setBusy(bool on) | 264 | void CategoryTabWidget::setBusy(bool on) |
265 | { | 265 | { |
266 | if ( on ) | 266 | if ( on ) |
267 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); | 267 | ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); |
268 | else | 268 | else |
269 | for (int i=0; i<tabs; i++) | 269 | for (int i=0; i<tabs; i++) |
270 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); | 270 | ((LauncherView*)stack->widget(i))->setBusy(FALSE); |
271 | } | 271 | } |
272 | 272 | ||
273 | 273 | ||
274 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) | 274 | CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) |
275 | : QTabBar( parent, name ) | 275 | : QTabBar( parent, name ) |
276 | { | 276 | { |
277 | setFocusPolicy( NoFocus ); | 277 | setFocusPolicy( NoFocus ); |
278 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); | 278 | connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); |
279 | } | 279 | } |
280 | 280 | ||
281 | CategoryTabBar::~CategoryTabBar() | 281 | CategoryTabBar::~CategoryTabBar() |
282 | { | 282 | { |
283 | } | 283 | } |
284 | 284 | ||
285 | void CategoryTabBar::layoutTabs() | 285 | void CategoryTabBar::layoutTabs() |
286 | { | 286 | { |
287 | if ( !count() ) | 287 | if ( !count() ) |
288 | return; | 288 | return; |
289 | 289 | ||
290 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; | 290 | // int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; |
291 | int hiddenTabWidth = -12; | 291 | int hiddenTabWidth = -12; |
292 | int middleTab = currentTab(); | 292 | int middleTab = currentTab(); |
293 | int hframe, vframe, overlap; | 293 | int hframe, vframe, overlap; |
294 | style().tabbarMetrics( this, hframe, vframe, overlap ); | 294 | style().tabbarMetrics( this, hframe, vframe, overlap ); |
295 | QFontMetrics fm = fontMetrics(); | 295 | QFontMetrics fm = fontMetrics(); |
296 | int x = 0; | 296 | int x = 0; |
297 | QRect r; | 297 | QRect r; |
298 | QTab *t; | 298 | QTab *t; |
299 | int available = width()-1; | 299 | int available = width()-1; |
300 | int required = 0; | 300 | int required = 0; |
301 | for ( int i = 0; i < count(); i++ ) { | 301 | for ( int i = 0; i < count(); i++ ) { |
302 | t = tab(i); | 302 | t = tab(i); |
303 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 303 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
304 | if ( i != middleTab ) { | 304 | if ( i != middleTab ) { |
305 | // required += hiddenTabWidth + hframe - overlap; | 305 | // required += hiddenTabWidth + hframe - overlap; |
306 | available -= hiddenTabWidth + hframe - overlap; | 306 | available -= hiddenTabWidth + hframe - overlap; |
307 | if ( t->iconSet() != 0 ) | 307 | if ( t->iconSet() != 0 ) |
308 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 308 | available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
309 | } else { | 309 | } else { |
310 | required += fm.width( t->text() ) + hframe - overlap; | 310 | required += fm.width( t->text() ) + hframe - overlap; |
311 | if ( t->iconSet() != 0 ) | 311 | if ( t->iconSet() != 0 ) |
312 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 312 | required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | for ( int i = 0; i < count(); i++ ) { | 315 | for ( int i = 0; i < count(); i++ ) { |
316 | t = tab(i); | 316 | t = tab(i); |
317 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { | 317 | // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { |
318 | if ( i != middleTab ) { | 318 | if ( i != middleTab ) { |
319 | int w = hiddenTabWidth; | 319 | int w = hiddenTabWidth; |
320 | int ih = 0; | 320 | int ih = 0; |
321 | if ( t->iconSet() != 0 ) { | 321 | if ( t->iconSet() != 0 ) { |
322 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 322 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
323 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 323 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
324 | } | 324 | } |
325 | int h = QMAX( fm.height(), ih ); | 325 | int h = QMAX( fm.height(), ih ); |
326 | h = QMAX( h, QApplication::globalStrut().height() ); | 326 | h = QMAX( h, QApplication::globalStrut().height() ); |
327 | 327 | ||
328 | h += vframe; | 328 | h += vframe; |
329 | w += hframe; | 329 | w += hframe; |
330 | 330 | ||
331 | t->setRect( QRect(x, 0, w, h) ); | 331 | t->setRect( QRect(x, 0, w, h) ); |
332 | x += t->rect().width() - overlap; | 332 | x += t->rect().width() - overlap; |
333 | r = r.unite( t->rect() ); | 333 | r = r.unite( t->rect() ); |
334 | } else { | 334 | } else { |
335 | int w = fm.width( t->text() ); | 335 | int w = fm.width( t->text() ); |
336 | int ih = 0; | 336 | int ih = 0; |
337 | if ( t->iconSet() != 0 ) { | 337 | if ( t->iconSet() != 0 ) { |
338 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); | 338 | w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); |
339 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 339 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
340 | } | 340 | } |
341 | int h = QMAX( fm.height(), ih ); | 341 | int h = QMAX( fm.height(), ih ); |
342 | h = QMAX( h, QApplication::globalStrut().height() ); | 342 | h = QMAX( h, QApplication::globalStrut().height() ); |
343 | 343 | ||
344 | h += vframe; | 344 | h += vframe; |
345 | w += hframe; | 345 | w += hframe; |
346 | 346 | ||
347 | // t->setRect( QRect(x, 0, w * available/required, h) ); | 347 | // t->setRect( QRect(x, 0, w * available/required, h) ); |
348 | t->setRect( QRect(x, 0, available, h) ); | 348 | t->setRect( QRect(x, 0, available, h) ); |
349 | x += t->rect().width() - overlap; | 349 | x += t->rect().width() - overlap; |
350 | r = r.unite( t->rect() ); | 350 | r = r.unite( t->rect() ); |
351 | } | 351 | } |
352 | } | 352 | } |
353 | 353 | ||
354 | QRect rr = tab(count()-1)->rect(); | 354 | QRect rr = tab(count()-1)->rect(); |
355 | rr.setRight(width()-1); | 355 | rr.setRight(width()-1); |
356 | tab(count()-1)->setRect( rr ); | 356 | tab(count()-1)->setRect( rr ); |
357 | 357 | ||
358 | for ( t = tabList()->first(); t; t = tabList()->next() ) { | 358 | for ( t = tabList()->first(); t; t = tabList()->next() ) { |
359 | QRect tr = t->rect(); | 359 | QRect tr = t->rect(); |
360 | tr.setHeight( r.height() ); | 360 | tr.setHeight( r.height() ); |
361 | t->setRect( tr ); | 361 | t->setRect( tr ); |
362 | } | 362 | } |
363 | 363 | ||
364 | update(); | 364 | update(); |
365 | } | 365 | } |
366 | 366 | ||
367 | 367 | ||
368 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const | 368 | void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const |
369 | { | 369 | { |
370 | #if QT_VERSION >= 300 | 370 | #if QT_VERSION >= 300 |
371 | QStyle::SFlags flags = QStyle::Style_Default; | 371 | QStyle::SFlags flags = QStyle::Style_Default; |
372 | if ( selected ) | 372 | if ( selected ) |
373 | flags |= QStyle::Style_Selected; | 373 | flags |= QStyle::Style_Selected; |
374 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), | 374 | style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), |
375 | colorGroup(), flags, QStyleOption(t) ); | 375 | colorGroup(), flags, QStyleOption(t) ); |
376 | #else | 376 | #else |
377 | style().drawTab( p, this, t, selected ); | 377 | style().drawTab( p, this, t, selected ); |
378 | #endif | 378 | #endif |
379 | 379 | ||
380 | QRect r( t->rect() ); | 380 | QRect r( t->rect() ); |
381 | QFont f( font() ); | 381 | QFont f( font() ); |
382 | if ( selected ) | 382 | if ( selected ) |
383 | f.setBold( TRUE ); | 383 | f.setBold( TRUE ); |
384 | p->setFont( f ); | 384 | p->setFont( f ); |
385 | 385 | ||
386 | int iw = 0; | 386 | int iw = 0; |
387 | int ih = 0; | 387 | int ih = 0; |
388 | if ( t->iconSet() != 0 ) { | 388 | if ( t->iconSet() != 0 ) { |
389 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; | 389 | iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; |
390 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); | 390 | ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); |
391 | } | 391 | } |
392 | int w = iw + p->fontMetrics().width( t->text() ) + 4; | 392 | int w = iw + p->fontMetrics().width( t->text() ) + 4; |
393 | int h = QMAX(p->fontMetrics().height() + 4, ih ); | 393 | int h = QMAX(p->fontMetrics().height() + 4, ih ); |
394 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, | 394 | paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, |
395 | r.top() + (r.height()-h)/2, w, h ), t, | 395 | r.top() + (r.height()-h)/2, w, h ), t, |
396 | #if QT_VERSION >= 300 | 396 | #if QT_VERSION >= 300 |
397 | t->identifier() == keyboardFocusTab() | 397 | t->identifier() == keyboardFocusTab() |
398 | #else | 398 | #else |
399 | t->identitifer() == keyboardFocusTab() | 399 | t->identitifer() == keyboardFocusTab() |
400 | #endif | 400 | #endif |
401 | ); | 401 | ); |
402 | } | 402 | } |
403 | 403 | ||
404 | 404 | ||
405 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, | 405 | void CategoryTabBar::paintLabel( QPainter* p, const QRect&, |
406 | QTab* t, bool has_focus ) const | 406 | QTab* t, bool has_focus ) const |
407 | { | 407 | { |
408 | QRect r = t->rect(); | 408 | QRect r = t->rect(); |
409 | // if ( t->id != currentTab() ) | 409 | // if ( t->id != currentTab() ) |
410 | //r.moveBy( 1, 1 ); | 410 | //r.moveBy( 1, 1 ); |
411 | // | 411 | // |
412 | if ( t->iconSet() ) { | 412 | if ( t->iconSet() ) { |
413 | // the tab has an iconset, draw it in the right mode | 413 | // the tab has an iconset, draw it in the right mode |
414 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; | 414 | QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; |
415 | if ( mode == QIconSet::Normal && has_focus ) | 415 | if ( mode == QIconSet::Normal && has_focus ) |
416 | mode = QIconSet::Active; | 416 | mode = QIconSet::Active; |
417 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); | 417 | QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); |
418 | int pixw = pixmap.width(); | 418 | int pixw = pixmap.width(); |
419 | int pixh = pixmap.height(); | 419 | int pixh = pixmap.height(); |
420 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); | 420 | p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); |
421 | r.setLeft( r.left() + pixw + 5 ); | 421 | r.setLeft( r.left() + pixw + 5 ); |
422 | } | 422 | } |
423 | 423 | ||
424 | QRect tr = r; | 424 | QRect tr = r; |
425 | 425 | ||
426 | if ( r.width() < 20 ) | 426 | if ( r.width() < 20 ) |
427 | return; | 427 | return; |
428 | 428 | ||
429 | if ( t->isEnabled() && isEnabled() ) { | 429 | if ( t->isEnabled() && isEnabled() ) { |
430 | #if defined(_WS_WIN32_) | 430 | #if defined(_WS_WIN32_) |
431 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) | 431 | if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) |
432 | p->setPen( colorGroup().buttonText() ); | 432 | p->setPen( colorGroup().buttonText() ); |
433 | else | 433 | else |
434 | p->setPen( colorGroup().foreground() ); | 434 | p->setPen( colorGroup().foreground() ); |
435 | #else | 435 | #else |
436 | p->setPen( colorGroup().foreground() ); | 436 | p->setPen( colorGroup().foreground() ); |
437 | #endif | 437 | #endif |
438 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 438 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
439 | } else { | 439 | } else { |
440 | p->setPen( palette().disabled().foreground() ); | 440 | p->setPen( palette().disabled().foreground() ); |
441 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); | 441 | p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); |
442 | } | 442 | } |
443 | } | 443 | } |
444 | 444 | ||
445 | //--------------------------------------------------------------------------- | 445 | //--------------------------------------------------------------------------- |
446 | 446 | ||
447 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) | 447 | Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) |
448 | : QMainWindow( parent, name, fl ) | 448 | : QMainWindow( parent, name, fl ) |
449 | { | 449 | { |
450 | setCaption( tr("Launcher") ); | 450 | setCaption( tr("Launcher") ); |
451 | 451 | ||
452 | syncDialog = 0; | 452 | syncDialog = 0; |
453 | 453 | ||
454 | // we have a pretty good idea how big we'll be | 454 | // we have a pretty good idea how big we'll be |
455 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); | 455 | setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); |
456 | 456 | ||
457 | tabs = 0; | 457 | tabs = 0; |
458 | rootFolder = 0; | 458 | rootFolder = 0; |
459 | docsFolder = 0; | 459 | docsFolder = 0; |
460 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know | 460 | int stamp = uidgen.generate(); // this is our timestamp to see which devices we know |
461 | //uidgen.store( stamp ); | 461 | //uidgen.store( stamp ); |
462 | m_timeStamp = QString::number( stamp ); | 462 | m_timeStamp = QString::number( stamp ); |
463 | 463 | ||
464 | tabs = new CategoryTabWidget( this ); | 464 | tabs = new CategoryTabWidget( this ); |
465 | tabs->setMaximumWidth( qApp->desktop()->width() ); | 465 | tabs->setMaximumWidth( qApp->desktop()->width() ); |
466 | setCentralWidget( tabs ); | 466 | setCentralWidget( tabs ); |
467 | 467 | ||
468 | connect( tabs, SIGNAL(selected(const QString&)), | 468 | connect( tabs, SIGNAL(selected(const QString&)), |
469 | this, SLOT(viewSelected(const QString&)) ); | 469 | this, SLOT(viewSelected(const QString&)) ); |
470 | connect( tabs, SIGNAL(clicked(const AppLnk*)), | 470 | connect( tabs, SIGNAL(clicked(const AppLnk*)), |
471 | this, SLOT(select(const AppLnk*))); | 471 | this, SLOT(select(const AppLnk*))); |
472 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), | 472 | connect( tabs, SIGNAL(rightPressed(AppLnk*)), |
473 | this, SLOT(properties(AppLnk*))); | 473 | this, SLOT(properties(AppLnk*))); |
474 | 474 | ||
475 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 475 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
476 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 476 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
477 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 477 | connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
478 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); | 478 | this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); |
479 | #endif | 479 | #endif |
480 | 480 | ||
481 | storage = new StorageInfo( this ); | 481 | storage = new StorageInfo( this ); |
482 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); | 482 | connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); |
483 | 483 | ||
484 | updateTabs(); | 484 | updateTabs(); |
485 | 485 | ||
486 | preloadApps(); | 486 | preloadApps(); |
487 | 487 | ||
488 | in_lnk_props = FALSE; | 488 | in_lnk_props = FALSE; |
489 | got_lnk_change = FALSE; | 489 | got_lnk_change = FALSE; |
490 | } | 490 | } |
491 | 491 | ||
492 | Launcher::~Launcher() | 492 | Launcher::~Launcher() |
493 | { | 493 | { |
494 | } | 494 | } |
495 | 495 | ||
496 | static bool isVisibleWindow(int wid) | 496 | static bool isVisibleWindow(int wid) |
497 | { | 497 | { |
498 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 498 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
499 | QWSWindow* w; | 499 | QWSWindow* w; |
500 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 500 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
501 | if ( w->winId() == wid ) | 501 | if ( w->winId() == wid ) |
502 | return !w->isFullyObscured(); | 502 | return !w->isFullyObscured(); |
503 | } | 503 | } |
504 | return FALSE; | 504 | return FALSE; |
505 | } | 505 | } |
506 | 506 | ||
507 | void Launcher::showMaximized() | 507 | void Launcher::showMaximized() |
508 | { | 508 | { |
509 | if ( isVisibleWindow( winId() ) ) | 509 | if ( isVisibleWindow( winId() ) ) |
510 | doMaximize(); | 510 | doMaximize(); |
511 | else | 511 | else |
512 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); | 512 | QTimer::singleShot( 20, this, SLOT(doMaximize()) ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void Launcher::doMaximize() | 515 | void Launcher::doMaximize() |
516 | { | 516 | { |
517 | QMainWindow::showMaximized(); | 517 | QMainWindow::showMaximized(); |
518 | } | 518 | } |
519 | 519 | ||
520 | void Launcher::updateMimeTypes() | 520 | void Launcher::updateMimeTypes() |
521 | { | 521 | { |
522 | MimeType::clear(); | 522 | MimeType::clear(); |
523 | updateMimeTypes(rootFolder); | 523 | updateMimeTypes(rootFolder); |
524 | } | 524 | } |
525 | 525 | ||
526 | void Launcher::updateMimeTypes(AppLnkSet* folder) | 526 | void Launcher::updateMimeTypes(AppLnkSet* folder) |
527 | { | 527 | { |
528 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { | 528 | for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { |
529 | AppLnk *app = it.current(); | 529 | AppLnk *app = it.current(); |
530 | if ( app->type() == "Folder" ) | 530 | if ( app->type() == "Folder" ) |
531 | updateMimeTypes((AppLnkSet *)app); | 531 | updateMimeTypes((AppLnkSet *)app); |
532 | else { | 532 | else { |
533 | MimeType::registerApp(*app); | 533 | MimeType::registerApp(*app); |
534 | } | 534 | } |
535 | } | 535 | } |
536 | } | 536 | } |
537 | 537 | ||
538 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | 538 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
539 | { | 539 | { |
540 | qWarning("loading Documents" ); | 540 | qWarning("loading Documents" ); |
541 | qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); | 541 | qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); |
542 | delete docsFolder; | 542 | delete docsFolder; |
543 | docsFolder = new DocLnkSet; | 543 | docsFolder = new DocLnkSet; |
544 | qWarning("new DocLnkSet" ); | 544 | qWarning("new DocLnkSet" ); |
545 | DocLnkSet *tmp = 0; | 545 | DocLnkSet *tmp = 0; |
546 | QString home = QString(getenv("HOME")) + "/Documents"; | 546 | QString home = QString(getenv("HOME")) + "/Documents"; |
547 | tmp = new DocLnkSet( home , QString::null); | 547 | tmp = new DocLnkSet( home , QString::null); |
548 | docsFolder->appendFrom( *tmp ); | 548 | docsFolder->appendFrom( *tmp ); |
549 | delete tmp; | 549 | delete tmp; |
550 | // find out wich filesystems are new in this round | 550 | // find out wich filesystems are new in this round |
551 | // We will do this by having a timestamp inside each mountpoint | 551 | // We will do this by having a timestamp inside each mountpoint |
552 | // if the current timestamp doesn't match this is a new file system and | 552 | // if the current timestamp doesn't match this is a new file system and |
553 | // come up with our MediumMountGui :) let the hacking begin | 553 | // come up with our MediumMountGui :) let the hacking begin |
554 | int stamp = uidgen.generate(); | 554 | int stamp = uidgen.generate(); |
555 | 555 | ||
556 | QString newStamp = QString::number( stamp ); // generates newtime Stamp | 556 | QString newStamp = QString::number( stamp ); // generates newtime Stamp |
557 | StorageInfo storage; | 557 | StorageInfo storage; |
558 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 558 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
559 | QListIterator<FileSystem> it ( fileSystems ); | 559 | QListIterator<FileSystem> it ( fileSystems ); |
560 | for ( ; it.current(); ++it ) { | 560 | for ( ; it.current(); ++it ) { |
561 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 561 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
562 | qWarning("%s is removeable", (*it)->path().latin1() ); | 562 | qWarning("%s is removeable", (*it)->path().latin1() ); |
563 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); | 563 | OConfig cfg( (*it)->path() + "/.opiestorage.cf"); |
564 | cfg.setGroup("main"); | 564 | cfg.setGroup("main"); |
565 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 565 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
566 | if( stamp == m_timeStamp ){ // ok we know this card | 566 | if( stamp == m_timeStamp ){ // ok we know this card |
567 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp | 567 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp |
568 | // we need to scan the list now. Hopefully the cache will be there | 568 | // we need to scan the list now. Hopefully the cache will be there |
569 | // read the mimetypes from the config and search for documents | 569 | // read the mimetypes from the config and search for documents |
570 | QStringList mimetypes = configToMime( &cfg); | 570 | QStringList mimetypes = configToMime( &cfg); |
571 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); | 571 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); |
572 | docsFolder->appendFrom( *tmp ); | 572 | docsFolder->appendFrom( *tmp ); |
573 | delete tmp; | 573 | delete tmp; |
574 | 574 | ||
575 | }else{ // come up with the gui cause this a new card | 575 | }else{ // come up with the gui cause this a new card |
576 | MediumMountGui medium((*it)->path() ); | 576 | MediumMountGui medium((*it)->path() ); |
577 | if( medium.check() ){ // we did not ask before or ask again is off | 577 | if( medium.check() ){ // we did not ask before or ask again is off |
578 | if( medium.exec() ){ // he clicked yes so search it | 578 | if( medium.exec() ){ // he clicked yes so search it |
579 | // speicher | 579 | // speicher |
580 | cfg.read(); // cause of a race we need to reread | 580 | cfg.read(); // cause of a race we need to reread |
581 | cfg.writeEntry("timestamp", newStamp ); | 581 | cfg.writeEntry("timestamp", newStamp ); |
582 | }// no else | 582 | }// no else |
583 | }else{ // we checked | 583 | }else{ // we checked |
584 | // do something different see what we need to do | 584 | // do something different see what we need to do |
585 | // let's see if we should check the device | 585 | // let's see if we should check the device |
586 | cfg.setGroup("main" ); | 586 | cfg.setGroup("main" ); |
587 | bool check = cfg.readBoolEntry("autocheck", true ); | 587 | bool check = cfg.readBoolEntry("autocheck", true ); |
588 | if( check ){ // find the documents | 588 | if( check ){ // find the documents |
589 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); | 589 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); |
590 | docsFolder->appendFrom( *tmp ); | 590 | docsFolder->appendFrom( *tmp ); |
591 | delete tmp; | 591 | delete tmp; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | } | 594 | } |
595 | } | 595 | } |
596 | } | 596 | } |
597 | m_timeStamp = newStamp; | 597 | m_timeStamp = newStamp; |
598 | } | 598 | } |
599 | 599 | ||
600 | void Launcher::updateTabs() | 600 | void Launcher::updateTabs() |
601 | { | 601 | { |
602 | MimeType::updateApplications(); // ### reads all applnks twice | 602 | MimeType::updateApplications(); // ### reads all applnks twice |
603 | 603 | ||
604 | delete rootFolder; | 604 | delete rootFolder; |
605 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 605 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
606 | 606 | ||
607 | loadDocs(); | 607 | loadDocs(); |
608 | 608 | ||
609 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 609 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
610 | } | 610 | } |
611 | 611 | ||
612 | void Launcher::updateDocs() | 612 | void Launcher::updateDocs() |
613 | { | 613 | { |
614 | loadDocs(); | 614 | loadDocs(); |
615 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 615 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
616 | } | 616 | } |
617 | 617 | ||
618 | void Launcher::viewSelected(const QString& s) | 618 | void Launcher::viewSelected(const QString& s) |
619 | { | 619 | { |
620 | setCaption( s + tr(" - Launcher") ); | 620 | setCaption( s + tr(" - Launcher") ); |
621 | } | 621 | } |
622 | 622 | ||
623 | void Launcher::nextView() | 623 | void Launcher::nextView() |
624 | { | 624 | { |
625 | tabs->nextTab(); | 625 | tabs->nextTab(); |
626 | } | 626 | } |
627 | 627 | ||
628 | 628 | ||
629 | void Launcher::select( const AppLnk *appLnk ) | 629 | void Launcher::select( const AppLnk *appLnk ) |
630 | { | 630 | { |
631 | if ( appLnk->type() == "Folder" ) { | 631 | if ( appLnk->type() == "Folder" ) { |
632 | // Not supported: flat is simpler for the user | 632 | // Not supported: flat is simpler for the user |
633 | } else { | 633 | } else { |
634 | if ( appLnk->exec().isNull() ) { | 634 | if ( appLnk->exec().isNull() ) { |
635 | QMessageBox::information(this,tr("No application"), | 635 | QMessageBox::information(this,tr("No application"), |
636 | tr("<p>No application is defined for this document." | 636 | tr("<p>No application is defined for this document." |
637 | "<p>Type is %1.").arg(appLnk->type())); | 637 | "<p>Type is %1.").arg(appLnk->type())); |
638 | return; | 638 | return; |
639 | } | 639 | } |
640 | tabs->setBusy(TRUE); | 640 | tabs->setBusy(TRUE); |
641 | emit executing( appLnk ); | 641 | emit executing( appLnk ); |
642 | appLnk->execute(); | 642 | appLnk->execute(); |
643 | } | 643 | } |
644 | } | 644 | } |
645 | 645 | ||
646 | void Launcher::externalSelected(const AppLnk *appLnk) | 646 | void Launcher::externalSelected(const AppLnk *appLnk) |
647 | { | 647 | { |
648 | tabs->setBusy(TRUE); | 648 | tabs->setBusy(TRUE); |
649 | emit executing( appLnk ); | 649 | emit executing( appLnk ); |
650 | } | 650 | } |
651 | 651 | ||
652 | void Launcher::properties( AppLnk *appLnk ) | 652 | void Launcher::properties( AppLnk *appLnk ) |
653 | { | 653 | { |
654 | if ( appLnk->type() == "Folder" ) { | 654 | if ( appLnk->type() == "Folder" ) { |
655 | // Not supported: flat is simpler for the user | 655 | // Not supported: flat is simpler for the user |
656 | } else { | 656 | } else { |
657 | in_lnk_props = TRUE; | 657 | in_lnk_props = TRUE; |
658 | got_lnk_change = FALSE; | 658 | got_lnk_change = FALSE; |
659 | LnkProperties prop(appLnk); | 659 | LnkProperties prop(appLnk); |
660 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 660 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
661 | prop.showMaximized(); | 661 | prop.showMaximized(); |
662 | prop.exec(); | 662 | prop.exec(); |
663 | in_lnk_props = FALSE; | 663 | in_lnk_props = FALSE; |
664 | if ( got_lnk_change ) { | 664 | if ( got_lnk_change ) { |
665 | updateLink(lnk_change); | 665 | updateLink(lnk_change); |
666 | } | 666 | } |
667 | } | 667 | } |
668 | } | 668 | } |
669 | 669 | ||
670 | void Launcher::updateLink(const QString& link) | 670 | void Launcher::updateLink(const QString& link) |
671 | { | 671 | { |
672 | if (link.isNull()) | 672 | if (link.isNull()) |
673 | updateTabs(); | 673 | updateTabs(); |
674 | else if (link.isEmpty()) | 674 | else if (link.isEmpty()) |
675 | updateDocs(); | 675 | updateDocs(); |
676 | else | 676 | else |
677 | tabs->updateLink(link); | 677 | tabs->updateLink(link); |
678 | } | 678 | } |
679 | 679 | ||
680 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 680 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
681 | { | 681 | { |
682 | QDataStream stream( data, IO_ReadOnly ); | 682 | QDataStream stream( data, IO_ReadOnly ); |
683 | if ( msg == "closing(QString)" ){ | 683 | if ( msg == "closing(QString)" ){ |
684 | QString app; | 684 | QString app; |
685 | stream >> app; | 685 | stream >> app; |
686 | qWarning("app closed %s", app.latin1() ); | 686 | qWarning("app closed %s", app.latin1() ); |
687 | MRUList::removeTask( app ); | 687 | MRUList::removeTask( app ); |
688 | }else if ( msg == "linkChanged(QString)" ) { | 688 | }else if ( msg == "linkChanged(QString)" ) { |
689 | QString link; | 689 | QString link; |
690 | stream >> link; | 690 | stream >> link; |
691 | if ( in_lnk_props ) { | 691 | if ( in_lnk_props ) { |
692 | got_lnk_change = TRUE; | 692 | got_lnk_change = TRUE; |
693 | lnk_change = link; | 693 | lnk_change = link; |
694 | } else { | 694 | } else { |
695 | updateLink(link); | 695 | updateLink(link); |
696 | } | 696 | } |
697 | } else if ( msg == "busy()" ) { | 697 | } else if ( msg == "busy()" ) { |
698 | emit busy(); | 698 | emit busy(); |
699 | } else if ( msg == "notBusy(QString)" ) { | 699 | } else if ( msg == "notBusy(QString)" ) { |
700 | QString app; | 700 | QString app; |
701 | stream >> app; | 701 | stream >> app; |
702 | tabs->setBusy(FALSE); | 702 | tabs->setBusy(FALSE); |
703 | emit notBusy(app); | 703 | emit notBusy(app); |
704 | } else if ( msg == "mkdir(QString)" ) { | 704 | } else if ( msg == "mkdir(QString)" ) { |
705 | QString dir; | 705 | QString dir; |
706 | stream >> dir; | 706 | stream >> dir; |
707 | if ( !dir.isEmpty() ) | 707 | if ( !dir.isEmpty() ) |
708 | mkdir( dir ); | 708 | mkdir( dir ); |
709 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 709 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
710 | QString baseFile, sigFile; | 710 | QString baseFile, sigFile; |
711 | stream >> baseFile >> sigFile; | 711 | stream >> baseFile >> sigFile; |
712 | QRsync::generateSignature( baseFile, sigFile ); | 712 | QRsync::generateSignature( baseFile, sigFile ); |
713 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 713 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
714 | QString baseFile, sigFile, deltaFile; | 714 | QString baseFile, sigFile, deltaFile; |
715 | stream >> baseFile >> sigFile >> deltaFile; | 715 | stream >> baseFile >> sigFile >> deltaFile; |
716 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 716 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
717 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 717 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
718 | QString baseFile, deltaFile; | 718 | QString baseFile, deltaFile; |
719 | stream >> baseFile >> deltaFile; | 719 | stream >> baseFile >> deltaFile; |
720 | if ( !QFile::exists( baseFile ) ) { | 720 | if ( !QFile::exists( baseFile ) ) { |
721 | QFile f( baseFile ); | 721 | QFile f( baseFile ); |
722 | f.open( IO_WriteOnly ); | 722 | f.open( IO_WriteOnly ); |
723 | f.close(); | 723 | f.close(); |
724 | } | 724 | } |
725 | QRsync::applyDiff( baseFile, deltaFile ); | 725 | QRsync::applyDiff( baseFile, deltaFile ); |
726 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 726 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
727 | e << baseFile; | 727 | e << baseFile; |
728 | } else if ( msg == "rdiffCleanup()" ) { | 728 | } else if ( msg == "rdiffCleanup()" ) { |
729 | mkdir( "/tmp/rdiff" ); | 729 | mkdir( "/tmp/rdiff" ); |
730 | QDir dir; | 730 | QDir dir; |
731 | dir.setPath( "/tmp/rdiff" ); | 731 | dir.setPath( "/tmp/rdiff" ); |
732 | QStringList entries = dir.entryList(); | 732 | QStringList entries = dir.entryList(); |
733 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 733 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
734 | dir.remove( *it ); | 734 | dir.remove( *it ); |
735 | } else if ( msg == "sendHandshakeInfo()" ) { | 735 | } else if ( msg == "sendHandshakeInfo()" ) { |
736 | QString home = getenv( "HOME" ); | 736 | QString home = getenv( "HOME" ); |
737 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 737 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
738 | e << home; | 738 | e << home; |
739 | int locked = (int) Desktop::screenLocked(); | 739 | int locked = (int) Desktop::screenLocked(); |
740 | e << locked; | 740 | e << locked; |
741 | // register an app for autostart | 741 | // register an app for autostart |
742 | // if clear is send the list is cleared. | 742 | // if clear is send the list is cleared. |
743 | } else if ( msg == "autoStart(QString)" ) { | 743 | } else if ( msg == "autoStart(QString)" ) { |
744 | QString appName; | 744 | QString appName; |
745 | stream >> appName; | 745 | stream >> appName; |
746 | Config cfg( "autostart" ); | 746 | Config cfg( "autostart" ); |
747 | cfg.setGroup( "AutoStart" ); | 747 | cfg.setGroup( "AutoStart" ); |
748 | if ( appName.compare("clear") == 0){ | 748 | if ( appName.compare("clear") == 0){ |
749 | cfg.writeEntry("Apps", ""); | 749 | cfg.writeEntry("Apps", ""); |
750 | } | 750 | } |
751 | } else if ( msg == "autoStart(QString,QString)" ) { | 751 | } else if ( msg == "autoStart(QString,QString)" ) { |
752 | QString modifier, appName; | 752 | QString modifier, appName; |
753 | stream >> modifier >> appName; | 753 | stream >> modifier >> appName; |
754 | Config cfg( "autostart" ); | 754 | Config cfg( "autostart" ); |
755 | cfg.setGroup( "AutoStart" ); | 755 | cfg.setGroup( "AutoStart" ); |
756 | if ( modifier.compare("add") == 0 ){ | 756 | if ( modifier.compare("add") == 0 ){ |
757 | // only add it appname is entered | 757 | // only add if appname is entered |
758 | if (!appName.isEmpty()) { | 758 | if (!appName.isEmpty()) { |
759 | cfg.writeEntry("Apps", appName); | 759 | cfg.writeEntry("Apps", appName); |
760 | } | 760 | } |
761 | } else if (modifier.compare("remove") == 0 ) { | 761 | } else if (modifier.compare("remove") == 0 ) { |
762 | // need to change for multiple entries | 762 | // need to change for multiple entries |
763 | // actually remove is right now simular to clear, but in future there | 763 | // actually remove is right now simular to clear, but in future there |
764 | // should be multiple apps in autostart possible. | 764 | // should be multiple apps in autostart possible. |
765 | QString checkName; | 765 | QString checkName; |
766 | checkName = cfg.readEntry("Apps", ""); | 766 | checkName = cfg.readEntry("Apps", ""); |
767 | if (checkName == appName) { | 767 | if (checkName == appName) { |
768 | cfg.writeEntry("Apps", ""); | 768 | cfg.writeEntry("Apps", ""); |
769 | } | 769 | } |
770 | } | 770 | } |
771 | } else if ( msg == "sendCardInfo()" ) { | 771 | // case the autostart feature should be delayed |
772 | } else if ( msg == "autoStart(QString, QString, QString)") { | ||
773 | QString modifier, appName, delay; | ||
774 | stream >> modifier >> appName >> delay; | ||
775 | Config cfg( "autostart" ); | ||
776 | cfg.setGroup( "AutoStart" ); | ||
777 | if ( modifier.compare("add") == 0 ){ | ||
778 | // only add it appname is entered | ||
779 | if (!appName.isEmpty()) { | ||
780 | cfg.writeEntry("Apps", appName); | ||
781 | cfg.writeEntry("Delay", delay); | ||
782 | } | ||
783 | } else { | ||
784 | } | ||
785 | } else if ( msg == "sendCardInfo()" ) { | ||
772 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 786 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
773 | const QList<FileSystem> &fs = storage->fileSystems(); | 787 | const QList<FileSystem> &fs = storage->fileSystems(); |
774 | QListIterator<FileSystem> it ( fs ); | 788 | QListIterator<FileSystem> it ( fs ); |
775 | QString s; | 789 | QString s; |
776 | QString homeDir = getenv("HOME"); | 790 | QString homeDir = getenv("HOME"); |
777 | QString hardDiskHome; | 791 | QString hardDiskHome; |
778 | for ( ; it.current(); ++it ) { | 792 | for ( ; it.current(); ++it ) { |
779 | if ( (*it)->isRemovable() ) | 793 | if ( (*it)->isRemovable() ) |
780 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 794 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
781 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 795 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
782 | + " " + (*it)->options() + ";"; | 796 | + " " + (*it)->options() + ";"; |
783 | else if ( (*it)->disk() == "/dev/mtdblock1" || | 797 | else if ( (*it)->disk() == "/dev/mtdblock1" || |
784 | (*it)->disk() == "/dev/mtdblock/1" ) | 798 | (*it)->disk() == "/dev/mtdblock/1" ) |
785 | s += (*it)->name() + "=" + homeDir + "/Documents " | 799 | s += (*it)->name() + "=" + homeDir + "/Documents " |
786 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 800 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
787 | + " " + (*it)->options() + ";"; | 801 | + " " + (*it)->options() + ";"; |
788 | else if ( (*it)->name().contains( "Hard Disk") && | 802 | else if ( (*it)->name().contains( "Hard Disk") && |
789 | homeDir.contains( (*it)->path() ) && | 803 | homeDir.contains( (*it)->path() ) && |
790 | (*it)->path().length() > hardDiskHome.length() ) | 804 | (*it)->path().length() > hardDiskHome.length() ) |
791 | hardDiskHome = | 805 | hardDiskHome = |
792 | (*it)->name() + "=" + homeDir + "/Documents " | 806 | (*it)->name() + "=" + homeDir + "/Documents " |
793 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 807 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
794 | + " " + (*it)->options() + ";"; | 808 | + " " + (*it)->options() + ";"; |
795 | } | 809 | } |
796 | if ( !hardDiskHome.isEmpty() ) | 810 | if ( !hardDiskHome.isEmpty() ) |
797 | s += hardDiskHome; | 811 | s += hardDiskHome; |
798 | 812 | ||
799 | e << s; | 813 | e << s; |
800 | } else if ( msg == "sendSyncDate(QString)" ) { | 814 | } else if ( msg == "sendSyncDate(QString)" ) { |
801 | QString app; | 815 | QString app; |
802 | stream >> app; | 816 | stream >> app; |
803 | Config cfg( "qpe" ); | 817 | Config cfg( "qpe" ); |
804 | cfg.setGroup("SyncDate"); | 818 | cfg.setGroup("SyncDate"); |
805 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 819 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
806 | e << app << cfg.readEntry( app ); | 820 | e << app << cfg.readEntry( app ); |
807 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 821 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
808 | //cfg.readEntry( app ).latin1() ); | 822 | //cfg.readEntry( app ).latin1() ); |
809 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 823 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
810 | QString app, date; | 824 | QString app, date; |
811 | stream >> app >> date; | 825 | stream >> app >> date; |
812 | Config cfg( "qpe" ); | 826 | Config cfg( "qpe" ); |
813 | cfg.setGroup("SyncDate"); | 827 | cfg.setGroup("SyncDate"); |
814 | cfg.writeEntry( app, date ); | 828 | cfg.writeEntry( app, date ); |
815 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 829 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
816 | } else if ( msg == "startSync(QString)" ) { | 830 | } else if ( msg == "startSync(QString)" ) { |
817 | QString what; | 831 | QString what; |
818 | stream >> what; | 832 | stream >> what; |
819 | delete syncDialog; syncDialog = 0; | 833 | delete syncDialog; syncDialog = 0; |
820 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 834 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
821 | WStyle_Tool | WStyle_Customize | | 835 | WStyle_Tool | WStyle_Customize | |
822 | Qt::WStyle_StaysOnTop ); | 836 | Qt::WStyle_StaysOnTop ); |
823 | syncDialog->showMaximized(); | 837 | syncDialog->showMaximized(); |
824 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 838 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
825 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 839 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
826 | SLOT( cancelSync() ) ); | 840 | SLOT( cancelSync() ) ); |
827 | } | 841 | } |
828 | else if ( msg == "stopSync()") { | 842 | else if ( msg == "stopSync()") { |
829 | delete syncDialog; syncDialog = 0; | 843 | delete syncDialog; syncDialog = 0; |
830 | } else if ( msg == "getAllDocLinks()" ) { | 844 | } else if ( msg == "getAllDocLinks()" ) { |
831 | loadDocs(); | 845 | loadDocs(); |
832 | 846 | ||
833 | QString contents; | 847 | QString contents; |
834 | 848 | ||
835 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 849 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
836 | DocLnk *doc = it.current(); | 850 | DocLnk *doc = it.current(); |
837 | QFileInfo fi( doc->file() ); | 851 | QFileInfo fi( doc->file() ); |
838 | if ( !fi.exists() ) | 852 | if ( !fi.exists() ) |
839 | continue; | 853 | continue; |
840 | 854 | ||
841 | bool fake = !doc->linkFileKnown(); | 855 | bool fake = !doc->linkFileKnown(); |
842 | if ( !fake ) { | 856 | if ( !fake ) { |
843 | QFile f( doc->linkFile() ); | 857 | QFile f( doc->linkFile() ); |
844 | if ( f.open( IO_ReadOnly ) ) { | 858 | if ( f.open( IO_ReadOnly ) ) { |
845 | QTextStream ts( &f ); | 859 | QTextStream ts( &f ); |
846 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 860 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
847 | contents += ts.read(); | 861 | contents += ts.read(); |
848 | f.close(); | 862 | f.close(); |
849 | } else | 863 | } else |
850 | fake = TRUE; | 864 | fake = TRUE; |
851 | } | 865 | } |
852 | if (fake) { | 866 | if (fake) { |
853 | contents += "[Desktop Entry]\n"; | 867 | contents += "[Desktop Entry]\n"; |
854 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 868 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
855 | contents += "File = "+doc->file()+"\n"; | 869 | contents += "File = "+doc->file()+"\n"; |
856 | contents += "Name = "+doc->name()+"\n"; | 870 | contents += "Name = "+doc->name()+"\n"; |
857 | contents += "Type = "+doc->type()+"\n"; | 871 | contents += "Type = "+doc->type()+"\n"; |
858 | } | 872 | } |
859 | contents += QString("Size = %1\n").arg( fi.size() ); | 873 | contents += QString("Size = %1\n").arg( fi.size() ); |
860 | } | 874 | } |
861 | 875 | ||
862 | //qDebug( "sending length %d", contents.length() ); | 876 | //qDebug( "sending length %d", contents.length() ); |
863 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 877 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
864 | e << contents; | 878 | e << contents; |
865 | 879 | ||
866 | qDebug( "================ \n\n%s\n\n===============", | 880 | qDebug( "================ \n\n%s\n\n===============", |
867 | contents.latin1() ); | 881 | contents.latin1() ); |
868 | 882 | ||
869 | delete docsFolder; | 883 | delete docsFolder; |
870 | docsFolder = 0; | 884 | docsFolder = 0; |
871 | } | 885 | } |
872 | } | 886 | } |
873 | 887 | ||
874 | void Launcher::cancelSync() | 888 | void Launcher::cancelSync() |
875 | { | 889 | { |
876 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 890 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
877 | } | 891 | } |
878 | 892 | ||
879 | void Launcher::storageChanged() | 893 | void Launcher::storageChanged() |
880 | { | 894 | { |
881 | if ( in_lnk_props ) { | 895 | if ( in_lnk_props ) { |
882 | got_lnk_change = TRUE; | 896 | got_lnk_change = TRUE; |
883 | lnk_change = ""; | 897 | lnk_change = ""; |
884 | } else { | 898 | } else { |
885 | updateDocs(); | 899 | updateDocs(); |
886 | } | 900 | } |
887 | } | 901 | } |
888 | 902 | ||
889 | 903 | ||
890 | bool Launcher::mkdir(const QString &localPath) | 904 | bool Launcher::mkdir(const QString &localPath) |
891 | { | 905 | { |
892 | QDir fullDir(localPath); | 906 | QDir fullDir(localPath); |
893 | if (fullDir.exists()) | 907 | if (fullDir.exists()) |
894 | return true; | 908 | return true; |
895 | 909 | ||
896 | // at this point the directory doesn't exist | 910 | // at this point the directory doesn't exist |
897 | // go through the directory tree and start creating the direcotories | 911 | // go through the directory tree and start creating the direcotories |
898 | // that don't exist; if we can't create the directories, return false | 912 | // that don't exist; if we can't create the directories, return false |
899 | 913 | ||
900 | QString dirSeps = "/"; | 914 | QString dirSeps = "/"; |
901 | int dirIndex = localPath.find(dirSeps); | 915 | int dirIndex = localPath.find(dirSeps); |
902 | QString checkedPath; | 916 | QString checkedPath; |
903 | 917 | ||
904 | // didn't find any seps; weird, use the cur dir instead | 918 | // didn't find any seps; weird, use the cur dir instead |
905 | if (dirIndex == -1) { | 919 | if (dirIndex == -1) { |
906 | //qDebug("No seperators found in path %s", localPath.latin1()); | 920 | //qDebug("No seperators found in path %s", localPath.latin1()); |
907 | checkedPath = QDir::currentDirPath(); | 921 | checkedPath = QDir::currentDirPath(); |
908 | } | 922 | } |
909 | 923 | ||
910 | while (checkedPath != localPath) { | 924 | while (checkedPath != localPath) { |
911 | // no more seperators found, use the local path | 925 | // no more seperators found, use the local path |
912 | if (dirIndex == -1) | 926 | if (dirIndex == -1) |
913 | checkedPath = localPath; | 927 | checkedPath = localPath; |
914 | else { | 928 | else { |
915 | // the next directory to check | 929 | // the next directory to check |
916 | checkedPath = localPath.left(dirIndex) + "/"; | 930 | checkedPath = localPath.left(dirIndex) + "/"; |
917 | // advance the iterator; the next dir seperator | 931 | // advance the iterator; the next dir seperator |
918 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 932 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
919 | } | 933 | } |
920 | 934 | ||
921 | QDir checkDir(checkedPath); | 935 | QDir checkDir(checkedPath); |
922 | if (!checkDir.exists()) { | 936 | if (!checkDir.exists()) { |
923 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 937 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
924 | 938 | ||
925 | if (!checkDir.mkdir(checkedPath)) { | 939 | if (!checkDir.mkdir(checkedPath)) { |
926 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 940 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
927 | return FALSE; | 941 | return FALSE; |
928 | } | 942 | } |
929 | } | 943 | } |
930 | 944 | ||
931 | } | 945 | } |
932 | return TRUE; | 946 | return TRUE; |
933 | } | 947 | } |
934 | 948 | ||
935 | void Launcher::preloadApps() | 949 | void Launcher::preloadApps() |
936 | { | 950 | { |
937 | Config cfg("Launcher"); | 951 | Config cfg("Launcher"); |
938 | cfg.setGroup("Preload"); | 952 | cfg.setGroup("Preload"); |
939 | QStringList apps = cfg.readListEntry("Apps",','); | 953 | QStringList apps = cfg.readListEntry("Apps",','); |
940 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 954 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
941 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 955 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
942 | } | 956 | } |
943 | } | 957 | } |
diff --git a/core/pim/today/today.cpp b/core/pim/today/today.cpp index 61bd0c4..f5ed8d2 100644 --- a/core/pim/today/today.cpp +++ b/core/pim/today/today.cpp | |||
@@ -1,593 +1,604 @@ | |||
1 | /* | 1 | /* |
2 | * today.cpp : main class | 2 | * today.cpp : main class |
3 | * | 3 | * |
4 | * --------------------- | 4 | * --------------------- |
5 | * | 5 | * |
6 | * begin : Sun 10 17:20:00 CEST 2002 | 6 | * begin : Sun 10 17:20:00 CEST 2002 |
7 | * copyright : (c) 2002 by Maximilian Reiß | 7 | * copyright : (c) 2002 by Maximilian Reiß |
8 | * email : max.reiss@gmx.de | 8 | * email : max.reiss@gmx.de |
9 | * | 9 | * |
10 | */ | 10 | */ |
11 | /*************************************************************************** | 11 | /*************************************************************************** |
12 | * * | 12 | * * |
13 | * This program is free software; you can redistribute it and/or modify * | 13 | * This program is free software; you can redistribute it and/or modify * |
14 | * it under the terms of the GNU General Public License as published by * | 14 | * it under the terms of the GNU General Public License as published by * |
15 | * the Free Software Foundation; either version 2 of the License, or * | 15 | * the Free Software Foundation; either version 2 of the License, or * |
16 | * (at your option) any later version. * | 16 | * (at your option) any later version. * |
17 | * * | 17 | * * |
18 | ***************************************************************************/ | 18 | ***************************************************************************/ |
19 | 19 | ||
20 | #include "today.h" | 20 | #include "today.h" |
21 | 21 | ||
22 | #include <qpe/timestring.h> | 22 | #include <qpe/timestring.h> |
23 | #include <qpe/config.h> | 23 | #include <qpe/config.h> |
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/qprocess.h> | 25 | //#include <qpe/qprocess.h> |
26 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
27 | #include <qpe/contact.h> | 27 | #include <qpe/contact.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | 30 | ||
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qfile.h> | 32 | #include <qfile.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qtextstream.h> | 34 | #include <qtextstream.h> |
35 | #include <qcheckbox.h> | 35 | #include <qcheckbox.h> |
36 | #include <qspinbox.h> | 36 | #include <qspinbox.h> |
37 | #include <qpushbutton.h> | 37 | #include <qpushbutton.h> |
38 | #include <qlabel.h> | 38 | #include <qlabel.h> |
39 | #include <qtimer.h> | 39 | #include <qtimer.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qfileinfo.h> | 41 | //#include <qfileinfo.h> |
42 | #include <qlayout.h> | 42 | #include <qlayout.h> |
43 | #include <qtl.h> | 43 | #include <qtl.h> |
44 | 44 | ||
45 | //#include <iostream.h> | 45 | //#include <iostream.h> |
46 | #include <unistd.h> | 46 | #include <unistd.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | 48 | ||
49 | int MAX_LINES_TASK; | 49 | int MAX_LINES_TASK; |
50 | int MAX_CHAR_CLIP; | 50 | int MAX_CHAR_CLIP; |
51 | int MAX_LINES_MEET; | 51 | int MAX_LINES_MEET; |
52 | int SHOW_LOCATION; | 52 | int SHOW_LOCATION; |
53 | int SHOW_NOTES; | 53 | int SHOW_NOTES; |
54 | // show only later dates | 54 | // show only later dates |
55 | int ONLY_LATER; | 55 | int ONLY_LATER; |
56 | int AUTOSTART; | 56 | int AUTOSTART; |
57 | int NEW_START=1; | 57 | int NEW_START=1; |
58 | QString AUTOSTART_TIMER; | ||
58 | 59 | ||
59 | /* | 60 | /* |
60 | * Constructs a Example which is a child of 'parent', with the | 61 | * Constructs a Example which is a child of 'parent', with the |
61 | * name 'name' and widget flags set to 'f' | 62 | * name 'name' and widget flags set to 'f' |
62 | */ | 63 | */ |
63 | Today::Today( QWidget* parent, const char* name, WFlags fl ) | 64 | Today::Today( QWidget* parent, const char* name, WFlags fl ) |
64 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { | 65 | : TodayBase( parent, name, fl ), AllDateBookEvents(NULL) { |
65 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); | 66 | QObject::connect( (QObject*)PushButton1, SIGNAL( clicked() ), this, SLOT(startConfig() ) ); |
66 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); | 67 | QObject::connect( (QObject*)TodoButton, SIGNAL( clicked() ), this, SLOT(startTodo() ) ); |
67 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); | 68 | QObject::connect( (QObject*)DatesButton, SIGNAL( clicked() ), this, SLOT(startDatebook() ) ); |
68 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); | 69 | QObject::connect( (QObject*)MailButton, SIGNAL( clicked() ), this, SLOT(startMail() ) ); |
69 | 70 | ||
70 | #if defined(Q_WS_QWS) | 71 | #if defined(Q_WS_QWS) |
71 | #if !defined(QT_NO_COP) | 72 | #if !defined(QT_NO_COP) |
72 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); | 73 | QCopChannel *todayChannel = new QCopChannel("QPE/Today" , this ); |
73 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), | 74 | connect (todayChannel, SIGNAL( received(const QCString &, const QByteArray &)), |
74 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); | 75 | this, SLOT ( channelReceived(const QCString &, const QByteArray &)) ); |
75 | #endif | 76 | #endif |
76 | #endif | 77 | #endif |
77 | 78 | ||
78 | 79 | ||
79 | 80 | ||
80 | db = NULL; | 81 | db = NULL; |
81 | setOwnerField(); | 82 | setOwnerField(); |
82 | todo = new ToDoDB; | 83 | todo = new ToDoDB; |
83 | getTodo(); | 84 | getTodo(); |
84 | draw(); | 85 | draw(); |
85 | autoStart(); | 86 | autoStart(); |
86 | } | 87 | } |
87 | 88 | ||
88 | /* | 89 | /* |
89 | * Qcop receive method. | 90 | * Qcop receive method. |
90 | */ | 91 | */ |
91 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { | 92 | void Today::channelReceived(const QCString &msg, const QByteArray & data) { |
92 | QDataStream stream(data, IO_ReadOnly ); | 93 | QDataStream stream(data, IO_ReadOnly ); |
93 | if ( msg == "message(QString)" ) { | 94 | if ( msg == "message(QString)" ) { |
94 | QString message; | 95 | QString message; |
95 | stream >> message; | 96 | stream >> message; |
96 | setOwnerField(message); | 97 | setOwnerField(message); |
97 | } | 98 | } |
98 | 99 | ||
99 | } | 100 | } |
100 | 101 | ||
101 | /* | 102 | /* |
102 | * Initialises the owner field with the default value, the username | 103 | * Initialises the owner field with the default value, the username |
103 | */ | 104 | */ |
104 | void Today::setOwnerField() { | 105 | void Today::setOwnerField() { |
105 | QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); | 106 | QString file = Global::applicationFileName("addressbook", "businesscard.vcf"); |
106 | if (QFile::exists(file)) { | 107 | if (QFile::exists(file)) { |
107 | Contact cont = Contact::readVCard(file)[0]; | 108 | Contact cont = Contact::readVCard(file)[0]; |
108 | QString returnString = cont.fullName(); | 109 | QString returnString = cont.fullName(); |
109 | OwnerField->setText( "<b>" +tr ("Owned by ") + returnString + "</b>"); | 110 | OwnerField->setText( "<b>" +tr ("Owned by ") + returnString + "</b>"); |
110 | } else { | 111 | } else { |
111 | OwnerField->setText( "<b>" + tr ("Please fill out the business card")+" </b>"); | 112 | OwnerField->setText( "<b>" + tr ("Please fill out the business card")+" </b>"); |
112 | } | 113 | } |
113 | } | 114 | } |
114 | 115 | ||
115 | /* | 116 | /* |
116 | * Set the owner field with a given QString, for example per qcop. | 117 | * Set the owner field with a given QString, for example per qcop. |
117 | */ | 118 | */ |
118 | void Today::setOwnerField(QString &message) { | 119 | void Today::setOwnerField(QString &message) { |
119 | if (!message.isEmpty()) { | 120 | if (!message.isEmpty()) { |
120 | OwnerField->setText("<b>" + message + "</b>"); | 121 | OwnerField->setText("<b>" + message + "</b>"); |
121 | } | 122 | } |
122 | } | 123 | } |
123 | 124 | ||
124 | /* | 125 | /* |
125 | * Autostart, uses the new (opie only) autostart method in the launcher code. | 126 | * Autostart, uses the new (opie only) autostart method in the launcher code. |
126 | * If registered against that today ist started on each resume. | 127 | * If registered against that today ist started on each resume. |
127 | */ | 128 | */ |
128 | void Today::autoStart() { | 129 | void Today::autoStart() { |
129 | Config cfg("today"); | 130 | // Config cfg("today"); |
130 | cfg.setGroup("Autostart"); | 131 | //cfg.setGroup("Autostart"); |
131 | AUTOSTART = cfg.readNumEntry("autostart",1); | 132 | //AUTOSTART = cfg.readNumEntry("autostart",1); |
133 | |||
132 | if (AUTOSTART) { | 134 | if (AUTOSTART) { |
133 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); | 135 | QCopEnvelope e("QPE/System", "autoStart(QString, QString, QString)"); |
134 | e << QString("add"); | 136 | e << QString("add"); |
135 | e << QString("today"); | 137 | e << QString("today"); |
138 | e << AUTOSTART_TIMER; | ||
136 | } else { | 139 | } else { |
137 | QCopEnvelope e("QPE/System", "autoStart(QString,QString)"); | 140 | QCopEnvelope e("QPE/System", "autoStart(QString, QString)"); |
138 | e << QString("remove"); | 141 | e << QString("remove"); |
139 | e << QString("today"); | 142 | e << QString("today"); |
140 | } | 143 | } |
141 | } | 144 | } |
142 | 145 | ||
143 | /* | 146 | /* |
144 | * Repaint method. Reread all fields. | 147 | * Repaint method. Reread all fields. |
145 | */ | 148 | */ |
146 | void Today::draw() { | 149 | void Today::draw() { |
147 | init(); | 150 | init(); |
148 | getDates(); | 151 | getDates(); |
149 | getMail(); | 152 | getMail(); |
150 | 153 | ||
151 | // if the todolist.xml file was not modified in between, do not parse it. | 154 | // if the todolist.xml file was not modified in between, do not parse it. |
152 | if (checkIfModified()) { | 155 | if (checkIfModified()) { |
153 | if (todo) delete todo; | 156 | if (todo) delete todo; |
154 | todo = new ToDoDB; | 157 | todo = new ToDoDB; |
155 | getTodo(); | 158 | getTodo(); |
156 | } | 159 | } |
157 | 160 | ||
158 | // how often refresh | 161 | // how often refresh |
159 | QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); | 162 | QTimer::singleShot( 20*1000, this, SLOT(draw() ) ); |
160 | } | 163 | } |
161 | 164 | ||
162 | /* | 165 | /* |
163 | * Check if the todolist.xml was modified (if there are new entries. | 166 | * Check if the todolist.xml was modified (if there are new entries. |
164 | * Returns true if it was modified. | 167 | * Returns true if it was modified. |
165 | */ | 168 | */ |
166 | bool Today::checkIfModified() { | 169 | bool Today::checkIfModified() { |
167 | 170 | ||
168 | QDir dir; | 171 | QDir dir; |
169 | QString homedir = dir.homeDirPath (); | 172 | QString homedir = dir.homeDirPath (); |
170 | QString time; | 173 | QString time; |
171 | 174 | ||
172 | Config cfg("today"); | 175 | Config cfg("today"); |
173 | cfg.setGroup("Files"); | 176 | cfg.setGroup("Files"); |
174 | time = cfg.readEntry("todolisttimestamp", ""); | 177 | time = cfg.readEntry("todolisttimestamp", ""); |
175 | 178 | ||
176 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); | 179 | QFileInfo file = (homedir +"/Applications/todolist/todolist.xml"); |
177 | QDateTime fileTime = file.lastModified(); | 180 | QDateTime fileTime = file.lastModified(); |
178 | if (time.compare(fileTime.toString()) == 0) { | 181 | if (time.compare(fileTime.toString()) == 0) { |
179 | return false; | 182 | return false; |
180 | } else { | 183 | } else { |
181 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); | 184 | cfg.writeEntry("todolisttimestamp", fileTime.toString() ); |
182 | cfg.write(); | 185 | cfg.write(); |
183 | return true; | 186 | return true; |
184 | } | 187 | } |
185 | } | 188 | } |
186 | 189 | ||
187 | 190 | ||
188 | /* | 191 | /* |
189 | * Init stuff needed for today. Reads the config file. | 192 | * Init stuff needed for today. Reads the config file. |
190 | */ | 193 | */ |
191 | void Today::init() { | 194 | void Today::init() { |
192 | QDate date = QDate::currentDate(); | 195 | QDate date = QDate::currentDate(); |
193 | QString time = (tr( date.toString()) ); | 196 | QString time = (tr( date.toString()) ); |
194 | 197 | ||
195 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); | 198 | TextLabel1->setText(QString("<font color=#FFFFFF>" + time + "</font>")); |
196 | 199 | ||
197 | // read config | 200 | // read config |
198 | Config cfg("today"); | 201 | Config cfg("today"); |
199 | cfg.setGroup("BaseConfig"); | 202 | cfg.setGroup("BaseConfig"); |
200 | 203 | ||
201 | // -- config file section -- | 204 | // -- config file section -- |
202 | // how many lines should be showed in the task section | 205 | // how many lines should be showed in the task section |
203 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); | 206 | MAX_LINES_TASK = cfg.readNumEntry("maxlinestask",5); |
204 | // after how many chars should the be cut off on tasks and notes | 207 | // after how many chars should the be cut off on tasks and notes |
205 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); | 208 | MAX_CHAR_CLIP = cfg.readNumEntry("maxcharclip",40); |
206 | // how many lines should be showed in the datebook section | 209 | // how many lines should be showed in the datebook section |
207 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); | 210 | MAX_LINES_MEET = cfg.readNumEntry("maxlinesmeet",5); |
208 | // If location is to be showed too, 1 to activate it. | 211 | // If location is to be showed too, 1 to activate it. |
209 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); | 212 | SHOW_LOCATION = cfg.readNumEntry("showlocation",1); |
210 | // if notes should be shown | 213 | // if notes should be shown |
211 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); | 214 | SHOW_NOTES = cfg.readNumEntry("shownotes",0); |
212 | // should only later appointments be shown or all for the current day. | 215 | // should only later appointments be shown or all for the current day. |
213 | ONLY_LATER = cfg.readNumEntry("onlylater",1); | 216 | ONLY_LATER = cfg.readNumEntry("onlylater",1); |
214 | 217 | ||
218 | cfg.setGroup("Autostart"); | ||
219 | AUTOSTART = cfg.readNumEntry("autostart",1); | ||
220 | AUTOSTART_TIMER = cfg.readEntry("autostartdelay", "0"); | ||
221 | |||
215 | //db = new DateBookDB; | 222 | //db = new DateBookDB; |
216 | } | 223 | } |
217 | 224 | ||
218 | /* | 225 | /* |
219 | * The method for the configuration dialog. | 226 | * The method for the configuration dialog. |
220 | */ | 227 | */ |
221 | void Today::startConfig() { | 228 | void Today::startConfig() { |
222 | 229 | ||
223 | conf = new todayconfig ( this, "", true ); | 230 | conf = new todayconfig ( this, "", true ); |
224 | // read the config | 231 | // read the config |
225 | Config cfg("today"); | 232 | Config cfg("today"); |
226 | cfg.setGroup("BaseConfig"); | 233 | cfg.setGroup("BaseConfig"); |
227 | 234 | ||
228 | //init(); | 235 | //init(); |
229 | 236 | ||
230 | conf->SpinBox1->setValue(MAX_LINES_MEET); | 237 | conf->SpinBox1->setValue(MAX_LINES_MEET); |
231 | // location show box | 238 | // location show box |
232 | conf->CheckBox1->setChecked(SHOW_LOCATION); | 239 | conf->CheckBox1->setChecked(SHOW_LOCATION); |
233 | // notes show box | 240 | // notes show box |
234 | conf->CheckBox2->setChecked(SHOW_NOTES); | 241 | conf->CheckBox2->setChecked(SHOW_NOTES); |
235 | // task lines | 242 | // task lines |
236 | conf->SpinBox2->setValue(MAX_LINES_TASK); | 243 | conf->SpinBox2->setValue(MAX_LINES_TASK); |
237 | // clip when? | 244 | // clip when? |
238 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); | 245 | conf->SpinBox7->setValue(MAX_CHAR_CLIP); |
239 | // only later | 246 | // only later |
240 | conf->CheckBox3->setChecked(ONLY_LATER); | 247 | conf->CheckBox3->setChecked(ONLY_LATER); |
241 | // if today should be autostarted | 248 | // if today should be autostarted |
242 | conf->CheckBoxAuto->setChecked(AUTOSTART); | 249 | conf->CheckBoxAuto->setChecked(AUTOSTART); |
250 | // autostart only if device has been suspended for X minutes | ||
251 | conf->SpinBoxTime->setValue( AUTOSTART_TIMER.toInt() ); | ||
243 | 252 | ||
244 | conf->exec(); | 253 | conf->exec(); |
245 | 254 | ||
246 | int maxlinestask = conf->SpinBox2->value(); | 255 | int maxlinestask = conf->SpinBox2->value(); |
247 | int maxmeet = conf->SpinBox1->value(); | 256 | int maxmeet = conf->SpinBox1->value(); |
248 | int location = conf->CheckBox1->isChecked(); | 257 | int location = conf->CheckBox1->isChecked(); |
249 | int notes = conf->CheckBox2->isChecked(); | 258 | int notes = conf->CheckBox2->isChecked(); |
250 | int maxcharclip = conf->SpinBox7->value(); | 259 | int maxcharclip = conf->SpinBox7->value(); |
251 | int onlylater = conf->CheckBox3->isChecked(); | 260 | int onlylater = conf->CheckBox3->isChecked(); |
252 | int autostart =conf->CheckBoxAuto->isChecked(); | 261 | int autostart = conf->CheckBoxAuto->isChecked(); |
262 | int autostartdelay = conf->SpinBoxTime->value(); | ||
253 | 263 | ||
254 | cfg.writeEntry("maxlinestask",maxlinestask); | 264 | cfg.writeEntry("maxlinestask",maxlinestask); |
255 | cfg.writeEntry("maxcharclip", maxcharclip); | 265 | cfg.writeEntry("maxcharclip", maxcharclip); |
256 | cfg.writeEntry("maxlinesmeet",maxmeet); | 266 | cfg.writeEntry("maxlinesmeet",maxmeet); |
257 | cfg.writeEntry("showlocation",location); | 267 | cfg.writeEntry("showlocation",location); |
258 | cfg.writeEntry("shownotes", notes); | 268 | cfg.writeEntry("shownotes", notes); |
259 | cfg.writeEntry("onlylater", onlylater); | 269 | cfg.writeEntry("onlylater", onlylater); |
260 | cfg.setGroup("Autostart"); | 270 | cfg.setGroup("Autostart"); |
261 | cfg.writeEntry("autostart", autostart); | 271 | cfg.writeEntry("autostart", autostart); |
272 | cfg.writeEntry("autostartdelay", autostartdelay); | ||
262 | 273 | ||
263 | // sync it to "disk" | 274 | // sync it to "disk" |
264 | cfg.write(); | 275 | cfg.write(); |
265 | NEW_START=1; | 276 | NEW_START=1; |
266 | draw(); | 277 | draw(); |
267 | autoStart(); | 278 | autoStart(); |
268 | } | 279 | } |
269 | 280 | ||
270 | 281 | ||
271 | /* | 282 | /* |
272 | * Get all events that are in the datebook xml file for today | 283 | * Get all events that are in the datebook xml file for today |
273 | */ | 284 | */ |
274 | void Today::getDates() { | 285 | void Today::getDates() { |
275 | QDate date = QDate::currentDate(); | 286 | QDate date = QDate::currentDate(); |
276 | 287 | ||
277 | if (AllDateBookEvents) delete AllDateBookEvents; | 288 | if (AllDateBookEvents) delete AllDateBookEvents; |
278 | AllDateBookEvents = new QWidget( ); | 289 | AllDateBookEvents = new QWidget( ); |
279 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); | 290 | QVBoxLayout* layoutDates = new QVBoxLayout(AllDateBookEvents); |
280 | 291 | ||
281 | if (db) { | 292 | if (db) { |
282 | delete db; | 293 | delete db; |
283 | } | 294 | } |
284 | db = new DateBookDB; | 295 | db = new DateBookDB; |
285 | 296 | ||
286 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); | 297 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(date, date); |
287 | 298 | ||
288 | qBubbleSort(list); | 299 | qBubbleSort(list); |
289 | // printf("Get dates\n"); | 300 | // printf("Get dates\n"); |
290 | 301 | ||
291 | Config config( "qpe" ); | 302 | Config config( "qpe" ); |
292 | // if 24 h format | 303 | // if 24 h format |
293 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); | 304 | //bool ampm = config.readBoolEntry( "AMPM", TRUE ); |
294 | 305 | ||
295 | int count=0; | 306 | int count=0; |
296 | 307 | ||
297 | if ( list.count() > 0 ) { | 308 | if ( list.count() > 0 ) { |
298 | 309 | ||
299 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 310 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
300 | it!=list.end(); ++it ) { | 311 | it!=list.end(); ++it ) { |
301 | 312 | ||
302 | 313 | ||
303 | if ( count <= MAX_LINES_MEET ) { | 314 | if ( count <= MAX_LINES_MEET ) { |
304 | 315 | ||
305 | QTime time = QTime::currentTime(); | 316 | QTime time = QTime::currentTime(); |
306 | 317 | ||
307 | if (!ONLY_LATER) { | 318 | if (!ONLY_LATER) { |
308 | count++; | 319 | count++; |
309 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 320 | DateBookEvent *l=new DateBookEvent(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); |
310 | layoutDates->addWidget(l); | 321 | layoutDates->addWidget(l); |
311 | connect (l, SIGNAL(editEvent(const Event &)), | 322 | connect (l, SIGNAL(editEvent(const Event &)), |
312 | this, SLOT(editEvent(const Event &))); | 323 | this, SLOT(editEvent(const Event &))); |
313 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { | 324 | } else if ((time.toString() <= TimeString::dateString((*it).event().end())) ) { |
314 | count++; | 325 | count++; |
315 | 326 | ||
316 | // show only later appointments | 327 | // show only later appointments |
317 | DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); | 328 | DateBookEventLater *l=new DateBookEventLater(*it, AllDateBookEvents, SHOW_LOCATION, SHOW_NOTES); |
318 | layoutDates->addWidget(l); | 329 | layoutDates->addWidget(l); |
319 | connect (l, SIGNAL(editEvent(const Event &)), | 330 | connect (l, SIGNAL(editEvent(const Event &)), |
320 | this, SLOT(editEvent(const Event &))); | 331 | this, SLOT(editEvent(const Event &))); |
321 | } | 332 | } |
322 | } | 333 | } |
323 | } | 334 | } |
324 | if (ONLY_LATER && count==0) { | 335 | if (ONLY_LATER && count==0) { |
325 | QLabel* noMoreEvents = new QLabel(AllDateBookEvents); | 336 | QLabel* noMoreEvents = new QLabel(AllDateBookEvents); |
326 | noMoreEvents->setText(tr("No more appointments today")); | 337 | noMoreEvents->setText(tr("No more appointments today")); |
327 | layoutDates->addWidget(noMoreEvents); | 338 | layoutDates->addWidget(noMoreEvents); |
328 | } | 339 | } |
329 | } else { | 340 | } else { |
330 | QLabel* noEvents = new QLabel(AllDateBookEvents); | 341 | QLabel* noEvents = new QLabel(AllDateBookEvents); |
331 | noEvents->setText(tr("No appointments today")); | 342 | noEvents->setText(tr("No appointments today")); |
332 | layoutDates->addWidget(noEvents); | 343 | layoutDates->addWidget(noEvents); |
333 | } | 344 | } |
334 | 345 | ||
335 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); | 346 | layoutDates->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); |
336 | sv1->addChild(AllDateBookEvents); | 347 | sv1->addChild(AllDateBookEvents); |
337 | AllDateBookEvents->show(); | 348 | AllDateBookEvents->show(); |
338 | } | 349 | } |
339 | 350 | ||
340 | 351 | ||
341 | void Today::getMail() { | 352 | void Today::getMail() { |
342 | Config cfg("opiemail"); | 353 | Config cfg("opiemail"); |
343 | cfg.setGroup("today"); | 354 | cfg.setGroup("today"); |
344 | 355 | ||
345 | // how many lines should be showed in the task section | 356 | // how many lines should be showed in the task section |
346 | int NEW_MAILS = cfg.readNumEntry("newmails",0); | 357 | int NEW_MAILS = cfg.readNumEntry("newmails",0); |
347 | int OUTGOING = cfg.readNumEntry("outgoing",0); | 358 | int OUTGOING = cfg.readNumEntry("outgoing",0); |
348 | 359 | ||
349 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); | 360 | QString output = tr("<b>%1</b> new mail(s), <b>%2</b> outgoing").arg(NEW_MAILS).arg(OUTGOING); |
350 | 361 | ||
351 | MailField->setText(output); | 362 | MailField->setText(output); |
352 | } | 363 | } |
353 | 364 | ||
354 | 365 | ||
355 | /* | 366 | /* |
356 | * Get the todos | 367 | * Get the todos |
357 | */ | 368 | */ |
358 | void Today::getTodo() { | 369 | void Today::getTodo() { |
359 | 370 | ||
360 | QString output; | 371 | QString output; |
361 | QString tmpout; | 372 | QString tmpout; |
362 | int count = 0; | 373 | int count = 0; |
363 | int ammount = 0; | 374 | int ammount = 0; |
364 | 375 | ||
365 | // get overdue todos first | 376 | // get overdue todos first |
366 | QValueList<ToDoEvent> overDueList = todo->overDue(); | 377 | QValueList<ToDoEvent> overDueList = todo->overDue(); |
367 | qBubbleSort(overDueList); | 378 | qBubbleSort(overDueList); |
368 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); | 379 | for ( QValueList<ToDoEvent>::Iterator it=overDueList.begin(); |
369 | it!=overDueList.end(); ++it ) { | 380 | it!=overDueList.end(); ++it ) { |
370 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { | 381 | if (!(*it).isCompleted() && ( ammount < MAX_LINES_TASK) ) { |
371 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; | 382 | tmpout += "<font color=#e00000><b>-" +((*it).description()).mid(0, MAX_CHAR_CLIP) + "</b></font><br>"; |
372 | ammount++; | 383 | ammount++; |
373 | } | 384 | } |
374 | } | 385 | } |
375 | 386 | ||
376 | // get total number of still open todos | 387 | // get total number of still open todos |
377 | QValueList<ToDoEvent> open = todo->rawToDos(); | 388 | QValueList<ToDoEvent> open = todo->rawToDos(); |
378 | qBubbleSort(open); | 389 | qBubbleSort(open); |
379 | for ( QValueList<ToDoEvent>::Iterator it=open.begin(); | 390 | for ( QValueList<ToDoEvent>::Iterator it=open.begin(); |
380 | it!=open.end(); ++it ) { | 391 | it!=open.end(); ++it ) { |
381 | if (!(*it).isCompleted()){ | 392 | if (!(*it).isCompleted()){ |
382 | count +=1; | 393 | count +=1; |
383 | // not the overdues, we allready got them, and not if we are | 394 | // not the overdues, we allready got them, and not if we are |
384 | // over the maxlines | 395 | // over the maxlines |
385 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { | 396 | if (!(*it).isOverdue() && ( ammount < MAX_LINES_TASK) ) { |
386 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; | 397 | tmpout += "<b>-</b>" + ((*it).description()).mid(0, MAX_CHAR_CLIP) + "<br>"; |
387 | ammount++; | 398 | ammount++; |
388 | } | 399 | } |
389 | } | 400 | } |
390 | } | 401 | } |
391 | 402 | ||
392 | 403 | ||
393 | if (count > 0) { | 404 | if (count > 0) { |
394 | if( count == 1 ) { | 405 | if( count == 1 ) { |
395 | output = tr("There is <b> 1</b> active task: <br>" ); | 406 | output = tr("There is <b> 1</b> active task: <br>" ); |
396 | } else { | 407 | } else { |
397 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); | 408 | output = tr("There are <b> %1</b> active tasks: <br>").arg(count); |
398 | } | 409 | } |
399 | output += tmpout; | 410 | output += tmpout; |
400 | } else { | 411 | } else { |
401 | output = tr("No active tasks"); | 412 | output = tr("No active tasks"); |
402 | } | 413 | } |
403 | 414 | ||
404 | TodoField->setText(tr(output)); | 415 | TodoField->setText(tr(output)); |
405 | } | 416 | } |
406 | 417 | ||
407 | /* | 418 | /* |
408 | * launches datebook | 419 | * launches datebook |
409 | */ | 420 | */ |
410 | void Today::startDatebook() { | 421 | void Today::startDatebook() { |
411 | QCopEnvelope e("QPE/System", "execute(QString)"); | 422 | QCopEnvelope e("QPE/System", "execute(QString)"); |
412 | e << QString("datebook"); | 423 | e << QString("datebook"); |
413 | } | 424 | } |
414 | 425 | ||
415 | /* | 426 | /* |
416 | * starts the edit dialog as known from datebook | 427 | * starts the edit dialog as known from datebook |
417 | */ | 428 | */ |
418 | 429 | ||
419 | extern QPEApplication *todayApp; | 430 | extern QPEApplication *todayApp; |
420 | 431 | ||
421 | void Today::editEvent(const Event &e) { | 432 | void Today::editEvent(const Event &e) { |
422 | startDatebook(); | 433 | startDatebook(); |
423 | 434 | ||
424 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); | 435 | while(!QCopChannel::isRegistered("QPE/Datebook")) todayApp->processEvents(); |
425 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); | 436 | QCopEnvelope env("QPE/Datebook", "editEvent(int)"); |
426 | env << e.uid(); | 437 | env << e.uid(); |
427 | } | 438 | } |
428 | 439 | ||
429 | /* | 440 | /* |
430 | * launches todolist | 441 | * launches todolist |
431 | */ | 442 | */ |
432 | void Today::startTodo() { | 443 | void Today::startTodo() { |
433 | QCopEnvelope e("QPE/System", "execute(QString)"); | 444 | QCopEnvelope e("QPE/System", "execute(QString)"); |
434 | e << QString("todolist"); | 445 | e << QString("todolist"); |
435 | } | 446 | } |
436 | 447 | ||
437 | /* | 448 | /* |
438 | * launch opiemail | 449 | * launch opiemail |
439 | */ | 450 | */ |
440 | void Today::startMail() { | 451 | void Today::startMail() { |
441 | QCopEnvelope e("QPE/System", "execute(QString)"); | 452 | QCopEnvelope e("QPE/System", "execute(QString)"); |
442 | e << QString("opiemail"); | 453 | e << QString("opiemail"); |
443 | } | 454 | } |
444 | 455 | ||
445 | 456 | ||
446 | Today::~Today() { | 457 | Today::~Today() { |
447 | } | 458 | } |
448 | 459 | ||
449 | /* | 460 | /* |
450 | * Gets the events for the current day, if it should get all dates | 461 | * Gets the events for the current day, if it should get all dates |
451 | */ | 462 | */ |
452 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, | 463 | DateBookEvent::DateBookEvent(const EffectiveEvent &ev, |
453 | QWidget* parent = 0, | 464 | QWidget* parent = 0, |
454 | int SHOW_LOCATION = 0, | 465 | int SHOW_LOCATION = 0, |
455 | int SHOW_NOTES = 0, | 466 | int SHOW_NOTES = 0, |
456 | const char* name = 0, | 467 | const char* name = 0, |
457 | WFlags fl = 0) : | 468 | WFlags fl = 0) : |
458 | ClickableLabel(parent,name,fl), event(ev) { | 469 | ClickableLabel(parent,name,fl), event(ev) { |
459 | 470 | ||
460 | QString msg; | 471 | QString msg; |
461 | //QTime time = QTime::currentTime(); | 472 | //QTime time = QTime::currentTime(); |
462 | 473 | ||
463 | Config config( "qpe" ); | 474 | Config config( "qpe" ); |
464 | // if 24 h format | 475 | // if 24 h format |
465 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 476 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
466 | 477 | ||
467 | 478 | ||
468 | if (!ONLY_LATER) { | 479 | if (!ONLY_LATER) { |
469 | msg += "<B>" + (ev).description() + "</B>"; | 480 | msg += "<B>" + (ev).description() + "</B>"; |
470 | if ( (ev).event().hasAlarm() ) { | 481 | if ( (ev).event().hasAlarm() ) { |
471 | msg += " <b>[with alarm]</b>"; | 482 | msg += " <b>[with alarm]</b>"; |
472 | } | 483 | } |
473 | // include location or not | 484 | // include location or not |
474 | if (SHOW_LOCATION == 1) { | 485 | if (SHOW_LOCATION == 1) { |
475 | msg += "<BR><i>" + (ev).location() + "</i>"; | 486 | msg += "<BR><i>" + (ev).location() + "</i>"; |
476 | } | 487 | } |
477 | 488 | ||
478 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 489 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
479 | msg += "<br>All day"; | 490 | msg += "<br>All day"; |
480 | } else { | 491 | } else { |
481 | // start time of event | 492 | // start time of event |
482 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 493 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
483 | // end time of event | 494 | // end time of event |
484 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 495 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
485 | } | 496 | } |
486 | 497 | ||
487 | // include possible note or not | 498 | // include possible note or not |
488 | if (SHOW_NOTES == 1) { | 499 | if (SHOW_NOTES == 1) { |
489 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | 500 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); |
490 | } | 501 | } |
491 | } | 502 | } |
492 | setText(msg); | 503 | setText(msg); |
493 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 504 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
494 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 505 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
495 | } | 506 | } |
496 | 507 | ||
497 | 508 | ||
498 | QString DateBookEvent::ampmTime(QTime tm) { | 509 | QString DateBookEvent::ampmTime(QTime tm) { |
499 | 510 | ||
500 | QString s; | 511 | QString s; |
501 | if( ampm ) { | 512 | if( ampm ) { |
502 | int hour = tm.hour(); | 513 | int hour = tm.hour(); |
503 | if (hour == 0) | 514 | if (hour == 0) |
504 | hour = 12; | 515 | hour = 12; |
505 | if (hour > 12) | 516 | if (hour > 12) |
506 | hour -= 12; | 517 | hour -= 12; |
507 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 518 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
508 | (tm.hour() >= 12) ? "PM" : "AM" ); | 519 | (tm.hour() >= 12) ? "PM" : "AM" ); |
509 | return s; | 520 | return s; |
510 | } else { | 521 | } else { |
511 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 522 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
512 | return s; | 523 | return s; |
513 | } | 524 | } |
514 | 525 | ||
515 | } | 526 | } |
516 | 527 | ||
517 | 528 | ||
518 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, | 529 | DateBookEventLater::DateBookEventLater(const EffectiveEvent &ev, |
519 | QWidget* parent = 0, | 530 | QWidget* parent = 0, |
520 | int SHOW_LOCATION = 0, | 531 | int SHOW_LOCATION = 0, |
521 | int SHOW_NOTES = 0, | 532 | int SHOW_NOTES = 0, |
522 | const char* name = 0, | 533 | const char* name = 0, |
523 | WFlags fl = 0) : | 534 | WFlags fl = 0) : |
524 | ClickableLabel(parent,name,fl), event(ev) { | 535 | ClickableLabel(parent,name,fl), event(ev) { |
525 | 536 | ||
526 | QString msg; | 537 | QString msg; |
527 | QTime time = QTime::currentTime(); | 538 | QTime time = QTime::currentTime(); |
528 | 539 | ||
529 | Config config( "qpe" ); | 540 | Config config( "qpe" ); |
530 | // if 24 h format | 541 | // if 24 h format |
531 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 542 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
532 | 543 | ||
533 | 544 | ||
534 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { | 545 | if ((time.toString() <= TimeString::dateString((ev).event().end())) ) { |
535 | // show only later appointments | 546 | // show only later appointments |
536 | msg += "<B>" + (ev).description() + "</B>"; | 547 | msg += "<B>" + (ev).description() + "</B>"; |
537 | if ( (ev).event().hasAlarm() ) { | 548 | if ( (ev).event().hasAlarm() ) { |
538 | msg += " <b>[with alarm]</b>"; | 549 | msg += " <b>[with alarm]</b>"; |
539 | } | 550 | } |
540 | // include location or not | 551 | // include location or not |
541 | if (SHOW_LOCATION == 1) { | 552 | if (SHOW_LOCATION == 1) { |
542 | msg += "<BR><i>" + (ev).location() + "</i>"; | 553 | msg += "<BR><i>" + (ev).location() + "</i>"; |
543 | } | 554 | } |
544 | 555 | ||
545 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { | 556 | if ( (TimeString::timeString(QTime((ev).event().start().time()) ) == "00:00") && (TimeString::timeString(QTime((ev).event().end().time()) ) == "23:59") ) { |
546 | msg += "<br>All day"; | 557 | msg += "<br>All day"; |
547 | } else { | 558 | } else { |
548 | // start time of event | 559 | // start time of event |
549 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) | 560 | msg += "<br>" + ampmTime(QTime((ev).event().start().time()) ) |
550 | // end time of event | 561 | // end time of event |
551 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); | 562 | + "<b> - </b>" + ampmTime(QTime((ev).event().end().time()) ); |
552 | } | 563 | } |
553 | // include possible note or not | 564 | // include possible note or not |
554 | if (SHOW_NOTES == 1) { | 565 | if (SHOW_NOTES == 1) { |
555 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); | 566 | msg += "<br> <i>note</i>:" +((ev).notes()).mid(0, MAX_CHAR_CLIP); |
556 | } | 567 | } |
557 | } | 568 | } |
558 | 569 | ||
559 | setText(msg); | 570 | setText(msg); |
560 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); | 571 | connect(this, SIGNAL(clicked()), this, SLOT(editMe())); |
561 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); | 572 | setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); |
562 | } | 573 | } |
563 | 574 | ||
564 | 575 | ||
565 | QString DateBookEventLater::ampmTime(QTime tm) { | 576 | QString DateBookEventLater::ampmTime(QTime tm) { |
566 | 577 | ||
567 | QString s; | 578 | QString s; |
568 | if( ampm ) { | 579 | if( ampm ) { |
569 | int hour = tm.hour(); | 580 | int hour = tm.hour(); |
570 | if (hour == 0) | 581 | if (hour == 0) |
571 | hour = 12; | 582 | hour = 12; |
572 | if (hour > 12) | 583 | if (hour > 12) |
573 | hour -= 12; | 584 | hour -= 12; |
574 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), | 585 | s.sprintf( "%2d:%02d %s", hour, tm.minute(), |
575 | (tm.hour() >= 12) ? "PM" : "AM" ); | 586 | (tm.hour() >= 12) ? "PM" : "AM" ); |
576 | return s; | 587 | return s; |
577 | } else { | 588 | } else { |
578 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); | 589 | s.sprintf( "%2d:%02d", tm.hour(), tm.minute() ); |
579 | return s; | 590 | return s; |
580 | } | 591 | } |
581 | 592 | ||
582 | } | 593 | } |
583 | 594 | ||
584 | 595 | ||
585 | void DateBookEvent::editMe() { | 596 | void DateBookEvent::editMe() { |
586 | emit editEvent(event.event()); | 597 | emit editEvent(event.event()); |
587 | } | 598 | } |
588 | 599 | ||
589 | void DateBookEventLater::editMe() { | 600 | void DateBookEventLater::editMe() { |
590 | emit editEvent(event.event()); | 601 | emit editEvent(event.event()); |
591 | } | 602 | } |
592 | 603 | ||
593 | 604 | ||
diff --git a/core/pim/today/todayconfig.cpp b/core/pim/today/todayconfig.cpp index 500e8fb..905ec4b 100644 --- a/core/pim/today/todayconfig.cpp +++ b/core/pim/today/todayconfig.cpp | |||
@@ -1,146 +1,151 @@ | |||
1 | /**************************************************************************** | 1 | /* |
2 | ** Form implementation generated from reading ui file 'todayconfig.ui' | 2 | * todayconfig.cpp |
3 | ** | 3 | * |
4 | ** Created: Thu Feb 14 15:04:33 2002 | 4 | * --------------------- |
5 | ** by: The User Interface Compiler (uic) | 5 | * |
6 | ** | 6 | * begin : Sun 10 17:20:00 CEST 2002 |
7 | ** WARNING! All changes made in this file will be lost! | 7 | * copyright : (c) 2002 by Maximilian Reiß |
8 | ****************************************************************************/ | 8 | * email : max.reiss@gmx.de |
9 | * | ||
10 | */ | ||
11 | /*************************************************************************** | ||
12 | * * | ||
13 | * This program is free software; you can redistribute it and/or modify * | ||
14 | * it under the terms of the GNU General Public License as published by * | ||
15 | * the Free Software Foundation; either version 2 of the License, or * | ||
16 | * (at your option) any later version. * | ||
17 | * * | ||
18 | ***************************************************************************/ | ||
19 | |||
9 | #include "todayconfig.h" | 20 | #include "todayconfig.h" |
10 | 21 | ||
11 | #include <qcheckbox.h> | 22 | #include <qcheckbox.h> |
12 | #include <qframe.h> | 23 | #include <qframe.h> |
13 | #include <qlabel.h> | 24 | #include <qlabel.h> |
14 | #include <qspinbox.h> | 25 | #include <qspinbox.h> |
15 | #include <qtabwidget.h> | 26 | #include <qtabwidget.h> |
16 | #include <qwidget.h> | 27 | #include <qwidget.h> |
17 | #include <qlayout.h> | 28 | #include <qlayout.h> |
18 | #include <qvariant.h> | 29 | #include <qvariant.h> |
19 | #include <qwhatsthis.h> | 30 | //#include <qwhatsthis.h> |
20 | 31 | ||
21 | /* | ||
22 | * Constructs a todayconfig which is a child of 'parent', with the | ||
23 | * name 'name' and widget flags set to 'f' | ||
24 | * | ||
25 | * The dialog will by default be modeless, unless you set 'modal' to | ||
26 | * TRUE to construct a modal dialog. | ||
27 | */ | ||
28 | todayconfig::todayconfig( QWidget* parent, const char* name, bool modal, WFlags fl ) | 32 | todayconfig::todayconfig( QWidget* parent, const char* name, bool modal, WFlags fl ) |
29 | : QDialog( parent, name, modal, fl ) | 33 | : QDialog( parent, name, modal, fl ) { |
30 | { | ||
31 | if ( !name ) | 34 | if ( !name ) |
32 | setName( "todayconfig" ); | 35 | setName( "todayconfig" ); |
33 | resize( 175, 232 ); | 36 | resize( 175, 232 ); |
34 | setCaption( tr( "Today config" ) ); | 37 | setCaption( tr( "Today config" ) ); |
35 | 38 | ||
36 | TabWidget3 = new QTabWidget( this, "TabWidget3" ); | 39 | TabWidget3 = new QTabWidget( this, "TabWidget3" ); |
37 | TabWidget3->setGeometry( QRect( 0, 0, 220, 320 ) ); | 40 | TabWidget3->setGeometry( QRect( 0, 0, 220, 320 ) ); |
38 | TabWidget3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, TabWidget3->sizePolicy().hasHeightForWidth() ) ); | 41 | TabWidget3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, TabWidget3->sizePolicy().hasHeightForWidth() ) ); |
39 | TabWidget3->setAutoMask( FALSE ); | 42 | TabWidget3->setAutoMask( FALSE ); |
40 | TabWidget3->setTabShape( QTabWidget::Rounded ); | 43 | TabWidget3->setTabShape( QTabWidget::Rounded ); |
41 | 44 | ||
42 | tab = new QWidget( TabWidget3, "tab" ); | 45 | tab = new QWidget( TabWidget3, "tab" ); |
43 | 46 | ||
44 | Frame8 = new QFrame( tab, "Frame8" ); | 47 | Frame8 = new QFrame( tab, "Frame8" ); |
45 | Frame8->setGeometry( QRect( -5, 0, 200, 300 ) ); | 48 | Frame8->setGeometry( QRect( -5, 0, 200, 300 ) ); |
46 | Frame8->setFrameShape( QFrame::StyledPanel ); | 49 | Frame8->setFrameShape( QFrame::StyledPanel ); |
47 | Frame8->setFrameShadow( QFrame::Raised ); | 50 | Frame8->setFrameShadow( QFrame::Raised ); |
48 | 51 | ||
49 | TextLabel4 = new QLabel( Frame8, "TextLabel4" ); | 52 | TextLabel4 = new QLabel( Frame8, "TextLabel4" ); |
50 | TextLabel4->setGeometry( QRect( 20, 65, 100, 60 ) ); | 53 | TextLabel4->setGeometry( QRect( 20, 65, 100, 60 ) ); |
51 | TextLabel4->setText( tr( "Should the \n" | 54 | TextLabel4->setText( tr( "Should the \n" |
52 | "location \n" | 55 | "location \n" |
53 | "be shown?" ) ); | 56 | "be shown?" ) ); |
54 | 57 | ||
55 | TextLabel5 = new QLabel( Frame8, "TextLabel5" ); | 58 | TextLabel5 = new QLabel( Frame8, "TextLabel5" ); |
56 | TextLabel5->setGeometry( QRect( 20, 160, 120, 40 ) ); | 59 | TextLabel5->setGeometry( QRect( 20, 160, 120, 40 ) ); |
57 | TextLabel5->setText( tr( "Should the notes \n" | 60 | TextLabel5->setText( tr( "Should the notes \n" |
58 | "be shown?" ) ); | 61 | "be shown?" ) ); |
59 | 62 | ||
60 | CheckBox2 = new QCheckBox( Frame8, "CheckBox2" ); | 63 | CheckBox2 = new QCheckBox( Frame8, "CheckBox2" ); |
61 | CheckBox2->setGeometry( QRect( 158, 170, 27, 21 ) ); | 64 | CheckBox2->setGeometry( QRect( 158, 170, 27, 21 ) ); |
62 | //CheckBox2->setText( tr( "" ) ); | 65 | //CheckBox2->setText( tr( "" ) ); |
63 | 66 | ||
64 | CheckBox1 = new QCheckBox( Frame8, "CheckBox1" ); | 67 | CheckBox1 = new QCheckBox( Frame8, "CheckBox1" ); |
65 | CheckBox1->setGeometry( QRect( 158, 65, 27, 50 ) ); | 68 | CheckBox1->setGeometry( QRect( 158, 65, 27, 50 ) ); |
66 | //CheckBox1->setText( tr( "" ) ); | 69 | //CheckBox1->setText( tr( "" ) ); |
67 | 70 | ||
68 | CheckBox3 = new QCheckBox (Frame8, "CheckBox3" ); | 71 | CheckBox3 = new QCheckBox (Frame8, "CheckBox3" ); |
69 | CheckBox3->setGeometry( QRect( 158, 125, 27, 21 ) ); | 72 | CheckBox3->setGeometry( QRect( 158, 125, 27, 21 ) ); |
70 | 73 | ||
71 | TextLabel6 = new QLabel( Frame8, "All Day"); | 74 | TextLabel6 = new QLabel( Frame8, "All Day"); |
72 | TextLabel6->setGeometry( QRect( 20, 120, 100, 30 ) ); | 75 | TextLabel6->setGeometry( QRect( 20, 120, 100, 30 ) ); |
73 | TextLabel6->setText( tr( "Show only later\n" | 76 | TextLabel6->setText( tr( "Show only later\n" |
74 | "appointments") ); | 77 | "appointments") ); |
75 | 78 | ||
76 | SpinBox1 = new QSpinBox( Frame8, "SpinBox1" ); | 79 | SpinBox1 = new QSpinBox( Frame8, "SpinBox1" ); |
77 | SpinBox1->setGeometry( QRect( 115, 20, 58, 25 ) ); | 80 | SpinBox1->setGeometry( QRect( 115, 20, 58, 25 ) ); |
78 | SpinBox1->setMaxValue( 10 ); | 81 | SpinBox1->setMaxValue( 10 ); |
79 | SpinBox1->setValue( 5 ); | 82 | SpinBox1->setValue( 5 ); |
80 | 83 | ||
81 | TextLabel3 = new QLabel( Frame8, "TextLabel3" ); | 84 | TextLabel3 = new QLabel( Frame8, "TextLabel3" ); |
82 | TextLabel3->setGeometry( QRect( 20, 10, 90, 60 ) ); | 85 | TextLabel3->setGeometry( QRect( 20, 10, 90, 60 ) ); |
83 | TextLabel3->setText( tr( "How many \n" | 86 | TextLabel3->setText( tr( "How many \n" |
84 | "appointment\n" | 87 | "appointment\n" |
85 | "should\n" | 88 | "should\n" |
86 | "be shown?" ) ); | 89 | "be shown?" ) ); |
87 | TabWidget3->insertTab( tab, tr( "Calendar" ) ); | 90 | TabWidget3->insertTab( tab, tr( "Calendar" ) ); |
88 | 91 | ||
89 | tab_2 = new QWidget( TabWidget3, "tab_2" ); | 92 | tab_2 = new QWidget( TabWidget3, "tab_2" ); |
90 | 93 | ||
91 | Frame9 = new QFrame( tab_2, "Frame9" ); | 94 | Frame9 = new QFrame( tab_2, "Frame9" ); |
92 | Frame9->setGeometry( QRect( -5, 0, 230, 310 ) ); | 95 | Frame9->setGeometry( QRect( -5, 0, 230, 310 ) ); |
93 | Frame9->setFrameShape( QFrame::StyledPanel ); | 96 | Frame9->setFrameShape( QFrame::StyledPanel ); |
94 | Frame9->setFrameShadow( QFrame::Raised ); | 97 | Frame9->setFrameShadow( QFrame::Raised ); |
95 | 98 | ||
96 | TextLabel6 = new QLabel( Frame9, "TextLabel6" ); | 99 | TextLabel6 = new QLabel( Frame9, "TextLabel6" ); |
97 | TextLabel6->setGeometry( QRect( 20, 10, 100, 60 ) ); | 100 | TextLabel6->setGeometry( QRect( 20, 10, 100, 60 ) ); |
98 | TextLabel6->setText( tr( "How many\n" | 101 | TextLabel6->setText( tr( "How many\n" |
99 | "tasks should \n" | 102 | "tasks should \n" |
100 | "be shown?" ) ); | 103 | "be shown?" ) ); |
101 | 104 | ||
102 | SpinBox2 = new QSpinBox( Frame9, "SpinBox2" ); | 105 | SpinBox2 = new QSpinBox( Frame9, "SpinBox2" ); |
103 | SpinBox2->setGeometry( QRect( 115, 20, 58, 25 ) ); | 106 | SpinBox2->setGeometry( QRect( 115, 20, 58, 25 ) ); |
104 | SpinBox2->setMaxValue( 20 ); | 107 | SpinBox2->setMaxValue( 20 ); |
105 | SpinBox2->setValue( 5 ); | 108 | SpinBox2->setValue( 5 ); |
106 | TabWidget3->insertTab( tab_2, tr( "Tasks" ) ); | 109 | TabWidget3->insertTab( tab_2, tr( "Tasks" ) ); |
107 | 110 | ||
108 | tab_3 = new QWidget( TabWidget3, "tab_3" ); | 111 | tab_3 = new QWidget( TabWidget3, "tab_3" ); |
109 | 112 | ||
110 | Frame14 = new QFrame( tab_3, "Frame14" ); | 113 | Frame14 = new QFrame( tab_3, "Frame14" ); |
111 | Frame14->setGeometry( QRect( -5, 0, 200, 220 ) ); | 114 | Frame14->setGeometry( QRect( -5, 0, 200, 220 ) ); |
112 | Frame14->setFrameShape( QFrame::StyledPanel ); | 115 | Frame14->setFrameShape( QFrame::StyledPanel ); |
113 | Frame14->setFrameShadow( QFrame::Raised ); | 116 | Frame14->setFrameShadow( QFrame::Raised ); |
114 | 117 | ||
115 | TextLabel1 = new QLabel( Frame14, "TextLabel1" ); | 118 | TextLabel1 = new QLabel( Frame14, "TextLabel1" ); |
116 | TextLabel1->setGeometry( QRect( 20, 20, 100, 30 ) ); | 119 | TextLabel1->setGeometry( QRect( 20, 20, 100, 30 ) ); |
117 | TextLabel1->setText( tr( "Clip after how\n" | 120 | TextLabel1->setText( tr( "Clip after how\n" |
118 | "many letters" ) ); | 121 | "many letters" ) ); |
119 | 122 | ||
120 | SpinBox7 = new QSpinBox( Frame14, "SpinBox7" ); | 123 | SpinBox7 = new QSpinBox( Frame14, "SpinBox7" ); |
121 | SpinBox7->setGeometry( QRect( 115, 20, 58, 25 ) ); | 124 | SpinBox7->setGeometry( QRect( 115, 20, 58, 25 ) ); |
122 | SpinBox7->setMaxValue( 80 ); | 125 | SpinBox7->setMaxValue( 80 ); |
123 | SpinBox7->setValue( 30 ); | ||
124 | 126 | ||
125 | TextLabel2 = new QLabel( Frame14, "AutoStart" ); | 127 | TextLabel2 = new QLabel( Frame14, "AutoStart" ); |
126 | TextLabel2->setGeometry( QRect( 20, 60, 100, 45 ) ); | 128 | TextLabel2->setGeometry( QRect( 20, 60, 100, 45 ) ); |
127 | TextLabel2->setText( tr( "Should today be\n" | 129 | TextLabel2->setText( tr( "Should today be\n" |
128 | "autostarted on\n" | 130 | "autostarted on\n" |
129 | "resume?" | 131 | "resume?" |
130 | " (Opie only)" ) ); | 132 | " (Opie only)" ) ); |
131 | 133 | ||
132 | CheckBoxAuto = new QCheckBox (Frame14, "CheckBoxAuto" ); | 134 | CheckBoxAuto = new QCheckBox (Frame14, "CheckBoxAuto" ); |
133 | CheckBoxAuto->setGeometry( QRect( 158, 60, 27, 21 ) ); | 135 | CheckBoxAuto->setGeometry( QRect( 158, 60, 27, 21 ) ); |
134 | 136 | ||
137 | TimeLabel = new QLabel( Frame14, "TimeLabel" ); | ||
138 | TimeLabel->setGeometry( QRect ( 20, 120, 120, 45 ) ); | ||
139 | TimeLabel->setText( tr( "Activate the \n" | ||
140 | "autostart after how\n" | ||
141 | "many minutes?" ) ); | ||
142 | SpinBoxTime = new QSpinBox( Frame14, "TimeSpinner"); | ||
143 | SpinBoxTime->setGeometry( QRect( 115, 120, 58, 25 ) ); | ||
144 | |||
135 | TabWidget3->insertTab( tab_3, tr( "Misc" ) ); | 145 | TabWidget3->insertTab( tab_3, tr( "Misc" ) ); |
136 | 146 | ||
137 | } | 147 | } |
138 | 148 | ||
139 | /* | 149 | todayconfig::~todayconfig() { |
140 | * Destroys the object and frees any allocated resources | ||
141 | */ | ||
142 | todayconfig::~todayconfig() | ||
143 | { | ||
144 | // no need to delete child widgets, Qt does it all for us | ||
145 | } | 150 | } |
146 | 151 | ||
diff --git a/core/pim/today/todayconfig.h b/core/pim/today/todayconfig.h index 4739b5a..2986c4c 100644 --- a/core/pim/today/todayconfig.h +++ b/core/pim/today/todayconfig.h | |||
@@ -1,55 +1,66 @@ | |||
1 | /**************************************************************************** | 1 | /* |
2 | ** Form interface generated from reading ui file 'todayconfig.ui' | 2 | * todayconfig.h |
3 | ** | 3 | * |
4 | ** Created: Thu Feb 14 15:04:33 2002 | 4 | * --------------------- |
5 | ** by: The User Interface Compiler (uic) | 5 | * |
6 | ** | 6 | * begin : Sun 10 17:20:00 CEST 2002 |
7 | ** WARNING! All changes made in this file will be lost! | 7 | * copyright : (c) 2002 by Maximilian Reiß |
8 | ****************************************************************************/ | 8 | * email : max.reiss@gmx.de |
9 | * | ||
10 | */ | ||
11 | /*************************************************************************** | ||
12 | * * | ||
13 | * This program is free software; you can redistribute it and/or modify * | ||
14 | * it under the terms of the GNU General Public License as published by * | ||
15 | * the Free Software Foundation; either version 2 of the License, or * | ||
16 | * (at your option) any later version. * | ||
17 | * * | ||
18 | ***************************************************************************/ | ||
9 | #ifndef TODAYCONFIG_H | 19 | #ifndef TODAYCONFIG_H |
10 | #define TODAYCONFIG_H | 20 | #define TODAYCONFIG_H |
11 | 21 | ||
12 | #include <qvariant.h> | 22 | #include <qvariant.h> |
13 | #include <qdialog.h> | 23 | #include <qdialog.h> |
14 | //class QVBoxLayout; | 24 | //class QVBoxLayout; |
15 | class QHBoxLayout; | 25 | class QHBoxLayout; |
16 | class QGridLayout; | 26 | class QGridLayout; |
17 | class QCheckBox; | 27 | class QCheckBox; |
18 | class QFrame; | 28 | class QFrame; |
19 | class QLabel; | 29 | class QLabel; |
20 | class QSpinBox; | 30 | class QSpinBox; |
21 | class QTabWidget; | 31 | class QTabWidget; |
22 | class QWidget; | 32 | class QWidget; |
23 | 33 | ||
24 | class todayconfig : public QDialog | 34 | class todayconfig : public QDialog { |
25 | { | ||
26 | Q_OBJECT | 35 | Q_OBJECT |
27 | 36 | ||
28 | public: | 37 | public: |
29 | todayconfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 38 | todayconfig( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
30 | ~todayconfig(); | 39 | ~todayconfig(); |
31 | 40 | ||
32 | QTabWidget* TabWidget3; | 41 | QTabWidget* TabWidget3; |
33 | QWidget* tab; | 42 | QWidget* tab; |
34 | QFrame* Frame8; | 43 | QFrame* Frame8; |
35 | QLabel* TextLabel4; | 44 | QLabel* TextLabel4; |
36 | QLabel* TextLabel5; | 45 | QLabel* TextLabel5; |
37 | QLabel* TextLabel2; | 46 | QLabel* TextLabel2; |
38 | QCheckBox* CheckBox3; | 47 | QCheckBox* CheckBox3; |
39 | QCheckBox* CheckBox2; | 48 | QCheckBox* CheckBox2; |
40 | QCheckBox* CheckBox1; | 49 | QCheckBox* CheckBox1; |
41 | QCheckBox* CheckBoxAuto; | 50 | QCheckBox* CheckBoxAuto; |
42 | QSpinBox* SpinBox1; | 51 | QSpinBox* SpinBox1; |
43 | QLabel* TextLabel3; | 52 | QLabel* TextLabel3; |
44 | QWidget* tab_2; | 53 | QWidget* tab_2; |
45 | QFrame* Frame9; | 54 | QFrame* Frame9; |
46 | QLabel* TextLabel6; | 55 | QLabel* TextLabel6; |
47 | QSpinBox* SpinBox2; | 56 | QSpinBox* SpinBox2; |
48 | QWidget* tab_3; | 57 | QWidget* tab_3; |
49 | QFrame* Frame14; | 58 | QFrame* Frame14; |
50 | QLabel* TextLabel1; | 59 | QLabel* TextLabel1; |
51 | QSpinBox* SpinBox7; | 60 | QSpinBox* SpinBox7; |
61 | QLabel* TimeLabel; | ||
62 | QSpinBox* SpinBoxTime; | ||
52 | 63 | ||
53 | }; | 64 | }; |
54 | 65 | ||
55 | #endif // TODAYCONFIG_H | 66 | #endif |