summaryrefslogtreecommitdiff
authorzecke <zecke>2002-10-18 01:46:28 (UTC)
committer zecke <zecke>2002-10-18 01:46:28 (UTC)
commit218bc4583c545db50f3475930d61b1c76aca3fbd (patch) (unidiff)
tree5ddd0dbca5a42d3f00914968150147c85b4da837
parent0457c48c165abef8afa2ac73c8f66d20e289681a (diff)
downloadopie-218bc4583c545db50f3475930d61b1c76aca3fbd.zip
opie-218bc4583c545db50f3475930d61b1c76aca3fbd.tar.gz
opie-218bc4583c545db50f3475930d61b1c76aca3fbd.tar.bz2
Remove some more #ifdefs
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp4
-rw-r--r--core/launcher/launcher.cpp2
2 files changed, 1 insertions, 5 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 1fd3f6a..3546e28 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,1053 +1,1049 @@
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
61using namespace Opie; 61using namespace Opie;
62 62
63class QCopKeyRegister 63class QCopKeyRegister
64{ 64{
65public: 65public:
66 QCopKeyRegister() : keyCode( 0 ) 66 QCopKeyRegister() : keyCode( 0 )
67 { } 67 { }
68 QCopKeyRegister( int k, const QString &c, const QString &m ) 68 QCopKeyRegister( int k, const QString &c, const QString &m )
69 : keyCode( k ), channel( c ), message( m ) 69 : keyCode( k ), channel( c ), message( m )
70 { } 70 { }
71 71
72 int getKeyCode() const 72 int getKeyCode() const
73 { 73 {
74 return keyCode; 74 return keyCode;
75 } 75 }
76 QString getChannel() const 76 QString getChannel() const
77 { 77 {
78 return channel; 78 return channel;
79 } 79 }
80 QString getMessage() const 80 QString getMessage() const
81 { 81 {
82 return message; 82 return message;
83 } 83 }
84 84
85private: 85private:
86 int keyCode; 86 int keyCode;
87 QString channel, message; 87 QString channel, message;
88}; 88};
89 89
90typedef QValueList<QCopKeyRegister> KeyRegisterList; 90typedef QValueList<QCopKeyRegister> KeyRegisterList;
91KeyRegisterList keyRegisterList; 91KeyRegisterList keyRegisterList;
92 92
93static Desktop* qpedesktop = 0; 93static Desktop* qpedesktop = 0;
94static int loggedin = 0; 94static int loggedin = 0;
95static void login( bool at_poweron ) 95static void login( bool at_poweron )
96{ 96{
97 if ( !loggedin ) { 97 if ( !loggedin ) {
98 Global::terminateBuiltin( "calibrate" ); 98 Global::terminateBuiltin( "calibrate" );
99 Password::authenticate( at_poweron ); 99 Password::authenticate( at_poweron );
100 loggedin = 1; 100 loggedin = 1;
101 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 101 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
102 } 102 }
103} 103}
104 104
105bool Desktop::screenLocked() 105bool Desktop::screenLocked()
106{ 106{
107 return loggedin == 0; 107 return loggedin == 0;
108} 108}
109 109
110/* 110/*
111 Priority is number of alerts that are needed to pop up 111 Priority is number of alerts that are needed to pop up
112 alert. 112 alert.
113 */ 113 */
114class DesktopPowerAlerter : public QMessageBox 114class DesktopPowerAlerter : public QMessageBox
115{ 115{
116public: 116public:
117 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 117 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
118 : QMessageBox( tr( "Battery Status" ), "Low Battery", 118 : QMessageBox( tr( "Battery Status" ), "Low Battery",
119 QMessageBox::Critical, 119 QMessageBox::Critical,
120 QMessageBox::Ok | QMessageBox::Default, 120 QMessageBox::Ok | QMessageBox::Default,
121 QMessageBox::NoButton, QMessageBox::NoButton, 121 QMessageBox::NoButton, QMessageBox::NoButton,
122 parent, name, FALSE ) 122 parent, name, FALSE )
123 { 123 {
124 currentPriority = INT_MAX; 124 currentPriority = INT_MAX;
125 alertCount = 0; 125 alertCount = 0;
126 } 126 }
127 127
128 void alert( const QString &text, int priority ); 128 void alert( const QString &text, int priority );
129 void hideEvent( QHideEvent * ); 129 void hideEvent( QHideEvent * );
130private: 130private:
131 int currentPriority; 131 int currentPriority;
132 int alertCount; 132 int alertCount;
133}; 133};
134 134
135void DesktopPowerAlerter::alert( const QString &text, int priority ) 135void DesktopPowerAlerter::alert( const QString &text, int priority )
136{ 136{
137 alertCount++; 137 alertCount++;
138 if ( alertCount < priority ) 138 if ( alertCount < priority )
139 return ; 139 return ;
140 if ( priority > currentPriority ) 140 if ( priority > currentPriority )
141 return ; 141 return ;
142 currentPriority = priority; 142 currentPriority = priority;
143 setText( text ); 143 setText( text );
144 show(); 144 show();
145} 145}
146 146
147 147
148void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 148void DesktopPowerAlerter::hideEvent( QHideEvent *e )
149{ 149{
150 QMessageBox::hideEvent( e ); 150 QMessageBox::hideEvent( e );
151 alertCount = 0; 151 alertCount = 0;
152 currentPriority = INT_MAX; 152 currentPriority = INT_MAX;
153} 153}
154 154
155class QPEScreenSaver : public QWSScreenSaver 155class QPEScreenSaver : public QWSScreenSaver
156{ 156{
157private: 157private:
158 int LcdOn; 158 int LcdOn;
159 159
160public: 160public:
161 QPEScreenSaver() 161 QPEScreenSaver()
162 { 162 {
163 m_disable_suspend = 100; 163 m_disable_suspend = 100;
164 m_enable_dim = false; 164 m_enable_dim = false;
165 m_enable_lightoff = false; 165 m_enable_lightoff = false;
166 m_enable_onlylcdoff = false; 166 m_enable_onlylcdoff = false;
167 167
168 m_lcd_status = true; 168 m_lcd_status = true;
169 169
170 m_backlight_bright = -1; 170 m_backlight_bright = -1;
171 m_backlight_forcedoff = false; 171 m_backlight_forcedoff = false;
172 172
173 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 173 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
174 ODevice::inst ( ) -> setDisplayStatus ( true ); 174 ODevice::inst ( ) -> setDisplayStatus ( true );
175 } 175 }
176 void restore() 176 void restore()
177 { 177 {
178 if ( !m_lcd_status ) { // We must have turned it off 178 if ( !m_lcd_status ) { // We must have turned it off
179 ODevice::inst ( ) -> setDisplayStatus ( true ); 179 ODevice::inst ( ) -> setDisplayStatus ( true );
180 m_lcd_status = true; 180 m_lcd_status = true;
181 } 181 }
182 182
183 setBacklight ( -1 ); 183 setBacklight ( -1 );
184 } 184 }
185 bool save( int level ) 185 bool save( int level )
186 { 186 {
187 switch ( level ) { 187 switch ( level ) {
188 case 0: 188 case 0:
189 if ( m_disable_suspend > 0 && m_enable_dim ) { 189 if ( m_disable_suspend > 0 && m_enable_dim ) {
190 if ( backlight() > 1 ) 190 if ( backlight() > 1 )
191 setBacklight( 1 ); // lowest non-off 191 setBacklight( 1 ); // lowest non-off
192 } 192 }
193 return true; 193 return true;
194 break; 194 break;
195 case 1: 195 case 1:
196 if ( m_disable_suspend > 1 && m_enable_lightoff ) { 196 if ( m_disable_suspend > 1 && m_enable_lightoff ) {
197 setBacklight( 0 ); // off 197 setBacklight( 0 ); // off
198 } 198 }
199 return true; 199 return true;
200 break; 200 break;
201 case 2: 201 case 2:
202 if ( m_enable_onlylcdoff ) { 202 if ( m_enable_onlylcdoff ) {
203 ODevice::inst ( ) -> setDisplayStatus ( false ); 203 ODevice::inst ( ) -> setDisplayStatus ( false );
204 m_lcd_status = false; 204 m_lcd_status = false;
205 return true; 205 return true;
206 } 206 }
207 else // We're going to suspend the whole machine 207 else // We're going to suspend the whole machine
208 { 208 {
209 if ( ( m_disable_suspend > 2 ) && 209 if ( ( m_disable_suspend > 2 ) &&
210 ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && 210 ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) &&
211 ( !Network::networkOnline ( ) ) ) { 211 ( !Network::networkOnline ( ) ) ) {
212 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 212 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
213 return true; 213 return true;
214 } 214 }
215 } 215 }
216 break; 216 break;
217 } 217 }
218 return false; 218 return false;
219 } 219 }
220 220
221private: 221private:
222 static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) 222 static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def )
223 { 223 {
224 if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) 224 if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 )
225 return 0; 225 return 0;
226 226
227 if ( interval < 0 ) { 227 if ( interval < 0 ) {
228 // Restore screen blanking and power saving state 228 // Restore screen blanking and power saving state
229 interval = config.readNumEntry( value, def ); 229 interval = config.readNumEntry( value, def );
230 } 230 }
231 return interval; 231 return interval;
232 } 232 }
233 233
234public: 234public:
235 void setIntervals( int i1, int i2, int i3 ) 235 void setIntervals( int i1, int i2, int i3 )
236 { 236 {
237 Config config( "qpe" ); 237 Config config( "qpe" );
238 config.setGroup( "Screensaver" ); 238 config.setGroup( "Screensaver" );
239 239
240 int v[ 4 ]; 240 int v[ 4 ];
241 i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); 241 i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 );
242 i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); 242 i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 );
243 i3 = ssi( i3, config, "", "Interval", 60 ); 243 i3 = ssi( i3, config, "", "Interval", 60 );
244 244
245 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 245 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
246 246
247 v [ 0 ] = QMAX( 1000 * i1, 100 ); 247 v [ 0 ] = QMAX( 1000 * i1, 100 );
248 v [ 1 ] = QMAX( 1000 * i2, 100 ); 248 v [ 1 ] = QMAX( 1000 * i2, 100 );
249 v [ 2 ] = QMAX( 1000 * i3, 100 ); 249 v [ 2 ] = QMAX( 1000 * i3, 100 );
250 v [ 3 ] = 0; 250 v [ 3 ] = 0;
251 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); 251 m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false );
252 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); 252 m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false );
253 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); 253 m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 );
254 254
255 if ( !i1 && !i2 && !i3 ) 255 if ( !i1 && !i2 && !i3 )
256 QWSServer::setScreenSaverInterval( 0 ); 256 QWSServer::setScreenSaverInterval( 0 );
257 else 257 else
258 QWSServer::setScreenSaverIntervals( v ); 258 QWSServer::setScreenSaverIntervals( v );
259 } 259 }
260 260
261 void setInterval ( int interval ) 261 void setInterval ( int interval )
262 { 262 {
263 setIntervals ( -1, -1, interval ); 263 setIntervals ( -1, -1, interval );
264 } 264 }
265 265
266 void setMode ( int mode ) 266 void setMode ( int mode )
267 { 267 {
268 if ( mode > m_disable_suspend ) 268 if ( mode > m_disable_suspend )
269 setInterval( -1 ); 269 setInterval( -1 );
270 m_disable_suspend = mode; 270 m_disable_suspend = mode;
271 } 271 }
272 272
273 int backlight ( ) 273 int backlight ( )
274 { 274 {
275 if ( m_backlight_bright == -1 ) { 275 if ( m_backlight_bright == -1 ) {
276 // Read from config 276 // Read from config
277 Config config ( "qpe" ); 277 Config config ( "qpe" );
278 config. setGroup ( "Screensaver" ); 278 config. setGroup ( "Screensaver" );
279 m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); 279 m_backlight_bright = config. readNumEntry ( "Brightness", 255 );
280 } 280 }
281 return m_backlight_bright; 281 return m_backlight_bright;
282 } 282 }
283 283
284 void setBacklight ( int bright ) 284 void setBacklight ( int bright )
285 { 285 {
286 if ( bright == -3 ) { 286 if ( bright == -3 ) {
287 // Forced on 287 // Forced on
288 m_backlight_forcedoff = false; 288 m_backlight_forcedoff = false;
289 bright = -1; 289 bright = -1;
290 } 290 }
291 if ( m_backlight_forcedoff && bright != -2 ) 291 if ( m_backlight_forcedoff && bright != -2 )
292 return ; 292 return ;
293 if ( bright == -2 ) { 293 if ( bright == -2 ) {
294 // Toggle between off and on 294 // Toggle between off and on
295 bright = m_backlight_bright ? 0 : -1; 295 bright = m_backlight_bright ? 0 : -1;
296 m_backlight_forcedoff = !bright; 296 m_backlight_forcedoff = !bright;
297 } 297 }
298 298
299 m_backlight_bright = bright; 299 m_backlight_bright = bright;
300 300
301 bright = backlight ( ); 301 bright = backlight ( );
302 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 302 ODevice::inst ( ) -> setDisplayBrightness ( bright );
303 303
304 m_backlight_bright = bright; 304 m_backlight_bright = bright;
305 } 305 }
306 306
307 void setDisplayState ( bool on ) 307 void setDisplayState ( bool on )
308 { 308 {
309 if ( m_lcd_status != on ) { 309 if ( m_lcd_status != on ) {
310 ODevice::inst ( ) -> setDisplayStatus ( on ); 310 ODevice::inst ( ) -> setDisplayStatus ( on );
311 m_lcd_status = on; 311 m_lcd_status = on;
312 } 312 }
313 } 313 }
314 314
315private: 315private:
316 int m_disable_suspend; 316 int m_disable_suspend;
317 bool m_enable_dim; 317 bool m_enable_dim;
318 bool m_enable_lightoff; 318 bool m_enable_lightoff;
319 bool m_enable_onlylcdoff; 319 bool m_enable_onlylcdoff;
320 320
321 bool m_lcd_status; 321 bool m_lcd_status;
322 322
323 int m_backlight_bright; 323 int m_backlight_bright;
324 bool m_backlight_forcedoff; 324 bool m_backlight_forcedoff;
325}; 325};
326 326
327void DesktopApplication::switchLCD ( bool on ) 327void DesktopApplication::switchLCD ( bool on )
328{ 328{
329 if ( qApp ) { 329 if ( qApp ) {
330 DesktopApplication *dapp = (DesktopApplication *) qApp; 330 DesktopApplication *dapp = (DesktopApplication *) qApp;
331 331
332 if ( dapp-> m_screensaver ) { 332 if ( dapp-> m_screensaver ) {
333 if ( on ) { 333 if ( on ) {
334 dapp-> m_screensaver-> setDisplayState ( true ); 334 dapp-> m_screensaver-> setDisplayState ( true );
335 dapp-> m_screensaver-> setBacklight ( -3 ); 335 dapp-> m_screensaver-> setBacklight ( -3 );
336 } 336 }
337 else { 337 else {
338 dapp-> m_screensaver-> setDisplayState ( false ); 338 dapp-> m_screensaver-> setDisplayState ( false );
339 } 339 }
340 } 340 }
341 } 341 }
342} 342}
343 343
344 344
345DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 345DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
346 : QPEApplication( argc, argv, appType ) 346 : QPEApplication( argc, argv, appType )
347{ 347{
348 348
349 QTimer * t = new QTimer( this ); 349 QTimer * t = new QTimer( this );
350 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); 350 connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) );
351 t->start( 10000 ); 351 t->start( 10000 );
352 ps = new PowerStatus; 352 ps = new PowerStatus;
353 pa = new DesktopPowerAlerter( 0 ); 353 pa = new DesktopPowerAlerter( 0 );
354 354
355 channel = new QCopChannel( "QPE/Desktop", this ); 355 channel = new QCopChannel( "QPE/Desktop", this );
356 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 356 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
357 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); 357 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) );
358 358
359 channel = new QCopChannel( "QPE/System", this ); 359 channel = new QCopChannel( "QPE/System", this );
360 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 360 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
361 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 361 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
362 362
363 m_screensaver = new QPEScreenSaver; 363 m_screensaver = new QPEScreenSaver;
364 364
365 m_screensaver-> setInterval ( -1 ); 365 m_screensaver-> setInterval ( -1 );
366 QWSServer::setScreenSaver( m_screensaver ); 366 QWSServer::setScreenSaver( m_screensaver );
367} 367}
368 368
369 369
370DesktopApplication::~DesktopApplication() 370DesktopApplication::~DesktopApplication()
371{ 371{
372 delete ps; 372 delete ps;
373 delete pa; 373 delete pa;
374} 374}
375 375
376void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) 376void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data )
377{ 377{
378#ifdef Q_WS_QWS
379 QDataStream stream( data, IO_ReadOnly ); 378 QDataStream stream( data, IO_ReadOnly );
380 if ( msg == "keyRegister(int key, QString channel, QString message)" ) { 379 if ( msg == "keyRegister(int key, QString channel, QString message)" ) {
381 int k; 380 int k;
382 QString c, m; 381 QString c, m;
383 stream >> k; 382 stream >> k;
384 stream >> c; 383 stream >> c;
385 stream >> m; 384 stream >> m;
386 385
387 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); 386 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m );
388 keyRegisterList.append( QCopKeyRegister( k, c, m ) ); 387 keyRegisterList.append( QCopKeyRegister( k, c, m ) );
389 } 388 }
390#endif
391} 389}
392 390
393 391
394void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 392void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
395{ 393{
396#ifdef Q_WS_QWS
397 QDataStream stream ( data, IO_ReadOnly ); 394 QDataStream stream ( data, IO_ReadOnly );
398 395
399 if ( msg == "setScreenSaverInterval(int)" ) { 396 if ( msg == "setScreenSaverInterval(int)" ) {
400 int time; 397 int time;
401 stream >> time; 398 stream >> time;
402 m_screensaver-> setInterval( time ); 399 m_screensaver-> setInterval( time );
403 } 400 }
404 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 401 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
405 int t1, t2, t3; 402 int t1, t2, t3;
406 stream >> t1 >> t2 >> t3; 403 stream >> t1 >> t2 >> t3;
407 m_screensaver-> setIntervals( t1, t2, t3 ); 404 m_screensaver-> setIntervals( t1, t2, t3 );
408 } 405 }
409 else if ( msg == "setBacklight(int)" ) { 406 else if ( msg == "setBacklight(int)" ) {
410 int bright; 407 int bright;
411 stream >> bright; 408 stream >> bright;
412 m_screensaver-> setBacklight( bright ); 409 m_screensaver-> setBacklight( bright );
413 } 410 }
414 else if ( msg == "setScreenSaverMode(int)" ) { 411 else if ( msg == "setScreenSaverMode(int)" ) {
415 int mode; 412 int mode;
416 stream >> mode; 413 stream >> mode;
417 m_screensaver-> setMode ( mode ); 414 m_screensaver-> setMode ( mode );
418 } 415 }
419 else if ( msg == "setDisplayState(int)" ) { 416 else if ( msg == "setDisplayState(int)" ) {
420 int state; 417 int state;
421 stream >> state; 418 stream >> state;
422 m_screensaver-> setDisplayState ( state != 0 ); 419 m_screensaver-> setDisplayState ( state != 0 );
423 } 420 }
424 else if ( msg == "suspend()" ) { 421 else if ( msg == "suspend()" ) {
425 emit power(); 422 emit power();
426 } 423 }
427#endif
428} 424}
429 425
430enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 426enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
431 427
432#ifdef Q_WS_QWS 428#ifdef Q_WS_QWS
433bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 429bool DesktopApplication::qwsEventFilter( QWSEvent *e )
434{ 430{
435 qpedesktop->checkMemory(); 431 qpedesktop->checkMemory();
436 432
437 if ( e->type == QWSEvent::Key ) { 433 if ( e->type == QWSEvent::Key ) {
438 QWSKeyEvent * ke = ( QWSKeyEvent * ) e; 434 QWSKeyEvent * ke = ( QWSKeyEvent * ) e;
439 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 435 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
440 return TRUE; 436 return TRUE;
441 bool press = ke->simpleData.is_press; 437 bool press = ke->simpleData.is_press;
442 bool autoRepeat = ke->simpleData.is_auto_repeat; 438 bool autoRepeat = ke->simpleData.is_auto_repeat;
443 439
444 /* 440 /*
445 app that registers key/message to be sent back to the app, when it doesn't have focus, 441 app that registers key/message to be sent back to the app, when it doesn't have focus,
446 when user presses key, unless keyboard has been requested from app. 442 when user presses key, unless keyboard has been requested from app.
447 will not send multiple repeats if user holds key 443 will not send multiple repeats if user holds key
448 i.e. one shot 444 i.e. one shot
449 */ 445 */
450 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { 446 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) {
451// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); 447// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode);
452 KeyRegisterList::Iterator it; 448 KeyRegisterList::Iterator it;
453 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 449 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
454 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { 450 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) {
455 if ( press ) 451 if ( press )
456 qDebug( "press" ); 452 qDebug( "press" );
457 else 453 else
458 qDebug( "release" ); 454 qDebug( "release" );
459 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); 455 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() );
460 } 456 }
461 } 457 }
462 } 458 }
463 459
464 if ( !keyboardGrabbed() ) { 460 if ( !keyboardGrabbed() ) {
465 if ( ke->simpleData.keycode == Key_F9 ) { 461 if ( ke->simpleData.keycode == Key_F9 ) {
466 if ( press ) 462 if ( press )
467 emit datebook(); 463 emit datebook();
468 return TRUE; 464 return TRUE;
469 } 465 }
470 if ( ke->simpleData.keycode == Key_F10 ) { 466 if ( ke->simpleData.keycode == Key_F10 ) {
471 if ( !press && cardSendTimer ) { 467 if ( !press && cardSendTimer ) {
472 emit contacts(); 468 emit contacts();
473 delete cardSendTimer; 469 delete cardSendTimer;
474 } 470 }
475 else if ( press ) { 471 else if ( press ) {
476 cardSendTimer = new QTimer(); 472 cardSendTimer = new QTimer();
477 cardSendTimer->start( 2000, TRUE ); 473 cardSendTimer->start( 2000, TRUE );
478 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 474 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
479 } 475 }
480 return TRUE; 476 return TRUE;
481 } 477 }
482 /* menu key now opens application menu/toolbar 478 /* menu key now opens application menu/toolbar
483 if ( ke->simpleData.keycode == Key_F11 ) { 479 if ( ke->simpleData.keycode == Key_F11 ) {
484 if ( press ) emit menu(); 480 if ( press ) emit menu();
485 return TRUE; 481 return TRUE;
486 } 482 }
487 */ 483 */
488 if ( ke->simpleData.keycode == Key_F12 ) { 484 if ( ke->simpleData.keycode == Key_F12 ) {
489 while ( activePopupWidget() ) 485 while ( activePopupWidget() )
490 activePopupWidget() ->close(); 486 activePopupWidget() ->close();
491 if ( press ) 487 if ( press )
492 emit launch(); 488 emit launch();
493 return TRUE; 489 return TRUE;
494 } 490 }
495 if ( ke->simpleData.keycode == Key_F13 ) { 491 if ( ke->simpleData.keycode == Key_F13 ) {
496 if ( press ) 492 if ( press )
497 emit email(); 493 emit email();
498 return TRUE; 494 return TRUE;
499 } 495 }
500 } 496 }
501 497
502 if ( ke->simpleData.keycode == Key_F34 ) { 498 if ( ke->simpleData.keycode == Key_F34 ) {
503 if ( press ) 499 if ( press )
504 emit power(); 500 emit power();
505 return TRUE; 501 return TRUE;
506 } 502 }
507 // This was used for the iPAQ PowerButton 503 // This was used for the iPAQ PowerButton
508 // See main.cpp for new KeyboardFilter 504 // See main.cpp for new KeyboardFilter
509 // 505 //
510 // if ( ke->simpleData.keycode == Key_SysReq ) { 506 // if ( ke->simpleData.keycode == Key_SysReq ) {
511 // if ( press ) emit power(); 507 // if ( press ) emit power();
512 // return TRUE; 508 // return TRUE;
513 // } 509 // }
514 if ( ke->simpleData.keycode == Key_F35 ) { 510 if ( ke->simpleData.keycode == Key_F35 ) {
515 if ( press ) 511 if ( press )
516 emit backlight(); 512 emit backlight();
517 return TRUE; 513 return TRUE;
518 } 514 }
519 if ( ke->simpleData.keycode == Key_F32 ) { 515 if ( ke->simpleData.keycode == Key_F32 ) {
520 if ( press ) 516 if ( press )
521 QCopEnvelope e( "QPE/Desktop", "startSync()" ); 517 QCopEnvelope e( "QPE/Desktop", "startSync()" );
522 return TRUE; 518 return TRUE;
523 } 519 }
524 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 520 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
525 if ( press ) 521 if ( press )
526 emit symbol(); 522 emit symbol();
527 return TRUE; 523 return TRUE;
528 } 524 }
529 if ( ke->simpleData.keycode == Key_NumLock ) { 525 if ( ke->simpleData.keycode == Key_NumLock ) {
530 if ( press ) 526 if ( press )
531 emit numLockStateToggle(); 527 emit numLockStateToggle();
532 } 528 }
533 if ( ke->simpleData.keycode == Key_CapsLock ) { 529 if ( ke->simpleData.keycode == Key_CapsLock ) {
534 if ( press ) 530 if ( press )
535 emit capsLockStateToggle(); 531 emit capsLockStateToggle();
536 } 532 }
537 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) 533 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) )
538 qpedesktop->keyClick(); 534 qpedesktop->keyClick();
539 } 535 }
540 else { 536 else {
541 if ( e->type == QWSEvent::Mouse ) { 537 if ( e->type == QWSEvent::Mouse ) {
542 QWSMouseEvent * me = ( QWSMouseEvent * ) e; 538 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
543 static bool up = TRUE; 539 static bool up = TRUE;
544 if ( me->simpleData.state & LeftButton ) { 540 if ( me->simpleData.state & LeftButton ) {
545 if ( up ) { 541 if ( up ) {
546 up = FALSE; 542 up = FALSE;
547 qpedesktop->screenClick(); 543 qpedesktop->screenClick();
548 } 544 }
549 } 545 }
550 else { 546 else {
551 up = TRUE; 547 up = TRUE;
552 } 548 }
553 } 549 }
554 } 550 }
555 551
556 return QPEApplication::qwsEventFilter( e ); 552 return QPEApplication::qwsEventFilter( e );
557} 553}
558#endif 554#endif
559 555
560void DesktopApplication::psTimeout() 556void DesktopApplication::psTimeout()
561{ 557{
562 qpedesktop->checkMemory(); // in case no events are being generated 558 qpedesktop->checkMemory(); // in case no events are being generated
563 559
564 *ps = PowerStatusManager::readStatus(); 560 *ps = PowerStatusManager::readStatus();
565 561
566 if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { 562 if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) {
567 pa->alert( tr( "Battery is running very low." ), 6 ); 563 pa->alert( tr( "Battery is running very low." ), 6 );
568 } 564 }
569 565
570 if ( ps->batteryStatus() == PowerStatus::Critical ) { 566 if ( ps->batteryStatus() == PowerStatus::Critical ) {
571 pa->alert( tr( "Battery level is critical!\n" 567 pa->alert( tr( "Battery level is critical!\n"
572 "Keep power off until power restored!" ), 1 ); 568 "Keep power off until power restored!" ), 1 );
573 } 569 }
574 570
575 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 571 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
576 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 572 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
577 } 573 }
578} 574}
579 575
580 576
581void DesktopApplication::sendCard() 577void DesktopApplication::sendCard()
582{ 578{
583 delete cardSendTimer; 579 delete cardSendTimer;
584 cardSendTimer = 0; 580 cardSendTimer = 0;
585 QString card = getenv( "HOME" ); 581 QString card = getenv( "HOME" );
586 card += "/Applications/addressbook/businesscard.vcf"; 582 card += "/Applications/addressbook/businesscard.vcf";
587 583
588 if ( QFile::exists( card ) ) { 584 if ( QFile::exists( card ) ) {
589 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); 585 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" );
590 QString mimetype = "text/x-vCard"; 586 QString mimetype = "text/x-vCard";
591 e << tr( "business card" ) << card << mimetype; 587 e << tr( "business card" ) << card << mimetype;
592 } 588 }
593} 589}
594 590
595#if defined(QPE_HAVE_MEMALERTER) 591#if defined(QPE_HAVE_MEMALERTER)
596QPE_MEMALERTER_IMPL 592QPE_MEMALERTER_IMPL
597#endif 593#endif
598 594
599//=========================================================================== 595//===========================================================================
600 596
601Desktop::Desktop() : 597Desktop::Desktop() :
602 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 598 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
603 qcopBridge( 0 ), 599 qcopBridge( 0 ),
604 transferServer( 0 ), 600 transferServer( 0 ),
605 packageSlave( 0 ) 601 packageSlave( 0 )
606{ 602{
607 qpedesktop = this; 603 qpedesktop = this;
608 604
609 // bg = new Info( this ); 605 // bg = new Info( this );
610 tb = new TaskBar; 606 tb = new TaskBar;
611 607
612 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 608 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
613 609
614 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); 610 connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) );
615 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); 611 connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) );
616 612
617 int displayw = qApp->desktop() ->width(); 613 int displayw = qApp->desktop() ->width();
618 int displayh = qApp->desktop() ->height(); 614 int displayh = qApp->desktop() ->height();
619 615
620 616
621 QSize sz = tb->sizeHint(); 617 QSize sz = tb->sizeHint();
622 618
623 setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 619 setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
624 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 620 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
625 621
626 tb->show(); 622 tb->show();
627 launcher->showMaximized(); 623 launcher->showMaximized();
628 launcher->show(); 624 launcher->show();
629 launcher->raise(); 625 launcher->raise();
630#if defined(QPE_HAVE_MEMALERTER) 626#if defined(QPE_HAVE_MEMALERTER)
631 627
632 initMemalerter(); 628 initMemalerter();
633#endif 629#endif
634 // start services 630 // start services
635 startTransferServer(); 631 startTransferServer();
636 ( void ) new IrServer( this ); 632 ( void ) new IrServer( this );
637 rereadVolumes(); 633 rereadVolumes();
638 634
639 packageSlave = new PackageSlave( this ); 635 packageSlave = new PackageSlave( this );
640 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); 636 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
641 637
642 qApp->installEventFilter( this ); 638 qApp->installEventFilter( this );
643 639
644 qApp-> setMainWidget ( launcher ); 640 qApp-> setMainWidget ( launcher );
645} 641}
646 642
647void Desktop::show() 643void Desktop::show()
648{ 644{
649 login( TRUE ); 645 login( TRUE );
650 QWidget::show(); 646 QWidget::show();
651} 647}
652 648
653Desktop::~Desktop() 649Desktop::~Desktop()
654{ 650{
655 delete launcher; 651 delete launcher;
656 delete tb; 652 delete tb;
657 delete qcopBridge; 653 delete qcopBridge;
658 delete transferServer; 654 delete transferServer;
659} 655}
660 656
661bool Desktop::recoverMemory() 657bool Desktop::recoverMemory()
662{ 658{
663 return tb->recoverMemory(); 659 return tb->recoverMemory();
664} 660}
665 661
666void Desktop::checkMemory() 662void Desktop::checkMemory()
667{ 663{
668#if defined(QPE_HAVE_MEMALERTER) 664#if defined(QPE_HAVE_MEMALERTER)
669 static bool ignoreNormal = FALSE; 665 static bool ignoreNormal = FALSE;
670 static bool existingMessage = FALSE; 666 static bool existingMessage = FALSE;
671 667
672 if ( existingMessage ) 668 if ( existingMessage )
673 return ; // don't show a second message while still on first 669 return ; // don't show a second message while still on first
674 670
675 existingMessage = TRUE; 671 existingMessage = TRUE;
676 switch ( memstate ) { 672 switch ( memstate ) {
677 case Unknown: 673 case Unknown:
678 break; 674 break;
679 case Low: 675 case Low:
680 memstate = Unknown; 676 memstate = Unknown;
681 if ( recoverMemory() ) 677 if ( recoverMemory() )
682 ignoreNormal = TRUE; 678 ignoreNormal = TRUE;
683 else 679 else
684 QMessageBox::warning( 0 , "Memory Status", 680 QMessageBox::warning( 0 , "Memory Status",
685 "The memory smacks of shortage. \n" 681 "The memory smacks of shortage. \n"
686 "Please save data. " ); 682 "Please save data. " );
687 break; 683 break;
688 case Normal: 684 case Normal:
689 memstate = Unknown; 685 memstate = Unknown;
690 if ( ignoreNormal ) 686 if ( ignoreNormal )
691 ignoreNormal = FALSE; 687 ignoreNormal = FALSE;
692// else 688// else
693// QMessageBox::information ( 0 , "Memory Status", 689// QMessageBox::information ( 0 , "Memory Status",
694// "There is enough memory again." ); 690// "There is enough memory again." );
695 break; 691 break;
696 case VeryLow: 692 case VeryLow:
697 memstate = Unknown; 693 memstate = Unknown;
698 QMessageBox::critical( 0 , "Memory Status", 694 QMessageBox::critical( 0 , "Memory Status",
699 "The memory is very low. \n" 695 "The memory is very low. \n"
700 "Please end this application \n" 696 "Please end this application \n"
701 "immediately." ); 697 "immediately." );
702 recoverMemory(); 698 recoverMemory();
703 } 699 }
704 existingMessage = FALSE; 700 existingMessage = FALSE;
705#endif 701#endif
706} 702}
707 703
708static bool isVisibleWindow( int wid ) 704static bool isVisibleWindow( int wid )
709{ 705{
710#ifdef QWS 706#ifdef QWS
711 const QList<QWSWindow> &list = qwsServer->clientWindows(); 707 const QList<QWSWindow> &list = qwsServer->clientWindows();
712 QWSWindow* w; 708 QWSWindow* w;
713 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 709 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
714 if ( w->winId() == wid ) 710 if ( w->winId() == wid )
715 return !w->isFullyObscured(); 711 return !w->isFullyObscured();
716 } 712 }
717#endif 713#endif
718 return FALSE; 714 return FALSE;
719} 715}
720 716
721static bool hasVisibleWindow( const QString& clientname ) 717static bool hasVisibleWindow( const QString& clientname )
722{ 718{
723#ifdef QWS 719#ifdef QWS
724 const QList<QWSWindow> &list = qwsServer->clientWindows(); 720 const QList<QWSWindow> &list = qwsServer->clientWindows();
725 QWSWindow* w; 721 QWSWindow* w;
726 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 722 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
727 if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) 723 if ( w->client() ->identity() == clientname && !w->isFullyObscured() )
728 return TRUE; 724 return TRUE;
729 } 725 }
730#endif 726#endif
731 return FALSE; 727 return FALSE;
732} 728}
733 729
734void Desktop::raiseLauncher() 730void Desktop::raiseLauncher()
735{ 731{
736 Config cfg( "qpe" ); //F12 'Home' 732 Config cfg( "qpe" ); //F12 'Home'
737 cfg.setGroup( "AppsKey" ); 733 cfg.setGroup( "AppsKey" );
738 QString tempItem; 734 QString tempItem;
739 tempItem = cfg.readEntry( "Middle", "Home" ); 735 tempItem = cfg.readEntry( "Middle", "Home" );
740 if ( tempItem == "Home" || tempItem.isEmpty() ) { 736 if ( tempItem == "Home" || tempItem.isEmpty() ) {
741 home ( ); 737 home ( );
742 } 738 }
743 else { 739 else {
744 QCopEnvelope e( "QPE/System", "execute(QString)" ); 740 QCopEnvelope e( "QPE/System", "execute(QString)" );
745 e << tempItem; 741 e << tempItem;
746 } 742 }
747} 743}
748 744
749void Desktop::home ( ) 745void Desktop::home ( )
750{ 746{
751 if ( isVisibleWindow( launcher->winId() ) ) 747 if ( isVisibleWindow( launcher->winId() ) )
752 launcher->nextView(); 748 launcher->nextView();
753 else 749 else
754 launcher->raise(); 750 launcher->raise();
755} 751}
756 752
757void Desktop::executeOrModify( const QString& appLnkFile ) 753void Desktop::executeOrModify( const QString& appLnkFile )
758{ 754{
759 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); 755 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile );
760 if ( lnk.isValid() ) { 756 if ( lnk.isValid() ) {
761 QCString app = lnk.exec().utf8(); 757 QCString app = lnk.exec().utf8();
762 Global::terminateBuiltin( "calibrate" ); 758 Global::terminateBuiltin( "calibrate" );
763 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { 759 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) {
764 // MRUList::addTask( &lnk ); 760 // MRUList::addTask( &lnk );
765 if ( hasVisibleWindow( app ) ) 761 if ( hasVisibleWindow( app ) )
766 QCopChannel::send( "QPE/Application/" + app, "nextView()" ); 762 QCopChannel::send( "QPE/Application/" + app, "nextView()" );
767 else 763 else
768 QCopChannel::send( "QPE/Application/" + app, "raise()" ); 764 QCopChannel::send( "QPE/Application/" + app, "raise()" );
769 } 765 }
770 else { 766 else {
771 lnk.execute(); 767 lnk.execute();
772 } 768 }
773 } 769 }
774} 770}
775 771
776void Desktop::raiseDatebook() 772void Desktop::raiseDatebook()
777{ 773{
778 Config cfg( "qpe" ); //F9 'Activity' 774 Config cfg( "qpe" ); //F9 'Activity'
779 cfg.setGroup( "AppsKey" ); 775 cfg.setGroup( "AppsKey" );
780 QString tempItem; 776 QString tempItem;
781 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); 777 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" );
782 if ( tempItem == "Calendar" || tempItem.isEmpty() ) { 778 if ( tempItem == "Calendar" || tempItem.isEmpty() ) {
783 tempItem = "datebook"; 779 tempItem = "datebook";
784 } 780 }
785 QCopEnvelope e( "QPE/System", "execute(QString)" ); 781 QCopEnvelope e( "QPE/System", "execute(QString)" );
786 e << tempItem; 782 e << tempItem;
787} 783}
788 784
789void Desktop::raiseContacts() 785void Desktop::raiseContacts()
790{ 786{
791 Config cfg( "qpe" ); //F10, 'Contacts' 787 Config cfg( "qpe" ); //F10, 'Contacts'
792 cfg.setGroup( "AppsKey" ); 788 cfg.setGroup( "AppsKey" );
793 QString tempItem; 789 QString tempItem;
794 tempItem = cfg.readEntry( "Left2nd", "Address Book" ); 790 tempItem = cfg.readEntry( "Left2nd", "Address Book" );
795 if ( tempItem == "Address Book" || tempItem.isEmpty() ) { 791 if ( tempItem == "Address Book" || tempItem.isEmpty() ) {
796 tempItem = "addressbook"; 792 tempItem = "addressbook";
797 } 793 }
798 QCopEnvelope e( "QPE/System", "execute(QString)" ); 794 QCopEnvelope e( "QPE/System", "execute(QString)" );
799 e << tempItem; 795 e << tempItem;
800} 796}
801 797
802void Desktop::raiseMenu() 798void Desktop::raiseMenu()
803{ 799{
804 Config cfg( "qpe" ); //F11, 'Menu 800 Config cfg( "qpe" ); //F11, 'Menu
805 cfg.setGroup( "AppsKey" ); 801 cfg.setGroup( "AppsKey" );
806 QString tempItem; 802 QString tempItem;
807 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); 803 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" );
808 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { 804 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) {
809 Global::terminateBuiltin( "calibrate" ); 805 Global::terminateBuiltin( "calibrate" );
810 tb->startMenu() ->launch(); 806 tb->startMenu() ->launch();
811 } 807 }
812 else { 808 else {
813 QCopEnvelope e( "QPE/System", "execute(QString)" ); 809 QCopEnvelope e( "QPE/System", "execute(QString)" );
814 e << tempItem; 810 e << tempItem;
815 } 811 }
816} 812}
817 813
818void Desktop::raiseEmail() 814void Desktop::raiseEmail()
819{ 815{
820 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 816 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11
821 cfg.setGroup( "AppsKey" ); 817 cfg.setGroup( "AppsKey" );
822 QString tempItem; 818 QString tempItem;
823 tempItem = cfg.readEntry( "RightEnd", "Mail" ); 819 tempItem = cfg.readEntry( "RightEnd", "Mail" );
824 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { 820 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) {
825 tempItem = "mail"; 821 tempItem = "mail";
826 } 822 }
827 QCopEnvelope e( "QPE/System", "execute(QString)" ); 823 QCopEnvelope e( "QPE/System", "execute(QString)" );
828 e << tempItem; 824 e << tempItem;
829} 825}
830 826
831// autoStarts apps on resume and start 827// autoStarts apps on resume and start
832void Desktop::execAutoStart() 828void Desktop::execAutoStart()
833{ 829{
834 QString appName; 830 QString appName;
835 int delay; 831 int delay;
836 QDateTime now = QDateTime::currentDateTime(); 832 QDateTime now = QDateTime::currentDateTime();
837 Config cfg( "autostart" ); 833 Config cfg( "autostart" );
838 cfg.setGroup( "AutoStart" ); 834 cfg.setGroup( "AutoStart" );
839 appName = cfg.readEntry( "Apps", "" ); 835 appName = cfg.readEntry( "Apps", "" );
840 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 836 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
841 // If the time between suspend and resume was longer then the 837 // If the time between suspend and resume was longer then the
842 // value saved as delay, start the app 838 // value saved as delay, start the app
843 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 839 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
844 QCopEnvelope e( "QPE/System", "execute(QString)" ); 840 QCopEnvelope e( "QPE/System", "execute(QString)" );
845 e << QString( appName ); 841 e << QString( appName );
846 } 842 }
847} 843}
848 844
849#if defined(QPE_HAVE_TOGGLELIGHT) 845#if defined(QPE_HAVE_TOGGLELIGHT)
850#include <qpe/config.h> 846#include <qpe/config.h>
851 847
852#include <sys/ioctl.h> 848#include <sys/ioctl.h>
853#include <sys/types.h> 849#include <sys/types.h>
854#include <fcntl.h> 850#include <fcntl.h>
855#include <unistd.h> 851#include <unistd.h>
856#include <errno.h> 852#include <errno.h>
857#include <linux/ioctl.h> 853#include <linux/ioctl.h>
858#include <time.h> 854#include <time.h>
859#endif 855#endif
860 856
861 857
862void Desktop::togglePower() 858void Desktop::togglePower()
863{ 859{
864 static bool excllock = false; 860 static bool excllock = false;
865 861
866 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); 862 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 );
867 863
868 if ( excllock ) 864 if ( excllock )
869 return; 865 return;
870 866
871 excllock = true; 867 excllock = true;
872 868
873 bool wasloggedin = loggedin; 869 bool wasloggedin = loggedin;
874 loggedin = 0; 870 loggedin = 0;
875 suspendTime = QDateTime::currentDateTime(); 871 suspendTime = QDateTime::currentDateTime();
876 872
877#ifdef QWS 873#ifdef QWS
878 if ( Password::needToAuthenticate ( true ) && qt_screen ) { 874 if ( Password::needToAuthenticate ( true ) && qt_screen ) {
879 // Should use a big black window instead. 875 // Should use a big black window instead.
880 // But this would not show up fast enough 876 // But this would not show up fast enough
881 QGfx *g = qt_screen-> screenGfx ( ); 877 QGfx *g = qt_screen-> screenGfx ( );
882 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); 878 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
883 delete g; 879 delete g;
884 } 880 }
885#endif 881#endif
886 882
887 ODevice::inst ( )-> suspend ( ); 883 ODevice::inst ( )-> suspend ( );
888 884
889 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 885 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
890 QWSServer::screenSaverActivate ( false ); 886 QWSServer::screenSaverActivate ( false );
891 887
892 { 888 {
893 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 889 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
894 } 890 }
895 891
896 if ( wasloggedin ) 892 if ( wasloggedin )
897 login ( true ); 893 login ( true );
898 894
899 execAutoStart(); 895 execAutoStart();
900 //qcopBridge->closeOpenConnections(); 896 //qcopBridge->closeOpenConnections();
901 897
902 excllock = false; 898 excllock = false;
903} 899}
904 900
905void Desktop::toggleLight() 901void Desktop::toggleLight()
906{ 902{
907 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 903 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
908 e << -2; // toggle 904 e << -2; // toggle
909} 905}
910 906
911void Desktop::toggleSymbolInput() 907void Desktop::toggleSymbolInput()
912{ 908{
913 tb->toggleSymbolInput(); 909 tb->toggleSymbolInput();
914} 910}
915 911
916void Desktop::toggleNumLockState() 912void Desktop::toggleNumLockState()
917{ 913{
918 tb->toggleNumLockState(); 914 tb->toggleNumLockState();
919} 915}
920 916
921void Desktop::toggleCapsLockState() 917void Desktop::toggleCapsLockState()
922{ 918{
923 tb->toggleCapsLockState(); 919 tb->toggleCapsLockState();
924} 920}
925 921
926void Desktop::styleChange( QStyle &s ) 922void Desktop::styleChange( QStyle &s )
927{ 923{
928 QWidget::styleChange( s ); 924 QWidget::styleChange( s );
929 int displayw = qApp->desktop() ->width(); 925 int displayw = qApp->desktop() ->width();
930 int displayh = qApp->desktop() ->height(); 926 int displayh = qApp->desktop() ->height();
931 927
932 QSize sz = tb->sizeHint(); 928 QSize sz = tb->sizeHint();
933 929
934 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 930 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
935} 931}
936 932
937void DesktopApplication::shutdown() 933void DesktopApplication::shutdown()
938{ 934{
939 if ( type() != GuiServer ) 935 if ( type() != GuiServer )
940 return ; 936 return ;
941 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 937 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
942 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), 938 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
943 this, SLOT( shutdown( ShutdownImpl::Type ) ) ); 939 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
944 sd->showMaximized(); 940 sd->showMaximized();
945} 941}
946 942
947void DesktopApplication::shutdown( ShutdownImpl::Type t ) 943void DesktopApplication::shutdown( ShutdownImpl::Type t )
948{ 944{
949 switch ( t ) { 945 switch ( t ) {
950 case ShutdownImpl::ShutdownSystem: 946 case ShutdownImpl::ShutdownSystem:
951 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); 947 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 );
952 break; 948 break;
953 case ShutdownImpl::RebootSystem: 949 case ShutdownImpl::RebootSystem:
954 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); 950 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 );
955 break; 951 break;
956 case ShutdownImpl::RestartDesktop: 952 case ShutdownImpl::RestartDesktop:
957 restart(); 953 restart();
958 break; 954 break;
959 case ShutdownImpl::TerminateDesktop: 955 case ShutdownImpl::TerminateDesktop:
960 prepareForTermination( FALSE ); 956 prepareForTermination( FALSE );
961 957
962 // This is a workaround for a Qt bug 958 // This is a workaround for a Qt bug
963 // clipboard applet has to stop its poll timer, or Qt/E 959 // clipboard applet has to stop its poll timer, or Qt/E
964 // will hang on quit() right before it emits aboutToQuit() 960 // will hang on quit() right before it emits aboutToQuit()
965 emit aboutToQuit ( ); 961 emit aboutToQuit ( );
966 962
967 quit(); 963 quit();
968 break; 964 break;
969 } 965 }
970} 966}
971 967
972void DesktopApplication::restart() 968void DesktopApplication::restart()
973{ 969{
974 prepareForTermination( TRUE ); 970 prepareForTermination( TRUE );
975 971
976#ifdef Q_WS_QWS 972#ifdef Q_WS_QWS
977 973
978 for ( int fd = 3; fd < 100; fd++ ) 974 for ( int fd = 3; fd < 100; fd++ )
979 close( fd ); 975 close( fd );
980#if defined(QT_DEMO_SINGLE_FLOPPY) 976#if defined(QT_DEMO_SINGLE_FLOPPY)
981 977
982 execl( "/sbin/init", "qpe", 0 ); 978 execl( "/sbin/init", "qpe", 0 );
983#elif defined(QT_QWS_CASSIOPEIA) 979#elif defined(QT_QWS_CASSIOPEIA)
984 980
985 execl( "/bin/sh", "sh", 0 ); 981 execl( "/bin/sh", "sh", 0 );
986#else 982#else
987 983
988 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 984 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
989#endif 985#endif
990 986
991 exit( 1 ); 987 exit( 1 );
992#endif 988#endif
993} 989}
994 990
995void Desktop::startTransferServer() 991void Desktop::startTransferServer()
996{ 992{
997 // start qcop bridge server 993 // start qcop bridge server
998 qcopBridge = new QCopBridge( 4243 ); 994 qcopBridge = new QCopBridge( 4243 );
999 if ( !qcopBridge->ok() ) { 995 if ( !qcopBridge->ok() ) {
1000 delete qcopBridge; 996 delete qcopBridge;
1001 qcopBridge = 0; 997 qcopBridge = 0;
1002 } 998 }
1003 // start transfer server 999 // start transfer server
1004 transferServer = new TransferServer( 4242 ); 1000 transferServer = new TransferServer( 4242 );
1005 if ( !transferServer->ok() ) { 1001 if ( !transferServer->ok() ) {
1006 delete transferServer; 1002 delete transferServer;
1007 transferServer = 0; 1003 transferServer = 0;
1008 } 1004 }
1009 if ( !transferServer || !qcopBridge ) 1005 if ( !transferServer || !qcopBridge )
1010 startTimer( 2000 ); 1006 startTimer( 2000 );
1011} 1007}
1012 1008
1013void Desktop::timerEvent( QTimerEvent *e ) 1009void Desktop::timerEvent( QTimerEvent *e )
1014{ 1010{
1015 killTimer( e->timerId() ); 1011 killTimer( e->timerId() );
1016 startTransferServer(); 1012 startTransferServer();
1017} 1013}
1018 1014
1019void Desktop::terminateServers() 1015void Desktop::terminateServers()
1020{ 1016{
1021 delete transferServer; 1017 delete transferServer;
1022 delete qcopBridge; 1018 delete qcopBridge;
1023 transferServer = 0; 1019 transferServer = 0;
1024 qcopBridge = 0; 1020 qcopBridge = 0;
1025} 1021}
1026 1022
1027void Desktop::rereadVolumes() 1023void Desktop::rereadVolumes()
1028{ 1024{
1029 Config cfg( "qpe" ); 1025 Config cfg( "qpe" );
1030 cfg.setGroup( "Volume" ); 1026 cfg.setGroup( "Volume" );
1031 touchclick = cfg.readBoolEntry( "TouchSound" ); 1027 touchclick = cfg.readBoolEntry( "TouchSound" );
1032 keyclick = cfg.readBoolEntry( "KeySound" ); 1028 keyclick = cfg.readBoolEntry( "KeySound" );
1033 alarmsound = cfg.readBoolEntry( "AlarmSound" ); 1029 alarmsound = cfg.readBoolEntry( "AlarmSound" );
1034} 1030}
1035 1031
1036void Desktop::keyClick() 1032void Desktop::keyClick()
1037{ 1033{
1038 if ( keyclick ) 1034 if ( keyclick )
1039 ODevice::inst ( ) -> keySound ( ); 1035 ODevice::inst ( ) -> keySound ( );
1040} 1036}
1041 1037
1042void Desktop::screenClick() 1038void Desktop::screenClick()
1043{ 1039{
1044 if ( touchclick ) 1040 if ( touchclick )
1045 ODevice::inst ( ) -> touchSound ( ); 1041 ODevice::inst ( ) -> touchSound ( );
1046} 1042}
1047 1043
1048void Desktop::soundAlarm() 1044void Desktop::soundAlarm()
1049{ 1045{
1050 if ( qpedesktop-> alarmsound ) 1046 if ( qpedesktop-> alarmsound )
1051 ODevice::inst ( ) -> alarmSound ( ); 1047 ODevice::inst ( ) -> alarmSound ( );
1052} 1048}
1053 1049
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index a5955a4..5a9ee1b 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,1250 +1,1250 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT 21// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
22// have this class. 22// have this class.
23#define QTOPIA_INTERNAL_FSLP 23#define QTOPIA_INTERNAL_FSLP
24 24
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/applnk.h> 27#include <qpe/applnk.h>
28#include <qpe/config.h> 28#include <qpe/config.h>
29#include <qpe/global.h> 29#include <qpe/global.h>
30#include <qpe/qpeapplication.h> 30#include <qpe/qpeapplication.h>
31#include <qpe/mimetype.h> 31#include <qpe/mimetype.h>
32#include <qpe/storage.h> 32#include <qpe/storage.h>
33#include <qpe/palmtoprecord.h> 33#include <qpe/palmtoprecord.h>
34 34
35#include <qpe/version.h> 35#include <qpe/version.h>
36 36
37#include <qdir.h> 37#include <qdir.h>
38#ifdef QWS 38#ifdef QWS
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#endif 40#endif
41#include <qtimer.h> 41#include <qtimer.h>
42#include <qcombobox.h> 42#include <qcombobox.h>
43#include <qvbox.h> 43#include <qvbox.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qstyle.h> 45#include <qstyle.h>
46#include <qpushbutton.h> 46#include <qpushbutton.h>
47#include <qtabbar.h> 47#include <qtabbar.h>
48#include <qwidgetstack.h> 48#include <qwidgetstack.h>
49#include <qlayout.h> 49#include <qlayout.h>
50#include <qregexp.h> 50#include <qregexp.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qframe.h> 52#include <qframe.h>
53#include <qpainter.h> 53#include <qpainter.h>
54#include <qlabel.h> 54#include <qlabel.h>
55#include <qtextstream.h> 55#include <qtextstream.h>
56#include <qpopupmenu.h> 56#include <qpopupmenu.h>
57 57
58#include "launcherview.h" 58#include "launcherview.h"
59#include "launcher.h" 59#include "launcher.h"
60#include "syncdialog.h" 60#include "syncdialog.h"
61#include "desktop.h" 61#include "desktop.h"
62#include <qpe/lnkproperties.h> 62#include <qpe/lnkproperties.h>
63//#include "mrulist.h" 63//#include "mrulist.h"
64#include "qrsync.h" 64#include "qrsync.h"
65#include <stdlib.h> 65#include <stdlib.h>
66#include <unistd.h> 66#include <unistd.h>
67 67
68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 68#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
69#include <stdio.h> 69#include <stdio.h>
70#include <sys/vfs.h> 70#include <sys/vfs.h>
71#include <mntent.h> 71#include <mntent.h>
72#endif 72#endif
73 73
74#include <qpe/storage.h> 74#include <qpe/storage.h>
75#include "mediummountgui.h" 75#include "mediummountgui.h"
76 76
77namespace { 77namespace {
78 QStringList configToMime( Config *cfg ){ 78 QStringList configToMime( Config *cfg ){
79 QStringList mimes; 79 QStringList mimes;
80 bool tmpMime = true; 80 bool tmpMime = true;
81 cfg->setGroup("mimetypes" ); 81 cfg->setGroup("mimetypes" );
82 tmpMime = cfg->readBoolEntry("all" ,true); 82 tmpMime = cfg->readBoolEntry("all" ,true);
83 if( tmpMime ){ 83 if( tmpMime ){
84 mimes << QString::null; 84 mimes << QString::null;
85 return mimes; 85 return mimes;
86 }else{ 86 }else{
87 tmpMime = cfg->readBoolEntry("audio", true ); 87 tmpMime = cfg->readBoolEntry("audio", true );
88 if(tmpMime ) 88 if(tmpMime )
89 mimes.append("audio/*" ); 89 mimes.append("audio/*" );
90 90
91 tmpMime = cfg->readBoolEntry("image", true ); 91 tmpMime = cfg->readBoolEntry("image", true );
92 if(tmpMime ) 92 if(tmpMime )
93 mimes.append("image/*" ); 93 mimes.append("image/*" );
94 94
95 tmpMime = cfg->readBoolEntry("text", true ); 95 tmpMime = cfg->readBoolEntry("text", true );
96 if(tmpMime ) 96 if(tmpMime )
97 mimes.append("text/*"); 97 mimes.append("text/*");
98 98
99 tmpMime = cfg->readBoolEntry("video", true ); 99 tmpMime = cfg->readBoolEntry("video", true );
100 if(tmpMime ) 100 if(tmpMime )
101 mimes.append("video/*" ); 101 mimes.append("video/*" );
102 } 102 }
103 return mimes; 103 return mimes;
104 } 104 }
105 105
106} 106}
107 107
108 108
109 109
110//#define SHOW_ALL 110//#define SHOW_ALL
111 111
112class CategoryTab : public QTab 112class CategoryTab : public QTab
113{ 113{
114public: 114public:
115 CategoryTab( const QIconSet &icon, const QString &text=QString::null ) 115 CategoryTab( const QIconSet &icon, const QString &text=QString::null )
116 : QTab( icon, text ) 116 : QTab( icon, text )
117 { 117 {
118 } 118 }
119 119
120 QColor bgColor; 120 QColor bgColor;
121 QColor fgColor; 121 QColor fgColor;
122}; 122};
123 123
124//=========================================================================== 124//===========================================================================
125 125
126CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 126CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
127 QVBox( parent ) 127 QVBox( parent )
128{ 128{
129 categoryBar = 0; 129 categoryBar = 0;
130 stack = 0; 130 stack = 0;
131} 131}
132 132
133void CategoryTabWidget::prevTab() 133void CategoryTabWidget::prevTab()
134{ 134{
135 if ( categoryBar ) { 135 if ( categoryBar ) {
136 int n = categoryBar->count(); 136 int n = categoryBar->count();
137 int tab = categoryBar->currentTab(); 137 int tab = categoryBar->currentTab();
138 if ( tab >= 0 ) 138 if ( tab >= 0 )
139 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 139 categoryBar->setCurrentTab( (tab - 1 + n)%n );
140 } 140 }
141} 141}
142 142
143void CategoryTabWidget::nextTab() 143void CategoryTabWidget::nextTab()
144{ 144{
145 if ( categoryBar ) { 145 if ( categoryBar ) {
146 int n = categoryBar->count(); 146 int n = categoryBar->count();
147 int tab = categoryBar->currentTab(); 147 int tab = categoryBar->currentTab();
148 categoryBar->setCurrentTab( (tab + 1)%n ); 148 categoryBar->setCurrentTab( (tab + 1)%n );
149 } 149 }
150} 150}
151 151
152void CategoryTabWidget::addItem( const QString& linkfile ) 152void CategoryTabWidget::addItem( const QString& linkfile )
153{ 153{
154 int i=0; 154 int i=0;
155 AppLnk *app = new AppLnk(linkfile); 155 AppLnk *app = new AppLnk(linkfile);
156 if ( !app->isValid() ) { 156 if ( !app->isValid() ) {
157 delete app; 157 delete app;
158 app=0; 158 app=0;
159 } 159 }
160 if ( !app || !app->file().isEmpty() ) { 160 if ( !app || !app->file().isEmpty() ) {
161 // A document 161 // A document
162 delete app; 162 delete app;
163 app = new DocLnk(linkfile); 163 app = new DocLnk(linkfile);
164 if ( app->fileKnown() ) { 164 if ( app->fileKnown() ) {
165 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); 165 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app);
166 } else { 166 } else {
167 ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); 167 ((LauncherView*)(stack->widget(ids.count()-1)))->sort();
168 delete app; 168 delete app;
169 } 169 }
170 return; 170 return;
171 } 171 }
172 // An application 172 // An application
173 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { 173 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) {
174 if ( !(*it).isEmpty() ) { 174 if ( !(*it).isEmpty() ) {
175 QRegExp tf(*it,FALSE,TRUE); 175 QRegExp tf(*it,FALSE,TRUE);
176 if ( tf.match(app->type()) >= 0 ) { 176 if ( tf.match(app->type()) >= 0 ) {
177 ((LauncherView*)stack->widget(i))->addItem(app); 177 ((LauncherView*)stack->widget(i))->addItem(app);
178 return; 178 return;
179 } 179 }
180 i++; 180 i++;
181 } 181 }
182 } 182 }
183 183
184 QCopEnvelope e("QPE/TaskBar","reloadApps()"); 184 QCopEnvelope e("QPE/TaskBar","reloadApps()");
185} 185}
186 186
187void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, 187void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
188 AppLnkSet* docFolder, const QList<FileSystem> &fs) 188 AppLnkSet* docFolder, const QList<FileSystem> &fs)
189{ 189{
190 delete categoryBar; 190 delete categoryBar;
191 categoryBar = new CategoryTabBar( this ); 191 categoryBar = new CategoryTabBar( this );
192 QPalette pal = categoryBar->palette(); 192 QPalette pal = categoryBar->palette();
193 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 193 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
194 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 194 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
195 categoryBar->setPalette( pal ); 195 categoryBar->setPalette( pal );
196 196
197 delete stack; 197 delete stack;
198 stack = new QWidgetStack(this); 198 stack = new QWidgetStack(this);
199 tabs=0; 199 tabs=0;
200 200
201 ids.clear(); 201 ids.clear();
202 202
203 Config cfg("Launcher"); 203 Config cfg("Launcher");
204 204
205 QStringList types = rootFolder->types(); 205 QStringList types = rootFolder->types();
206 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 206 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
207 if ( !(*it).isEmpty() ) { 207 if ( !(*it).isEmpty() ) {
208 (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); 208 (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it));
209 setTabAppearance( *it, cfg ); 209 setTabAppearance( *it, cfg );
210 } 210 }
211 } 211 }
212 QListIterator<AppLnk> it( rootFolder->children() ); 212 QListIterator<AppLnk> it( rootFolder->children() );
213 AppLnk* l; 213 AppLnk* l;
214 while ( (l=it.current()) ) { 214 while ( (l=it.current()) ) {
215 if ( l->type() == "Separator" ) { // No tr 215 if ( l->type() == "Separator" ) { // No tr
216 rootFolder->remove(l); 216 rootFolder->remove(l);
217 delete l; 217 delete l;
218 } else { 218 } else {
219 int i=0; 219 int i=0;
220 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 220 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
221 if ( *it == l->type() ) 221 if ( *it == l->type() )
222 ((LauncherView*)stack->widget(i))->addItem(l,FALSE); 222 ((LauncherView*)stack->widget(i))->addItem(l,FALSE);
223 i++; 223 i++;
224 } 224 }
225 } 225 }
226 ++it; 226 ++it;
227 } 227 }
228 rootFolder->detachChildren(); 228 rootFolder->detachChildren();
229 for (int i=0; i<tabs; i++) 229 for (int i=0; i<tabs; i++)
230 ((LauncherView*)stack->widget(i))->sort(); 230 ((LauncherView*)stack->widget(i))->sort();
231 231
232 // all documents 232 // all documents
233 QImage img( Resource::loadImage( "DocsIcon" ) ); 233 QImage img( Resource::loadImage( "DocsIcon" ) );
234 QPixmap pm; 234 QPixmap pm;
235 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 235 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
236 docview = newView( "Documents", // No tr 236 docview = newView( "Documents", // No tr
237 pm, tr("Documents")); 237 pm, tr("Documents"));
238 docview->populate( docFolder, QString::null ); 238 docview->populate( docFolder, QString::null );
239 docFolder->detachChildren(); 239 docFolder->detachChildren();
240 docview->setFileSystems(fs); 240 docview->setFileSystems(fs);
241 docview->setToolsEnabled(TRUE); 241 docview->setToolsEnabled(TRUE);
242 setTabAppearance( "Documents", cfg ); // No tr 242 setTabAppearance( "Documents", cfg ); // No tr
243 243
244 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); 244 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) );
245 245
246 ((LauncherView*)stack->widget(0))->setFocus(); 246 ((LauncherView*)stack->widget(0))->setFocus();
247 247
248 cfg. setGroup ( "GUI" ); 248 cfg. setGroup ( "GUI" );
249 setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null )); 249 setBusyIndicatorType ( cfg. readEntry ( "BusyType", QString::null ));
250 250
251 categoryBar->show(); 251 categoryBar->show();
252 stack->show(); 252 stack->show();
253} 253}
254 254
255void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg ) 255void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg )
256{ 256{
257 QString grp( "Tab %1" ); // No tr 257 QString grp( "Tab %1" ); // No tr
258 cfg.setGroup( grp.arg(id) ); 258 cfg.setGroup( grp.arg(id) );
259 LauncherView *v = view( id ); 259 LauncherView *v = view( id );
260 int idx = ids.findIndex( id ); 260 int idx = ids.findIndex( id );
261 CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx ); 261 CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx );
262 262
263 // View 263 // View
264 QString view = cfg.readEntry( "View", "Icon" ); 264 QString view = cfg.readEntry( "View", "Icon" );
265 if ( view == "List" ) // No tr 265 if ( view == "List" ) // No tr
266 v->setViewMode( LauncherView::List ); 266 v->setViewMode( LauncherView::List );
267 QString bgType = cfg.readEntry( "BackgroundType", "Image" ); 267 QString bgType = cfg.readEntry( "BackgroundType", "Image" );
268 if ( bgType == "Image" ) { // No tr 268 if ( bgType == "Image" ) { // No tr
269 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" ); 269 QString pm = cfg.readEntry( "BackgroundImage", "launcher/opie-background" );
270 v->setBackgroundType( LauncherView::Image, pm ); 270 v->setBackgroundType( LauncherView::Image, pm );
271 } else if ( bgType == "SolidColor" ) { 271 } else if ( bgType == "SolidColor" ) {
272 QString c = cfg.readEntry( "BackgroundColor" ); 272 QString c = cfg.readEntry( "BackgroundColor" );
273 v->setBackgroundType( LauncherView::SolidColor, c ); 273 v->setBackgroundType( LauncherView::SolidColor, c );
274 } 274 }
275 QString textCol = cfg.readEntry( "TextColor" ); 275 QString textCol = cfg.readEntry( "TextColor" );
276 if ( textCol.isEmpty() ) 276 if ( textCol.isEmpty() )
277 v->setTextColor( QColor() ); 277 v->setTextColor( QColor() );
278 else 278 else
279 v->setTextColor( QColor(textCol) ); 279 v->setTextColor( QColor(textCol) );
280 QStringList font = cfg.readListEntry( "Font", ',' ); 280 QStringList font = cfg.readListEntry( "Font", ',' );
281 if ( font.count() == 4 ) 281 if ( font.count() == 4 )
282 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) ); 282 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
283 283
284 // Tabs 284 // Tabs
285 QString tabCol = cfg.readEntry( "TabColor" ); 285 QString tabCol = cfg.readEntry( "TabColor" );
286 if ( tabCol.isEmpty() ) 286 if ( tabCol.isEmpty() )
287 tab->bgColor = QColor(); 287 tab->bgColor = QColor();
288 else 288 else
289 tab->bgColor = QColor(tabCol); 289 tab->bgColor = QColor(tabCol);
290 QString tabTextCol = cfg.readEntry( "TabTextColor" ); 290 QString tabTextCol = cfg.readEntry( "TabTextColor" );
291 if ( tabTextCol.isEmpty() ) 291 if ( tabTextCol.isEmpty() )
292 tab->fgColor = QColor(); 292 tab->fgColor = QColor();
293 else 293 else
294 tab->fgColor = QColor(tabTextCol); 294 tab->fgColor = QColor(tabTextCol);
295} 295}
296 296
297void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) 297void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs)
298{ 298{
299 docview->populate( docFolder, QString::null ); 299 docview->populate( docFolder, QString::null );
300 docFolder->detachChildren(); 300 docFolder->detachChildren();
301 docview->setFileSystems(fs); 301 docview->setFileSystems(fs);
302 docview->updateTools(); 302 docview->updateTools();
303} 303}
304 304
305void CategoryTabWidget::tabProperties() 305void CategoryTabWidget::tabProperties()
306{ 306{
307 LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() ); 307 LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() );
308 QPopupMenu *m = new QPopupMenu( this ); 308 QPopupMenu *m = new QPopupMenu( this );
309 m->insertItem( tr("Icon View"), LauncherView::Icon ); 309 m->insertItem( tr("Icon View"), LauncherView::Icon );
310 m->insertItem( tr("List View"), LauncherView::List ); 310 m->insertItem( tr("List View"), LauncherView::List );
311 m->setItemChecked( (int)view->viewMode(), TRUE ); 311 m->setItemChecked( (int)view->viewMode(), TRUE );
312 int rv = m->exec( QCursor::pos() ); 312 int rv = m->exec( QCursor::pos() );
313 if ( rv >= 0 && rv != view->viewMode() ) { 313 if ( rv >= 0 && rv != view->viewMode() ) {
314 view->setViewMode( (LauncherView::ViewMode)rv ); 314 view->setViewMode( (LauncherView::ViewMode)rv );
315 } 315 }
316 316
317 delete m; 317 delete m;
318} 318}
319 319
320QString CategoryTabWidget::getAllDocLinkInfo() const 320QString CategoryTabWidget::getAllDocLinkInfo() const
321{ 321{
322 return docview->getAllDocLinkInfo(); 322 return docview->getAllDocLinkInfo();
323} 323}
324 324
325LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 325LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
326{ 326{
327 LauncherView* view = new LauncherView( stack ); 327 LauncherView* view = new LauncherView( stack );
328 connect( view, SIGNAL(clicked(const AppLnk*)), 328 connect( view, SIGNAL(clicked(const AppLnk*)),
329 this, SIGNAL(clicked(const AppLnk*))); 329 this, SIGNAL(clicked(const AppLnk*)));
330 connect( view, SIGNAL(rightPressed(AppLnk*)), 330 connect( view, SIGNAL(rightPressed(AppLnk*)),
331 this, SIGNAL(rightPressed(AppLnk*))); 331 this, SIGNAL(rightPressed(AppLnk*)));
332 ids.append(id); 332 ids.append(id);
333 categoryBar->addTab( new CategoryTab( pm, label ) ); 333 categoryBar->addTab( new CategoryTab( pm, label ) );
334 stack->addWidget( view, tabs++ ); 334 stack->addWidget( view, tabs++ );
335 return view; 335 return view;
336} 336}
337 337
338void CategoryTabWidget::updateLink(const QString& linkfile) 338void CategoryTabWidget::updateLink(const QString& linkfile)
339{ 339{
340 int i=0; 340 int i=0;
341 LauncherView* view; 341 LauncherView* view;
342 while ((view = (LauncherView*)stack->widget(i++))) { 342 while ((view = (LauncherView*)stack->widget(i++))) {
343 if ( view->removeLink(linkfile) ) 343 if ( view->removeLink(linkfile) )
344 break; 344 break;
345 } 345 }
346 addItem(linkfile); 346 addItem(linkfile);
347 docview->updateTools(); 347 docview->updateTools();
348} 348}
349 349
350void CategoryTabWidget::paletteChange( const QPalette &p ) 350void CategoryTabWidget::paletteChange( const QPalette &p )
351{ 351{
352 QVBox::paletteChange( p ); 352 QVBox::paletteChange( p );
353 QPalette pal = palette(); 353 QPalette pal = palette();
354 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 354 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
355 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 355 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
356 categoryBar->setPalette( pal ); 356 categoryBar->setPalette( pal );
357 categoryBar->update(); 357 categoryBar->update();
358} 358}
359 359
360void CategoryTabWidget::setBusy(bool on) 360void CategoryTabWidget::setBusy(bool on)
361{ 361{
362 if ( on ) 362 if ( on )
363 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE); 363 ((LauncherView*)stack->visibleWidget())->setBusy(TRUE);
364 else 364 else
365 for (int i=0; i<tabs; i++) 365 for (int i=0; i<tabs; i++)
366 ((LauncherView*)stack->widget(i))->setBusy(FALSE); 366 ((LauncherView*)stack->widget(i))->setBusy(FALSE);
367} 367}
368 368
369LauncherView *CategoryTabWidget::view( const QString &id ) 369LauncherView *CategoryTabWidget::view( const QString &id )
370{ 370{
371 int idx = ids.findIndex( id ); 371 int idx = ids.findIndex( id );
372 return (LauncherView *)stack->widget(idx); 372 return (LauncherView *)stack->widget(idx);
373} 373}
374 374
375void CategoryTabWidget::setBusyIndicatorType ( const QString &type ) 375void CategoryTabWidget::setBusyIndicatorType ( const QString &type )
376{ 376{
377 for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it ) 377 for ( QStringList::Iterator it = ids. begin ( ); it != ids. end ( ); ++it )
378 view ( *it )-> setBusyIndicatorType ( type ); 378 view ( *it )-> setBusyIndicatorType ( type );
379} 379}
380 380
381//=========================================================================== 381//===========================================================================
382 382
383CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) 383CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name )
384 : QTabBar( parent, name ) 384 : QTabBar( parent, name )
385{ 385{
386 setFocusPolicy( NoFocus ); 386 setFocusPolicy( NoFocus );
387 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) ); 387 connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) );
388} 388}
389 389
390CategoryTabBar::~CategoryTabBar() 390CategoryTabBar::~CategoryTabBar()
391{ 391{
392} 392}
393 393
394void CategoryTabBar::layoutTabs() 394void CategoryTabBar::layoutTabs()
395{ 395{
396 if ( !count() ) 396 if ( !count() )
397 return; 397 return;
398 398
399// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; 399// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 };
400 int available = width()-1; 400 int available = width()-1;
401 QFontMetrics fm = fontMetrics(); 401 QFontMetrics fm = fontMetrics();
402 int hiddenTabWidth = -7; 402 int hiddenTabWidth = -7;
403 int middleTab = currentTab(); 403 int middleTab = currentTab();
404 int hframe, vframe, overlap; 404 int hframe, vframe, overlap;
405 style().tabbarMetrics( this, hframe, vframe, overlap ); 405 style().tabbarMetrics( this, hframe, vframe, overlap );
406 int x = 0; 406 int x = 0;
407 QRect r; 407 QRect r;
408 QTab *t; 408 QTab *t;
409 int required = 0; 409 int required = 0;
410 int eventabwidth = (width()-1)/count(); 410 int eventabwidth = (width()-1)/count();
411 enum Mode { HideBackText, Pack, Even } mode=Even; 411 enum Mode { HideBackText, Pack, Even } mode=Even;
412 for ( int i = 0; i < count(); i++ ) { 412 for ( int i = 0; i < count(); i++ ) {
413 t = tab(i); 413 t = tab(i);
414 int iw = fm.width( t->text() ) + hframe - overlap; 414 int iw = fm.width( t->text() ) + hframe - overlap;
415 if ( i != middleTab ) { 415 if ( i != middleTab ) {
416 available -= hiddenTabWidth + hframe - overlap; 416 available -= hiddenTabWidth + hframe - overlap;
417 if ( t->iconSet() != 0 ) 417 if ( t->iconSet() != 0 )
418 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 418 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
419 } 419 }
420 if ( t->iconSet() != 0 ) 420 if ( t->iconSet() != 0 )
421 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 421 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
422 required += iw; 422 required += iw;
423 // As space gets tight, packed looks better than even. "10" must be at least 0. 423 // As space gets tight, packed looks better than even. "10" must be at least 0.
424 if ( iw >= eventabwidth-10 ) 424 if ( iw >= eventabwidth-10 )
425 mode = Pack; 425 mode = Pack;
426 } 426 }
427 if ( mode == Pack && required > width()-1 ) 427 if ( mode == Pack && required > width()-1 )
428 mode = HideBackText; 428 mode = HideBackText;
429 for ( int i = 0; i < count(); i++ ) { 429 for ( int i = 0; i < count(); i++ ) {
430 t = tab(i); 430 t = tab(i);
431 if ( mode != HideBackText ) { 431 if ( mode != HideBackText ) {
432 int w = fm.width( t->text() ); 432 int w = fm.width( t->text() );
433 int ih = 0; 433 int ih = 0;
434 if ( t->iconSet() != 0 ) { 434 if ( t->iconSet() != 0 ) {
435 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 435 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
436 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 436 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
437 } 437 }
438 int h = QMAX( fm.height(), ih ); 438 int h = QMAX( fm.height(), ih );
439 h = QMAX( h, QApplication::globalStrut().height() ); 439 h = QMAX( h, QApplication::globalStrut().height() );
440 440
441 h += vframe; 441 h += vframe;
442 w += hframe; 442 w += hframe;
443 443
444 QRect tr(x, 0, 444 QRect tr(x, 0,
445 mode == Even ? eventabwidth : w * (width()-1)/required, h); 445 mode == Even ? eventabwidth : w * (width()-1)/required, h);
446 t->setRect(tr); 446 t->setRect(tr);
447 x += tr.width() - overlap; 447 x += tr.width() - overlap;
448 r = r.unite(tr); 448 r = r.unite(tr);
449 } else if ( i != middleTab ) { 449 } else if ( i != middleTab ) {
450 int w = hiddenTabWidth; 450 int w = hiddenTabWidth;
451 int ih = 0; 451 int ih = 0;
452 if ( t->iconSet() != 0 ) { 452 if ( t->iconSet() != 0 ) {
453 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 453 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
454 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 454 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
455 } 455 }
456 int h = QMAX( fm.height(), ih ); 456 int h = QMAX( fm.height(), ih );
457 h = QMAX( h, QApplication::globalStrut().height() ); 457 h = QMAX( h, QApplication::globalStrut().height() );
458 458
459 h += vframe; 459 h += vframe;
460 w += hframe; 460 w += hframe;
461 461
462 t->setRect( QRect(x, 0, w, h) ); 462 t->setRect( QRect(x, 0, w, h) );
463 x += t->rect().width() - overlap; 463 x += t->rect().width() - overlap;
464 r = r.unite( t->rect() ); 464 r = r.unite( t->rect() );
465 } else { 465 } else {
466 int ih = 0; 466 int ih = 0;
467 if ( t->iconSet() != 0 ) { 467 if ( t->iconSet() != 0 ) {
468 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 468 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
469 } 469 }
470 int h = QMAX( fm.height(), ih ); 470 int h = QMAX( fm.height(), ih );
471 h = QMAX( h, QApplication::globalStrut().height() ); 471 h = QMAX( h, QApplication::globalStrut().height() );
472 472
473 h += vframe; 473 h += vframe;
474 474
475 t->setRect( QRect(x, 0, available, h) ); 475 t->setRect( QRect(x, 0, available, h) );
476 x += t->rect().width() - overlap; 476 x += t->rect().width() - overlap;
477 r = r.unite( t->rect() ); 477 r = r.unite( t->rect() );
478 } 478 }
479 } 479 }
480 480
481 QRect rr = tab(count()-1)->rect(); 481 QRect rr = tab(count()-1)->rect();
482 rr.setRight(width()-1); 482 rr.setRight(width()-1);
483 tab(count()-1)->setRect( rr ); 483 tab(count()-1)->setRect( rr );
484 484
485 for ( t = tabList()->first(); t; t = tabList()->next() ) { 485 for ( t = tabList()->first(); t; t = tabList()->next() ) {
486 QRect tr = t->rect(); 486 QRect tr = t->rect();
487 tr.setHeight( r.height() ); 487 tr.setHeight( r.height() );
488 t->setRect( tr ); 488 t->setRect( tr );
489 } 489 }
490 490
491 update(); 491 update();
492} 492}
493 493
494 494
495void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const 495void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
496{ 496{
497 CategoryTabBar *that = (CategoryTabBar *) this; 497 CategoryTabBar *that = (CategoryTabBar *) this;
498 CategoryTab *ct = (CategoryTab *)t; 498 CategoryTab *ct = (CategoryTab *)t;
499 QPalette pal = palette(); 499 QPalette pal = palette();
500 bool setPal = FALSE; 500 bool setPal = FALSE;
501 if ( ct->bgColor.isValid() ) { 501 if ( ct->bgColor.isValid() ) {
502 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor ); 502 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor );
503 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor ); 503 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor );
504 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor ); 504 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor );
505 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor ); 505 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor );
506 that->setUpdatesEnabled( FALSE ); 506 that->setUpdatesEnabled( FALSE );
507 that->setPalette( pal ); 507 that->setPalette( pal );
508 setPal = TRUE; 508 setPal = TRUE;
509 } 509 }
510#if QT_VERSION >= 300 510#if QT_VERSION >= 300
511 QStyle::SFlags flags = QStyle::Style_Default; 511 QStyle::SFlags flags = QStyle::Style_Default;
512 if ( selected ) 512 if ( selected )
513 flags |= QStyle::Style_Selected; 513 flags |= QStyle::Style_Selected;
514 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(), 514 style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
515 colorGroup(), flags, QStyleOption(t) ); 515 colorGroup(), flags, QStyleOption(t) );
516#else 516#else
517 style().drawTab( p, this, t, selected ); 517 style().drawTab( p, this, t, selected );
518#endif 518#endif
519 519
520 QRect r( t->rect() ); 520 QRect r( t->rect() );
521 QFont f( font() ); 521 QFont f( font() );
522 if ( selected ) 522 if ( selected )
523 f.setBold( TRUE ); 523 f.setBold( TRUE );
524 p->setFont( f ); 524 p->setFont( f );
525 525
526 if ( ct->fgColor.isValid() ) { 526 if ( ct->fgColor.isValid() ) {
527 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor ); 527 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor );
528 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor ); 528 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor );
529 that->setUpdatesEnabled( FALSE ); 529 that->setUpdatesEnabled( FALSE );
530 that->setPalette( pal ); 530 that->setPalette( pal );
531 setPal = TRUE; 531 setPal = TRUE;
532 } 532 }
533 int iw = 0; 533 int iw = 0;
534 int ih = 0; 534 int ih = 0;
535 if ( t->iconSet() != 0 ) { 535 if ( t->iconSet() != 0 ) {
536 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2; 536 iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
537 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 537 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
538 } 538 }
539 int w = iw + p->fontMetrics().width( t->text() ) + 4; 539 int w = iw + p->fontMetrics().width( t->text() ) + 4;
540 int h = QMAX(p->fontMetrics().height() + 4, ih ); 540 int h = QMAX(p->fontMetrics().height() + 4, ih );
541 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3, 541 paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
542 r.top() + (r.height()-h)/2, w, h ), t, 542 r.top() + (r.height()-h)/2, w, h ), t,
543#if QT_VERSION >= 300 543#if QT_VERSION >= 300
544 t->identifier() == keyboardFocusTab() 544 t->identifier() == keyboardFocusTab()
545#else 545#else
546 t->identitifer() == keyboardFocusTab() 546 t->identitifer() == keyboardFocusTab()
547#endif 547#endif
548 ); 548 );
549 if ( setPal ) { 549 if ( setPal ) {
550 that->unsetPalette(); 550 that->unsetPalette();
551 that->setUpdatesEnabled( TRUE ); 551 that->setUpdatesEnabled( TRUE );
552 } 552 }
553} 553}
554 554
555 555
556void CategoryTabBar::paintLabel( QPainter* p, const QRect&, 556void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
557 QTab* t, bool has_focus ) const 557 QTab* t, bool has_focus ) const
558{ 558{
559 QRect r = t->rect(); 559 QRect r = t->rect();
560 // if ( t->id != currentTab() ) 560 // if ( t->id != currentTab() )
561 //r.moveBy( 1, 1 ); 561 //r.moveBy( 1, 1 );
562 // 562 //
563 if ( t->iconSet() ) { 563 if ( t->iconSet() ) {
564 // the tab has an iconset, draw it in the right mode 564 // the tab has an iconset, draw it in the right mode
565 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled; 565 QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
566 if ( mode == QIconSet::Normal && has_focus ) 566 if ( mode == QIconSet::Normal && has_focus )
567 mode = QIconSet::Active; 567 mode = QIconSet::Active;
568 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode ); 568 QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
569 int pixw = pixmap.width(); 569 int pixw = pixmap.width();
570 int pixh = pixmap.height(); 570 int pixh = pixmap.height();
571 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap ); 571 p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap );
572 r.setLeft( r.left() + pixw + 5 ); 572 r.setLeft( r.left() + pixw + 5 );
573 } 573 }
574 574
575 QRect tr = r; 575 QRect tr = r;
576 576
577 if ( r.width() < 20 ) 577 if ( r.width() < 20 )
578 return; 578 return;
579 579
580 if ( t->isEnabled() && isEnabled() ) { 580 if ( t->isEnabled() && isEnabled() ) {
581#if defined(_WS_WIN32_) 581#if defined(_WS_WIN32_)
582 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) ) 582 if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
583 p->setPen( colorGroup().buttonText() ); 583 p->setPen( colorGroup().buttonText() );
584 else 584 else
585 p->setPen( colorGroup().foreground() ); 585 p->setPen( colorGroup().foreground() );
586#else 586#else
587 p->setPen( colorGroup().foreground() ); 587 p->setPen( colorGroup().foreground() );
588#endif 588#endif
589 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 589 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
590 } else { 590 } else {
591 p->setPen( palette().disabled().foreground() ); 591 p->setPen( palette().disabled().foreground() );
592 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() ); 592 p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
593 } 593 }
594} 594}
595 595
596//--------------------------------------------------------------------------- 596//---------------------------------------------------------------------------
597 597
598Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 598Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
599 : QMainWindow( parent, name, fl ) 599 : QMainWindow( parent, name, fl )
600{ 600{
601 setCaption( tr("Launcher") ); 601 setCaption( tr("Launcher") );
602 602
603 syncDialog = 0; 603 syncDialog = 0;
604 604
605 // we have a pretty good idea how big we'll be 605 // we have a pretty good idea how big we'll be
606 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 606 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
607 607
608 tabs = 0; 608 tabs = 0;
609 rootFolder = 0; 609 rootFolder = 0;
610 docsFolder = 0; 610 docsFolder = 0;
611 611
612 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know 612 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
613 //uidgen.store( stamp ); 613 //uidgen.store( stamp );
614 m_timeStamp = QString::number( stamp ); 614 m_timeStamp = QString::number( stamp );
615 615
616 tabs = new CategoryTabWidget( this ); 616 tabs = new CategoryTabWidget( this );
617 tabs->setMaximumWidth( qApp->desktop()->width() ); 617 tabs->setMaximumWidth( qApp->desktop()->width() );
618 setCentralWidget( tabs ); 618 setCentralWidget( tabs );
619 619
620 connect( tabs, SIGNAL(selected(const QString&)), 620 connect( tabs, SIGNAL(selected(const QString&)),
621 this, SLOT(viewSelected(const QString&)) ); 621 this, SLOT(viewSelected(const QString&)) );
622 connect( tabs, SIGNAL(clicked(const AppLnk*)), 622 connect( tabs, SIGNAL(clicked(const AppLnk*)),
623 this, SLOT(select(const AppLnk*))); 623 this, SLOT(select(const AppLnk*)));
624 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 624 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
625 this, SLOT(properties(AppLnk*))); 625 this, SLOT(properties(AppLnk*)));
626 626
627#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 627#if !defined(QT_NO_COP)
628 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 628 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
629 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 629 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
630 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 630 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
631 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this ); 631 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
632 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 632 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
633 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) ); 633 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) );
634#endif 634#endif
635 635
636 storage = new StorageInfo( this ); 636 storage = new StorageInfo( this );
637 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 637 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
638 638
639 updateTabs(); 639 updateTabs();
640 640
641 preloadApps(); 641 preloadApps();
642 642
643 in_lnk_props = FALSE; 643 in_lnk_props = FALSE;
644 got_lnk_change = FALSE; 644 got_lnk_change = FALSE;
645} 645}
646 646
647Launcher::~Launcher() 647Launcher::~Launcher()
648{ 648{
649 delete rootFolder; 649 delete rootFolder;
650 delete docsFolder; 650 delete docsFolder;
651} 651}
652 652
653static bool isVisibleWindow(int wid) 653static bool isVisibleWindow(int wid)
654{ 654{
655#ifdef QWS 655#ifdef QWS
656 const QList<QWSWindow> &list = qwsServer->clientWindows(); 656 const QList<QWSWindow> &list = qwsServer->clientWindows();
657 QWSWindow* w; 657 QWSWindow* w;
658 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 658 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
659 if ( w->winId() == wid ) 659 if ( w->winId() == wid )
660 return !w->isFullyObscured(); 660 return !w->isFullyObscured();
661 } 661 }
662#endif 662#endif
663 return FALSE; 663 return FALSE;
664} 664}
665 665
666void Launcher::showMaximized() 666void Launcher::showMaximized()
667{ 667{
668 if ( isVisibleWindow( winId() ) ) 668 if ( isVisibleWindow( winId() ) )
669 doMaximize(); 669 doMaximize();
670 else 670 else
671 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 671 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
672} 672}
673 673
674void Launcher::doMaximize() 674void Launcher::doMaximize()
675{ 675{
676 QMainWindow::showMaximized(); 676 QMainWindow::showMaximized();
677} 677}
678 678
679void Launcher::updateMimeTypes() 679void Launcher::updateMimeTypes()
680{ 680{
681 MimeType::clear(); 681 MimeType::clear();
682 updateMimeTypes(rootFolder); 682 updateMimeTypes(rootFolder);
683} 683}
684 684
685void Launcher::updateMimeTypes(AppLnkSet* folder) 685void Launcher::updateMimeTypes(AppLnkSet* folder)
686{ 686{
687 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 687 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
688 AppLnk *app = it.current(); 688 AppLnk *app = it.current();
689 if ( app->type() == "Folder" ) // No tr 689 if ( app->type() == "Folder" ) // No tr
690 updateMimeTypes((AppLnkSet *)app); 690 updateMimeTypes((AppLnkSet *)app);
691 else { 691 else {
692 MimeType::registerApp(*app); 692 MimeType::registerApp(*app);
693 } 693 }
694 } 694 }
695} 695}
696 696
697/** This is a HACK.... 697/** This is a HACK....
698 * Reason: scanning huge mediums, microdirvers for examples 698 * Reason: scanning huge mediums, microdirvers for examples
699 * consomes time. To avoid that we invented the MediumMountCheck 699 * consomes time. To avoid that we invented the MediumMountCheck
700 * 700 *
701 * a) the user globally disabled medium checking. We can ignore 701 * a) the user globally disabled medium checking. We can ignore
702 * all removable medium 702 * all removable medium
703 * b) the user enabled medium checking globally and we need to use this mimefilter 703 * b) the user enabled medium checking globally and we need to use this mimefilter
704 * c) the user enabled medium checking on a per medium bases 704 * c) the user enabled medium checking on a per medium bases
705 * c1) we already checked and its not ask again turns 705 * c1) we already checked and its not ask again turns
706 * c2) we need to ask and then apply the mimefilter 706 * c2) we need to ask and then apply the mimefilter
707 */ 707 */
708void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 708void Launcher::loadDocs() // ok here comes a hack belonging to Global::
709{ 709{
710 delete docsFolder; 710 delete docsFolder;
711 docsFolder = new DocLnkSet; 711 docsFolder = new DocLnkSet;
712 712
713 DocLnkSet *tmp = 0; 713 DocLnkSet *tmp = 0;
714 QString home = QString(getenv("HOME")) + "/Documents"; 714 QString home = QString(getenv("HOME")) + "/Documents";
715 tmp = new DocLnkSet( home , QString::null); 715 tmp = new DocLnkSet( home , QString::null);
716 docsFolder->appendFrom( *tmp ); 716 docsFolder->appendFrom( *tmp );
717 delete tmp; 717 delete tmp;
718 718
719 // RAM documents 719 // RAM documents
720 StorageInfo storage; 720 StorageInfo storage;
721 const QList<FileSystem> &fileSystems = storage.fileSystems(); 721 const QList<FileSystem> &fileSystems = storage.fileSystems();
722 QListIterator<FileSystem> it ( fileSystems ); 722 QListIterator<FileSystem> it ( fileSystems );
723 723
724 for ( ; it.current(); ++it ) { 724 for ( ; it.current(); ++it ) {
725 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { 725 if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) {
726 tmp = new DocLnkSet( (*it)->path(), QString::null ); 726 tmp = new DocLnkSet( (*it)->path(), QString::null );
727 docsFolder->appendFrom( *tmp ); 727 docsFolder->appendFrom( *tmp );
728 delete tmp; 728 delete tmp;
729 } 729 }
730 } 730 }
731 731
732 Config mediumCfg( "medium"); 732 Config mediumCfg( "medium");
733 mediumCfg.setGroup("main"); 733 mediumCfg.setGroup("main");
734 // a) -zecke we don't want to check 734 // a) -zecke we don't want to check
735 if(!mediumCfg.readBoolEntry("use", true ) ) 735 if(!mediumCfg.readBoolEntry("use", true ) )
736 return; 736 return;
737 737
738 // find out wich filesystems are new in this round 738 // find out wich filesystems are new in this round
739 // We will do this by having a timestamp inside each mountpoint 739 // We will do this by having a timestamp inside each mountpoint
740 // if the current timestamp doesn't match this is a new file system and 740 // if the current timestamp doesn't match this is a new file system and
741 // come up with our MediumMountGui :) let the hacking begin 741 // come up with our MediumMountGui :) let the hacking begin
742 int stamp = uidgen.generate(); 742 int stamp = uidgen.generate();
743 743
744 QString newStamp = QString::number( stamp ); // generates newtime Stamp 744 QString newStamp = QString::number( stamp ); // generates newtime Stamp
745 745
746 // b) 746 // b)
747 if( mediumCfg.readBoolEntry("global", true ) ){ 747 if( mediumCfg.readBoolEntry("global", true ) ){
748 QString mime = configToMime(&mediumCfg).join(";"); 748 QString mime = configToMime(&mediumCfg).join(";");
749 for( it.toFirst(); it.current(); ++it ){ 749 for( it.toFirst(); it.current(); ++it ){
750 if( (*it)->isRemovable() ){ 750 if( (*it)->isRemovable() ){
751 tmp = new DocLnkSet( (*it)->path(), mime ); 751 tmp = new DocLnkSet( (*it)->path(), mime );
752 docsFolder->appendFrom( *tmp ); 752 docsFolder->appendFrom( *tmp );
753 delete tmp; 753 delete tmp;
754 } 754 }
755 } // done 755 } // done
756 return; // save the else 756 return; // save the else
757 } 757 }
758 // c) zecke 758 // c) zecke
759 for ( it.toFirst(); it.current(); ++it ) { 759 for ( it.toFirst(); it.current(); ++it ) {
760 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 760 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
761 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); 761 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File);
762 cfg.setGroup("main"); 762 cfg.setGroup("main");
763 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 763 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
764 /** This medium is uptodate 764 /** This medium is uptodate
765 */ 765 */
766 if( stamp == m_timeStamp ){ // ok we know this card 766 if( stamp == m_timeStamp ){ // ok we know this card
767 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 767 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
768 // we need to scan the list now. Hopefully the cache will be there 768 // we need to scan the list now. Hopefully the cache will be there
769 // read the mimetypes from the config and search for documents 769 // read the mimetypes from the config and search for documents
770 QStringList mimetypes = configToMime( &cfg); 770 QStringList mimetypes = configToMime( &cfg);
771 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 771 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
772 docsFolder->appendFrom( *tmp ); 772 docsFolder->appendFrom( *tmp );
773 delete tmp; 773 delete tmp;
774 774
775 }else{ // come up with the gui cause this a new card 775 }else{ // come up with the gui cause this a new card
776 MediumMountGui medium(&cfg, (*it)->path() ); 776 MediumMountGui medium(&cfg, (*it)->path() );
777 if( medium.check() ){ // we did not ask before or ask again is off 777 if( medium.check() ){ // we did not ask before or ask again is off
778 /** c2) */ 778 /** c2) */
779 if( medium.exec() ){ // he clicked yes so search it 779 if( medium.exec() ){ // he clicked yes so search it
780 // speicher 780 // speicher
781 //cfg.read(); // cause of a race we need to reread - fixed 781 //cfg.read(); // cause of a race we need to reread - fixed
782 cfg.setGroup("main"); 782 cfg.setGroup("main");
783 cfg.writeEntry("timestamp", newStamp ); 783 cfg.writeEntry("timestamp", newStamp );
784 cfg.write(); 784 cfg.write();
785 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); 785 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) );
786 docsFolder->appendFrom( *tmp ); 786 docsFolder->appendFrom( *tmp );
787 delete tmp; 787 delete tmp;
788 }// no else 788 }// no else
789 /** c1) */ 789 /** c1) */
790 }else{ // we checked 790 }else{ // we checked
791 // do something different see what we need to do 791 // do something different see what we need to do
792 // let's see if we should check the device 792 // let's see if we should check the device
793 cfg.setGroup("main" ); 793 cfg.setGroup("main" );
794 bool check = cfg.readBoolEntry("autocheck", true ); 794 bool check = cfg.readBoolEntry("autocheck", true );
795 if( check ){ // find the documents 795 if( check ){ // find the documents
796 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); 796 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
797 docsFolder->appendFrom( *tmp ); 797 docsFolder->appendFrom( *tmp );
798 delete tmp; 798 delete tmp;
799 } 799 }
800 } 800 }
801 } 801 }
802 } 802 }
803 } 803 }
804 m_timeStamp = newStamp; 804 m_timeStamp = newStamp;
805} 805}
806 806
807void Launcher::updateTabs() 807void Launcher::updateTabs()
808{ 808{
809 MimeType::updateApplications(); // ### reads all applnks twice 809 MimeType::updateApplications(); // ### reads all applnks twice
810 810
811 delete rootFolder; 811 delete rootFolder;
812 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 812 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
813 813
814 loadDocs(); 814 loadDocs();
815 815
816 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 816 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
817} 817}
818 818
819void Launcher::updateDocs() 819void Launcher::updateDocs()
820{ 820{
821 loadDocs(); 821 loadDocs();
822 tabs->updateDocs(docsFolder,storage->fileSystems()); 822 tabs->updateDocs(docsFolder,storage->fileSystems());
823} 823}
824 824
825void Launcher::viewSelected(const QString& s) 825void Launcher::viewSelected(const QString& s)
826{ 826{
827 setCaption( s + tr(" - Launcher") ); 827 setCaption( s + tr(" - Launcher") );
828} 828}
829 829
830void Launcher::nextView() 830void Launcher::nextView()
831{ 831{
832 tabs->nextTab(); 832 tabs->nextTab();
833} 833}
834 834
835 835
836void Launcher::select( const AppLnk *appLnk ) 836void Launcher::select( const AppLnk *appLnk )
837{ 837{
838 if ( appLnk->type() == "Folder" ) { // No tr 838 if ( appLnk->type() == "Folder" ) { // No tr
839 // Not supported: flat is simpler for the user 839 // Not supported: flat is simpler for the user
840 } else { 840 } else {
841 if ( appLnk->exec().isNull() ) { 841 if ( appLnk->exec().isNull() ) {
842 QMessageBox::information(this,tr("No application"), 842 QMessageBox::information(this,tr("No application"),
843 tr("<p>No application is defined for this document." 843 tr("<p>No application is defined for this document."
844 "<p>Type is %1.").arg(appLnk->type())); 844 "<p>Type is %1.").arg(appLnk->type()));
845 return; 845 return;
846 } 846 }
847 tabs->setBusy(TRUE); 847 tabs->setBusy(TRUE);
848 emit executing( appLnk ); 848 emit executing( appLnk );
849 appLnk->execute(); 849 appLnk->execute();
850 } 850 }
851} 851}
852 852
853void Launcher::externalSelected(const AppLnk *appLnk) 853void Launcher::externalSelected(const AppLnk *appLnk)
854{ 854{
855 tabs->setBusy(TRUE); 855 tabs->setBusy(TRUE);
856 emit executing( appLnk ); 856 emit executing( appLnk );
857} 857}
858 858
859void Launcher::properties( AppLnk *appLnk ) 859void Launcher::properties( AppLnk *appLnk )
860{ 860{
861 if ( appLnk->type() == "Folder" ) { // No tr 861 if ( appLnk->type() == "Folder" ) { // No tr
862 // Not supported: flat is simpler for the user 862 // Not supported: flat is simpler for the user
863 } else { 863 } else {
864 in_lnk_props = TRUE; 864 in_lnk_props = TRUE;
865 got_lnk_change = FALSE; 865 got_lnk_change = FALSE;
866 LnkProperties prop(appLnk); 866 LnkProperties prop(appLnk);
867 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *))); 867 connect(&prop, SIGNAL(select(const AppLnk *)), this, SLOT(externalSelected(const AppLnk *)));
868 prop.showMaximized(); 868 prop.showMaximized();
869 prop.exec(); 869 prop.exec();
870 in_lnk_props = FALSE; 870 in_lnk_props = FALSE;
871 if ( got_lnk_change ) { 871 if ( got_lnk_change ) {
872 updateLink(lnk_change); 872 updateLink(lnk_change);
873 } 873 }
874 } 874 }
875} 875}
876 876
877void Launcher::updateLink(const QString& link) 877void Launcher::updateLink(const QString& link)
878{ 878{
879 if (link.isNull()) 879 if (link.isNull())
880 updateTabs(); 880 updateTabs();
881 else if (link.isEmpty()) 881 else if (link.isEmpty())
882 updateDocs(); 882 updateDocs();
883 else 883 else
884 tabs->updateLink(link); 884 tabs->updateLink(link);
885} 885}
886 886
887void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 887void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
888{ 888{
889 QDataStream stream( data, IO_ReadOnly ); 889 QDataStream stream( data, IO_ReadOnly );
890 if ( msg == "linkChanged(QString)" ) { 890 if ( msg == "linkChanged(QString)" ) {
891 QString link; 891 QString link;
892 stream >> link; 892 stream >> link;
893 if ( in_lnk_props ) { 893 if ( in_lnk_props ) {
894 got_lnk_change = TRUE; 894 got_lnk_change = TRUE;
895 lnk_change = link; 895 lnk_change = link;
896 } else { 896 } else {
897 updateLink(link); 897 updateLink(link);
898 } 898 }
899 } else if ( msg == "busy()" ) { 899 } else if ( msg == "busy()" ) {
900 emit busy(); 900 emit busy();
901 } else if ( msg == "notBusy(QString)" ) { 901 } else if ( msg == "notBusy(QString)" ) {
902 QString app; 902 QString app;
903 stream >> app; 903 stream >> app;
904 tabs->setBusy(FALSE); 904 tabs->setBusy(FALSE);
905 emit notBusy(app); 905 emit notBusy(app);
906 } else if ( msg == "mkdir(QString)" ) { 906 } else if ( msg == "mkdir(QString)" ) {
907 QString dir; 907 QString dir;
908 stream >> dir; 908 stream >> dir;
909 if ( !dir.isEmpty() ) 909 if ( !dir.isEmpty() )
910 mkdir( dir ); 910 mkdir( dir );
911 } else if ( msg == "rdiffGenSig(QString,QString)" ) { 911 } else if ( msg == "rdiffGenSig(QString,QString)" ) {
912 QString baseFile, sigFile; 912 QString baseFile, sigFile;
913 stream >> baseFile >> sigFile; 913 stream >> baseFile >> sigFile;
914 QRsync::generateSignature( baseFile, sigFile ); 914 QRsync::generateSignature( baseFile, sigFile );
915 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { 915 } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) {
916 QString baseFile, sigFile, deltaFile; 916 QString baseFile, sigFile, deltaFile;
917 stream >> baseFile >> sigFile >> deltaFile; 917 stream >> baseFile >> sigFile >> deltaFile;
918 QRsync::generateDiff( baseFile, sigFile, deltaFile ); 918 QRsync::generateDiff( baseFile, sigFile, deltaFile );
919 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { 919 } else if ( msg == "rdiffApplyPatch(QString,QString)" ) {
920 QString baseFile, deltaFile; 920 QString baseFile, deltaFile;
921 stream >> baseFile >> deltaFile; 921 stream >> baseFile >> deltaFile;
922 if ( !QFile::exists( baseFile ) ) { 922 if ( !QFile::exists( baseFile ) ) {
923 QFile f( baseFile ); 923 QFile f( baseFile );
924 f.open( IO_WriteOnly ); 924 f.open( IO_WriteOnly );
925 f.close(); 925 f.close();
926 } 926 }
927 QRsync::applyDiff( baseFile, deltaFile ); 927 QRsync::applyDiff( baseFile, deltaFile );
928#ifndef QT_NO_COP 928#ifndef QT_NO_COP
929 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 929 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
930 e << baseFile; 930 e << baseFile;
931#endif 931#endif
932 } else if ( msg == "rdiffCleanup()" ) { 932 } else if ( msg == "rdiffCleanup()" ) {
933 mkdir( "/tmp/rdiff" ); 933 mkdir( "/tmp/rdiff" );
934 QDir dir; 934 QDir dir;
935 dir.setPath( "/tmp/rdiff" ); 935 dir.setPath( "/tmp/rdiff" );
936 QStringList entries = dir.entryList(); 936 QStringList entries = dir.entryList();
937 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) 937 for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it )
938 dir.remove( *it ); 938 dir.remove( *it );
939 } else if ( msg == "sendHandshakeInfo()" ) { 939 } else if ( msg == "sendHandshakeInfo()" ) {
940 QString home = getenv( "HOME" ); 940 QString home = getenv( "HOME" );
941#ifndef QT_NO_COP 941#ifndef QT_NO_COP
942 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 942 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
943 e << home; 943 e << home;
944 int locked = (int) Desktop::screenLocked(); 944 int locked = (int) Desktop::screenLocked();
945 e << locked; 945 e << locked;
946#endif 946#endif
947 } else if ( msg == "autoStart(QString)" ) { 947 } else if ( msg == "autoStart(QString)" ) {
948 QString appName; 948 QString appName;
949 stream >> appName; 949 stream >> appName;
950 Config cfg( "autostart" ); 950 Config cfg( "autostart" );
951 cfg.setGroup( "AutoStart" ); 951 cfg.setGroup( "AutoStart" );
952 if ( appName.compare("clear") == 0){ 952 if ( appName.compare("clear") == 0){
953 cfg.writeEntry("Apps", ""); 953 cfg.writeEntry("Apps", "");
954 } 954 }
955 } else if ( msg == "autoStart(QString,QString)" ) { 955 } else if ( msg == "autoStart(QString,QString)" ) {
956 QString modifier, appName; 956 QString modifier, appName;
957 stream >> modifier >> appName; 957 stream >> modifier >> appName;
958 Config cfg( "autostart" ); 958 Config cfg( "autostart" );
959 cfg.setGroup( "AutoStart" ); 959 cfg.setGroup( "AutoStart" );
960 if ( modifier.compare("add") == 0 ){ 960 if ( modifier.compare("add") == 0 ){
961 // only add if appname is entered 961 // only add if appname is entered
962 if (!appName.isEmpty()) { 962 if (!appName.isEmpty()) {
963 cfg.writeEntry("Apps", appName); 963 cfg.writeEntry("Apps", appName);
964 } 964 }
965 } else if (modifier.compare("remove") == 0 ) { 965 } else if (modifier.compare("remove") == 0 ) {
966 // need to change for multiple entries 966 // need to change for multiple entries
967 // actually remove is right now simular to clear, but in future there 967 // actually remove is right now simular to clear, but in future there
968 // should be multiple apps in autostart possible. 968 // should be multiple apps in autostart possible.
969 QString checkName; 969 QString checkName;
970 checkName = cfg.readEntry("Apps", ""); 970 checkName = cfg.readEntry("Apps", "");
971 if (checkName == appName) { 971 if (checkName == appName) {
972 cfg.writeEntry("Apps", ""); 972 cfg.writeEntry("Apps", "");
973 } 973 }
974 } 974 }
975 // case the autostart feature should be delayed 975 // case the autostart feature should be delayed
976 } else if ( msg == "autoStart(QString,QString,QString)") { 976 } else if ( msg == "autoStart(QString,QString,QString)") {
977 QString modifier, appName, delay; 977 QString modifier, appName, delay;
978 stream >> modifier >> appName >> delay; 978 stream >> modifier >> appName >> delay;
979 Config cfg( "autostart" ); 979 Config cfg( "autostart" );
980 cfg.setGroup( "AutoStart" ); 980 cfg.setGroup( "AutoStart" );
981 if ( modifier.compare("add") == 0 ){ 981 if ( modifier.compare("add") == 0 ){
982 // only add it appname is entered 982 // only add it appname is entered
983 if (!appName.isEmpty()) { 983 if (!appName.isEmpty()) {
984 cfg.writeEntry("Apps", appName); 984 cfg.writeEntry("Apps", appName);
985 cfg.writeEntry("Delay", delay); 985 cfg.writeEntry("Delay", delay);
986 } 986 }
987 } else { 987 } else {
988 } 988 }
989 } 989 }
990 /* 990 /*
991 * QtopiaDesktop relies on the major number 991 * QtopiaDesktop relies on the major number
992 * to start with 1. We're at 0.9 992 * to start with 1. We're at 0.9
993 * so wee need to fake at least 1.4 to be able 993 * so wee need to fake at least 1.4 to be able
994 * to sync with QtopiaDesktop1.6 994 * to sync with QtopiaDesktop1.6
995 */ 995 */
996 else if ( msg == "sendVersionInfo()" ) { 996 else if ( msg == "sendVersionInfo()" ) {
997 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" ); 997 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" );
998 QString v2 = QString::fromLatin1("1.4"); 998 QString v2 = QString::fromLatin1("1.4");
999 e << v2; 999 e << v2;
1000 //qDebug("version %s\n", line.latin1()); 1000 //qDebug("version %s\n", line.latin1());
1001 } else if ( msg == "sendCardInfo()" ) { 1001 } else if ( msg == "sendCardInfo()" ) {
1002#ifndef QT_NO_COP 1002#ifndef QT_NO_COP
1003 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 1003 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
1004#endif 1004#endif
1005 const QList<FileSystem> &fs = storage->fileSystems(); 1005 const QList<FileSystem> &fs = storage->fileSystems();
1006 QListIterator<FileSystem> it ( fs ); 1006 QListIterator<FileSystem> it ( fs );
1007 QString s; 1007 QString s;
1008 QString homeDir = getenv("HOME"); 1008 QString homeDir = getenv("HOME");
1009 QString hardDiskHome, hardDiskHomePath; 1009 QString hardDiskHome, hardDiskHomePath;
1010 for ( ; it.current(); ++it ) { 1010 for ( ; it.current(); ++it ) {
1011 int k4 = (*it)->blockSize()/256; 1011 int k4 = (*it)->blockSize()/256;
1012 if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") { 1012 if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") {
1013 s += (*it)->name() + "=" + (*it)->path() + "/Documents " 1013 s += (*it)->name() + "=" + (*it)->path() + "/Documents "
1014 + QString::number( (*it)->availBlocks() * k4/4 ) 1014 + QString::number( (*it)->availBlocks() * k4/4 )
1015 + "K " + (*it)->options() + ";"; 1015 + "K " + (*it)->options() + ";";
1016 } else if ( (*it)->disk() == "/dev/mtdblock1" || 1016 } else if ( (*it)->disk() == "/dev/mtdblock1" ||
1017 (*it)->disk() == "/dev/mtdblock/1" ) { 1017 (*it)->disk() == "/dev/mtdblock/1" ) {
1018 s += (*it)->name() + "=" + homeDir + "/Documents " 1018 s += (*it)->name() + "=" + homeDir + "/Documents "
1019 + QString::number( (*it)->availBlocks() * k4/4 ) 1019 + QString::number( (*it)->availBlocks() * k4/4 )
1020 + "K " + (*it)->options() + ";"; 1020 + "K " + (*it)->options() + ";";
1021 } else if ( (*it)->name().contains( "Hard Disk") && 1021 } else if ( (*it)->name().contains( "Hard Disk") &&
1022 homeDir.contains( (*it)->path() ) && 1022 homeDir.contains( (*it)->path() ) &&
1023 (*it)->path().length() > hardDiskHomePath.length() ) { 1023 (*it)->path().length() > hardDiskHomePath.length() ) {
1024 hardDiskHomePath = (*it)->path(); 1024 hardDiskHomePath = (*it)->path();
1025 hardDiskHome = 1025 hardDiskHome =
1026 (*it)->name() + "=" + homeDir + "/Documents " 1026 (*it)->name() + "=" + homeDir + "/Documents "
1027 + QString::number( (*it)->availBlocks() * k4/4 ) 1027 + QString::number( (*it)->availBlocks() * k4/4 )
1028 + "K " + (*it)->options() + ";"; 1028 + "K " + (*it)->options() + ";";
1029 } 1029 }
1030 } 1030 }
1031 if ( !hardDiskHome.isEmpty() ) 1031 if ( !hardDiskHome.isEmpty() )
1032 s += hardDiskHome; 1032 s += hardDiskHome;
1033 1033
1034#ifndef QT_NO_COP 1034#ifndef QT_NO_COP
1035 e << s; 1035 e << s;
1036#endif 1036#endif
1037 } else if ( msg == "sendSyncDate(QString)" ) { 1037 } else if ( msg == "sendSyncDate(QString)" ) {
1038 QString app; 1038 QString app;
1039 stream >> app; 1039 stream >> app;
1040 Config cfg( "qpe" ); 1040 Config cfg( "qpe" );
1041 cfg.setGroup("SyncDate"); 1041 cfg.setGroup("SyncDate");
1042#ifndef QT_NO_COP 1042#ifndef QT_NO_COP
1043 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 1043 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
1044 e << app << cfg.readEntry( app ); 1044 e << app << cfg.readEntry( app );
1045#endif 1045#endif
1046 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 1046 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
1047 //cfg.readEntry( app ).latin1() ); 1047 //cfg.readEntry( app ).latin1() );
1048 } else if ( msg == "setSyncDate(QString,QString)" ) { 1048 } else if ( msg == "setSyncDate(QString,QString)" ) {
1049 QString app, date; 1049 QString app, date;
1050 stream >> app >> date; 1050 stream >> app >> date;
1051 Config cfg( "qpe" ); 1051 Config cfg( "qpe" );
1052 cfg.setGroup("SyncDate"); 1052 cfg.setGroup("SyncDate");
1053 cfg.writeEntry( app, date ); 1053 cfg.writeEntry( app, date );
1054 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); 1054 //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1());
1055 } else if ( msg == "startSync(QString)" ) { 1055 } else if ( msg == "startSync(QString)" ) {
1056 QString what; 1056 QString what;
1057 stream >> what; 1057 stream >> what;
1058 delete syncDialog; syncDialog = 0; 1058 delete syncDialog; syncDialog = 0;
1059 syncDialog = new SyncDialog( this, "syncProgress", FALSE, 1059 syncDialog = new SyncDialog( this, "syncProgress", FALSE,
1060 WStyle_Tool | WStyle_Customize | 1060 WStyle_Tool | WStyle_Customize |
1061 Qt::WStyle_StaysOnTop ); 1061 Qt::WStyle_StaysOnTop );
1062 syncDialog->showMaximized(); 1062 syncDialog->showMaximized();
1063 syncDialog->whatLabel->setText( "<b>" + what + "</b>" ); 1063 syncDialog->whatLabel->setText( "<b>" + what + "</b>" );
1064 connect( syncDialog->buttonCancel, SIGNAL( clicked() ), 1064 connect( syncDialog->buttonCancel, SIGNAL( clicked() ),
1065 SLOT( cancelSync() ) ); 1065 SLOT( cancelSync() ) );
1066 } else if ( msg == "stopSync()") { 1066 } else if ( msg == "stopSync()") {
1067 delete syncDialog; syncDialog = 0; 1067 delete syncDialog; syncDialog = 0;
1068 } else if ( msg == "getAllDocLinks()" ) { 1068 } else if ( msg == "getAllDocLinks()" ) {
1069 loadDocs(); 1069 loadDocs();
1070 1070
1071 QString contents; 1071 QString contents;
1072 1072
1073 //Categories cats; 1073 //Categories cats;
1074 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { 1074 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
1075 DocLnk *doc = it.current(); 1075 DocLnk *doc = it.current();
1076 QFileInfo fi( doc->file() ); 1076 QFileInfo fi( doc->file() );
1077 if ( !fi.exists() ) 1077 if ( !fi.exists() )
1078 continue; 1078 continue;
1079 1079
1080 bool fake = !doc->linkFileKnown(); 1080 bool fake = !doc->linkFileKnown();
1081 if ( !fake ) { 1081 if ( !fake ) {
1082 QFile f( doc->linkFile() ); 1082 QFile f( doc->linkFile() );
1083 if ( f.open( IO_ReadOnly ) ) { 1083 if ( f.open( IO_ReadOnly ) ) {
1084 QTextStream ts( &f ); 1084 QTextStream ts( &f );
1085 ts.setEncoding( QTextStream::UnicodeUTF8 ); 1085 ts.setEncoding( QTextStream::UnicodeUTF8 );
1086 contents += ts.read(); 1086 contents += ts.read();
1087 f.close(); 1087 f.close();
1088 } else 1088 } else
1089 fake = TRUE; 1089 fake = TRUE;
1090 } 1090 }
1091 if (fake) { 1091 if (fake) {
1092 contents += "[Desktop Entry]\n"; 1092 contents += "[Desktop Entry]\n";
1093 contents += "Categories = " + // No tr 1093 contents += "Categories = " + // No tr
1094 // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr 1094 // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
1095 Qtopia::Record::idsToString( doc->categories() ) + "\n"; 1095 Qtopia::Record::idsToString( doc->categories() ) + "\n";
1096 contents += "Name = "+doc->name()+"\n"; // No tr 1096 contents += "Name = "+doc->name()+"\n"; // No tr
1097 contents += "Type = "+doc->type()+"\n"; // No tr 1097 contents += "Type = "+doc->type()+"\n"; // No tr
1098 } 1098 }
1099 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) 1099 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
1100 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 1100 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
1101 } 1101 }
1102 1102
1103 //qDebug( "sending length %d", contents.length() ); 1103 //qDebug( "sending length %d", contents.length() );
1104#ifndef QT_NO_COP 1104#ifndef QT_NO_COP
1105 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 1105 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
1106 e << contents; 1106 e << contents;
1107#endif 1107#endif
1108 1108
1109 //qDebug( "================ \n\n%s\n\n===============", 1109 //qDebug( "================ \n\n%s\n\n===============",
1110 //contents.latin1() ); 1110 //contents.latin1() );
1111 1111
1112 delete docsFolder; 1112 delete docsFolder;
1113 docsFolder = 0; 1113 docsFolder = 0;
1114#ifdef QWS 1114#ifdef QWS
1115 } else if ( msg == "setMouseProto(QString)" ) { 1115 } else if ( msg == "setMouseProto(QString)" ) {
1116 QString mice; 1116 QString mice;
1117 stream >> mice; 1117 stream >> mice;
1118 setenv("QWS_MOUSE_PROTO",mice.latin1(),1); 1118 setenv("QWS_MOUSE_PROTO",mice.latin1(),1);
1119 qwsServer->openMouse(); 1119 qwsServer->openMouse();
1120 } else if ( msg == "setKeyboard(QString)" ) { 1120 } else if ( msg == "setKeyboard(QString)" ) {
1121 QString kb; 1121 QString kb;
1122 stream >> kb; 1122 stream >> kb;
1123 setenv("QWS_KEYBOARD",kb.latin1(),1); 1123 setenv("QWS_KEYBOARD",kb.latin1(),1);
1124 qwsServer->openKeyboard(); 1124 qwsServer->openKeyboard();
1125#endif 1125#endif
1126 } 1126 }
1127} 1127}
1128 1128
1129void Launcher::cancelSync() 1129void Launcher::cancelSync()
1130{ 1130{
1131#ifndef QT_NO_COP 1131#ifndef QT_NO_COP
1132 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 1132 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
1133#endif 1133#endif
1134} 1134}
1135 1135
1136void Launcher::launcherMessage( const QCString &msg, const QByteArray &data) 1136void Launcher::launcherMessage( const QCString &msg, const QByteArray &data)
1137{ 1137{
1138 QDataStream stream( data, IO_ReadOnly ); 1138 QDataStream stream( data, IO_ReadOnly );
1139 if ( msg == "setTabView(QString,int)" ) { 1139 if ( msg == "setTabView(QString,int)" ) {
1140 QString id; 1140 QString id;
1141 stream >> id; 1141 stream >> id;
1142 int mode; 1142 int mode;
1143 stream >> mode; 1143 stream >> mode;
1144 if ( tabs->view(id) ) 1144 if ( tabs->view(id) )
1145 tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode ); 1145 tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode );
1146 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 1146 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
1147 QString id; 1147 QString id;
1148 stream >> id; 1148 stream >> id;
1149 int mode; 1149 int mode;
1150 stream >> mode; 1150 stream >> mode;
1151 QString pixmapOrColor; 1151 QString pixmapOrColor;
1152 stream >> pixmapOrColor; 1152 stream >> pixmapOrColor;
1153 if ( tabs->view(id) ) 1153 if ( tabs->view(id) )
1154 tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 1154 tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
1155 } else if ( msg == "setTextColor(QString,QString)" ) { 1155 } else if ( msg == "setTextColor(QString,QString)" ) {
1156 QString id; 1156 QString id;
1157 stream >> id; 1157 stream >> id;
1158 QString color; 1158 QString color;
1159 stream >> color; 1159 stream >> color;
1160 if ( tabs->view(id) ) 1160 if ( tabs->view(id) )
1161 tabs->view(id)->setTextColor( QColor(color) ); 1161 tabs->view(id)->setTextColor( QColor(color) );
1162 } else if ( msg == "setFont(QString,QString,int,int,int)" ) { 1162 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
1163 QString id; 1163 QString id;
1164 stream >> id; 1164 stream >> id;
1165 QString fam; 1165 QString fam;
1166 stream >> fam; 1166 stream >> fam;
1167 int size; 1167 int size;
1168 stream >> size; 1168 stream >> size;
1169 int weight; 1169 int weight;
1170 stream >> weight; 1170 stream >> weight;
1171 int italic; 1171 int italic;
1172 stream >> italic; 1172 stream >> italic;
1173 if ( tabs->view(id) ) 1173 if ( tabs->view(id) )
1174 tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); 1174 tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
1175 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic ); 1175 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic );
1176 } 1176 }
1177 else if ( msg == "setBusyIndicatorType(QString)" ) { 1177 else if ( msg == "setBusyIndicatorType(QString)" ) {
1178 QString type; 1178 QString type;
1179 stream >> type; 1179 stream >> type;
1180 tabs->setBusyIndicatorType(type); 1180 tabs->setBusyIndicatorType(type);
1181 } 1181 }
1182} 1182}
1183 1183
1184void Launcher::storageChanged() 1184void Launcher::storageChanged()
1185{ 1185{
1186 if ( in_lnk_props ) { 1186 if ( in_lnk_props ) {
1187 got_lnk_change = TRUE; 1187 got_lnk_change = TRUE;
1188 lnk_change = QString::null; 1188 lnk_change = QString::null;
1189 } else { 1189 } else {
1190 updateLink( QString::null ); 1190 updateLink( QString::null );
1191 } 1191 }
1192} 1192}
1193 1193
1194 1194
1195bool Launcher::mkdir(const QString &localPath) 1195bool Launcher::mkdir(const QString &localPath)
1196{ 1196{
1197 QDir fullDir(localPath); 1197 QDir fullDir(localPath);
1198 if (fullDir.exists()) 1198 if (fullDir.exists())
1199 return true; 1199 return true;
1200 1200
1201 // at this point the directory doesn't exist 1201 // at this point the directory doesn't exist
1202 // go through the directory tree and start creating the direcotories 1202 // go through the directory tree and start creating the direcotories
1203 // that don't exist; if we can't create the directories, return false 1203 // that don't exist; if we can't create the directories, return false
1204 1204
1205 QString dirSeps = "/"; 1205 QString dirSeps = "/";
1206 int dirIndex = localPath.find(dirSeps); 1206 int dirIndex = localPath.find(dirSeps);
1207 QString checkedPath; 1207 QString checkedPath;
1208 1208
1209 // didn't find any seps; weird, use the cur dir instead 1209 // didn't find any seps; weird, use the cur dir instead
1210 if (dirIndex == -1) { 1210 if (dirIndex == -1) {
1211 //qDebug("No seperators found in path %s", localPath.latin1()); 1211 //qDebug("No seperators found in path %s", localPath.latin1());
1212 checkedPath = QDir::currentDirPath(); 1212 checkedPath = QDir::currentDirPath();
1213 } 1213 }
1214 1214
1215 while (checkedPath != localPath) { 1215 while (checkedPath != localPath) {
1216 // no more seperators found, use the local path 1216 // no more seperators found, use the local path
1217 if (dirIndex == -1) 1217 if (dirIndex == -1)
1218 checkedPath = localPath; 1218 checkedPath = localPath;
1219 else { 1219 else {
1220 // the next directory to check 1220 // the next directory to check
1221 checkedPath = localPath.left(dirIndex) + "/"; 1221 checkedPath = localPath.left(dirIndex) + "/";
1222 // advance the iterator; the next dir seperator 1222 // advance the iterator; the next dir seperator
1223 dirIndex = localPath.find(dirSeps, dirIndex+1); 1223 dirIndex = localPath.find(dirSeps, dirIndex+1);
1224 } 1224 }
1225 1225
1226 QDir checkDir(checkedPath); 1226 QDir checkDir(checkedPath);
1227 if (!checkDir.exists()) { 1227 if (!checkDir.exists()) {
1228 //qDebug("mkdir making dir %s", checkedPath.latin1()); 1228 //qDebug("mkdir making dir %s", checkedPath.latin1());
1229 1229
1230 if (!checkDir.mkdir(checkedPath)) { 1230 if (!checkDir.mkdir(checkedPath)) {
1231 qDebug("Unable to make directory %s", checkedPath.latin1()); 1231 qDebug("Unable to make directory %s", checkedPath.latin1());
1232 return FALSE; 1232 return FALSE;
1233 } 1233 }
1234 } 1234 }
1235 1235
1236 } 1236 }
1237 return TRUE; 1237 return TRUE;
1238} 1238}
1239 1239
1240void Launcher::preloadApps() 1240void Launcher::preloadApps()
1241{ 1241{
1242 Config cfg("Launcher"); 1242 Config cfg("Launcher");
1243 cfg.setGroup("Preload"); 1243 cfg.setGroup("Preload");
1244 QStringList apps = cfg.readListEntry("Apps",','); 1244 QStringList apps = cfg.readListEntry("Apps",',');
1245 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 1245 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
1246#ifndef QT_NO_COP 1246#ifndef QT_NO_COP
1247 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 1247 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
1248#endif 1248#endif
1249 } 1249 }
1250} 1250}