-rw-r--r-- | core/launcher/desktop.cpp | 6 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 6 | ||||
-rw-r--r-- | core/launcher/launcher.pro | 2 | ||||
-rw-r--r-- | core/launcher/runningappbar.cpp | 287 | ||||
-rw-r--r-- | core/launcher/runningappbar.h | 88 | ||||
-rw-r--r-- | core/launcher/startmenu.cpp | 4 | ||||
-rw-r--r-- | core/launcher/taskbar.cpp | 21 | ||||
-rw-r--r-- | core/launcher/taskbar.h | 10 |
8 files changed, 405 insertions, 19 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index a19e4c6..bca95b2 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,1034 +1,1034 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "desktop.h" | 21 | #include "desktop.h" |
22 | #include "info.h" | 22 | #include "info.h" |
23 | #include "launcher.h" | 23 | #include "launcher.h" |
24 | #include "mrulist.h" | 24 | //#include "mrulist.h" |
25 | #include "qcopbridge.h" | 25 | #include "qcopbridge.h" |
26 | #include "shutdownimpl.h" | 26 | #include "shutdownimpl.h" |
27 | #include "startmenu.h" | 27 | #include "startmenu.h" |
28 | #include "taskbar.h" | 28 | #include "taskbar.h" |
29 | #include "transferserver.h" | 29 | #include "transferserver.h" |
30 | #include "irserver.h" | 30 | #include "irserver.h" |
31 | #include "packageslave.h" | 31 | #include "packageslave.h" |
32 | 32 | ||
33 | #include <qpe/applnk.h> | 33 | #include <qpe/applnk.h> |
34 | #include <qpe/mimetype.h> | 34 | #include <qpe/mimetype.h> |
35 | #include <qpe/password.h> | 35 | #include <qpe/password.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/power.h> | 37 | #include <qpe/power.h> |
38 | #include <qpe/timeconversion.h> | 38 | #include <qpe/timeconversion.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/network.h> | 40 | #include <qpe/network.h> |
41 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
42 | 42 | ||
43 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 43 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
44 | #include <qpe/custom.h> | 44 | #include <qpe/custom.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include <opie/odevice.h> | 47 | #include <opie/odevice.h> |
48 | 48 | ||
49 | #include <qgfx_qws.h> | 49 | #include <qgfx_qws.h> |
50 | #include <qmainwindow.h> | 50 | #include <qmainwindow.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qwindowsystem_qws.h> | 53 | #include <qwindowsystem_qws.h> |
54 | 54 | ||
55 | #include <qvaluelist.h> | 55 | #include <qvaluelist.h> |
56 | 56 | ||
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #include <fcntl.h> | 59 | #include <fcntl.h> |
60 | 60 | ||
61 | class QCopKeyRegister | 61 | class QCopKeyRegister |
62 | { | 62 | { |
63 | public: | 63 | public: |
64 | QCopKeyRegister() : keyCode( 0 ) | 64 | QCopKeyRegister() : keyCode( 0 ) |
65 | { } | 65 | { } |
66 | QCopKeyRegister( int k, const QString &c, const QString &m ) | 66 | QCopKeyRegister( int k, const QString &c, const QString &m ) |
67 | : keyCode( k ), channel( c ), message( m ) | 67 | : keyCode( k ), channel( c ), message( m ) |
68 | { } | 68 | { } |
69 | 69 | ||
70 | int getKeyCode() const | 70 | int getKeyCode() const |
71 | { | 71 | { |
72 | return keyCode; | 72 | return keyCode; |
73 | } | 73 | } |
74 | QString getChannel() const | 74 | QString getChannel() const |
75 | { | 75 | { |
76 | return channel; | 76 | return channel; |
77 | } | 77 | } |
78 | QString getMessage() const | 78 | QString getMessage() const |
79 | { | 79 | { |
80 | return message; | 80 | return message; |
81 | } | 81 | } |
82 | 82 | ||
83 | private: | 83 | private: |
84 | int keyCode; | 84 | int keyCode; |
85 | QString channel, message; | 85 | QString channel, message; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 88 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
89 | KeyRegisterList keyRegisterList; | 89 | KeyRegisterList keyRegisterList; |
90 | 90 | ||
91 | static Desktop* qpedesktop = 0; | 91 | static Desktop* qpedesktop = 0; |
92 | static int loggedin = 0; | 92 | static int loggedin = 0; |
93 | static void login( bool at_poweron ) | 93 | static void login( bool at_poweron ) |
94 | { | 94 | { |
95 | if ( !loggedin ) { | 95 | if ( !loggedin ) { |
96 | Global::terminateBuiltin( "calibrate" ); | 96 | Global::terminateBuiltin( "calibrate" ); |
97 | Password::authenticate( at_poweron ); | 97 | Password::authenticate( at_poweron ); |
98 | loggedin = 1; | 98 | loggedin = 1; |
99 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 99 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | bool Desktop::screenLocked() | 103 | bool Desktop::screenLocked() |
104 | { | 104 | { |
105 | return loggedin == 0; | 105 | return loggedin == 0; |
106 | } | 106 | } |
107 | 107 | ||
108 | /* | 108 | /* |
109 | Priority is number of alerts that are needed to pop up | 109 | Priority is number of alerts that are needed to pop up |
110 | alert. | 110 | alert. |
111 | */ | 111 | */ |
112 | class DesktopPowerAlerter : public QMessageBox | 112 | class DesktopPowerAlerter : public QMessageBox |
113 | { | 113 | { |
114 | public: | 114 | public: |
115 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 115 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
116 | : QMessageBox( tr( "Battery Status" ), "Low Battery", | 116 | : QMessageBox( tr( "Battery Status" ), "Low Battery", |
117 | QMessageBox::Critical, | 117 | QMessageBox::Critical, |
118 | QMessageBox::Ok | QMessageBox::Default, | 118 | QMessageBox::Ok | QMessageBox::Default, |
119 | QMessageBox::NoButton, QMessageBox::NoButton, | 119 | QMessageBox::NoButton, QMessageBox::NoButton, |
120 | parent, name, FALSE ) | 120 | parent, name, FALSE ) |
121 | { | 121 | { |
122 | currentPriority = INT_MAX; | 122 | currentPriority = INT_MAX; |
123 | alertCount = 0; | 123 | alertCount = 0; |
124 | } | 124 | } |
125 | 125 | ||
126 | void alert( const QString &text, int priority ); | 126 | void alert( const QString &text, int priority ); |
127 | void hideEvent( QHideEvent * ); | 127 | void hideEvent( QHideEvent * ); |
128 | private: | 128 | private: |
129 | int currentPriority; | 129 | int currentPriority; |
130 | int alertCount; | 130 | int alertCount; |
131 | }; | 131 | }; |
132 | 132 | ||
133 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 133 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
134 | { | 134 | { |
135 | alertCount++; | 135 | alertCount++; |
136 | if ( alertCount < priority ) | 136 | if ( alertCount < priority ) |
137 | return ; | 137 | return ; |
138 | if ( priority > currentPriority ) | 138 | if ( priority > currentPriority ) |
139 | return ; | 139 | return ; |
140 | currentPriority = priority; | 140 | currentPriority = priority; |
141 | setText( text ); | 141 | setText( text ); |
142 | show(); | 142 | show(); |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 146 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
147 | { | 147 | { |
148 | QMessageBox::hideEvent( e ); | 148 | QMessageBox::hideEvent( e ); |
149 | alertCount = 0; | 149 | alertCount = 0; |
150 | currentPriority = INT_MAX; | 150 | currentPriority = INT_MAX; |
151 | } | 151 | } |
152 | 152 | ||
153 | 153 | ||
154 | class QPEScreenSaver : public QWSScreenSaver | 154 | class QPEScreenSaver : public QWSScreenSaver |
155 | { | 155 | { |
156 | private: | 156 | private: |
157 | int LcdOn; | 157 | int LcdOn; |
158 | 158 | ||
159 | public: | 159 | public: |
160 | QPEScreenSaver() | 160 | QPEScreenSaver() |
161 | { | 161 | { |
162 | m_disable_suspend = 100; | 162 | m_disable_suspend = 100; |
163 | m_enable_dim = false; | 163 | m_enable_dim = false; |
164 | m_enable_lightoff = false; | 164 | m_enable_lightoff = false; |
165 | m_enable_onlylcdoff = false; | 165 | m_enable_onlylcdoff = false; |
166 | 166 | ||
167 | m_lcd_status = true; | 167 | m_lcd_status = true; |
168 | 168 | ||
169 | m_backlight_bright = -1; | 169 | m_backlight_bright = -1; |
170 | m_backlight_forcedoff = false; | 170 | m_backlight_forcedoff = false; |
171 | 171 | ||
172 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 172 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
173 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 173 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
174 | } | 174 | } |
175 | void restore() | 175 | void restore() |
176 | { | 176 | { |
177 | if ( !m_lcd_status ) // We must have turned it off | 177 | if ( !m_lcd_status ) // We must have turned it off |
178 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 178 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
179 | 179 | ||
180 | setBacklight ( -1 ); | 180 | setBacklight ( -1 ); |
181 | } | 181 | } |
182 | bool save( int level ) | 182 | bool save( int level ) |
183 | { | 183 | { |
184 | switch ( level ) { | 184 | switch ( level ) { |
185 | case 0: | 185 | case 0: |
186 | if ( m_disable_suspend > 0 && m_enable_dim ) { | 186 | if ( m_disable_suspend > 0 && m_enable_dim ) { |
187 | if ( backlight() > 1 ) | 187 | if ( backlight() > 1 ) |
188 | setBacklight( 1 ); // lowest non-off | 188 | setBacklight( 1 ); // lowest non-off |
189 | } | 189 | } |
190 | return true; | 190 | return true; |
191 | break; | 191 | break; |
192 | case 1: | 192 | case 1: |
193 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { | 193 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { |
194 | setBacklight( 0 ); // off | 194 | setBacklight( 0 ); // off |
195 | } | 195 | } |
196 | return true; | 196 | return true; |
197 | break; | 197 | break; |
198 | case 2: | 198 | case 2: |
199 | if ( m_enable_onlylcdoff ) { | 199 | if ( m_enable_onlylcdoff ) { |
200 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 200 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
201 | m_lcd_status = false; | 201 | m_lcd_status = false; |
202 | return true; | 202 | return true; |
203 | } | 203 | } |
204 | else // We're going to suspend the whole machine | 204 | else // We're going to suspend the whole machine |
205 | { | 205 | { |
206 | if ( ( m_disable_suspend > 2 ) && | 206 | if ( ( m_disable_suspend > 2 ) && |
207 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && | 207 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && |
208 | ( !Network::networkOnline ( ) ) ) { | 208 | ( !Network::networkOnline ( ) ) ) { |
209 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 209 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
210 | return true; | 210 | return true; |
211 | } | 211 | } |
212 | } | 212 | } |
213 | break; | 213 | break; |
214 | } | 214 | } |
215 | return false; | 215 | return false; |
216 | } | 216 | } |
217 | 217 | ||
218 | private: | 218 | private: |
219 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) | 219 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) |
220 | { | 220 | { |
221 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) | 221 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) |
222 | return 0; | 222 | return 0; |
223 | 223 | ||
224 | if ( interval < 0 ) { | 224 | if ( interval < 0 ) { |
225 | // Restore screen blanking and power saving state | 225 | // Restore screen blanking and power saving state |
226 | interval = config.readNumEntry( value, def ); | 226 | interval = config.readNumEntry( value, def ); |
227 | } | 227 | } |
228 | return interval; | 228 | return interval; |
229 | } | 229 | } |
230 | 230 | ||
231 | public: | 231 | public: |
232 | void setIntervals( int i1, int i2, int i3 ) | 232 | void setIntervals( int i1, int i2, int i3 ) |
233 | { | 233 | { |
234 | Config config( "qpe" ); | 234 | Config config( "qpe" ); |
235 | config.setGroup( "Screensaver" ); | 235 | config.setGroup( "Screensaver" ); |
236 | 236 | ||
237 | int v[ 4 ]; | 237 | int v[ 4 ]; |
238 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); | 238 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); |
239 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); | 239 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); |
240 | i3 = ssi( i3, config, "", "Interval", 60 ); | 240 | i3 = ssi( i3, config, "", "Interval", 60 ); |
241 | 241 | ||
242 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | 242 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); |
243 | 243 | ||
244 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 244 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
245 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | 245 | v [ 1 ] = QMAX( 1000 * i2, 100 ); |
246 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | 246 | v [ 2 ] = QMAX( 1000 * i3, 100 ); |
247 | v [ 3 ] = 0; | 247 | v [ 3 ] = 0; |
248 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); | 248 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); |
249 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); | 249 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); |
250 | m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); | 250 | m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); |
251 | 251 | ||
252 | if ( !i1 && !i2 && !i3 ) | 252 | if ( !i1 && !i2 && !i3 ) |
253 | QWSServer::setScreenSaverInterval( 0 ); | 253 | QWSServer::setScreenSaverInterval( 0 ); |
254 | else | 254 | else |
255 | QWSServer::setScreenSaverIntervals( v ); | 255 | QWSServer::setScreenSaverIntervals( v ); |
256 | } | 256 | } |
257 | 257 | ||
258 | void setInterval ( int interval ) | 258 | void setInterval ( int interval ) |
259 | { | 259 | { |
260 | setIntervals ( -1, -1, interval ); | 260 | setIntervals ( -1, -1, interval ); |
261 | } | 261 | } |
262 | 262 | ||
263 | void setMode ( int mode ) | 263 | void setMode ( int mode ) |
264 | { | 264 | { |
265 | if ( mode > m_disable_suspend ) | 265 | if ( mode > m_disable_suspend ) |
266 | setInterval( -1 ); | 266 | setInterval( -1 ); |
267 | m_disable_suspend = mode; | 267 | m_disable_suspend = mode; |
268 | } | 268 | } |
269 | 269 | ||
270 | int backlight ( ) | 270 | int backlight ( ) |
271 | { | 271 | { |
272 | if ( m_backlight_bright == -1 ) { | 272 | if ( m_backlight_bright == -1 ) { |
273 | // Read from config | 273 | // Read from config |
274 | Config config ( "qpe" ); | 274 | Config config ( "qpe" ); |
275 | config. setGroup ( "Screensaver" ); | 275 | config. setGroup ( "Screensaver" ); |
276 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); | 276 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); |
277 | } | 277 | } |
278 | return m_backlight_bright; | 278 | return m_backlight_bright; |
279 | } | 279 | } |
280 | 280 | ||
281 | void setBacklight ( int bright ) | 281 | void setBacklight ( int bright ) |
282 | { | 282 | { |
283 | if ( bright == -3 ) { | 283 | if ( bright == -3 ) { |
284 | // Forced on | 284 | // Forced on |
285 | m_backlight_forcedoff = false; | 285 | m_backlight_forcedoff = false; |
286 | bright = -1; | 286 | bright = -1; |
287 | } | 287 | } |
288 | if ( m_backlight_forcedoff && bright != -2 ) | 288 | if ( m_backlight_forcedoff && bright != -2 ) |
289 | return ; | 289 | return ; |
290 | if ( bright == -2 ) { | 290 | if ( bright == -2 ) { |
291 | // Toggle between off and on | 291 | // Toggle between off and on |
292 | bright = m_backlight_bright ? 0 : -1; | 292 | bright = m_backlight_bright ? 0 : -1; |
293 | m_backlight_forcedoff = !bright; | 293 | m_backlight_forcedoff = !bright; |
294 | } | 294 | } |
295 | 295 | ||
296 | m_backlight_bright = bright; | 296 | m_backlight_bright = bright; |
297 | 297 | ||
298 | bright = backlight ( ); | 298 | bright = backlight ( ); |
299 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 299 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); |
300 | 300 | ||
301 | m_backlight_bright = bright; | 301 | m_backlight_bright = bright; |
302 | } | 302 | } |
303 | 303 | ||
304 | private: | 304 | private: |
305 | int m_disable_suspend; | 305 | int m_disable_suspend; |
306 | bool m_enable_dim; | 306 | bool m_enable_dim; |
307 | bool m_enable_lightoff; | 307 | bool m_enable_lightoff; |
308 | bool m_enable_onlylcdoff; | 308 | bool m_enable_onlylcdoff; |
309 | 309 | ||
310 | bool m_lcd_status; | 310 | bool m_lcd_status; |
311 | 311 | ||
312 | int m_backlight_bright; | 312 | int m_backlight_bright; |
313 | bool m_backlight_forcedoff; | 313 | bool m_backlight_forcedoff; |
314 | }; | 314 | }; |
315 | 315 | ||
316 | 316 | ||
317 | void DesktopApplication::switchLCD ( bool on ) | 317 | void DesktopApplication::switchLCD ( bool on ) |
318 | { | 318 | { |
319 | if ( qApp ) { | 319 | if ( qApp ) { |
320 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 320 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
321 | 321 | ||
322 | if ( dapp-> m_screensaver ) | 322 | if ( dapp-> m_screensaver ) |
323 | dapp-> m_screensaver-> setBacklight ( on ? -3 : -1 ); | 323 | dapp-> m_screensaver-> setBacklight ( on ? -3 : -1 ); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 328 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
329 | : QPEApplication( argc, argv, appType ) | 329 | : QPEApplication( argc, argv, appType ) |
330 | { | 330 | { |
331 | 331 | ||
332 | QTimer * t = new QTimer( this ); | 332 | QTimer * t = new QTimer( this ); |
333 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); | 333 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); |
334 | t->start( 10000 ); | 334 | t->start( 10000 ); |
335 | ps = new PowerStatus; | 335 | ps = new PowerStatus; |
336 | pa = new DesktopPowerAlerter( 0 ); | 336 | pa = new DesktopPowerAlerter( 0 ); |
337 | 337 | ||
338 | channel = new QCopChannel( "QPE/Desktop", this ); | 338 | channel = new QCopChannel( "QPE/Desktop", this ); |
339 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 339 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
340 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 340 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
341 | 341 | ||
342 | channel = new QCopChannel( "QPE/System", this ); | 342 | channel = new QCopChannel( "QPE/System", this ); |
343 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 343 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
344 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 344 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
345 | 345 | ||
346 | m_screensaver = new QPEScreenSaver; | 346 | m_screensaver = new QPEScreenSaver; |
347 | 347 | ||
348 | m_screensaver-> setInterval ( -1 ); | 348 | m_screensaver-> setInterval ( -1 ); |
349 | QWSServer::setScreenSaver( m_screensaver ); | 349 | QWSServer::setScreenSaver( m_screensaver ); |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
353 | DesktopApplication::~DesktopApplication() | 353 | DesktopApplication::~DesktopApplication() |
354 | { | 354 | { |
355 | delete ps; | 355 | delete ps; |
356 | delete pa; | 356 | delete pa; |
357 | } | 357 | } |
358 | 358 | ||
359 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 359 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
360 | { | 360 | { |
361 | #ifdef Q_WS_QWS | 361 | #ifdef Q_WS_QWS |
362 | QDataStream stream( data, IO_ReadOnly ); | 362 | QDataStream stream( data, IO_ReadOnly ); |
363 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 363 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
364 | int k; | 364 | int k; |
365 | QString c, m; | 365 | QString c, m; |
366 | stream >> k; | 366 | stream >> k; |
367 | stream >> c; | 367 | stream >> c; |
368 | stream >> m; | 368 | stream >> m; |
369 | 369 | ||
370 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 370 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); |
371 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 371 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
372 | } | 372 | } |
373 | else if ( msg == "suspend()" ) { | 373 | else if ( msg == "suspend()" ) { |
374 | emit power(); | 374 | emit power(); |
375 | } | 375 | } |
376 | #endif | 376 | #endif |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 380 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
381 | { | 381 | { |
382 | #ifdef Q_WS_QWS | 382 | #ifdef Q_WS_QWS |
383 | QDataStream stream ( data, IO_ReadOnly ); | 383 | QDataStream stream ( data, IO_ReadOnly ); |
384 | 384 | ||
385 | if ( msg == "setScreenSaverInterval(int)" ) { | 385 | if ( msg == "setScreenSaverInterval(int)" ) { |
386 | int time; | 386 | int time; |
387 | stream >> time; | 387 | stream >> time; |
388 | m_screensaver-> setInterval( time ); | 388 | m_screensaver-> setInterval( time ); |
389 | } | 389 | } |
390 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 390 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
391 | int t1, t2, t3; | 391 | int t1, t2, t3; |
392 | stream >> t1 >> t2 >> t3; | 392 | stream >> t1 >> t2 >> t3; |
393 | m_screensaver-> setIntervals( t1, t2, t3 ); | 393 | m_screensaver-> setIntervals( t1, t2, t3 ); |
394 | } | 394 | } |
395 | else if ( msg == "setBacklight(int)" ) { | 395 | else if ( msg == "setBacklight(int)" ) { |
396 | int bright; | 396 | int bright; |
397 | stream >> bright; | 397 | stream >> bright; |
398 | m_screensaver-> setBacklight( bright ); | 398 | m_screensaver-> setBacklight( bright ); |
399 | } | 399 | } |
400 | else if ( msg == "setScreenSaverMode(int)" ) { | 400 | else if ( msg == "setScreenSaverMode(int)" ) { |
401 | int mode; | 401 | int mode; |
402 | stream >> mode; | 402 | stream >> mode; |
403 | m_screensaver-> setMode ( mode ); | 403 | m_screensaver-> setMode ( mode ); |
404 | } | 404 | } |
405 | #endif | 405 | #endif |
406 | } | 406 | } |
407 | 407 | ||
408 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 408 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
409 | 409 | ||
410 | #ifdef Q_WS_QWS | 410 | #ifdef Q_WS_QWS |
411 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 411 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
412 | { | 412 | { |
413 | qpedesktop->checkMemory(); | 413 | qpedesktop->checkMemory(); |
414 | 414 | ||
415 | if ( e->type == QWSEvent::Key ) { | 415 | if ( e->type == QWSEvent::Key ) { |
416 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 416 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
417 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 417 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
418 | return TRUE; | 418 | return TRUE; |
419 | bool press = ke->simpleData.is_press; | 419 | bool press = ke->simpleData.is_press; |
420 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 420 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
421 | 421 | ||
422 | /* | 422 | /* |
423 | app that registers key/message to be sent back to the app, when it doesn't have focus, | 423 | app that registers key/message to be sent back to the app, when it doesn't have focus, |
424 | when user presses key, unless keyboard has been requested from app. | 424 | when user presses key, unless keyboard has been requested from app. |
425 | will not send multiple repeats if user holds key | 425 | will not send multiple repeats if user holds key |
426 | i.e. one shot | 426 | i.e. one shot |
427 | */ | 427 | */ |
428 | if ( !keyRegisterList.isEmpty() ) { | 428 | if ( !keyRegisterList.isEmpty() ) { |
429 | KeyRegisterList::Iterator it; | 429 | KeyRegisterList::Iterator it; |
430 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 430 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
431 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press ) { | 431 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press ) { |
432 | if ( press ) | 432 | if ( press ) |
433 | qDebug( "press" ); | 433 | qDebug( "press" ); |
434 | else | 434 | else |
435 | qDebug( "release" ); | 435 | qDebug( "release" ); |
436 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); | 436 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); |
437 | } | 437 | } |
438 | } | 438 | } |
439 | } | 439 | } |
440 | 440 | ||
441 | if ( !keyboardGrabbed() ) { | 441 | if ( !keyboardGrabbed() ) { |
442 | if ( ke->simpleData.keycode == Key_F9 ) { | 442 | if ( ke->simpleData.keycode == Key_F9 ) { |
443 | if ( press ) | 443 | if ( press ) |
444 | emit datebook(); | 444 | emit datebook(); |
445 | return TRUE; | 445 | return TRUE; |
446 | } | 446 | } |
447 | if ( ke->simpleData.keycode == Key_F10 ) { | 447 | if ( ke->simpleData.keycode == Key_F10 ) { |
448 | if ( !press && cardSendTimer ) { | 448 | if ( !press && cardSendTimer ) { |
449 | emit contacts(); | 449 | emit contacts(); |
450 | delete cardSendTimer; | 450 | delete cardSendTimer; |
451 | } | 451 | } |
452 | else if ( press ) { | 452 | else if ( press ) { |
453 | cardSendTimer = new QTimer(); | 453 | cardSendTimer = new QTimer(); |
454 | cardSendTimer->start( 2000, TRUE ); | 454 | cardSendTimer->start( 2000, TRUE ); |
455 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 455 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
456 | } | 456 | } |
457 | return TRUE; | 457 | return TRUE; |
458 | } | 458 | } |
459 | /* menu key now opens application menu/toolbar | 459 | /* menu key now opens application menu/toolbar |
460 | if ( ke->simpleData.keycode == Key_F11 ) { | 460 | if ( ke->simpleData.keycode == Key_F11 ) { |
461 | if ( press ) emit menu(); | 461 | if ( press ) emit menu(); |
462 | return TRUE; | 462 | return TRUE; |
463 | } | 463 | } |
464 | */ | 464 | */ |
465 | if ( ke->simpleData.keycode == Key_F12 ) { | 465 | if ( ke->simpleData.keycode == Key_F12 ) { |
466 | while ( activePopupWidget() ) | 466 | while ( activePopupWidget() ) |
467 | activePopupWidget() ->close(); | 467 | activePopupWidget() ->close(); |
468 | if ( press ) | 468 | if ( press ) |
469 | emit launch(); | 469 | emit launch(); |
470 | return TRUE; | 470 | return TRUE; |
471 | } | 471 | } |
472 | if ( ke->simpleData.keycode == Key_F13 ) { | 472 | if ( ke->simpleData.keycode == Key_F13 ) { |
473 | if ( press ) | 473 | if ( press ) |
474 | emit email(); | 474 | emit email(); |
475 | return TRUE; | 475 | return TRUE; |
476 | } | 476 | } |
477 | } | 477 | } |
478 | 478 | ||
479 | if ( ke->simpleData.keycode == Key_F34 ) { | 479 | if ( ke->simpleData.keycode == Key_F34 ) { |
480 | if ( press ) | 480 | if ( press ) |
481 | emit power(); | 481 | emit power(); |
482 | return TRUE; | 482 | return TRUE; |
483 | } | 483 | } |
484 | // This was used for the iPAQ PowerButton | 484 | // This was used for the iPAQ PowerButton |
485 | // See main.cpp for new KeyboardFilter | 485 | // See main.cpp for new KeyboardFilter |
486 | // | 486 | // |
487 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 487 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
488 | // if ( press ) emit power(); | 488 | // if ( press ) emit power(); |
489 | // return TRUE; | 489 | // return TRUE; |
490 | // } | 490 | // } |
491 | if ( ke->simpleData.keycode == Key_F35 ) { | 491 | if ( ke->simpleData.keycode == Key_F35 ) { |
492 | if ( press ) | 492 | if ( press ) |
493 | emit backlight(); | 493 | emit backlight(); |
494 | return TRUE; | 494 | return TRUE; |
495 | } | 495 | } |
496 | if ( ke->simpleData.keycode == Key_F32 ) { | 496 | if ( ke->simpleData.keycode == Key_F32 ) { |
497 | if ( press ) | 497 | if ( press ) |
498 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 498 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
499 | return TRUE; | 499 | return TRUE; |
500 | } | 500 | } |
501 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 501 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
502 | if ( press ) | 502 | if ( press ) |
503 | emit symbol(); | 503 | emit symbol(); |
504 | return TRUE; | 504 | return TRUE; |
505 | } | 505 | } |
506 | if ( ke->simpleData.keycode == Key_NumLock ) { | 506 | if ( ke->simpleData.keycode == Key_NumLock ) { |
507 | if ( press ) | 507 | if ( press ) |
508 | emit numLockStateToggle(); | 508 | emit numLockStateToggle(); |
509 | } | 509 | } |
510 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 510 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
511 | if ( press ) | 511 | if ( press ) |
512 | emit capsLockStateToggle(); | 512 | emit capsLockStateToggle(); |
513 | } | 513 | } |
514 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) | 514 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) |
515 | qpedesktop->keyClick(); | 515 | qpedesktop->keyClick(); |
516 | } | 516 | } |
517 | else { | 517 | else { |
518 | if ( e->type == QWSEvent::Mouse ) { | 518 | if ( e->type == QWSEvent::Mouse ) { |
519 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 519 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
520 | static bool up = TRUE; | 520 | static bool up = TRUE; |
521 | if ( me->simpleData.state & LeftButton ) { | 521 | if ( me->simpleData.state & LeftButton ) { |
522 | if ( up ) { | 522 | if ( up ) { |
523 | up = FALSE; | 523 | up = FALSE; |
524 | qpedesktop->screenClick(); | 524 | qpedesktop->screenClick(); |
525 | } | 525 | } |
526 | } | 526 | } |
527 | else { | 527 | else { |
528 | up = TRUE; | 528 | up = TRUE; |
529 | } | 529 | } |
530 | } | 530 | } |
531 | } | 531 | } |
532 | 532 | ||
533 | return QPEApplication::qwsEventFilter( e ); | 533 | return QPEApplication::qwsEventFilter( e ); |
534 | } | 534 | } |
535 | #endif | 535 | #endif |
536 | 536 | ||
537 | void DesktopApplication::psTimeout() | 537 | void DesktopApplication::psTimeout() |
538 | { | 538 | { |
539 | qpedesktop->checkMemory(); // in case no events are being generated | 539 | qpedesktop->checkMemory(); // in case no events are being generated |
540 | 540 | ||
541 | *ps = PowerStatusManager::readStatus(); | 541 | *ps = PowerStatusManager::readStatus(); |
542 | 542 | ||
543 | if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 543 | if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
544 | pa->alert( tr( "Battery is running very low." ), 6 ); | 544 | pa->alert( tr( "Battery is running very low." ), 6 ); |
545 | } | 545 | } |
546 | 546 | ||
547 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 547 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
548 | pa->alert( tr( "Battery level is critical!\n" | 548 | pa->alert( tr( "Battery level is critical!\n" |
549 | "Keep power off until power restored!" ), 1 ); | 549 | "Keep power off until power restored!" ), 1 ); |
550 | } | 550 | } |
551 | 551 | ||
552 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 552 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
553 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 553 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | 557 | ||
558 | void DesktopApplication::sendCard() | 558 | void DesktopApplication::sendCard() |
559 | { | 559 | { |
560 | delete cardSendTimer; | 560 | delete cardSendTimer; |
561 | cardSendTimer = 0; | 561 | cardSendTimer = 0; |
562 | QString card = getenv( "HOME" ); | 562 | QString card = getenv( "HOME" ); |
563 | card += "/Applications/addressbook/businesscard.vcf"; | 563 | card += "/Applications/addressbook/businesscard.vcf"; |
564 | 564 | ||
565 | if ( QFile::exists( card ) ) { | 565 | if ( QFile::exists( card ) ) { |
566 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); | 566 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); |
567 | QString mimetype = "text/x-vCard"; | 567 | QString mimetype = "text/x-vCard"; |
568 | e << tr( "business card" ) << card << mimetype; | 568 | e << tr( "business card" ) << card << mimetype; |
569 | } | 569 | } |
570 | } | 570 | } |
571 | 571 | ||
572 | #if defined(QPE_HAVE_MEMALERTER) | 572 | #if defined(QPE_HAVE_MEMALERTER) |
573 | QPE_MEMALERTER_IMPL | 573 | QPE_MEMALERTER_IMPL |
574 | #endif | 574 | #endif |
575 | 575 | ||
576 | //=========================================================================== | 576 | //=========================================================================== |
577 | 577 | ||
578 | Desktop::Desktop() : | 578 | Desktop::Desktop() : |
579 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 579 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
580 | qcopBridge( 0 ), | 580 | qcopBridge( 0 ), |
581 | transferServer( 0 ), | 581 | transferServer( 0 ), |
582 | packageSlave( 0 ) | 582 | packageSlave( 0 ) |
583 | { | 583 | { |
584 | qpedesktop = this; | 584 | qpedesktop = this; |
585 | 585 | ||
586 | // bg = new Info( this ); | 586 | // bg = new Info( this ); |
587 | tb = new TaskBar; | 587 | tb = new TaskBar; |
588 | 588 | ||
589 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 589 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
590 | 590 | ||
591 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 591 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
592 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 592 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
593 | 593 | ||
594 | int displayw = qApp->desktop() ->width(); | 594 | int displayw = qApp->desktop() ->width(); |
595 | int displayh = qApp->desktop() ->height(); | 595 | int displayh = qApp->desktop() ->height(); |
596 | 596 | ||
597 | 597 | ||
598 | QSize sz = tb->sizeHint(); | 598 | QSize sz = tb->sizeHint(); |
599 | 599 | ||
600 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 600 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
601 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 601 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
602 | 602 | ||
603 | tb->show(); | 603 | tb->show(); |
604 | launcher->showMaximized(); | 604 | launcher->showMaximized(); |
605 | launcher->show(); | 605 | launcher->show(); |
606 | launcher->raise(); | 606 | launcher->raise(); |
607 | #if defined(QPE_HAVE_MEMALERTER) | 607 | #if defined(QPE_HAVE_MEMALERTER) |
608 | 608 | ||
609 | initMemalerter(); | 609 | initMemalerter(); |
610 | #endif | 610 | #endif |
611 | // start services | 611 | // start services |
612 | startTransferServer(); | 612 | startTransferServer(); |
613 | ( void ) new IrServer( this ); | 613 | ( void ) new IrServer( this ); |
614 | rereadVolumes(); | 614 | rereadVolumes(); |
615 | 615 | ||
616 | packageSlave = new PackageSlave( this ); | 616 | packageSlave = new PackageSlave( this ); |
617 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); | 617 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); |
618 | 618 | ||
619 | qApp->installEventFilter( this ); | 619 | qApp->installEventFilter( this ); |
620 | } | 620 | } |
621 | 621 | ||
622 | void Desktop::show() | 622 | void Desktop::show() |
623 | { | 623 | { |
624 | login( TRUE ); | 624 | login( TRUE ); |
625 | QWidget::show(); | 625 | QWidget::show(); |
626 | } | 626 | } |
627 | 627 | ||
628 | Desktop::~Desktop() | 628 | Desktop::~Desktop() |
629 | { | 629 | { |
630 | delete launcher; | 630 | delete launcher; |
631 | delete tb; | 631 | delete tb; |
632 | delete qcopBridge; | 632 | delete qcopBridge; |
633 | delete transferServer; | 633 | delete transferServer; |
634 | } | 634 | } |
635 | 635 | ||
636 | bool Desktop::recoverMemory() | 636 | bool Desktop::recoverMemory() |
637 | { | 637 | { |
638 | return tb->recoverMemory(); | 638 | return tb->recoverMemory(); |
639 | } | 639 | } |
640 | 640 | ||
641 | void Desktop::checkMemory() | 641 | void Desktop::checkMemory() |
642 | { | 642 | { |
643 | #if defined(QPE_HAVE_MEMALERTER) | 643 | #if defined(QPE_HAVE_MEMALERTER) |
644 | static bool ignoreNormal = FALSE; | 644 | static bool ignoreNormal = FALSE; |
645 | static bool existingMessage = FALSE; | 645 | static bool existingMessage = FALSE; |
646 | 646 | ||
647 | if ( existingMessage ) | 647 | if ( existingMessage ) |
648 | return ; // don't show a second message while still on first | 648 | return ; // don't show a second message while still on first |
649 | 649 | ||
650 | existingMessage = TRUE; | 650 | existingMessage = TRUE; |
651 | switch ( memstate ) { | 651 | switch ( memstate ) { |
652 | case Unknown: | 652 | case Unknown: |
653 | break; | 653 | break; |
654 | case Low: | 654 | case Low: |
655 | memstate = Unknown; | 655 | memstate = Unknown; |
656 | if ( recoverMemory() ) | 656 | if ( recoverMemory() ) |
657 | ignoreNormal = TRUE; | 657 | ignoreNormal = TRUE; |
658 | else | 658 | else |
659 | QMessageBox::warning( 0 , "Memory Status", | 659 | QMessageBox::warning( 0 , "Memory Status", |
660 | "The memory smacks of shortage. \n" | 660 | "The memory smacks of shortage. \n" |
661 | "Please save data. " ); | 661 | "Please save data. " ); |
662 | break; | 662 | break; |
663 | case Normal: | 663 | case Normal: |
664 | memstate = Unknown; | 664 | memstate = Unknown; |
665 | if ( ignoreNormal ) | 665 | if ( ignoreNormal ) |
666 | ignoreNormal = FALSE; | 666 | ignoreNormal = FALSE; |
667 | else | 667 | else |
668 | QMessageBox::information ( 0 , "Memory Status", | 668 | QMessageBox::information ( 0 , "Memory Status", |
669 | "There is enough memory again." ); | 669 | "There is enough memory again." ); |
670 | break; | 670 | break; |
671 | case VeryLow: | 671 | case VeryLow: |
672 | memstate = Unknown; | 672 | memstate = Unknown; |
673 | QMessageBox::critical( 0 , "Memory Status", | 673 | QMessageBox::critical( 0 , "Memory Status", |
674 | "The memory is very low. \n" | 674 | "The memory is very low. \n" |
675 | "Please end this application \n" | 675 | "Please end this application \n" |
676 | "immediately." ); | 676 | "immediately." ); |
677 | recoverMemory(); | 677 | recoverMemory(); |
678 | } | 678 | } |
679 | existingMessage = FALSE; | 679 | existingMessage = FALSE; |
680 | #endif | 680 | #endif |
681 | } | 681 | } |
682 | 682 | ||
683 | static bool isVisibleWindow( int wid ) | 683 | static bool isVisibleWindow( int wid ) |
684 | { | 684 | { |
685 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 685 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
686 | QWSWindow* w; | 686 | QWSWindow* w; |
687 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 687 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
688 | if ( w->winId() == wid ) | 688 | if ( w->winId() == wid ) |
689 | return !w->isFullyObscured(); | 689 | return !w->isFullyObscured(); |
690 | } | 690 | } |
691 | return FALSE; | 691 | return FALSE; |
692 | } | 692 | } |
693 | 693 | ||
694 | static bool hasVisibleWindow( const QString& clientname ) | 694 | static bool hasVisibleWindow( const QString& clientname ) |
695 | { | 695 | { |
696 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 696 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
697 | QWSWindow* w; | 697 | QWSWindow* w; |
698 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 698 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
699 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 699 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
700 | return TRUE; | 700 | return TRUE; |
701 | } | 701 | } |
702 | return FALSE; | 702 | return FALSE; |
703 | } | 703 | } |
704 | 704 | ||
705 | void Desktop::raiseLauncher() | 705 | void Desktop::raiseLauncher() |
706 | { | 706 | { |
707 | Config cfg( "qpe" ); //F12 'Home' | 707 | Config cfg( "qpe" ); //F12 'Home' |
708 | cfg.setGroup( "AppsKey" ); | 708 | cfg.setGroup( "AppsKey" ); |
709 | QString tempItem; | 709 | QString tempItem; |
710 | tempItem = cfg.readEntry( "Middle", "Home" ); | 710 | tempItem = cfg.readEntry( "Middle", "Home" ); |
711 | if ( tempItem == "Home" || tempItem.isEmpty() ) { | 711 | if ( tempItem == "Home" || tempItem.isEmpty() ) { |
712 | if ( isVisibleWindow( launcher->winId() ) ) | 712 | if ( isVisibleWindow( launcher->winId() ) ) |
713 | launcher->nextView(); | 713 | launcher->nextView(); |
714 | else | 714 | else |
715 | launcher->raise(); | 715 | launcher->raise(); |
716 | } | 716 | } |
717 | else { | 717 | else { |
718 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 718 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
719 | e << tempItem; | 719 | e << tempItem; |
720 | } | 720 | } |
721 | } | 721 | } |
722 | 722 | ||
723 | void Desktop::executeOrModify( const QString& appLnkFile ) | 723 | void Desktop::executeOrModify( const QString& appLnkFile ) |
724 | { | 724 | { |
725 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 725 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
726 | if ( lnk.isValid() ) { | 726 | if ( lnk.isValid() ) { |
727 | QCString app = lnk.exec().utf8(); | 727 | QCString app = lnk.exec().utf8(); |
728 | Global::terminateBuiltin( "calibrate" ); | 728 | Global::terminateBuiltin( "calibrate" ); |
729 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 729 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
730 | MRUList::addTask( &lnk ); | 730 | //MRUList::addTask( &lnk ); |
731 | if ( hasVisibleWindow( app ) ) | 731 | if ( hasVisibleWindow( app ) ) |
732 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 732 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
733 | else | 733 | else |
734 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 734 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
735 | } | 735 | } |
736 | else { | 736 | else { |
737 | lnk.execute(); | 737 | lnk.execute(); |
738 | } | 738 | } |
739 | } | 739 | } |
740 | } | 740 | } |
741 | 741 | ||
742 | void Desktop::raiseDatebook() | 742 | void Desktop::raiseDatebook() |
743 | { | 743 | { |
744 | Config cfg( "qpe" ); //F9 'Activity' | 744 | Config cfg( "qpe" ); //F9 'Activity' |
745 | cfg.setGroup( "AppsKey" ); | 745 | cfg.setGroup( "AppsKey" ); |
746 | QString tempItem; | 746 | QString tempItem; |
747 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); | 747 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); |
748 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { | 748 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { |
749 | tempItem = "datebook"; | 749 | tempItem = "datebook"; |
750 | } | 750 | } |
751 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 751 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
752 | e << tempItem; | 752 | e << tempItem; |
753 | } | 753 | } |
754 | 754 | ||
755 | void Desktop::raiseContacts() | 755 | void Desktop::raiseContacts() |
756 | { | 756 | { |
757 | Config cfg( "qpe" ); //F10, 'Contacts' | 757 | Config cfg( "qpe" ); //F10, 'Contacts' |
758 | cfg.setGroup( "AppsKey" ); | 758 | cfg.setGroup( "AppsKey" ); |
759 | QString tempItem; | 759 | QString tempItem; |
760 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); | 760 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); |
761 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { | 761 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { |
762 | tempItem = "addressbook"; | 762 | tempItem = "addressbook"; |
763 | } | 763 | } |
764 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 764 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
765 | e << tempItem; | 765 | e << tempItem; |
766 | } | 766 | } |
767 | 767 | ||
768 | void Desktop::raiseMenu() | 768 | void Desktop::raiseMenu() |
769 | { | 769 | { |
770 | Config cfg( "qpe" ); //F11, 'Menu | 770 | Config cfg( "qpe" ); //F11, 'Menu |
771 | cfg.setGroup( "AppsKey" ); | 771 | cfg.setGroup( "AppsKey" ); |
772 | QString tempItem; | 772 | QString tempItem; |
773 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); | 773 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); |
774 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { | 774 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { |
775 | Global::terminateBuiltin( "calibrate" ); | 775 | Global::terminateBuiltin( "calibrate" ); |
776 | tb->startMenu() ->launch(); | 776 | tb->startMenu() ->launch(); |
777 | } | 777 | } |
778 | else { | 778 | else { |
779 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 779 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
780 | e << tempItem; | 780 | e << tempItem; |
781 | } | 781 | } |
782 | } | 782 | } |
783 | 783 | ||
784 | void Desktop::raiseEmail() | 784 | void Desktop::raiseEmail() |
785 | { | 785 | { |
786 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 | 786 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 |
787 | cfg.setGroup( "AppsKey" ); | 787 | cfg.setGroup( "AppsKey" ); |
788 | QString tempItem; | 788 | QString tempItem; |
789 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); | 789 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); |
790 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { | 790 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { |
791 | tempItem = "mail"; | 791 | tempItem = "mail"; |
792 | } | 792 | } |
793 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 793 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
794 | e << tempItem; | 794 | e << tempItem; |
795 | } | 795 | } |
796 | 796 | ||
797 | // autoStarts apps on resume and start | 797 | // autoStarts apps on resume and start |
798 | void Desktop::execAutoStart() | 798 | void Desktop::execAutoStart() |
799 | { | 799 | { |
800 | QString appName; | 800 | QString appName; |
801 | int delay; | 801 | int delay; |
802 | QDateTime now = QDateTime::currentDateTime(); | 802 | QDateTime now = QDateTime::currentDateTime(); |
803 | Config cfg( "autostart" ); | 803 | Config cfg( "autostart" ); |
804 | cfg.setGroup( "AutoStart" ); | 804 | cfg.setGroup( "AutoStart" ); |
805 | appName = cfg.readEntry( "Apps", "" ); | 805 | appName = cfg.readEntry( "Apps", "" ); |
806 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 806 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
807 | // If the time between suspend and resume was longer then the | 807 | // If the time between suspend and resume was longer then the |
808 | // value saved as delay, start the app | 808 | // value saved as delay, start the app |
809 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 809 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
810 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 810 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
811 | e << QString( appName ); | 811 | e << QString( appName ); |
812 | } | 812 | } |
813 | } | 813 | } |
814 | 814 | ||
815 | #if defined(QPE_HAVE_TOGGLELIGHT) | 815 | #if defined(QPE_HAVE_TOGGLELIGHT) |
816 | #include <qpe/config.h> | 816 | #include <qpe/config.h> |
817 | 817 | ||
818 | #include <sys/ioctl.h> | 818 | #include <sys/ioctl.h> |
819 | #include <sys/types.h> | 819 | #include <sys/types.h> |
820 | #include <fcntl.h> | 820 | #include <fcntl.h> |
821 | #include <unistd.h> | 821 | #include <unistd.h> |
822 | #include <errno.h> | 822 | #include <errno.h> |
823 | #include <linux/ioctl.h> | 823 | #include <linux/ioctl.h> |
824 | #include <time.h> | 824 | #include <time.h> |
825 | #endif | 825 | #endif |
826 | 826 | ||
827 | 827 | ||
828 | void Desktop::togglePower() | 828 | void Desktop::togglePower() |
829 | { | 829 | { |
830 | static bool excllock = false; | 830 | static bool excllock = false; |
831 | 831 | ||
832 | if ( excllock ) | 832 | if ( excllock ) |
833 | return ; | 833 | return ; |
834 | 834 | ||
835 | excllock = true; | 835 | excllock = true; |
836 | 836 | ||
837 | bool wasloggedin = loggedin; | 837 | bool wasloggedin = loggedin; |
838 | loggedin = 0; | 838 | loggedin = 0; |
839 | suspendTime = QDateTime::currentDateTime(); | 839 | suspendTime = QDateTime::currentDateTime(); |
840 | 840 | ||
841 | ODevice::inst ( ) -> suspend ( ); | 841 | ODevice::inst ( ) -> suspend ( ); |
842 | 842 | ||
843 | QWSServer::screenSaverActivate ( false ); | 843 | QWSServer::screenSaverActivate ( false ); |
844 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 844 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
845 | 845 | ||
846 | { | 846 | { |
847 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 847 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
848 | } | 848 | } |
849 | 849 | ||
850 | if ( wasloggedin ) | 850 | if ( wasloggedin ) |
851 | login( TRUE ); | 851 | login( TRUE ); |
852 | 852 | ||
853 | execAutoStart(); | 853 | execAutoStart(); |
854 | //qcopBridge->closeOpenConnections(); | 854 | //qcopBridge->closeOpenConnections(); |
855 | 855 | ||
856 | excllock = false; | 856 | excllock = false; |
857 | } | 857 | } |
858 | 858 | ||
859 | void Desktop::toggleLight() | 859 | void Desktop::toggleLight() |
860 | { | 860 | { |
861 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 861 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
862 | e << -2; // toggle | 862 | e << -2; // toggle |
863 | } | 863 | } |
864 | 864 | ||
865 | void Desktop::toggleSymbolInput() | 865 | void Desktop::toggleSymbolInput() |
866 | { | 866 | { |
867 | tb->toggleSymbolInput(); | 867 | tb->toggleSymbolInput(); |
868 | } | 868 | } |
869 | 869 | ||
870 | void Desktop::toggleNumLockState() | 870 | void Desktop::toggleNumLockState() |
871 | { | 871 | { |
872 | tb->toggleNumLockState(); | 872 | tb->toggleNumLockState(); |
873 | } | 873 | } |
874 | 874 | ||
875 | void Desktop::toggleCapsLockState() | 875 | void Desktop::toggleCapsLockState() |
876 | { | 876 | { |
877 | tb->toggleCapsLockState(); | 877 | tb->toggleCapsLockState(); |
878 | } | 878 | } |
879 | 879 | ||
880 | void Desktop::styleChange( QStyle &s ) | 880 | void Desktop::styleChange( QStyle &s ) |
881 | { | 881 | { |
882 | QWidget::styleChange( s ); | 882 | QWidget::styleChange( s ); |
883 | int displayw = qApp->desktop() ->width(); | 883 | int displayw = qApp->desktop() ->width(); |
884 | int displayh = qApp->desktop() ->height(); | 884 | int displayh = qApp->desktop() ->height(); |
885 | 885 | ||
886 | QSize sz = tb->sizeHint(); | 886 | QSize sz = tb->sizeHint(); |
887 | 887 | ||
888 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 888 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
889 | } | 889 | } |
890 | 890 | ||
891 | void DesktopApplication::shutdown() | 891 | void DesktopApplication::shutdown() |
892 | { | 892 | { |
893 | if ( type() != GuiServer ) | 893 | if ( type() != GuiServer ) |
894 | return ; | 894 | return ; |
895 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 895 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
896 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), | 896 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), |
897 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); | 897 | this, SLOT( shutdown( ShutdownImpl::Type ) ) ); |
898 | sd->showMaximized(); | 898 | sd->showMaximized(); |
899 | } | 899 | } |
900 | 900 | ||
901 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) | 901 | void DesktopApplication::shutdown( ShutdownImpl::Type t ) |
902 | { | 902 | { |
903 | switch ( t ) { | 903 | switch ( t ) { |
904 | case ShutdownImpl::ShutdownSystem: | 904 | case ShutdownImpl::ShutdownSystem: |
905 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); | 905 | execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); |
906 | break; | 906 | break; |
907 | case ShutdownImpl::RebootSystem: | 907 | case ShutdownImpl::RebootSystem: |
908 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); | 908 | execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); |
909 | break; | 909 | break; |
910 | case ShutdownImpl::RestartDesktop: | 910 | case ShutdownImpl::RestartDesktop: |
911 | restart(); | 911 | restart(); |
912 | break; | 912 | break; |
913 | case ShutdownImpl::TerminateDesktop: | 913 | case ShutdownImpl::TerminateDesktop: |
914 | prepareForTermination( FALSE ); | 914 | prepareForTermination( FALSE ); |
915 | 915 | ||
916 | // This is a workaround for a Qt bug | 916 | // This is a workaround for a Qt bug |
917 | // clipboard applet has to stop its poll timer, or Qt/E | 917 | // clipboard applet has to stop its poll timer, or Qt/E |
918 | // will hang on quit() right before it emits aboutToQuit() | 918 | // will hang on quit() right before it emits aboutToQuit() |
919 | emit aboutToQuit ( ); | 919 | emit aboutToQuit ( ); |
920 | 920 | ||
921 | quit(); | 921 | quit(); |
922 | break; | 922 | break; |
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | void DesktopApplication::restart() | 926 | void DesktopApplication::restart() |
927 | { | 927 | { |
928 | prepareForTermination( TRUE ); | 928 | prepareForTermination( TRUE ); |
929 | 929 | ||
930 | #ifdef Q_WS_QWS | 930 | #ifdef Q_WS_QWS |
931 | 931 | ||
932 | for ( int fd = 3; fd < 100; fd++ ) | 932 | for ( int fd = 3; fd < 100; fd++ ) |
933 | close( fd ); | 933 | close( fd ); |
934 | #if defined(QT_DEMO_SINGLE_FLOPPY) | 934 | #if defined(QT_DEMO_SINGLE_FLOPPY) |
935 | 935 | ||
936 | execl( "/sbin/init", "qpe", 0 ); | 936 | execl( "/sbin/init", "qpe", 0 ); |
937 | #elif defined(QT_QWS_CASSIOPEIA) | 937 | #elif defined(QT_QWS_CASSIOPEIA) |
938 | 938 | ||
939 | execl( "/bin/sh", "sh", 0 ); | 939 | execl( "/bin/sh", "sh", 0 ); |
940 | #else | 940 | #else |
941 | 941 | ||
942 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); | 942 | execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); |
943 | #endif | 943 | #endif |
944 | 944 | ||
945 | exit( 1 ); | 945 | exit( 1 ); |
946 | #endif | 946 | #endif |
947 | } | 947 | } |
948 | 948 | ||
949 | void Desktop::startTransferServer() | 949 | void Desktop::startTransferServer() |
950 | { | 950 | { |
951 | // start qcop bridge server | 951 | // start qcop bridge server |
952 | qcopBridge = new QCopBridge( 4243 ); | 952 | qcopBridge = new QCopBridge( 4243 ); |
953 | if ( !qcopBridge->ok() ) { | 953 | if ( !qcopBridge->ok() ) { |
954 | delete qcopBridge; | 954 | delete qcopBridge; |
955 | qcopBridge = 0; | 955 | qcopBridge = 0; |
956 | } | 956 | } |
957 | // start transfer server | 957 | // start transfer server |
958 | transferServer = new TransferServer( 4242 ); | 958 | transferServer = new TransferServer( 4242 ); |
959 | if ( !transferServer->ok() ) { | 959 | if ( !transferServer->ok() ) { |
960 | delete transferServer; | 960 | delete transferServer; |
961 | transferServer = 0; | 961 | transferServer = 0; |
962 | } | 962 | } |
963 | if ( !transferServer || !qcopBridge ) | 963 | if ( !transferServer || !qcopBridge ) |
964 | startTimer( 2000 ); | 964 | startTimer( 2000 ); |
965 | } | 965 | } |
966 | 966 | ||
967 | void Desktop::timerEvent( QTimerEvent *e ) | 967 | void Desktop::timerEvent( QTimerEvent *e ) |
968 | { | 968 | { |
969 | killTimer( e->timerId() ); | 969 | killTimer( e->timerId() ); |
970 | startTransferServer(); | 970 | startTransferServer(); |
971 | } | 971 | } |
972 | 972 | ||
973 | void Desktop::terminateServers() | 973 | void Desktop::terminateServers() |
974 | { | 974 | { |
975 | delete transferServer; | 975 | delete transferServer; |
976 | delete qcopBridge; | 976 | delete qcopBridge; |
977 | transferServer = 0; | 977 | transferServer = 0; |
978 | qcopBridge = 0; | 978 | qcopBridge = 0; |
979 | } | 979 | } |
980 | 980 | ||
981 | void Desktop::rereadVolumes() | 981 | void Desktop::rereadVolumes() |
982 | { | 982 | { |
983 | Config cfg( "qpe" ); | 983 | Config cfg( "qpe" ); |
984 | cfg.setGroup( "Volume" ); | 984 | cfg.setGroup( "Volume" ); |
985 | touchclick = cfg.readBoolEntry( "TouchSound" ); | 985 | touchclick = cfg.readBoolEntry( "TouchSound" ); |
986 | keyclick = cfg.readBoolEntry( "KeySound" ); | 986 | keyclick = cfg.readBoolEntry( "KeySound" ); |
987 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); | 987 | alarmsound = cfg.readBoolEntry( "AlarmSound" ); |
988 | } | 988 | } |
989 | 989 | ||
990 | void Desktop::keyClick() | 990 | void Desktop::keyClick() |
991 | { | 991 | { |
992 | if ( keyclick ) | 992 | if ( keyclick ) |
993 | ODevice::inst ( ) -> keySound ( ); | 993 | ODevice::inst ( ) -> keySound ( ); |
994 | } | 994 | } |
995 | 995 | ||
996 | void Desktop::screenClick() | 996 | void Desktop::screenClick() |
997 | { | 997 | { |
998 | if ( touchclick ) | 998 | if ( touchclick ) |
999 | ODevice::inst ( ) -> touchSound ( ); | 999 | ODevice::inst ( ) -> touchSound ( ); |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | void Desktop::soundAlarm() | 1002 | void Desktop::soundAlarm() |
1003 | { | 1003 | { |
1004 | if ( qpedesktop-> alarmsound ) | 1004 | if ( qpedesktop-> alarmsound ) |
1005 | ODevice::inst ( ) -> alarmSound ( ); | 1005 | ODevice::inst ( ) -> alarmSound ( ); |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | bool Desktop::eventFilter( QObject *, QEvent *ev ) | 1008 | bool Desktop::eventFilter( QObject *, QEvent *ev ) |
1009 | { | 1009 | { |
1010 | if ( ev-> type ( ) == QEvent::KeyPress ) { | 1010 | if ( ev-> type ( ) == QEvent::KeyPress ) { |
1011 | QKeyEvent * ke = ( QKeyEvent * ) ev; | 1011 | QKeyEvent * ke = ( QKeyEvent * ) ev; |
1012 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key | 1012 | if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key |
1013 | QWidget * active = qApp-> activeWindow ( ); | 1013 | QWidget * active = qApp-> activeWindow ( ); |
1014 | 1014 | ||
1015 | if ( active && active-> isPopup ( ) ) | 1015 | if ( active && active-> isPopup ( ) ) |
1016 | active->close(); | 1016 | active->close(); |
1017 | 1017 | ||
1018 | /* | 1018 | /* |
1019 | * On iPAQ 38xx that key is not the "menu key" but the mail key | 1019 | * On iPAQ 38xx that key is not the "menu key" but the mail key |
1020 | * To not confuse the users, make it launch the mail app on 38xx | 1020 | * To not confuse the users, make it launch the mail app on 38xx |
1021 | */ | 1021 | */ |
1022 | if ( ODevice::inst() ->model() == OMODEL_iPAQ_H38xx ) { | 1022 | if ( ODevice::inst() ->model() == OMODEL_iPAQ_H38xx ) { |
1023 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 1023 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
1024 | e << QString( "mail" ); | 1024 | e << QString( "mail" ); |
1025 | return true; | 1025 | return true; |
1026 | } | 1026 | } |
1027 | else { | 1027 | else { |
1028 | raiseMenu ( ); | 1028 | raiseMenu ( ); |
1029 | return true; | 1029 | return true; |
1030 | } | 1030 | } |
1031 | } | 1031 | } |
1032 | } | 1032 | } |
1033 | return false; | 1033 | return false; |
1034 | } | 1034 | } |
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index effcd24..fd89410 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,1003 +1,1003 @@ | |||
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 <qpe/config.h> | 26 | #include <qpe/config.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 = true; | 82 | bool tmpMime = true; |
83 | cfg->setGroup("mimetypes" ); | 83 | cfg->setGroup("mimetypes" ); |
84 | tmpMime = cfg->readBoolEntry("all" ,true); | 84 | tmpMime = cfg->readBoolEntry("all" ,true); |
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 = -7; | 291 | int hiddenTabWidth = -7; |
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 | /** This is a HACK.... | 537 | /** This is a HACK.... |
538 | * Reason: scanning huge mediums, microdirvers for examples | 538 | * Reason: scanning huge mediums, microdirvers for examples |
539 | * consomes time. To avoid that we invented the MediumMountCheck | 539 | * consomes time. To avoid that we invented the MediumMountCheck |
540 | * | 540 | * |
541 | * a) the user globally disabled medium checking. We can ignore | 541 | * a) the user globally disabled medium checking. We can ignore |
542 | * all removable medium | 542 | * all removable medium |
543 | * b) the user enabled medium checking globally and we need to use this mimefilter | 543 | * b) the user enabled medium checking globally and we need to use this mimefilter |
544 | * c) the user enabled medium checking on a per medium bases | 544 | * c) the user enabled medium checking on a per medium bases |
545 | * c1) we already checked and its not ask again turns | 545 | * c1) we already checked and its not ask again turns |
546 | * c2) we need to ask and then apply the mimefilter | 546 | * c2) we need to ask and then apply the mimefilter |
547 | */ | 547 | */ |
548 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: | 548 | void Launcher::loadDocs() // ok here comes a hack belonging to Global:: |
549 | { | 549 | { |
550 | delete docsFolder; | 550 | delete docsFolder; |
551 | docsFolder = new DocLnkSet; | 551 | docsFolder = new DocLnkSet; |
552 | 552 | ||
553 | DocLnkSet *tmp = 0; | 553 | DocLnkSet *tmp = 0; |
554 | QString home = QString(getenv("HOME")) + "/Documents"; | 554 | QString home = QString(getenv("HOME")) + "/Documents"; |
555 | tmp = new DocLnkSet( home , QString::null); | 555 | tmp = new DocLnkSet( home , QString::null); |
556 | docsFolder->appendFrom( *tmp ); | 556 | docsFolder->appendFrom( *tmp ); |
557 | delete tmp; | 557 | delete tmp; |
558 | 558 | ||
559 | // RAM documents | 559 | // RAM documents |
560 | StorageInfo storage; | 560 | StorageInfo storage; |
561 | const QList<FileSystem> &fileSystems = storage.fileSystems(); | 561 | const QList<FileSystem> &fileSystems = storage.fileSystems(); |
562 | QListIterator<FileSystem> it ( fileSystems ); | 562 | QListIterator<FileSystem> it ( fileSystems ); |
563 | 563 | ||
564 | for ( ; it.current(); ++it ) { | 564 | for ( ; it.current(); ++it ) { |
565 | if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | 565 | if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { |
566 | tmp = new DocLnkSet( (*it)->path(), QString::null ); | 566 | tmp = new DocLnkSet( (*it)->path(), QString::null ); |
567 | docsFolder->appendFrom( *tmp ); | 567 | docsFolder->appendFrom( *tmp ); |
568 | delete tmp; | 568 | delete tmp; |
569 | } | 569 | } |
570 | } | 570 | } |
571 | 571 | ||
572 | Config mediumCfg( "medium"); | 572 | Config mediumCfg( "medium"); |
573 | mediumCfg.setGroup("main"); | 573 | mediumCfg.setGroup("main"); |
574 | // a) -zecke we don't want to check | 574 | // a) -zecke we don't want to check |
575 | if(!mediumCfg.readBoolEntry("use", true ) ) | 575 | if(!mediumCfg.readBoolEntry("use", true ) ) |
576 | return; | 576 | return; |
577 | 577 | ||
578 | // find out wich filesystems are new in this round | 578 | // find out wich filesystems are new in this round |
579 | // We will do this by having a timestamp inside each mountpoint | 579 | // We will do this by having a timestamp inside each mountpoint |
580 | // if the current timestamp doesn't match this is a new file system and | 580 | // if the current timestamp doesn't match this is a new file system and |
581 | // come up with our MediumMountGui :) let the hacking begin | 581 | // come up with our MediumMountGui :) let the hacking begin |
582 | int stamp = uidgen.generate(); | 582 | int stamp = uidgen.generate(); |
583 | 583 | ||
584 | QString newStamp = QString::number( stamp ); // generates newtime Stamp | 584 | QString newStamp = QString::number( stamp ); // generates newtime Stamp |
585 | 585 | ||
586 | // b) | 586 | // b) |
587 | if( mediumCfg.readBoolEntry("global", true ) ){ | 587 | if( mediumCfg.readBoolEntry("global", true ) ){ |
588 | QString mime = configToMime(&mediumCfg).join(";"); | 588 | QString mime = configToMime(&mediumCfg).join(";"); |
589 | for( it.toFirst(); it.current(); ++it ){ | 589 | for( it.toFirst(); it.current(); ++it ){ |
590 | if( (*it)->isRemovable() ){ | 590 | if( (*it)->isRemovable() ){ |
591 | tmp = new DocLnkSet( (*it)->path(), mime ); | 591 | tmp = new DocLnkSet( (*it)->path(), mime ); |
592 | docsFolder->appendFrom( *tmp ); | 592 | docsFolder->appendFrom( *tmp ); |
593 | delete tmp; | 593 | delete tmp; |
594 | } | 594 | } |
595 | } // done | 595 | } // done |
596 | return; // save the else | 596 | return; // save the else |
597 | } | 597 | } |
598 | // c) zecke | 598 | // c) zecke |
599 | for ( it.toFirst(); it.current(); ++it ) { | 599 | for ( it.toFirst(); it.current(); ++it ) { |
600 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 600 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
601 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); | 601 | Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); |
602 | cfg.setGroup("main"); | 602 | cfg.setGroup("main"); |
603 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); | 603 | QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); |
604 | /** This medium is uptodate | 604 | /** This medium is uptodate |
605 | */ | 605 | */ |
606 | if( stamp == m_timeStamp ){ // ok we know this card | 606 | if( stamp == m_timeStamp ){ // ok we know this card |
607 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp | 607 | cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp |
608 | // we need to scan the list now. Hopefully the cache will be there | 608 | // we need to scan the list now. Hopefully the cache will be there |
609 | // read the mimetypes from the config and search for documents | 609 | // read the mimetypes from the config and search for documents |
610 | QStringList mimetypes = configToMime( &cfg); | 610 | QStringList mimetypes = configToMime( &cfg); |
611 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); | 611 | tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); |
612 | docsFolder->appendFrom( *tmp ); | 612 | docsFolder->appendFrom( *tmp ); |
613 | delete tmp; | 613 | delete tmp; |
614 | 614 | ||
615 | }else{ // come up with the gui cause this a new card | 615 | }else{ // come up with the gui cause this a new card |
616 | MediumMountGui medium(&cfg, (*it)->path() ); | 616 | MediumMountGui medium(&cfg, (*it)->path() ); |
617 | if( medium.check() ){ // we did not ask before or ask again is off | 617 | if( medium.check() ){ // we did not ask before or ask again is off |
618 | /** c2) */ | 618 | /** c2) */ |
619 | if( medium.exec() ){ // he clicked yes so search it | 619 | if( medium.exec() ){ // he clicked yes so search it |
620 | // speicher | 620 | // speicher |
621 | //cfg.read(); // cause of a race we need to reread - fixed | 621 | //cfg.read(); // cause of a race we need to reread - fixed |
622 | cfg.setGroup("main"); | 622 | cfg.setGroup("main"); |
623 | cfg.writeEntry("timestamp", newStamp ); | 623 | cfg.writeEntry("timestamp", newStamp ); |
624 | cfg.write(); | 624 | cfg.write(); |
625 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); | 625 | tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); |
626 | docsFolder->appendFrom( *tmp ); | 626 | docsFolder->appendFrom( *tmp ); |
627 | delete tmp; | 627 | delete tmp; |
628 | }// no else | 628 | }// no else |
629 | /** c1) */ | 629 | /** c1) */ |
630 | }else{ // we checked | 630 | }else{ // we checked |
631 | // do something different see what we need to do | 631 | // do something different see what we need to do |
632 | // let's see if we should check the device | 632 | // let's see if we should check the device |
633 | cfg.setGroup("main" ); | 633 | cfg.setGroup("main" ); |
634 | bool check = cfg.readBoolEntry("autocheck", true ); | 634 | bool check = cfg.readBoolEntry("autocheck", true ); |
635 | if( check ){ // find the documents | 635 | if( check ){ // find the documents |
636 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); | 636 | tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); |
637 | docsFolder->appendFrom( *tmp ); | 637 | docsFolder->appendFrom( *tmp ); |
638 | delete tmp; | 638 | delete tmp; |
639 | } | 639 | } |
640 | } | 640 | } |
641 | } | 641 | } |
642 | } | 642 | } |
643 | } | 643 | } |
644 | m_timeStamp = newStamp; | 644 | m_timeStamp = newStamp; |
645 | } | 645 | } |
646 | 646 | ||
647 | void Launcher::updateTabs() | 647 | void Launcher::updateTabs() |
648 | { | 648 | { |
649 | MimeType::updateApplications(); // ### reads all applnks twice | 649 | MimeType::updateApplications(); // ### reads all applnks twice |
650 | 650 | ||
651 | delete rootFolder; | 651 | delete rootFolder; |
652 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); | 652 | rootFolder = new AppLnkSet( MimeType::appsFolderName() ); |
653 | 653 | ||
654 | loadDocs(); | 654 | loadDocs(); |
655 | 655 | ||
656 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); | 656 | tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); |
657 | } | 657 | } |
658 | 658 | ||
659 | void Launcher::updateDocs() | 659 | void Launcher::updateDocs() |
660 | { | 660 | { |
661 | loadDocs(); | 661 | loadDocs(); |
662 | tabs->updateDocs(docsFolder,storage->fileSystems()); | 662 | tabs->updateDocs(docsFolder,storage->fileSystems()); |
663 | } | 663 | } |
664 | 664 | ||
665 | void Launcher::viewSelected(const QString& s) | 665 | void Launcher::viewSelected(const QString& s) |
666 | { | 666 | { |
667 | setCaption( s + tr(" - Launcher") ); | 667 | setCaption( s + tr(" - Launcher") ); |
668 | } | 668 | } |
669 | 669 | ||
670 | void Launcher::nextView() | 670 | void Launcher::nextView() |
671 | { | 671 | { |
672 | tabs->nextTab(); | 672 | tabs->nextTab(); |
673 | } | 673 | } |
674 | 674 | ||
675 | 675 | ||
676 | void Launcher::select( const AppLnk *appLnk ) | 676 | void Launcher::select( const AppLnk *appLnk ) |
677 | { | 677 | { |
678 | if ( appLnk->type() == "Folder" ) { | 678 | if ( appLnk->type() == "Folder" ) { |
679 | // Not supported: flat is simpler for the user | 679 | // Not supported: flat is simpler for the user |
680 | } else { | 680 | } else { |
681 | if ( appLnk->exec().isNull() ) { | 681 | if ( appLnk->exec().isNull() ) { |
682 | QMessageBox::information(this,tr("No application"), | 682 | QMessageBox::information(this,tr("No application"), |
683 | tr("<p>No application is defined for this document." | 683 | tr("<p>No application is defined for this document." |
684 | "<p>Type is %1.").arg(appLnk->type())); | 684 | "<p>Type is %1.").arg(appLnk->type())); |
685 | return; | 685 | return; |
686 | } | 686 | } |
687 | tabs->setBusy(TRUE); | 687 | tabs->setBusy(TRUE); |
688 | emit executing( appLnk ); | 688 | emit executing( appLnk ); |
689 | appLnk->execute(); | 689 | appLnk->execute(); |
690 | } | 690 | } |
691 | } | 691 | } |
692 | 692 | ||
693 | void Launcher::externalSelected(const AppLnk *appLnk) | 693 | void Launcher::externalSelected(const AppLnk *appLnk) |
694 | { | 694 | { |
695 | tabs->setBusy(TRUE); | 695 | tabs->setBusy(TRUE); |
696 | emit executing( appLnk ); | 696 | emit executing( appLnk ); |
697 | } | 697 | } |
698 | 698 | ||
699 | void Launcher::properties( AppLnk *appLnk ) | 699 | void Launcher::properties( AppLnk *appLnk ) |
700 | { | 700 | { |
701 | if ( appLnk->type() == "Folder" ) { | 701 | if ( appLnk->type() == "Folder" ) { |
702 | // Not supported: flat is simpler for the user | 702 | // Not supported: flat is simpler for the user |
703 | } else { | 703 | } else { |
704 | in_lnk_props = TRUE; | 704 | in_lnk_props = TRUE; |
705 | got_lnk_change = FALSE; | 705 | got_lnk_change = FALSE; |
706 | LnkProperties prop(appLnk); | 706 | LnkProperties prop(appLnk); |
707 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); | 707 | connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); |
708 | prop.showMaximized(); | 708 | prop.showMaximized(); |
709 | prop.exec(); | 709 | prop.exec(); |
710 | in_lnk_props = FALSE; | 710 | in_lnk_props = FALSE; |
711 | if ( got_lnk_change ) { | 711 | if ( got_lnk_change ) { |
712 | updateLink(lnk_change); | 712 | updateLink(lnk_change); |
713 | } | 713 | } |
714 | } | 714 | } |
715 | } | 715 | } |
716 | 716 | ||
717 | void Launcher::updateLink(const QString& link) | 717 | void Launcher::updateLink(const QString& link) |
718 | { | 718 | { |
719 | if (link.isNull()) | 719 | if (link.isNull()) |
720 | updateTabs(); | 720 | updateTabs(); |
721 | else if (link.isEmpty()) | 721 | else if (link.isEmpty()) |
722 | updateDocs(); | 722 | updateDocs(); |
723 | else | 723 | else |
724 | tabs->updateLink(link); | 724 | tabs->updateLink(link); |
725 | } | 725 | } |
726 | 726 | ||
727 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) | 727 | void Launcher::systemMessage( const QCString &msg, const QByteArray &data) |
728 | { | 728 | { |
729 | QDataStream stream( data, IO_ReadOnly ); | 729 | QDataStream stream( data, IO_ReadOnly ); |
730 | if ( msg == "closing(QString)" ){ | 730 | if ( msg == "closing(QString)" ){ |
731 | QString app; | 731 | QString app; |
732 | stream >> app; | 732 | stream >> app; |
733 | qWarning("app closed %s", app.latin1() ); | 733 | //qWarning("app closed %s", app.latin1() ); |
734 | MRUList::removeTask( app ); | 734 | // MRUList::removeTask( app ); |
735 | }else if ( msg == "linkChanged(QString)" ) { | 735 | }else if ( msg == "linkChanged(QString)" ) { |
736 | QString link; | 736 | QString link; |
737 | stream >> link; | 737 | stream >> link; |
738 | if ( in_lnk_props ) { | 738 | if ( in_lnk_props ) { |
739 | got_lnk_change = TRUE; | 739 | got_lnk_change = TRUE; |
740 | lnk_change = link; | 740 | lnk_change = link; |
741 | } else { | 741 | } else { |
742 | updateLink(link); | 742 | updateLink(link); |
743 | } | 743 | } |
744 | } else if ( msg == "busy()" ) { | 744 | } else if ( msg == "busy()" ) { |
745 | emit busy(); | 745 | emit busy(); |
746 | } else if ( msg == "notBusy(QString)" ) { | 746 | } else if ( msg == "notBusy(QString)" ) { |
747 | QString app; | 747 | QString app; |
748 | stream >> app; | 748 | stream >> app; |
749 | tabs->setBusy(FALSE); | 749 | tabs->setBusy(FALSE); |
750 | emit notBusy(app); | 750 | emit notBusy(app); |
751 | } else if ( msg == "mkdir(QString)" ) { | 751 | } else if ( msg == "mkdir(QString)" ) { |
752 | QString dir; | 752 | QString dir; |
753 | stream >> dir; | 753 | stream >> dir; |
754 | if ( !dir.isEmpty() ) | 754 | if ( !dir.isEmpty() ) |
755 | mkdir( dir ); | 755 | mkdir( dir ); |
756 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 756 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
757 | QString baseFile, sigFile; | 757 | QString baseFile, sigFile; |
758 | stream >> baseFile >> sigFile; | 758 | stream >> baseFile >> sigFile; |
759 | QRsync::generateSignature( baseFile, sigFile ); | 759 | QRsync::generateSignature( baseFile, sigFile ); |
760 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 760 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
761 | QString baseFile, sigFile, deltaFile; | 761 | QString baseFile, sigFile, deltaFile; |
762 | stream >> baseFile >> sigFile >> deltaFile; | 762 | stream >> baseFile >> sigFile >> deltaFile; |
763 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 763 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
764 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 764 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
765 | QString baseFile, deltaFile; | 765 | QString baseFile, deltaFile; |
766 | stream >> baseFile >> deltaFile; | 766 | stream >> baseFile >> deltaFile; |
767 | if ( !QFile::exists( baseFile ) ) { | 767 | if ( !QFile::exists( baseFile ) ) { |
768 | QFile f( baseFile ); | 768 | QFile f( baseFile ); |
769 | f.open( IO_WriteOnly ); | 769 | f.open( IO_WriteOnly ); |
770 | f.close(); | 770 | f.close(); |
771 | } | 771 | } |
772 | QRsync::applyDiff( baseFile, deltaFile ); | 772 | QRsync::applyDiff( baseFile, deltaFile ); |
773 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 773 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
774 | e << baseFile; | 774 | e << baseFile; |
775 | } else if ( msg == "rdiffCleanup()" ) { | 775 | } else if ( msg == "rdiffCleanup()" ) { |
776 | mkdir( "/tmp/rdiff" ); | 776 | mkdir( "/tmp/rdiff" ); |
777 | QDir dir; | 777 | QDir dir; |
778 | dir.setPath( "/tmp/rdiff" ); | 778 | dir.setPath( "/tmp/rdiff" ); |
779 | QStringList entries = dir.entryList(); | 779 | QStringList entries = dir.entryList(); |
780 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 780 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
781 | dir.remove( *it ); | 781 | dir.remove( *it ); |
782 | } else if ( msg == "sendHandshakeInfo()" ) { | 782 | } else if ( msg == "sendHandshakeInfo()" ) { |
783 | QString home = getenv( "HOME" ); | 783 | QString home = getenv( "HOME" ); |
784 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 784 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
785 | e << home; | 785 | e << home; |
786 | int locked = (int) Desktop::screenLocked(); | 786 | int locked = (int) Desktop::screenLocked(); |
787 | e << locked; | 787 | e << locked; |
788 | // register an app for autostart | 788 | // register an app for autostart |
789 | // if clear is send the list is cleared. | 789 | // if clear is send the list is cleared. |
790 | } else if ( msg == "autoStart(QString)" ) { | 790 | } else if ( msg == "autoStart(QString)" ) { |
791 | QString appName; | 791 | QString appName; |
792 | stream >> appName; | 792 | stream >> appName; |
793 | Config cfg( "autostart" ); | 793 | Config cfg( "autostart" ); |
794 | cfg.setGroup( "AutoStart" ); | 794 | cfg.setGroup( "AutoStart" ); |
795 | if ( appName.compare("clear") == 0){ | 795 | if ( appName.compare("clear") == 0){ |
796 | cfg.writeEntry("Apps", ""); | 796 | cfg.writeEntry("Apps", ""); |
797 | } | 797 | } |
798 | } else if ( msg == "autoStart(QString,QString)" ) { | 798 | } else if ( msg == "autoStart(QString,QString)" ) { |
799 | QString modifier, appName; | 799 | QString modifier, appName; |
800 | stream >> modifier >> appName; | 800 | stream >> modifier >> appName; |
801 | Config cfg( "autostart" ); | 801 | Config cfg( "autostart" ); |
802 | cfg.setGroup( "AutoStart" ); | 802 | cfg.setGroup( "AutoStart" ); |
803 | if ( modifier.compare("add") == 0 ){ | 803 | if ( modifier.compare("add") == 0 ){ |
804 | // only add if appname is entered | 804 | // only add if appname is entered |
805 | if (!appName.isEmpty()) { | 805 | if (!appName.isEmpty()) { |
806 | cfg.writeEntry("Apps", appName); | 806 | cfg.writeEntry("Apps", appName); |
807 | } | 807 | } |
808 | } else if (modifier.compare("remove") == 0 ) { | 808 | } else if (modifier.compare("remove") == 0 ) { |
809 | // need to change for multiple entries | 809 | // need to change for multiple entries |
810 | // actually remove is right now simular to clear, but in future there | 810 | // actually remove is right now simular to clear, but in future there |
811 | // should be multiple apps in autostart possible. | 811 | // should be multiple apps in autostart possible. |
812 | QString checkName; | 812 | QString checkName; |
813 | checkName = cfg.readEntry("Apps", ""); | 813 | checkName = cfg.readEntry("Apps", ""); |
814 | if (checkName == appName) { | 814 | if (checkName == appName) { |
815 | cfg.writeEntry("Apps", ""); | 815 | cfg.writeEntry("Apps", ""); |
816 | } | 816 | } |
817 | } | 817 | } |
818 | // case the autostart feature should be delayed | 818 | // case the autostart feature should be delayed |
819 | } else if ( msg == "autoStart(QString,QString,QString)") { | 819 | } else if ( msg == "autoStart(QString,QString,QString)") { |
820 | QString modifier, appName, delay; | 820 | QString modifier, appName, delay; |
821 | stream >> modifier >> appName >> delay; | 821 | stream >> modifier >> appName >> delay; |
822 | Config cfg( "autostart" ); | 822 | Config cfg( "autostart" ); |
823 | cfg.setGroup( "AutoStart" ); | 823 | cfg.setGroup( "AutoStart" ); |
824 | if ( modifier.compare("add") == 0 ){ | 824 | if ( modifier.compare("add") == 0 ){ |
825 | // only add it appname is entered | 825 | // only add it appname is entered |
826 | if (!appName.isEmpty()) { | 826 | if (!appName.isEmpty()) { |
827 | cfg.writeEntry("Apps", appName); | 827 | cfg.writeEntry("Apps", appName); |
828 | cfg.writeEntry("Delay", delay); | 828 | cfg.writeEntry("Delay", delay); |
829 | } | 829 | } |
830 | } else { | 830 | } else { |
831 | } | 831 | } |
832 | } else if ( msg == "sendCardInfo()" ) { | 832 | } else if ( msg == "sendCardInfo()" ) { |
833 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 833 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
834 | const QList<FileSystem> &fs = storage->fileSystems(); | 834 | const QList<FileSystem> &fs = storage->fileSystems(); |
835 | QListIterator<FileSystem> it ( fs ); | 835 | QListIterator<FileSystem> it ( fs ); |
836 | QString s; | 836 | QString s; |
837 | QString homeDir = getenv("HOME"); | 837 | QString homeDir = getenv("HOME"); |
838 | QString hardDiskHome; | 838 | QString hardDiskHome; |
839 | for ( ; it.current(); ++it ) { | 839 | for ( ; it.current(); ++it ) { |
840 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) | 840 | if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) |
841 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " | 841 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " |
842 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 842 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
843 | + " " + (*it)->options() + ";"; | 843 | + " " + (*it)->options() + ";"; |
844 | else if ( (*it)->disk() == "/dev/mtdblock1" || | 844 | else if ( (*it)->disk() == "/dev/mtdblock1" || |
845 | (*it)->disk() == "/dev/mtdblock/1" ) | 845 | (*it)->disk() == "/dev/mtdblock/1" ) |
846 | s += (*it)->name() + "=" + homeDir + "/Documents " | 846 | s += (*it)->name() + "=" + homeDir + "/Documents " |
847 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 847 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
848 | + " " + (*it)->options() + ";"; | 848 | + " " + (*it)->options() + ";"; |
849 | else if ( (*it)->name().contains( tr("Hard Disk") ) && | 849 | else if ( (*it)->name().contains( tr("Hard Disk") ) && |
850 | homeDir.contains( (*it)->path() ) && | 850 | homeDir.contains( (*it)->path() ) && |
851 | (*it)->path().length() > hardDiskHome.length() ) | 851 | (*it)->path().length() > hardDiskHome.length() ) |
852 | hardDiskHome = | 852 | hardDiskHome = |
853 | (*it)->name() + "=" + homeDir + "/Documents " | 853 | (*it)->name() + "=" + homeDir + "/Documents " |
854 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) | 854 | + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) |
855 | + " " + (*it)->options() + ";"; | 855 | + " " + (*it)->options() + ";"; |
856 | } | 856 | } |
857 | if ( !hardDiskHome.isEmpty() ) | 857 | if ( !hardDiskHome.isEmpty() ) |
858 | s += hardDiskHome; | 858 | s += hardDiskHome; |
859 | 859 | ||
860 | e << s; | 860 | e << s; |
861 | } else if ( msg == "sendSyncDate(QString)" ) { | 861 | } else if ( msg == "sendSyncDate(QString)" ) { |
862 | QString app; | 862 | QString app; |
863 | stream >> app; | 863 | stream >> app; |
864 | Config cfg( "qpe" ); | 864 | Config cfg( "qpe" ); |
865 | cfg.setGroup("SyncDate"); | 865 | cfg.setGroup("SyncDate"); |
866 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 866 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
867 | e << app << cfg.readEntry( app ); | 867 | e << app << cfg.readEntry( app ); |
868 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 868 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
869 | //cfg.readEntry( app ).latin1() ); | 869 | //cfg.readEntry( app ).latin1() ); |
870 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 870 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
871 | QString app, date; | 871 | QString app, date; |
872 | stream >> app >> date; | 872 | stream >> app >> date; |
873 | Config cfg( "qpe" ); | 873 | Config cfg( "qpe" ); |
874 | cfg.setGroup("SyncDate"); | 874 | cfg.setGroup("SyncDate"); |
875 | cfg.writeEntry( app, date ); | 875 | cfg.writeEntry( app, date ); |
876 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 876 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
877 | } else if ( msg == "startSync(QString)" ) { | 877 | } else if ( msg == "startSync(QString)" ) { |
878 | QString what; | 878 | QString what; |
879 | stream >> what; | 879 | stream >> what; |
880 | delete syncDialog; syncDialog = 0; | 880 | delete syncDialog; syncDialog = 0; |
881 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, | 881 | syncDialog = new SyncDialog( this, "syncProgress", FALSE, |
882 | WStyle_Tool | WStyle_Customize | | 882 | WStyle_Tool | WStyle_Customize | |
883 | Qt::WStyle_StaysOnTop ); | 883 | Qt::WStyle_StaysOnTop ); |
884 | syncDialog->showMaximized(); | 884 | syncDialog->showMaximized(); |
885 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); | 885 | syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); |
886 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), | 886 | connect( syncDialog->buttonCancel, SIGNAL( clicked() ), |
887 | SLOT( cancelSync() ) ); | 887 | SLOT( cancelSync() ) ); |
888 | } else if ( msg == "stopSync()") { | 888 | } else if ( msg == "stopSync()") { |
889 | delete syncDialog; syncDialog = 0; | 889 | delete syncDialog; syncDialog = 0; |
890 | } else if ( msg == "getAllDocLinks()" ) { | 890 | } else if ( msg == "getAllDocLinks()" ) { |
891 | loadDocs(); | 891 | loadDocs(); |
892 | 892 | ||
893 | QString contents; | 893 | QString contents; |
894 | 894 | ||
895 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { | 895 | for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { |
896 | DocLnk *doc = it.current(); | 896 | DocLnk *doc = it.current(); |
897 | QFileInfo fi( doc->file() ); | 897 | QFileInfo fi( doc->file() ); |
898 | if ( !fi.exists() ) | 898 | if ( !fi.exists() ) |
899 | continue; | 899 | continue; |
900 | 900 | ||
901 | bool fake = !doc->linkFileKnown(); | 901 | bool fake = !doc->linkFileKnown(); |
902 | if ( !fake ) { | 902 | if ( !fake ) { |
903 | QFile f( doc->linkFile() ); | 903 | QFile f( doc->linkFile() ); |
904 | if ( f.open( IO_ReadOnly ) ) { | 904 | if ( f.open( IO_ReadOnly ) ) { |
905 | QTextStream ts( &f ); | 905 | QTextStream ts( &f ); |
906 | ts.setEncoding( QTextStream::UnicodeUTF8 ); | 906 | ts.setEncoding( QTextStream::UnicodeUTF8 ); |
907 | contents += ts.read(); | 907 | contents += ts.read(); |
908 | f.close(); | 908 | f.close(); |
909 | } else | 909 | } else |
910 | fake = TRUE; | 910 | fake = TRUE; |
911 | } | 911 | } |
912 | if (fake) { | 912 | if (fake) { |
913 | contents += "[Desktop Entry]\n"; | 913 | contents += "[Desktop Entry]\n"; |
914 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; | 914 | contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; |
915 | contents += "File = "+doc->file()+"\n"; | 915 | contents += "File = "+doc->file()+"\n"; |
916 | contents += "Name = "+doc->name()+"\n"; | 916 | contents += "Name = "+doc->name()+"\n"; |
917 | contents += "Type = "+doc->type()+"\n"; | 917 | contents += "Type = "+doc->type()+"\n"; |
918 | } | 918 | } |
919 | contents += QString("Size = %1\n").arg( fi.size() ); | 919 | contents += QString("Size = %1\n").arg( fi.size() ); |
920 | } | 920 | } |
921 | 921 | ||
922 | //qDebug( "sending length %d", contents.length() ); | 922 | //qDebug( "sending length %d", contents.length() ); |
923 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); | 923 | QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); |
924 | e << contents; | 924 | e << contents; |
925 | 925 | ||
926 | qDebug( "================ \n\n%s\n\n===============", | 926 | qDebug( "================ \n\n%s\n\n===============", |
927 | contents.latin1() ); | 927 | contents.latin1() ); |
928 | 928 | ||
929 | delete docsFolder; | 929 | delete docsFolder; |
930 | docsFolder = 0; | 930 | docsFolder = 0; |
931 | } | 931 | } |
932 | } | 932 | } |
933 | 933 | ||
934 | void Launcher::cancelSync() | 934 | void Launcher::cancelSync() |
935 | { | 935 | { |
936 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 936 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
937 | } | 937 | } |
938 | 938 | ||
939 | void Launcher::storageChanged() | 939 | void Launcher::storageChanged() |
940 | { | 940 | { |
941 | if ( in_lnk_props ) { | 941 | if ( in_lnk_props ) { |
942 | got_lnk_change = TRUE; | 942 | got_lnk_change = TRUE; |
943 | lnk_change = ""; | 943 | lnk_change = ""; |
944 | } else { | 944 | } else { |
945 | updateDocs(); | 945 | updateDocs(); |
946 | } | 946 | } |
947 | } | 947 | } |
948 | 948 | ||
949 | 949 | ||
950 | bool Launcher::mkdir(const QString &localPath) | 950 | bool Launcher::mkdir(const QString &localPath) |
951 | { | 951 | { |
952 | QDir fullDir(localPath); | 952 | QDir fullDir(localPath); |
953 | if (fullDir.exists()) | 953 | if (fullDir.exists()) |
954 | return true; | 954 | return true; |
955 | 955 | ||
956 | // at this point the directory doesn't exist | 956 | // at this point the directory doesn't exist |
957 | // go through the directory tree and start creating the direcotories | 957 | // go through the directory tree and start creating the direcotories |
958 | // that don't exist; if we can't create the directories, return false | 958 | // that don't exist; if we can't create the directories, return false |
959 | 959 | ||
960 | QString dirSeps = "/"; | 960 | QString dirSeps = "/"; |
961 | int dirIndex = localPath.find(dirSeps); | 961 | int dirIndex = localPath.find(dirSeps); |
962 | QString checkedPath; | 962 | QString checkedPath; |
963 | 963 | ||
964 | // didn't find any seps; weird, use the cur dir instead | 964 | // didn't find any seps; weird, use the cur dir instead |
965 | if (dirIndex == -1) { | 965 | if (dirIndex == -1) { |
966 | //qDebug("No seperators found in path %s", localPath.latin1()); | 966 | //qDebug("No seperators found in path %s", localPath.latin1()); |
967 | checkedPath = QDir::currentDirPath(); | 967 | checkedPath = QDir::currentDirPath(); |
968 | } | 968 | } |
969 | 969 | ||
970 | while (checkedPath != localPath) { | 970 | while (checkedPath != localPath) { |
971 | // no more seperators found, use the local path | 971 | // no more seperators found, use the local path |
972 | if (dirIndex == -1) | 972 | if (dirIndex == -1) |
973 | checkedPath = localPath; | 973 | checkedPath = localPath; |
974 | else { | 974 | else { |
975 | // the next directory to check | 975 | // the next directory to check |
976 | checkedPath = localPath.left(dirIndex) + "/"; | 976 | checkedPath = localPath.left(dirIndex) + "/"; |
977 | // advance the iterator; the next dir seperator | 977 | // advance the iterator; the next dir seperator |
978 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 978 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
979 | } | 979 | } |
980 | 980 | ||
981 | QDir checkDir(checkedPath); | 981 | QDir checkDir(checkedPath); |
982 | if (!checkDir.exists()) { | 982 | if (!checkDir.exists()) { |
983 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 983 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
984 | 984 | ||
985 | if (!checkDir.mkdir(checkedPath)) { | 985 | if (!checkDir.mkdir(checkedPath)) { |
986 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 986 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
987 | return FALSE; | 987 | return FALSE; |
988 | } | 988 | } |
989 | } | 989 | } |
990 | 990 | ||
991 | } | 991 | } |
992 | return TRUE; | 992 | return TRUE; |
993 | } | 993 | } |
994 | 994 | ||
995 | void Launcher::preloadApps() | 995 | void Launcher::preloadApps() |
996 | { | 996 | { |
997 | Config cfg("Launcher"); | 997 | Config cfg("Launcher"); |
998 | cfg.setGroup("Preload"); | 998 | cfg.setGroup("Preload"); |
999 | QStringList apps = cfg.readListEntry("Apps",','); | 999 | QStringList apps = cfg.readListEntry("Apps",','); |
1000 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 1000 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
1001 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 1001 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
1002 | } | 1002 | } |
1003 | } | 1003 | } |
diff --git a/core/launcher/launcher.pro b/core/launcher/launcher.pro index 5b32bc3..0e557aa 100644 --- a/core/launcher/launcher.pro +++ b/core/launcher/launcher.pro | |||
@@ -1,118 +1,120 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = ../../bin | 3 | DESTDIR = ../../bin |
4 | HEADERS = background.h \ | 4 | HEADERS = background.h \ |
5 | desktop.h \ | 5 | desktop.h \ |
6 | qprocess.h \ | 6 | qprocess.h \ |
7 | mediummountgui.h \ | 7 | mediummountgui.h \ |
8 | info.h \ | 8 | info.h \ |
9 | appicons.h \ | 9 | appicons.h \ |
10 | taskbar.h \ | 10 | taskbar.h \ |
11 | sidething.h \ | 11 | sidething.h \ |
12 | mrulist.h \ | 12 | mrulist.h \ |
13 | runningappbar.h \ | ||
13 | stabmon.h \ | 14 | stabmon.h \ |
14 | inputmethods.h \ | 15 | inputmethods.h \ |
15 | systray.h \ | 16 | systray.h \ |
16 | wait.h \ | 17 | wait.h \ |
17 | shutdownimpl.h \ | 18 | shutdownimpl.h \ |
18 | launcher.h \ | 19 | launcher.h \ |
19 | launcherview.h \ | 20 | launcherview.h \ |
20 | ../../core/apps/calibrate/calibrate.h \ | 21 | ../../core/apps/calibrate/calibrate.h \ |
21 | startmenu.h \ | 22 | startmenu.h \ |
22 | transferserver.h \ | 23 | transferserver.h \ |
23 | qcopbridge.h \ | 24 | qcopbridge.h \ |
24 | packageslave.h \ | 25 | packageslave.h \ |
25 | irserver.h \ | 26 | irserver.h \ |
26 | ../../rsync/buf.h \ | 27 | ../../rsync/buf.h \ |
27 | ../../rsync/checksum.h \ | 28 | ../../rsync/checksum.h \ |
28 | ../../rsync/command.h \ | 29 | ../../rsync/command.h \ |
29 | ../../rsync/emit.h \ | 30 | ../../rsync/emit.h \ |
30 | ../../rsync/job.h \ | 31 | ../../rsync/job.h \ |
31 | ../../rsync/netint.h \ | 32 | ../../rsync/netint.h \ |
32 | ../../rsync/protocol.h \ | 33 | ../../rsync/protocol.h \ |
33 | ../../rsync/prototab.h \ | 34 | ../../rsync/prototab.h \ |
34 | ../../rsync/rsync.h \ | 35 | ../../rsync/rsync.h \ |
35 | ../../rsync/search.h \ | 36 | ../../rsync/search.h \ |
36 | ../../rsync/stream.h \ | 37 | ../../rsync/stream.h \ |
37 | ../../rsync/sumset.h \ | 38 | ../../rsync/sumset.h \ |
38 | ../../rsync/trace.h \ | 39 | ../../rsync/trace.h \ |
39 | ../../rsync/types.h \ | 40 | ../../rsync/types.h \ |
40 | ../../rsync/util.h \ | 41 | ../../rsync/util.h \ |
41 | ../../rsync/whole.h \ | 42 | ../../rsync/whole.h \ |
42 | ../../rsync/config_rsync.h \ | 43 | ../../rsync/config_rsync.h \ |
43 | ../../rsync/qrsync.h | 44 | ../../rsync/qrsync.h |
44 | # quicklauncher.h \ | 45 | # quicklauncher.h \ |
45 | SOURCES = background.cpp \ | 46 | SOURCES = background.cpp \ |
46 | desktop.cpp \ | 47 | desktop.cpp \ |
47 | mediummountgui.cpp \ | 48 | mediummountgui.cpp \ |
48 | qprocess.cpp qprocess_unix.cpp \ | 49 | qprocess.cpp qprocess_unix.cpp \ |
49 | info.cpp \ | 50 | info.cpp \ |
50 | appicons.cpp \ | 51 | appicons.cpp \ |
51 | taskbar.cpp \ | 52 | taskbar.cpp \ |
52 | sidething.cpp \ | 53 | sidething.cpp \ |
53 | mrulist.cpp \ | 54 | mrulist.cpp \ |
55 | runningappbar.cpp \ | ||
54 | stabmon.cpp \ | 56 | stabmon.cpp \ |
55 | inputmethods.cpp \ | 57 | inputmethods.cpp \ |
56 | systray.cpp \ | 58 | systray.cpp \ |
57 | wait.cpp \ | 59 | wait.cpp \ |
58 | shutdownimpl.cpp \ | 60 | shutdownimpl.cpp \ |
59 | launcher.cpp \ | 61 | launcher.cpp \ |
60 | launcherview.cpp \ | 62 | launcherview.cpp \ |
61 | ../../core/apps/calibrate/calibrate.cpp \ | 63 | ../../core/apps/calibrate/calibrate.cpp \ |
62 | transferserver.cpp \ | 64 | transferserver.cpp \ |
63 | packageslave.cpp \ | 65 | packageslave.cpp \ |
64 | irserver.cpp \ | 66 | irserver.cpp \ |
65 | qcopbridge.cpp \ | 67 | qcopbridge.cpp \ |
66 | startmenu.cpp \ | 68 | startmenu.cpp \ |
67 | main.cpp \ | 69 | main.cpp \ |
68 | ../../rsync/base64.c \ | 70 | ../../rsync/base64.c \ |
69 | ../../rsync/buf.c \ | 71 | ../../rsync/buf.c \ |
70 | ../../rsync/checksum.c \ | 72 | ../../rsync/checksum.c \ |
71 | ../../rsync/command.c \ | 73 | ../../rsync/command.c \ |
72 | ../../rsync/delta.c \ | 74 | ../../rsync/delta.c \ |
73 | ../../rsync/emit.c \ | 75 | ../../rsync/emit.c \ |
74 | ../../rsync/hex.c \ | 76 | ../../rsync/hex.c \ |
75 | ../../rsync/job.c \ | 77 | ../../rsync/job.c \ |
76 | ../../rsync/mdfour.c \ | 78 | ../../rsync/mdfour.c \ |
77 | ../../rsync/mksum.c \ | 79 | ../../rsync/mksum.c \ |
78 | ../../rsync/msg.c \ | 80 | ../../rsync/msg.c \ |
79 | ../../rsync/netint.c \ | 81 | ../../rsync/netint.c \ |
80 | ../../rsync/patch.c \ | 82 | ../../rsync/patch.c \ |
81 | ../../rsync/prototab.c \ | 83 | ../../rsync/prototab.c \ |
82 | ../../rsync/readsums.c \ | 84 | ../../rsync/readsums.c \ |
83 | ../../rsync/scoop.c \ | 85 | ../../rsync/scoop.c \ |
84 | ../../rsync/search.c \ | 86 | ../../rsync/search.c \ |
85 | ../../rsync/stats.c \ | 87 | ../../rsync/stats.c \ |
86 | ../../rsync/stream.c \ | 88 | ../../rsync/stream.c \ |
87 | ../../rsync/sumset.c \ | 89 | ../../rsync/sumset.c \ |
88 | ../../rsync/trace.c \ | 90 | ../../rsync/trace.c \ |
89 | ../../rsync/tube.c \ | 91 | ../../rsync/tube.c \ |
90 | ../../rsync/util.c \ | 92 | ../../rsync/util.c \ |
91 | ../../rsync/version.c \ | 93 | ../../rsync/version.c \ |
92 | ../../rsync/whole.c \ | 94 | ../../rsync/whole.c \ |
93 | ../../rsync/qrsync.cpp | 95 | ../../rsync/qrsync.cpp |
94 | INTERFACES= syncdialog.ui | 96 | INTERFACES= syncdialog.ui |
95 | INCLUDEPATH += ../../include | 97 | INCLUDEPATH += ../../include |
96 | DEPENDPATH+= ../../include . | 98 | DEPENDPATH+= ../../include . |
97 | INCLUDEPATH += ../../core/apps/calibrate | 99 | INCLUDEPATH += ../../core/apps/calibrate |
98 | DEPENDPATH+= ../../core/apps/calibrate | 100 | DEPENDPATH+= ../../core/apps/calibrate |
99 | INCLUDEPATH += ../../rsync | 101 | INCLUDEPATH += ../../rsync |
100 | DEPENDPATH+= ../../rsync | 102 | DEPENDPATH+= ../../rsync |
101 | TARGET = qpe | 103 | TARGET = qpe |
102 | LIBS += -lqpe -lcrypt -lopie | 104 | LIBS += -lqpe -lcrypt -lopie |
103 | 105 | ||
104 | TRANSLATIONS = ../../i18n/de/qpe.ts \ | 106 | TRANSLATIONS = ../../i18n/de/qpe.ts \ |
105 | ../../i18n/en/qpe.ts \ | 107 | ../../i18n/en/qpe.ts \ |
106 | ../../i18n/es/qpe.ts \ | 108 | ../../i18n/es/qpe.ts \ |
107 | ../../i18n/fr/qpe.ts \ | 109 | ../../i18n/fr/qpe.ts \ |
108 | ../../i18n/hu/qpe.ts \ | 110 | ../../i18n/hu/qpe.ts \ |
109 | ../../i18n/ja/qpe.ts \ | 111 | ../../i18n/ja/qpe.ts \ |
110 | ../../i18n/ko/qpe.ts \ | 112 | ../../i18n/ko/qpe.ts \ |
111 | ../../i18n/no/qpe.ts \ | 113 | ../../i18n/no/qpe.ts \ |
112 | ../../i18n/pl/qpe.ts \ | 114 | ../../i18n/pl/qpe.ts \ |
113 | ../../i18n/pt/qpe.ts \ | 115 | ../../i18n/pt/qpe.ts \ |
114 | ../../i18n/pt_BR/qpe.ts \ | 116 | ../../i18n/pt_BR/qpe.ts \ |
115 | ../../i18n/sl/qpe.ts \ | 117 | ../../i18n/sl/qpe.ts \ |
116 | ../../i18n/zh_CN/qpe.ts \ | 118 | ../../i18n/zh_CN/qpe.ts \ |
117 | ../../i18n/it/qpe.ts \ | 119 | ../../i18n/it/qpe.ts \ |
118 | ../../i18n/zh_TW/qpe.ts | 120 | ../../i18n/zh_TW/qpe.ts |
diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp new file mode 100644 index 0000000..298f671 --- a/dev/null +++ b/core/launcher/runningappbar.cpp | |||
@@ -0,0 +1,287 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | ********************************************************************** | ||
20 | */ | ||
21 | |||
22 | #define QTOPIA_INTERNAL_PRELOADACCESS | ||
23 | |||
24 | // For "kill" | ||
25 | #include <sys/types.h> | ||
26 | #include <signal.h> | ||
27 | |||
28 | #include <qtimer.h> | ||
29 | #include <qpopupmenu.h> | ||
30 | #include <qmessagebox.h> | ||
31 | #include <qpainter.h> | ||
32 | #include "qprocess.h" | ||
33 | #include <qpe/qpeapplication.h> | ||
34 | #include <qpe/applnk.h> | ||
35 | #include <qpe/qcopenvelope_qws.h> | ||
36 | #include <qpe/global.h> | ||
37 | #include <qwindowsystem_qws.h> | ||
38 | #include "runningappbar.h" | ||
39 | |||
40 | RunningAppBar::RunningAppBar(QWidget* parent) | ||
41 | : QFrame(parent), m_AppLnkSet(0L), m_SelectedAppIndex(-1) | ||
42 | { | ||
43 | m_AppLnkSet = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); | ||
44 | |||
45 | connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); | ||
46 | connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); | ||
47 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | ||
48 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
49 | this, SLOT(received(const QCString&, const QByteArray&)) ); | ||
50 | |||
51 | spacing = AppLnk::smallIconSize()+3; | ||
52 | } | ||
53 | |||
54 | RunningAppBar::~RunningAppBar() { | ||
55 | } | ||
56 | |||
57 | void RunningAppBar::newQcopChannel(const QString& channelName) { | ||
58 | QString prefix("QPE/Application/"); | ||
59 | if (channelName.startsWith(prefix)) { | ||
60 | QString appName = channelName.mid(prefix.length()); | ||
61 | // qDebug("App %s just connected!", appName.latin1()); | ||
62 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); | ||
63 | if (newGuy && !newGuy->isPreloaded()) { | ||
64 | addTask(*newGuy); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | |||
69 | void RunningAppBar::removedQcopChannel(const QString& channelName) { | ||
70 | QString prefix("QPE/Application/"); | ||
71 | if (channelName.startsWith(prefix)) { | ||
72 | QString appName = channelName.mid(prefix.length()); | ||
73 | qDebug("App %s just disconnected!", appName.latin1()); | ||
74 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); | ||
75 | if (newGuy) { | ||
76 | removeTask(*newGuy); | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | void RunningAppBar::received(const QCString& msg, const QByteArray& data) { | ||
82 | // Since fast apps appear and disappear without disconnecting from their | ||
83 | // channel we need to watch for the showing/hiding events and update according. | ||
84 | QDataStream stream( data, IO_ReadOnly ); | ||
85 | if ( msg == "fastAppShowing(QString)") { | ||
86 | QString appName; | ||
87 | stream >> appName; | ||
88 | addTask(*m_AppLnkSet->findExec(appName)); | ||
89 | } else if ( msg == "fastAppHiding(QString)") { | ||
90 | QString appName; | ||
91 | stream >> appName; | ||
92 | removeTask(*m_AppLnkSet->findExec(appName)); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | void RunningAppBar::addTask(const AppLnk& appLnk) { | ||
97 | // qDebug("Added %s to app list.", appLnk.name().latin1()); | ||
98 | AppLnk* newApp = new AppLnk(appLnk); | ||
99 | newApp->setExec(appLnk.exec()); | ||
100 | m_AppList.prepend(newApp); | ||
101 | update(); | ||
102 | } | ||
103 | |||
104 | void RunningAppBar::removeTask(const AppLnk& appLnk) { | ||
105 | unsigned int i = 0; | ||
106 | for (; i < m_AppList.count() ; i++) { | ||
107 | AppLnk* target = m_AppList.at(i); | ||
108 | if (target->exec() == appLnk.exec()) { | ||
109 | qDebug("Removing %s from app list.", appLnk.name().latin1()); | ||
110 | m_AppList.remove(); | ||
111 | delete target; | ||
112 | } | ||
113 | } | ||
114 | update(); | ||
115 | } | ||
116 | |||
117 | void RunningAppBar::mousePressEvent(QMouseEvent *e) | ||
118 | { | ||
119 | // Find out if the user is clicking on an app icon... | ||
120 | // If so, snag the index so when we repaint we show it | ||
121 | // as highlighed. | ||
122 | m_SelectedAppIndex = 0; | ||
123 | int x=0; | ||
124 | QListIterator<AppLnk> it( m_AppList ); | ||
125 | for ( ; it.current(); ++it,++m_SelectedAppIndex,x+=spacing ) { | ||
126 | if ( x + spacing <= width() ) { | ||
127 | if ( e->x() >= x && e->x() < x+spacing ) { | ||
128 | if ( m_SelectedAppIndex < (int)m_AppList.count() ) { | ||
129 | repaint(FALSE); | ||
130 | return; | ||
131 | } | ||
132 | } | ||
133 | } else { | ||
134 | break; | ||
135 | } | ||
136 | } | ||
137 | m_SelectedAppIndex = -1; | ||
138 | repaint( FALSE ); | ||
139 | } | ||
140 | |||
141 | void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) | ||
142 | { | ||
143 | if (e->button() == QMouseEvent::RightButton) { | ||
144 | return; | ||
145 | } | ||
146 | if ( m_SelectedAppIndex >= 0 ) { | ||
147 | QString channel = QString("QPE/Application/") + m_AppList.at(m_SelectedAppIndex)->exec(); | ||
148 | if (QCopChannel::isRegistered(channel.latin1())) { | ||
149 | // qDebug("%s is running!", m_AppList.at(m_SelectedAppIndex)->exec().latin1()); | ||
150 | QCopEnvelope e(channel.latin1(), "raise()"); | ||
151 | // This class will delete itself after hearing from the app or the timer expiring | ||
152 | (void)new AppMonitor(*m_AppList.at(m_SelectedAppIndex), *this); | ||
153 | } | ||
154 | else { | ||
155 | removeTask(*m_AppList.at(m_SelectedAppIndex)); | ||
156 | } | ||
157 | |||
158 | m_SelectedAppIndex = -1; | ||
159 | update(); | ||
160 | } | ||
161 | } | ||
162 | |||
163 | void RunningAppBar::paintEvent( QPaintEvent * ) | ||
164 | { | ||
165 | QPainter p( this ); | ||
166 | AppLnk *curApp; | ||
167 | int x = 0; | ||
168 | int y = (height() - AppLnk::smallIconSize()) / 2; | ||
169 | int i = 0; | ||
170 | |||
171 | p.fillRect( 0, 0, width(), height(), colorGroup().background() ); | ||
172 | |||
173 | QListIterator<AppLnk> it(m_AppList); | ||
174 | |||
175 | for (; it.current(); i++, ++it ) { | ||
176 | if ( x + spacing <= width() ) { | ||
177 | curApp = it.current(); | ||
178 | if ( (int)i == m_SelectedAppIndex ) | ||
179 | p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() ); | ||
180 | else | ||
181 | p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); | ||
182 | p.drawPixmap( x, y, curApp->pixmap() ); | ||
183 | x += spacing; | ||
184 | } | ||
185 | } | ||
186 | } | ||
187 | |||
188 | QSize RunningAppBar::sizeHint() const | ||
189 | { | ||
190 | return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 ); | ||
191 | } | ||
192 | |||
193 | const int AppMonitor::RAISE_TIMEOUT_MS = 500; | ||
194 | |||
195 | AppMonitor::AppMonitor(const AppLnk& app, RunningAppBar& owner) | ||
196 | : QObject(0L), m_Owner(owner), m_App(app), m_PsProc(0L), m_AppKillerBox(0L) { | ||
197 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | ||
198 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | ||
199 | this, SLOT(received(const QCString&, const QByteArray&)) ); | ||
200 | connect(&m_Timer, SIGNAL(timeout()), this, SLOT(timerExpired())); | ||
201 | m_Timer.start(RAISE_TIMEOUT_MS, TRUE); | ||
202 | } | ||
203 | |||
204 | AppMonitor::~AppMonitor() { | ||
205 | if (m_AppKillerBox) { | ||
206 | delete m_AppKillerBox; | ||
207 | m_AppKillerBox = 0L; | ||
208 | } | ||
209 | } | ||
210 | |||
211 | void AppMonitor::received(const QCString& msg, const QByteArray& data) { | ||
212 | QDataStream stream( data, IO_ReadOnly ); | ||
213 | |||
214 | if (msg == "appRaised(QString)") { | ||
215 | QString appName; | ||
216 | stream >> appName; | ||
217 | if (appName == m_App.exec()) { | ||
218 | // qDebug("Got a heartbeat from %s", appName.latin1()); | ||
219 | m_Timer.stop(); | ||
220 | // Check to make sure we're not waiting on user input... | ||
221 | if (m_AppKillerBox) { | ||
222 | // If we are, we kill the dialog box, and the code waiting on the result | ||
223 | // will clean us up (basically the user said "no"). | ||
224 | delete m_AppKillerBox; | ||
225 | m_AppKillerBox = 0L; | ||
226 | } | ||
227 | else { | ||
228 | // Ok, we're not waiting on user input, so clean us up now. | ||
229 | // WE DELETE OURSELVES HERE! Don't do anything else!! | ||
230 | delete this; | ||
231 | } | ||
232 | } | ||
233 | } | ||
234 | } | ||
235 | |||
236 | void AppMonitor::timerExpired() { | ||
237 | // qDebug("Checking in on %s", m_App.name().latin1()); | ||
238 | // We store this incase the application responds while we're | ||
239 | // waiting for user input so we know not to delete ourselves. This | ||
240 | // will be cleaned up in the destructor. | ||
241 | m_AppKillerBox = new QMessageBox(tr("Application Problem"), | ||
242 | tr("<p>%1 is not responding.</p>").arg(m_App.name()) + | ||
243 | tr("<p>Would you like to force the application to exit?</p>"), | ||
244 | QMessageBox::Warning, QMessageBox::Yes, | ||
245 | QMessageBox::No | QMessageBox::Default, | ||
246 | QMessageBox::NoButton); | ||
247 | if (m_AppKillerBox->exec() == QMessageBox::Yes) { | ||
248 | // qDebug("Killing the app!!! Bwuhahahaha!"); | ||
249 | m_PsProc = new QProcess(QString("ps")); | ||
250 | m_PsProc->addArgument("h"); | ||
251 | m_PsProc->addArgument("-C"); | ||
252 | m_PsProc->addArgument(m_App.exec()); | ||
253 | m_PsProc->addArgument("-o"); | ||
254 | m_PsProc->addArgument("pid"); | ||
255 | connect(m_PsProc, SIGNAL(processExited()), this, SLOT(psProcFinished())); | ||
256 | m_PsProc->start(); | ||
257 | } | ||
258 | else { | ||
259 | // qDebug("Wuss.."); | ||
260 | // WE DELETE OURSELVES HERE! Don't do anything else!! | ||
261 | delete this; | ||
262 | } | ||
263 | } | ||
264 | |||
265 | void AppMonitor::psProcFinished() { | ||
266 | QString pid = m_PsProc->readLineStdout(); | ||
267 | delete m_PsProc; | ||
268 | m_PsProc = 0L; | ||
269 | |||
270 | // qDebug("Killing app %s", pid.latin1()); | ||
271 | if (pid.isEmpty()) { | ||
272 | // Hmm.. did the application bail before we got there? | ||
273 | qDebug("AppMonitor: Tried to kill application %s but ps couldn't find it.", m_App.exec().latin1()); | ||
274 | } | ||
275 | else { | ||
276 | int success = kill(pid.toUInt(), SIGKILL); | ||
277 | if (success == 0) { | ||
278 | m_Owner.removeTask(m_App); | ||
279 | } | ||
280 | else { | ||
281 | qWarning("Could not kill task %s", m_App.exec().latin1()); | ||
282 | } | ||
283 | } | ||
284 | |||
285 | // WE DELETE OURSELVES HERE! Don't do anything else!! | ||
286 | delete this; | ||
287 | } | ||
diff --git a/core/launcher/runningappbar.h b/core/launcher/runningappbar.h new file mode 100644 index 0000000..880bb69 --- a/dev/null +++ b/core/launcher/runningappbar.h | |||
@@ -0,0 +1,88 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #ifndef RUNNING_APP_BAR_H | ||
22 | #define RUNNING_APP_BAR_H | ||
23 | |||
24 | #include <qframe.h> | ||
25 | #include <qlist.h> | ||
26 | #include <qtimer.h> | ||
27 | |||
28 | class AppLnk; | ||
29 | class AppLnkSet; | ||
30 | class QCString; | ||
31 | class QProcess; | ||
32 | class QMessageBox; | ||
33 | |||
34 | class RunningAppBar : public QFrame { | ||
35 | Q_OBJECT | ||
36 | |||
37 | public: | ||
38 | RunningAppBar(QWidget* parent); | ||
39 | ~RunningAppBar(); | ||
40 | |||
41 | void addTask(const AppLnk& appLnk); | ||
42 | void removeTask(const AppLnk& appLnk); | ||
43 | void paintEvent(QPaintEvent* event); | ||
44 | void mousePressEvent(QMouseEvent*); | ||
45 | void mouseReleaseEvent(QMouseEvent*); | ||
46 | QSize sizeHint() const; | ||
47 | |||
48 | private slots: | ||
49 | void newQcopChannel(const QString& channel); | ||
50 | void removedQcopChannel(const QString& channel); | ||
51 | void received(const QCString& msg, const QByteArray& data); | ||
52 | |||
53 | private: | ||
54 | AppLnkSet* m_AppLnkSet; | ||
55 | QList<AppLnk> m_AppList; | ||
56 | int m_SelectedAppIndex; | ||
57 | int spacing; | ||
58 | }; | ||
59 | |||
60 | /** | ||
61 | * Internal class that checks back in on the process when timerExpired is called | ||
62 | * to make sure the process is on top. If it's not it displays a dialog | ||
63 | * box asking permission to kill it. | ||
64 | */ | ||
65 | class AppMonitor : public QObject { | ||
66 | Q_OBJECT | ||
67 | |||
68 | public: | ||
69 | static const int RAISE_TIMEOUT_MS; | ||
70 | |||
71 | AppMonitor(const AppLnk& app, RunningAppBar& owner); | ||
72 | ~AppMonitor(); | ||
73 | |||
74 | private slots: | ||
75 | void timerExpired(); | ||
76 | void received(const QCString& msg, const QByteArray& data); | ||
77 | void psProcFinished(); | ||
78 | |||
79 | private: | ||
80 | RunningAppBar& m_Owner; | ||
81 | const AppLnk& m_App; | ||
82 | QTimer m_Timer; | ||
83 | QProcess* m_PsProc; | ||
84 | QMessageBox* m_AppKillerBox; | ||
85 | }; | ||
86 | |||
87 | #endif | ||
88 | |||
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index 5bac874..5506c55 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp | |||
@@ -1,171 +1,171 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "startmenu.h" | 21 | #include "startmenu.h" |
22 | #include "sidething.h" | 22 | #include "sidething.h" |
23 | #include "mrulist.h" | 23 | //#include "mrulist.h" |
24 | #include "info.h" | 24 | #include "info.h" |
25 | 25 | ||
26 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #include <qpe/applnk.h> | 28 | #include <qpe/applnk.h> |
29 | #include <qpe/global.h> | 29 | #include <qpe/global.h> |
30 | #include <qpe/resource.h> | 30 | #include <qpe/resource.h> |
31 | 31 | ||
32 | #include <qdict.h> | 32 | #include <qdict.h> |
33 | 33 | ||
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | 35 | ||
36 | 36 | ||
37 | // #define USE_CONFIG_FILE | 37 | // #define USE_CONFIG_FILE |
38 | 38 | ||
39 | 39 | ||
40 | StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) | 40 | StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) |
41 | { | 41 | { |
42 | loadOptions(); | 42 | loadOptions(); |
43 | 43 | ||
44 | setPixmap( Resource::loadPixmap( startButtonPixmap ) ); | 44 | setPixmap( Resource::loadPixmap( startButtonPixmap ) ); |
45 | setFocusPolicy( NoFocus ); | 45 | setFocusPolicy( NoFocus ); |
46 | //setFlat( startButtonIsFlat ); | 46 | //setFlat( startButtonIsFlat ); |
47 | 47 | ||
48 | apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); | 48 | apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); |
49 | 49 | ||
50 | createMenu(); | 50 | createMenu(); |
51 | } | 51 | } |
52 | 52 | ||
53 | 53 | ||
54 | void StartMenu::mousePressEvent( QMouseEvent * ) | 54 | void StartMenu::mousePressEvent( QMouseEvent * ) |
55 | { | 55 | { |
56 | launch(); | 56 | launch(); |
57 | if (desktopInfo) | 57 | if (desktopInfo) |
58 | desktopInfo->menuClicked(); | 58 | desktopInfo->menuClicked(); |
59 | } | 59 | } |
60 | 60 | ||
61 | 61 | ||
62 | StartMenu::~StartMenu() | 62 | StartMenu::~StartMenu() |
63 | { | 63 | { |
64 | delete apps; | 64 | delete apps; |
65 | } | 65 | } |
66 | 66 | ||
67 | 67 | ||
68 | void StartMenu::loadOptions() | 68 | void StartMenu::loadOptions() |
69 | { | 69 | { |
70 | #ifdef USE_CONFIG_FILE | 70 | #ifdef USE_CONFIG_FILE |
71 | // Read configuration file | 71 | // Read configuration file |
72 | Config config("StartMenu"); | 72 | Config config("StartMenu"); |
73 | config.setGroup( "StartMenu" ); | 73 | config.setGroup( "StartMenu" ); |
74 | QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" ); | 74 | QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" ); |
75 | useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE; | 75 | useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE; |
76 | QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" ); | 76 | QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" ); |
77 | startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE; | 77 | startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE; |
78 | QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" ); | 78 | // QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" ); |
79 | popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" ); | 79 | popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" ); |
80 | startButtonPixmap = config.readEntry( "StartButtonPixmap", "go" ); | 80 | startButtonPixmap = config.readEntry( "StartButtonPixmap", "go" ); |
81 | #else | 81 | #else |
82 | // Basically just #include the .qpe_menu.conf file settings | 82 | // Basically just #include the .qpe_menu.conf file settings |
83 | useWidePopupMenu = FALSE; | 83 | useWidePopupMenu = FALSE; |
84 | popupMenuSidePixmap = "lauchner/sidebar"; | 84 | popupMenuSidePixmap = "lauchner/sidebar"; |
85 | startButtonIsFlat = TRUE; | 85 | startButtonIsFlat = TRUE; |
86 | startButtonPixmap = "launcher/start_button"; | 86 | startButtonPixmap = "launcher/start_button"; |
87 | #endif | 87 | #endif |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
91 | void StartMenu::createMenu() | 91 | void StartMenu::createMenu() |
92 | { | 92 | { |
93 | if ( useWidePopupMenu ) | 93 | if ( useWidePopupMenu ) |
94 | launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); | 94 | launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); |
95 | else | 95 | else |
96 | launchMenu = new StartPopupMenu( this ); | 96 | launchMenu = new StartPopupMenu( this ); |
97 | 97 | ||
98 | loadMenu( apps, launchMenu ); | 98 | loadMenu( apps, launchMenu ); |
99 | 99 | ||
100 | } | 100 | } |
101 | 101 | ||
102 | void StartMenu::itemSelected( int id ) | 102 | void StartMenu::itemSelected( int id ) |
103 | { | 103 | { |
104 | const AppLnk *app = apps->find( id ); | 104 | const AppLnk *app = apps->find( id ); |
105 | if ( app ) | 105 | if ( app ) |
106 | app->execute(); | 106 | app->execute(); |
107 | } | 107 | } |
108 | 108 | ||
109 | bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) | 109 | bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) |
110 | { | 110 | { |
111 | bool result = FALSE; | 111 | bool result = FALSE; |
112 | 112 | ||
113 | QStringList typs = folder->types(); | 113 | QStringList typs = folder->types(); |
114 | QDict<QPopupMenu> typpop; | 114 | QDict<QPopupMenu> typpop; |
115 | for (QStringList::Iterator tit=typs.begin(); tit!=typs.end(); ++tit) { | 115 | for (QStringList::Iterator tit=typs.begin(); tit!=typs.end(); ++tit) { |
116 | if ( !(*tit).isEmpty() ) { | 116 | if ( !(*tit).isEmpty() ) { |
117 | QPopupMenu *new_menu = new StartPopupMenu( menu ); | 117 | QPopupMenu *new_menu = new StartPopupMenu( menu ); |
118 | typpop.insert(*tit, new_menu); | 118 | typpop.insert(*tit, new_menu); |
119 | connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); | 119 | connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); |
120 | menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu ); | 120 | menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu ); |
121 | } | 121 | } |
122 | } | 122 | } |
123 | 123 | ||
124 | QListIterator<AppLnk> it( folder->children() ); | 124 | QListIterator<AppLnk> it( folder->children() ); |
125 | for ( ; it.current(); ++it ) { | 125 | for ( ; it.current(); ++it ) { |
126 | AppLnk *app = it.current(); | 126 | AppLnk *app = it.current(); |
127 | if ( app->type() == "Separator" ) { | 127 | if ( app->type() == "Separator" ) { |
128 | menu->insertSeparator(); | 128 | menu->insertSeparator(); |
129 | } else { | 129 | } else { |
130 | QString t = app->type(); | 130 | QString t = app->type(); |
131 | QPopupMenu* pmenu = typpop.find(t); | 131 | QPopupMenu* pmenu = typpop.find(t); |
132 | if ( !pmenu ) | 132 | if ( !pmenu ) |
133 | pmenu = menu; | 133 | pmenu = menu; |
134 | pmenu->insertItem( app->pixmap(), app->name(), app->id() ); | 134 | pmenu->insertItem( app->pixmap(), app->name(), app->id() ); |
135 | result=TRUE; | 135 | result=TRUE; |
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | if ( result ) | 139 | if ( result ) |
140 | connect( menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); | 140 | connect( menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); |
141 | 141 | ||
142 | return result; | 142 | return result; |
143 | } | 143 | } |
144 | 144 | ||
145 | 145 | ||
146 | void StartMenu::launch() | 146 | void StartMenu::launch() |
147 | { | 147 | { |
148 | int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); | 148 | int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); |
149 | 149 | ||
150 | if ( launchMenu->isVisible() ) | 150 | if ( launchMenu->isVisible() ) |
151 | launchMenu->hide(); | 151 | launchMenu->hide(); |
152 | else | 152 | else |
153 | launchMenu->popup( QPoint( 1, y ) ); | 153 | launchMenu->popup( QPoint( 1, y ) ); |
154 | } | 154 | } |
155 | 155 | ||
156 | const AppLnk* StartMenu::execToLink(const QString& appname) | 156 | const AppLnk* StartMenu::execToLink(const QString& appname) |
157 | { | 157 | { |
158 | const AppLnk* a = apps->findExec( appname ); | 158 | const AppLnk* a = apps->findExec( appname ); |
159 | return a; | 159 | return a; |
160 | } | 160 | } |
161 | 161 | ||
162 | void StartPopupMenu::keyPressEvent( QKeyEvent *e ) | 162 | void StartPopupMenu::keyPressEvent( QKeyEvent *e ) |
163 | { | 163 | { |
164 | if ( e->key() == Key_F33 || e->key() == Key_Space ) { | 164 | if ( e->key() == Key_F33 || e->key() == Key_Space ) { |
165 | // "OK" button, little hacky | 165 | // "OK" button, little hacky |
166 | QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); | 166 | QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); |
167 | QPopupMenu::keyPressEvent( &ke ); | 167 | QPopupMenu::keyPressEvent( &ke ); |
168 | } else { | 168 | } else { |
169 | QPopupMenu::keyPressEvent( e ); | 169 | QPopupMenu::keyPressEvent( e ); |
170 | } | 170 | } |
171 | } | 171 | } |
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp index e38b9fe..9f397eb 100644 --- a/core/launcher/taskbar.cpp +++ b/core/launcher/taskbar.cpp | |||
@@ -1,316 +1,323 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | *********************************************************************/ | 19 | *********************************************************************/ |
20 | 20 | ||
21 | #include "startmenu.h" | 21 | #include "startmenu.h" |
22 | #include "inputmethods.h" | 22 | #include "inputmethods.h" |
23 | #include "mrulist.h" | 23 | #include "mrulist.h" |
24 | #include "runningappbar.h" | ||
24 | #include "systray.h" | 25 | #include "systray.h" |
25 | #include "calibrate.h" | 26 | #include "calibrate.h" |
26 | #include "wait.h" | 27 | #include "wait.h" |
27 | #include "appicons.h" | 28 | #include "appicons.h" |
28 | 29 | ||
29 | #include "taskbar.h" | 30 | #include "taskbar.h" |
30 | #include "desktop.h" | 31 | #include "desktop.h" |
31 | 32 | ||
32 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/qcopenvelope_qws.h> | 34 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <qpe/global.h> | 35 | #include <qpe/global.h> |
35 | 36 | ||
36 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 37 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
37 | #include <qpe/custom.h> | 38 | #include <qpe/custom.h> |
38 | #endif | 39 | #endif |
39 | 40 | ||
40 | #include <opie/odevice.h> | 41 | #include <opie/odevice.h> |
41 | 42 | ||
42 | #include <qlabel.h> | 43 | #include <qlabel.h> |
43 | #include <qlayout.h> | 44 | #include <qlayout.h> |
44 | #include <qtimer.h> | 45 | #include <qtimer.h> |
45 | #include <qwindowsystem_qws.h> | 46 | #include <qwindowsystem_qws.h> |
46 | #include <qwidgetstack.h> | 47 | #include <qwidgetstack.h> |
47 | 48 | ||
48 | #if defined( Q_WS_QWS ) | 49 | #if defined( Q_WS_QWS ) |
49 | #include <qwsdisplay_qws.h> | 50 | #include <qwsdisplay_qws.h> |
50 | #include <qgfx_qws.h> | 51 | #include <qgfx_qws.h> |
51 | #endif | 52 | #endif |
52 | 53 | ||
53 | 54 | ||
54 | #define FACTORY(T) \ | 55 | #define FACTORY(T) \ |
55 | static QWidget *new##T( bool maximized ) { \ | 56 | static QWidget *new##T( bool maximized ) { \ |
56 | QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ | 57 | QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ |
57 | if ( maximized ) { \ | 58 | if ( maximized ) { \ |
58 | if ( qApp->desktop()->width() <= 350 ) { \ | 59 | if ( qApp->desktop()->width() <= 350 ) { \ |
59 | w->showMaximized(); \ | 60 | w->showMaximized(); \ |
60 | } else { \ | 61 | } else { \ |
61 | w->resize( QSize( 300, 300 ) ); \ | 62 | w->resize( QSize( 300, 300 ) ); \ |
62 | } \ | 63 | } \ |
63 | } \ | 64 | } \ |
64 | w->show(); \ | 65 | w->show(); \ |
65 | return w; \ | 66 | return w; \ |
66 | } | 67 | } |
67 | 68 | ||
68 | 69 | ||
69 | #ifdef SINGLE_APP | 70 | #ifdef SINGLE_APP |
70 | #define APP(a,b,c,d) FACTORY(b) | 71 | #define APP(a,b,c,d) FACTORY(b) |
71 | #include "../launcher/apps.h" | 72 | #include "../launcher/apps.h" |
72 | #undef APP | 73 | #undef APP |
73 | #endif // SINGLE_APP | 74 | #endif // SINGLE_APP |
74 | 75 | ||
75 | static Global::Command builtins[] = { | 76 | static Global::Command builtins[] = { |
76 | 77 | ||
77 | #ifdef SINGLE_APP | 78 | #ifdef SINGLE_APP |
78 | #define APP(a,b,c,d) { a, new##b, c }, | 79 | #define APP(a,b,c,d) { a, new##b, c }, |
79 | #include "../launcher/apps.h" | 80 | #include "../launcher/apps.h" |
80 | #undef APP | 81 | #undef APP |
81 | #endif | 82 | #endif |
82 | 83 | ||
83 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX) | 84 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX) |
84 | { "calibrate", TaskBar::calibrate, 1, 0 }, | 85 | { "calibrate", TaskBar::calibrate, 1, 0 }, |
85 | #endif | 86 | #endif |
86 | #if !defined(QT_QWS_CASSIOPEIA) | 87 | #if !defined(QT_QWS_CASSIOPEIA) |
87 | { "shutdown", Global::shutdown, 1, 0 }, | 88 | { "shutdown", Global::shutdown, 1, 0 }, |
88 | // { "run", run, 1, 0 }, | 89 | // { "run", run, 1, 0 }, |
89 | #endif | 90 | #endif |
90 | 91 | ||
91 | { 0, TaskBar::calibrate, 0, 0 }, | 92 | { 0, TaskBar::calibrate, 0, 0 }, |
92 | }; | 93 | }; |
93 | 94 | ||
94 | static bool initNumLock() | 95 | static bool initNumLock() |
95 | { | 96 | { |
96 | #ifdef QPE_INITIAL_NUMLOCK_STATE | 97 | #ifdef QPE_INITIAL_NUMLOCK_STATE |
97 | QPE_INITIAL_NUMLOCK_STATE | 98 | QPE_INITIAL_NUMLOCK_STATE |
98 | #endif | 99 | #endif |
99 | return FALSE; | 100 | return FALSE; |
100 | } | 101 | } |
101 | 102 | ||
102 | class LockKeyState : public QWidget | 103 | class LockKeyState : public QWidget |
103 | { | 104 | { |
104 | public: | 105 | public: |
105 | LockKeyState( QWidget *parent ) : | 106 | LockKeyState( QWidget *parent ) : |
106 | QWidget(parent), | 107 | QWidget(parent), |
107 | nl(initNumLock()), cl(FALSE) | 108 | nl(initNumLock()), cl(FALSE) |
108 | { | 109 | { |
109 | nl_pm = Resource::loadPixmap("numlock"); | 110 | nl_pm = Resource::loadPixmap("numlock"); |
110 | cl_pm = Resource::loadPixmap("capslock"); | 111 | cl_pm = Resource::loadPixmap("capslock"); |
111 | } | 112 | } |
112 | QSize sizeHint() const | 113 | QSize sizeHint() const |
113 | { | 114 | { |
114 | return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); | 115 | return QSize(nl_pm.width()+2,nl_pm.width()+nl_pm.height()+1); |
115 | } | 116 | } |
116 | void toggleNumLockState() | 117 | void toggleNumLockState() |
117 | { | 118 | { |
118 | nl = !nl; repaint(); | 119 | nl = !nl; repaint(); |
119 | } | 120 | } |
120 | void toggleCapsLockState() | 121 | void toggleCapsLockState() |
121 | { | 122 | { |
122 | cl = !cl; repaint(); | 123 | cl = !cl; repaint(); |
123 | } | 124 | } |
124 | void paintEvent( QPaintEvent * ) | 125 | void paintEvent( QPaintEvent * ) |
125 | { | 126 | { |
126 | int y = (height()-sizeHint().height())/2; | 127 | int y = (height()-sizeHint().height())/2; |
127 | QPainter p(this); | 128 | QPainter p(this); |
128 | if ( nl ) | 129 | if ( nl ) |
129 | p.drawPixmap(1,y,nl_pm); | 130 | p.drawPixmap(1,y,nl_pm); |
130 | if ( cl ) | 131 | if ( cl ) |
131 | p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); | 132 | p.drawPixmap(1,y+nl_pm.height()+1,cl_pm); |
132 | } | 133 | } |
133 | private: | 134 | private: |
134 | QPixmap nl_pm, cl_pm; | 135 | QPixmap nl_pm, cl_pm; |
135 | bool nl, cl; | 136 | bool nl, cl; |
136 | }; | 137 | }; |
137 | 138 | ||
138 | TaskBar::~TaskBar() | 139 | TaskBar::~TaskBar() |
139 | { | 140 | { |
140 | } | 141 | } |
141 | 142 | ||
142 | 143 | ||
143 | TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) | 144 | TaskBar::TaskBar() : QHBox(0, 0, WStyle_Customize | WStyle_Tool | WStyle_StaysOnTop | WGroupLeader) |
144 | { | 145 | { |
145 | Global::setBuiltinCommands(builtins); | 146 | Global::setBuiltinCommands(builtins); |
146 | 147 | ||
147 | sm = new StartMenu( this ); | 148 | sm = new StartMenu( this ); |
148 | 149 | ||
149 | inputMethods = new InputMethods( this ); | 150 | inputMethods = new InputMethods( this ); |
150 | connect( inputMethods, SIGNAL(inputToggled(bool)), | 151 | connect( inputMethods, SIGNAL(inputToggled(bool)), |
151 | this, SLOT(calcMaxWindowRect()) ); | 152 | this, SLOT(calcMaxWindowRect()) ); |
152 | //new QuickLauncher( this ); | 153 | //new QuickLauncher( this ); |
153 | 154 | ||
154 | stack = new QWidgetStack( this ); | 155 | stack = new QWidgetStack( this ); |
155 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); | 156 | stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); |
156 | label = new QLabel(stack); | 157 | label = new QLabel(stack); |
157 | 158 | ||
158 | mru = new MRUList( stack ); | 159 | //mru = new MRUList( stack ); |
159 | stack->raiseWidget( mru ); | 160 | //stack->raiseWidget( mru ); |
161 | |||
162 | runningAppBar = new RunningAppBar(stack); | ||
163 | stack->raiseWidget(runningAppBar); | ||
160 | 164 | ||
161 | waitIcon = new Wait( this ); | 165 | waitIcon = new Wait( this ); |
162 | (void) new AppIcons( this ); | 166 | (void) new AppIcons( this ); |
163 | 167 | ||
164 | sysTray = new SysTray( this ); | 168 | sysTray = new SysTray( this ); |
165 | 169 | ||
166 | // ## make customizable in some way? | 170 | // ## make customizable in some way? |
167 | #ifdef QT_QWS_CUSTOM | 171 | #ifdef QT_QWS_CUSTOM |
168 | lockState = new LockKeyState( this ); | 172 | lockState = new LockKeyState( this ); |
169 | #else | 173 | y#else |
170 | lockState = 0; | 174 | lockState = 0; |
171 | #endif | 175 | #endif |
172 | 176 | ||
173 | #if defined(Q_WS_QWS) | 177 | #if defined(Q_WS_QWS) |
174 | #if !defined(QT_NO_COP) | 178 | #if !defined(QT_NO_COP) |
175 | QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); | 179 | QCopChannel *channel = new QCopChannel( "QPE/TaskBar", this ); |
176 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 180 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
177 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 181 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
178 | #endif | 182 | #endif |
179 | #endif | 183 | #endif |
180 | waitTimer = new QTimer( this ); | 184 | waitTimer = new QTimer( this ); |
181 | connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); | 185 | connect( waitTimer, SIGNAL( timeout() ), this, SLOT( stopWait() ) ); |
182 | clearer = new QTimer( this ); | 186 | clearer = new QTimer( this ); |
183 | QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); | 187 | QObject::connect(clearer, SIGNAL(timeout()), SLOT(clearStatusBar())); |
184 | QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); | 188 | QObject::connect(clearer, SIGNAL(timeout()), sysTray, SLOT(show())); |
185 | } | 189 | } |
186 | 190 | ||
187 | void TaskBar::setStatusMessage( const QString &text ) | 191 | void TaskBar::setStatusMessage( const QString &text ) |
188 | { | 192 | { |
189 | label->setText( text ); | 193 | label->setText( text ); |
190 | stack->raiseWidget( label ); | 194 | stack->raiseWidget( label ); |
191 | if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) | 195 | if ( sysTray && ( label->fontMetrics().width( text ) > label->width() ) ) |
192 | sysTray->hide(); | 196 | sysTray->hide(); |
193 | clearer->start( 3000 ); | 197 | clearer->start( 3000 ); |
194 | } | 198 | } |
195 | 199 | ||
196 | void TaskBar::clearStatusBar() | 200 | void TaskBar::clearStatusBar() |
197 | { | 201 | { |
198 | label->clear(); | 202 | label->clear(); |
199 | stack->raiseWidget( mru ); | 203 | stack->raiseWidget(runningAppBar); |
204 | // stack->raiseWidget( mru ); | ||
200 | } | 205 | } |
201 | 206 | ||
202 | void TaskBar::startWait() | 207 | void TaskBar::startWait() |
203 | { | 208 | { |
204 | waitIcon->setWaiting( true ); | 209 | waitIcon->setWaiting( true ); |
205 | // a catchall stop after 10 seconds... | 210 | // a catchall stop after 10 seconds... |
206 | waitTimer->start( 10 * 1000, true ); | 211 | waitTimer->start( 10 * 1000, true ); |
207 | } | 212 | } |
208 | 213 | ||
209 | void TaskBar::stopWait(const QString& app) | 214 | void TaskBar::stopWait(const QString& app) |
210 | { | 215 | { |
211 | waitTimer->stop(); | 216 | waitTimer->stop(); |
212 | mru->addTask(sm->execToLink(app)); | 217 | //mru->addTask(sm->execToLink(app)); |
213 | waitIcon->setWaiting( false ); | 218 | waitIcon->setWaiting( false ); |
214 | } | 219 | } |
215 | 220 | ||
216 | void TaskBar::stopWait() | 221 | void TaskBar::stopWait() |
217 | { | 222 | { |
218 | waitTimer->stop(); | 223 | waitTimer->stop(); |
224 | |||
219 | waitIcon->setWaiting( false ); | 225 | waitIcon->setWaiting( false ); |
220 | } | 226 | } |
221 | 227 | ||
222 | void TaskBar::resizeEvent( QResizeEvent *e ) | 228 | void TaskBar::resizeEvent( QResizeEvent *e ) |
223 | { | 229 | { |
224 | QHBox::resizeEvent( e ); | 230 | QHBox::resizeEvent( e ); |
225 | calcMaxWindowRect(); | 231 | calcMaxWindowRect(); |
226 | } | 232 | } |
227 | 233 | ||
228 | void TaskBar::styleChange( QStyle &s ) | 234 | void TaskBar::styleChange( QStyle &s ) |
229 | { | 235 | { |
230 | QHBox::styleChange( s ); | 236 | QHBox::styleChange( s ); |
231 | calcMaxWindowRect(); | 237 | calcMaxWindowRect(); |
232 | } | 238 | } |
233 | 239 | ||
234 | void TaskBar::calcMaxWindowRect() | 240 | void TaskBar::calcMaxWindowRect() |
235 | { | 241 | { |
236 | #ifdef Q_WS_QWS | 242 | #ifdef Q_WS_QWS |
237 | QRect wr; | 243 | QRect wr; |
238 | int displayWidth = qApp->desktop()->width(); | 244 | int displayWidth = qApp->desktop()->width(); |
239 | QRect ir = inputMethods->inputRect(); | 245 | QRect ir = inputMethods->inputRect(); |
240 | if ( ir.isValid() ) { | 246 | if ( ir.isValid() ) { |
241 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); | 247 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); |
242 | } else { | 248 | } else { |
243 | wr.setCoords( 0, 0, displayWidth-1, y()-1 ); | 249 | wr.setCoords( 0, 0, displayWidth-1, y()-1 ); |
244 | } | 250 | } |
245 | 251 | ||
246 | #if QT_VERSION < 300 | 252 | #if QT_VERSION < 300 |
247 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, | 253 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, |
248 | QSize(qt_screen->width(),qt_screen->height())) | 254 | QSize(qt_screen->width(),qt_screen->height())) |
249 | ); | 255 | ); |
250 | #else | 256 | #else |
251 | QWSServer::setMaxWindowRect( wr ); | 257 | QWSServer::setMaxWindowRect( wr ); |
252 | #endif | 258 | #endif |
253 | #endif | 259 | #endif |
254 | } | 260 | } |
255 | 261 | ||
256 | void TaskBar::receive( const QCString &msg, const QByteArray &data ) | 262 | void TaskBar::receive( const QCString &msg, const QByteArray &data ) |
257 | { | 263 | { |
258 | QDataStream stream( data, IO_ReadOnly ); | 264 | QDataStream stream( data, IO_ReadOnly ); |
259 | if ( msg == "message(QString)" ) { | 265 | if ( msg == "message(QString)" ) { |
260 | QString text; | 266 | QString text; |
261 | stream >> text; | 267 | stream >> text; |
262 | setStatusMessage( text ); | 268 | setStatusMessage( text ); |
263 | } else if ( msg == "hideInputMethod()" ) { | 269 | } else if ( msg == "hideInputMethod()" ) { |
264 | inputMethods->hideInputMethod(); | 270 | inputMethods->hideInputMethod(); |
265 | } else if ( msg == "showInputMethod()" ) { | 271 | } else if ( msg == "showInputMethod()" ) { |
266 | inputMethods->showInputMethod(); | 272 | inputMethods->showInputMethod(); |
267 | } else if ( msg == "reloadInputMethods()" ) { | 273 | } else if ( msg == "reloadInputMethods()" ) { |
268 | inputMethods->loadInputMethods(); | 274 | inputMethods->loadInputMethods(); |
269 | } else if ( msg == "reloadApplets()" ) { | 275 | } else if ( msg == "reloadApplets()" ) { |
270 | sysTray->loadApplets(); | 276 | sysTray->loadApplets(); |
271 | } else if ( msg == "soundAlarm()" ) { | 277 | } else if ( msg == "soundAlarm()" ) { |
272 | Desktop::soundAlarm(); | 278 | Desktop::soundAlarm(); |
273 | } | 279 | } |
274 | else if ( msg == "setLed(int,bool)" ) { | 280 | else if ( msg == "setLed(int,bool)" ) { |
275 | int led, status; | 281 | int led, status; |
276 | stream >> led >> status; | 282 | stream >> led >> status; |
277 | 283 | ||
278 | ODevice::inst ( )-> setLed ( led, status ? OLED_BlinkSlow : OLED_Off ); | 284 | ODevice::inst ( )-> setLed ( led, status ? OLED_BlinkSlow : OLED_Off ); |
279 | } | 285 | } |
280 | } | 286 | } |
281 | 287 | ||
282 | QWidget *TaskBar::calibrate(bool) | 288 | QWidget *TaskBar::calibrate(bool) |
283 | { | 289 | { |
284 | #ifdef Q_WS_QWS | 290 | #ifdef Q_WS_QWS |
285 | Calibrate *c = new Calibrate; | 291 | Calibrate *c = new Calibrate; |
286 | c->show(); | 292 | c->show(); |
287 | return c; | 293 | return c; |
288 | #else | 294 | #else |
289 | return 0; | 295 | return 0; |
290 | #endif | 296 | #endif |
291 | } | 297 | } |
292 | 298 | ||
293 | void TaskBar::toggleNumLockState() | 299 | void TaskBar::toggleNumLockState() |
294 | { | 300 | { |
295 | if ( lockState ) lockState->toggleNumLockState(); | 301 | if ( lockState ) lockState->toggleNumLockState(); |
296 | } | 302 | } |
297 | 303 | ||
298 | void TaskBar::toggleCapsLockState() | 304 | void TaskBar::toggleCapsLockState() |
299 | { | 305 | { |
300 | if ( lockState ) lockState->toggleCapsLockState(); | 306 | if ( lockState ) lockState->toggleCapsLockState(); |
301 | } | 307 | } |
302 | 308 | ||
303 | void TaskBar::toggleSymbolInput() | 309 | void TaskBar::toggleSymbolInput() |
304 | { | 310 | { |
305 | if ( inputMethods->currentShown() == "Unicode" ) { | 311 | if ( inputMethods->currentShown() == "Unicode" ) { |
306 | inputMethods->hideInputMethod(); | 312 | inputMethods->hideInputMethod(); |
307 | } else { | 313 | } else { |
308 | inputMethods->showInputMethod("Unicode"); | 314 | inputMethods->showInputMethod("Unicode"); |
309 | } | 315 | } |
310 | } | 316 | } |
311 | 317 | ||
312 | bool TaskBar::recoverMemory() | 318 | bool TaskBar::recoverMemory() |
313 | { | 319 | { |
314 | return mru->quitOldApps(); | 320 | //eturn mru->quitOldApps(); |
321 | return true; | ||
315 | } | 322 | } |
316 | 323 | ||
diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h index 40983af..cd631ef 100644 --- a/core/launcher/taskbar.h +++ b/core/launcher/taskbar.h | |||
@@ -1,82 +1,84 @@ | |||
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 __TASKBAR_H__ | 21 | #ifndef __TASKBAR_H__ |
22 | #define __TASKBAR_H__ | 22 | #define __TASKBAR_H__ |
23 | 23 | ||
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | 25 | ||
26 | class QLabel; | 26 | class QLabel; |
27 | class QTimer; | 27 | class QTimer; |
28 | class InputMethods; | 28 | class InputMethods; |
29 | class Wait; | 29 | class Wait; |
30 | class SysTray; | 30 | class SysTray; |
31 | class MRUList; | 31 | //class MRUList; |
32 | class RunningAppBar; | ||
32 | class QWidgetStack; | 33 | class QWidgetStack; |
33 | class QTimer; | 34 | class QTimer; |
34 | class QLabel; | 35 | class QLabel; |
35 | class StartMenu; | 36 | class StartMenu; |
36 | class LockKeyState; | 37 | class LockKeyState; |
37 | 38 | ||
38 | class TaskBar : public QHBox { | 39 | class TaskBar : public QHBox { |
39 | Q_OBJECT | 40 | Q_OBJECT |
40 | public: | 41 | public: |
41 | TaskBar(); | 42 | TaskBar(); |
42 | ~TaskBar(); | 43 | ~TaskBar(); |
43 | 44 | ||
44 | static QWidget *calibrate( bool ); | 45 | static QWidget *calibrate( bool ); |
45 | 46 | ||
46 | bool recoverMemory(); | 47 | bool recoverMemory(); |
47 | 48 | ||
48 | StartMenu *startMenu() const { return sm; } | 49 | StartMenu *startMenu() const { return sm; } |
49 | public slots: | 50 | public slots: |
50 | void startWait(); | 51 | void startWait(); |
51 | void stopWait(const QString&); | 52 | void stopWait(const QString&); |
52 | void stopWait(); | 53 | void stopWait(); |
53 | void clearStatusBar(); | 54 | void clearStatusBar(); |
54 | void toggleNumLockState(); | 55 | void toggleNumLockState(); |
55 | void toggleCapsLockState(); | 56 | void toggleCapsLockState(); |
56 | void toggleSymbolInput(); | 57 | void toggleSymbolInput(); |
57 | 58 | ||
58 | protected: | 59 | protected: |
59 | void resizeEvent( QResizeEvent * ); | 60 | void resizeEvent( QResizeEvent * ); |
60 | void styleChange( QStyle & ); | 61 | void styleChange( QStyle & ); |
61 | void setStatusMessage( const QString &text ); | 62 | void setStatusMessage( const QString &text ); |
62 | 63 | ||
63 | private slots: | 64 | private slots: |
64 | void calcMaxWindowRect(); | 65 | void calcMaxWindowRect(); |
65 | void receive( const QCString &msg, const QByteArray &data ); | 66 | void receive( const QCString &msg, const QByteArray &data ); |
66 | 67 | ||
67 | private: | 68 | private: |
68 | 69 | ||
69 | QTimer *waitTimer; | 70 | QTimer *waitTimer; |
70 | Wait *waitIcon; | 71 | Wait *waitIcon; |
71 | InputMethods *inputMethods; | 72 | InputMethods *inputMethods; |
72 | SysTray *sysTray; | 73 | SysTray *sysTray; |
73 | MRUList *mru; | 74 | // MRUList *mru; |
75 | RunningAppBar* runningAppBar; | ||
74 | QWidgetStack *stack; | 76 | QWidgetStack *stack; |
75 | QTimer *clearer; | 77 | QTimer *clearer; |
76 | QLabel *label; | 78 | QLabel *label; |
77 | LockKeyState* lockState; | 79 | LockKeyState* lockState; |
78 | StartMenu *sm; | 80 | StartMenu *sm; |
79 | }; | 81 | }; |
80 | 82 | ||
81 | 83 | ||
82 | #endif // __TASKBAR_H__ | 84 | #endif // __TASKBAR_H__ |