summaryrefslogtreecommitdiff
path: root/core/launcher/launcher.cpp
Unidiff
Diffstat (limited to 'core/launcher/launcher.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcher.cpp354
1 files changed, 292 insertions, 62 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index fd89410..dc81c9e 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -1,8 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (c) 2002 Holger zecke Freyther 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** Copyright (C) 2000 Trolltech AS. All rights reserved.
4** 3**
5** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
6** 5**
7** 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
8** 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
@@ -23,8 +22,9 @@
23// have this class. 22// have this class.
24#define QTOPIA_INTERNAL_FSLP 23#define QTOPIA_INTERNAL_FSLP
25 24
26#include <qpe/config.h> 25#ifdef QWS
27#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
27#endif
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include <qpe/applnk.h> 29#include <qpe/applnk.h>
30#include <qpe/config.h> 30#include <qpe/config.h>
@@ -34,9 +34,12 @@
34#include <qpe/storage.h> 34#include <qpe/storage.h>
35#include <qpe/palmtoprecord.h> 35#include <qpe/palmtoprecord.h>
36 36
37#include <qdatetime.h> 37#include <qpe/version.h>
38
38#include <qdir.h> 39#include <qdir.h>
40#ifdef QWS
39#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42#endif
40#include <qtimer.h> 43#include <qtimer.h>
41#include <qcombobox.h> 44#include <qcombobox.h>
42#include <qvbox.h> 45#include <qvbox.h>
@@ -52,6 +55,7 @@
52#include <qpainter.h> 55#include <qpainter.h>
53#include <qlabel.h> 56#include <qlabel.h>
54#include <qtextstream.h> 57#include <qtextstream.h>
58#include <qpopupmenu.h>
55 59
56#include "launcherview.h" 60#include "launcherview.h"
57#include "launcher.h" 61#include "launcher.h"
@@ -71,11 +75,7 @@
71 75
72#include <qpe/storage.h> 76#include <qpe/storage.h>
73#include "mediummountgui.h" 77#include "mediummountgui.h"
74//#define SHOW_ALL
75
76// uidGen
77 78
78// uidGen
79namespace { 79namespace {
80 QStringList configToMime( Config *cfg ){ 80 QStringList configToMime( Config *cfg ){
81 QStringList mimes; 81 QStringList mimes;
@@ -108,6 +108,23 @@ namespace {
108} 108}
109 109
110 110
111
112//#define SHOW_ALL
113
114class CategoryTab : public QTab
115{
116public:
117 CategoryTab( const QIconSet &icon, const QString &text=QString::null )
118 : QTab( icon, text )
119 {
120 }
121
122 QColor bgColor;
123 QColor fgColor;
124};
125
126//===========================================================================
127
111CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 128CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
112 QVBox( parent ) 129 QVBox( parent )
113{ 130{
@@ -140,15 +157,21 @@ void CategoryTabWidget::addItem( const QString& linkfile )
140 AppLnk *app = new AppLnk(linkfile); 157 AppLnk *app = new AppLnk(linkfile);
141 if ( !app->isValid() ) { 158 if ( !app->isValid() ) {
142 delete app; 159 delete app;
143 return; 160 app=0;
144 } 161 }
145 if ( !app->file().isEmpty() ) { 162 if ( !app || !app->file().isEmpty() ) {
146 // A document 163 // A document
147 delete app; 164 delete app;
148 app = new DocLnk(linkfile); 165 app = new DocLnk(linkfile);
166 if ( app->fileKnown() ) {
149 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); 167 ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app);
168 } else {
169 ((LauncherView*)(stack->widget(ids.count()-1)))->sort();
170 delete app;
171 }
150 return; 172 return;
151 } 173 }
174 // An application
152 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { 175 for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) {
153 if ( !(*it).isEmpty() ) { 176 if ( !(*it).isEmpty() ) {
154 QRegExp tf(*it,FALSE,TRUE); 177 QRegExp tf(*it,FALSE,TRUE);
@@ -159,6 +182,8 @@ void CategoryTabWidget::addItem( const QString& linkfile )
159 i++; 182 i++;
160 } 183 }
161 } 184 }
185
186 QCopEnvelope e("QPE/TaskBar","reloadApps()");
162} 187}
163 188
164void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, 189void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
@@ -177,16 +202,19 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
177 202
178 ids.clear(); 203 ids.clear();
179 204
205 Config cfg("Launcher");
206
180 QStringList types = rootFolder->types(); 207 QStringList types = rootFolder->types();
181 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { 208 for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) {
182 if ( !(*it).isEmpty() ) { 209 if ( !(*it).isEmpty() ) {
183 newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); 210 (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it));
211 setTabAppearance( *it, cfg );
184 } 212 }
185 } 213 }
186 QListIterator<AppLnk> it( rootFolder->children() ); 214 QListIterator<AppLnk> it( rootFolder->children() );
187 AppLnk* l; 215 AppLnk* l;
188 while ( (l=it.current()) ) { 216 while ( (l=it.current()) ) {
189 if ( l->type() == "Separator" ) { 217 if ( l->type() == "Separator" ) { // No tr
190 rootFolder->remove(l); 218 rootFolder->remove(l);
191 delete l; 219 delete l;
192 } else { 220 } else {
@@ -204,11 +232,16 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
204 ((LauncherView*)stack->widget(i))->sort(); 232 ((LauncherView*)stack->widget(i))->sort();
205 233
206 // all documents 234 // all documents
207 docview = newView( QString::null, Resource::loadPixmap("DocsIcon"), tr("Documents")); 235 QImage img( Resource::loadImage( "DocsIcon" ) );
236 QPixmap pm;
237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
238 docview = newView( "Documents", // No tr
239 pm, tr("Documents"));
208 docview->populate( docFolder, QString::null ); 240 docview->populate( docFolder, QString::null );
209 docFolder->detachChildren(); 241 docFolder->detachChildren();
210 docview->setFileSystems(fs); 242 docview->setFileSystems(fs);
211 docview->setToolsEnabled(TRUE); 243 docview->setToolsEnabled(TRUE);
244 setTabAppearance( "Documents", cfg ); // No tr
212 245
213 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) ); 246 connect( categoryBar, SIGNAL(selected(int)), stack, SLOT(raiseWidget(int)) );
214 247
@@ -218,6 +251,48 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
218 stack->show(); 251 stack->show();
219} 252}
220 253
254void CategoryTabWidget::setTabAppearance( const QString &id, Config &cfg )
255{
256 QString grp( "Tab %1" ); // No tr
257 cfg.setGroup( grp.arg(id) );
258 LauncherView *v = view( id );
259 int idx = ids.findIndex( id );
260 CategoryTab *tab = (CategoryTab *)categoryBar->tab( idx );
261
262 // View
263 QString view = cfg.readEntry( "View", "Icon" );
264 if ( view == "List" ) // No tr
265 v->setViewMode( LauncherView::List );
266 QString bgType = cfg.readEntry( "BackgroundType", "Ruled" );
267 if ( bgType == "Image" ) { // No tr
268 QString pm = cfg.readEntry( "BackgroundImage", "wallpaper/marble" );
269 v->setBackgroundType( LauncherView::Image, pm );
270 } else if ( bgType == "SolidColor" ) {
271 QString c = cfg.readEntry( "BackgroundColor" );
272 v->setBackgroundType( LauncherView::SolidColor, c );
273 }
274 QString textCol = cfg.readEntry( "TextColor" );
275 if ( textCol.isEmpty() )
276 v->setTextColor( QColor() );
277 else
278 v->setTextColor( QColor(textCol) );
279 QStringList font = cfg.readListEntry( "Font", ',' );
280 if ( font.count() == 4 )
281 v->setViewFont( QFont(font[0], font[1].toInt(), font[2].toInt(), font[3].toInt()!=0) );
282
283 // Tabs
284 QString tabCol = cfg.readEntry( "TabColor" );
285 if ( tabCol.isEmpty() )
286 tab->bgColor = QColor();
287 else
288 tab->bgColor = QColor(tabCol);
289 QString tabTextCol = cfg.readEntry( "TabTextColor" );
290 if ( tabTextCol.isEmpty() )
291 tab->fgColor = QColor();
292 else
293 tab->fgColor = QColor(tabTextCol);
294}
295
221void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs) 296void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem> &fs)
222{ 297{
223 docview->populate( docFolder, QString::null ); 298 docview->populate( docFolder, QString::null );
@@ -226,6 +301,26 @@ void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem>
226 docview->updateTools(); 301 docview->updateTools();
227} 302}
228 303
304void CategoryTabWidget::tabProperties()
305{
306 LauncherView *view = (LauncherView*)stack->widget( categoryBar->currentTab() );
307 QPopupMenu *m = new QPopupMenu( this );
308 m->insertItem( tr("Icon View"), LauncherView::Icon );
309 m->insertItem( tr("List View"), LauncherView::List );
310 m->setItemChecked( (int)view->viewMode(), TRUE );
311 int rv = m->exec( QCursor::pos() );
312 if ( rv >= 0 && rv != view->viewMode() ) {
313 view->setViewMode( (LauncherView::ViewMode)rv );
314 }
315
316 delete m;
317}
318
319QString CategoryTabWidget::getAllDocLinkInfo() const
320{
321 return docview->getAllDocLinkInfo();
322}
323
229LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label ) 324LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm, const QString& label )
230{ 325{
231 LauncherView* view = new LauncherView( stack ); 326 LauncherView* view = new LauncherView( stack );
@@ -234,7 +329,7 @@ LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm,
234 connect( view, SIGNAL(rightPressed(AppLnk*)), 329 connect( view, SIGNAL(rightPressed(AppLnk*)),
235 this, SIGNAL(rightPressed(AppLnk*))); 330 this, SIGNAL(rightPressed(AppLnk*)));
236 ids.append(id); 331 ids.append(id);
237 categoryBar->addTab( new QTab( pm, label ) ); 332 categoryBar->addTab( new CategoryTab( pm, label ) );
238 stack->addWidget( view, tabs++ ); 333 stack->addWidget( view, tabs++ );
239 return view; 334 return view;
240} 335}
@@ -270,6 +365,13 @@ void CategoryTabWidget::setBusy(bool on)
270 ((LauncherView*)stack->widget(i))->setBusy(FALSE); 365 ((LauncherView*)stack->widget(i))->setBusy(FALSE);
271} 366}
272 367
368LauncherView *CategoryTabWidget::view( const QString &id )
369{
370 int idx = ids.findIndex( id );
371 return (LauncherView *)stack->widget(idx);
372}
373
374//===========================================================================
273 375
274CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name ) 376CategoryTabBar::CategoryTabBar( QWidget *parent, const char *name )
275 : QTabBar( parent, name ) 377 : QTabBar( parent, name )
@@ -288,34 +390,56 @@ void CategoryTabBar::layoutTabs()
288 return; 390 return;
289 391
290// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 }; 392// int percentFalloffTable[] = { 100, 70, 40, 12, 6, 3, 1, 0 };
393 int available = width()-1;
394 QFontMetrics fm = fontMetrics();
291 int hiddenTabWidth = -7; 395 int hiddenTabWidth = -7;
292 int middleTab = currentTab(); 396 int middleTab = currentTab();
293 int hframe, vframe, overlap; 397 int hframe, vframe, overlap;
294 style().tabbarMetrics( this, hframe, vframe, overlap ); 398 style().tabbarMetrics( this, hframe, vframe, overlap );
295 QFontMetrics fm = fontMetrics();
296 int x = 0; 399 int x = 0;
297 QRect r; 400 QRect r;
298 QTab *t; 401 QTab *t;
299 int available = width()-1;
300 int required = 0; 402 int required = 0;
403 int eventabwidth = (width()-1)/count();
404 enum Mode { HideBackText, Pack, Even } mode=Even;
301 for ( int i = 0; i < count(); i++ ) { 405 for ( int i = 0; i < count(); i++ ) {
302 t = tab(i); 406 t = tab(i);
303 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { 407 int iw = fm.width( t->text() ) + hframe - overlap;
304 if ( i != middleTab ) { 408 if ( i != middleTab ) {
305 // required += hiddenTabWidth + hframe - overlap;
306 available -= hiddenTabWidth + hframe - overlap; 409 available -= hiddenTabWidth + hframe - overlap;
307 if ( t->iconSet() != 0 ) 410 if ( t->iconSet() != 0 )
308 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width(); 411 available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
309 } else {
310 required += fm.width( t->text() ) + hframe - overlap;
311 if ( t->iconSet() != 0 )
312 required += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
313 }
314 } 412 }
413 if ( t->iconSet() != 0 )
414 iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
415 required += iw;
416 // As space gets tight, packed looks better than even. "10" must be at least 0.
417 if ( iw >= eventabwidth-10 )
418 mode = Pack;
419 }
420 if ( mode == Pack && required > width()-1 )
421 mode = HideBackText;
315 for ( int i = 0; i < count(); i++ ) { 422 for ( int i = 0; i < count(); i++ ) {
316 t = tab(i); 423 t = tab(i);
317 // if (( i < (middleTab - 1) ) || ( i > (middleTab + 1) )) { 424 if ( mode != HideBackText ) {
318 if ( i != middleTab ) { 425 int w = fm.width( t->text() );
426 int ih = 0;
427 if ( t->iconSet() != 0 ) {
428 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
429 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
430 }
431 int h = QMAX( fm.height(), ih );
432 h = QMAX( h, QApplication::globalStrut().height() );
433
434 h += vframe;
435 w += hframe;
436
437 QRect tr(x, 0,
438 mode == Even ? eventabwidth : w * (width()-1)/required, h);
439 t->setRect(tr);
440 x += tr.width() - overlap;
441 r = r.unite(tr);
442 } else if ( i != middleTab ) {
319 int w = hiddenTabWidth; 443 int w = hiddenTabWidth;
320 int ih = 0; 444 int ih = 0;
321 if ( t->iconSet() != 0 ) { 445 if ( t->iconSet() != 0 ) {
@@ -332,19 +456,15 @@ void CategoryTabBar::layoutTabs()
332 x += t->rect().width() - overlap; 456 x += t->rect().width() - overlap;
333 r = r.unite( t->rect() ); 457 r = r.unite( t->rect() );
334 } else { 458 } else {
335 int w = fm.width( t->text() );
336 int ih = 0; 459 int ih = 0;
337 if ( t->iconSet() != 0 ) { 460 if ( t->iconSet() != 0 ) {
338 w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
339 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height(); 461 ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
340 } 462 }
341 int h = QMAX( fm.height(), ih ); 463 int h = QMAX( fm.height(), ih );
342 h = QMAX( h, QApplication::globalStrut().height() ); 464 h = QMAX( h, QApplication::globalStrut().height() );
343 465
344 h += vframe; 466 h += vframe;
345 w += hframe;
346 467
347 // t->setRect( QRect(x, 0, w * available/required, h) );
348 t->setRect( QRect(x, 0, available, h) ); 468 t->setRect( QRect(x, 0, available, h) );
349 x += t->rect().width() - overlap; 469 x += t->rect().width() - overlap;
350 r = r.unite( t->rect() ); 470 r = r.unite( t->rect() );
@@ -367,6 +487,19 @@ void CategoryTabBar::layoutTabs()
367 487
368void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const 488void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
369{ 489{
490 CategoryTabBar *that = (CategoryTabBar *) this;
491 CategoryTab *ct = (CategoryTab *)t;
492 QPalette pal = palette();
493 bool setPal = FALSE;
494 if ( ct->bgColor.isValid() ) {
495 pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor );
496 pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor );
497 pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor );
498 pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor );
499 that->setUpdatesEnabled( FALSE );
500 that->setPalette( pal );
501 setPal = TRUE;
502 }
370#if QT_VERSION >= 300 503#if QT_VERSION >= 300
371 QStyle::SFlags flags = QStyle::Style_Default; 504 QStyle::SFlags flags = QStyle::Style_Default;
372 if ( selected ) 505 if ( selected )
@@ -383,6 +516,13 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
383 f.setBold( TRUE ); 516 f.setBold( TRUE );
384 p->setFont( f ); 517 p->setFont( f );
385 518
519 if ( ct->fgColor.isValid() ) {
520 pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor );
521 pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor );
522 that->setUpdatesEnabled( FALSE );
523 that->setPalette( pal );
524 setPal = TRUE;
525 }
386 int iw = 0; 526 int iw = 0;
387 int ih = 0; 527 int ih = 0;
388 if ( t->iconSet() != 0 ) { 528 if ( t->iconSet() != 0 ) {
@@ -399,6 +539,10 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
399 t->identitifer() == keyboardFocusTab() 539 t->identitifer() == keyboardFocusTab()
400#endif 540#endif
401 ); 541 );
542 if ( setPal ) {
543 that->unsetPalette();
544 that->setUpdatesEnabled( TRUE );
545 }
402} 546}
403 547
404 548
@@ -457,6 +601,7 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
457 tabs = 0; 601 tabs = 0;
458 rootFolder = 0; 602 rootFolder = 0;
459 docsFolder = 0; 603 docsFolder = 0;
604
460 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know 605 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
461 //uidgen.store( stamp ); 606 //uidgen.store( stamp );
462 m_timeStamp = QString::number( stamp ); 607 m_timeStamp = QString::number( stamp );
@@ -476,6 +621,9 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 621 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 622 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
478 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 623 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
624 QCopChannel *channel = new QCopChannel( "QPE/Launcher", this );
625 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
626 this, SLOT(launcherMessage(const QCString&, const QByteArray&)) );
479#endif 627#endif
480 628
481 storage = new StorageInfo( this ); 629 storage = new StorageInfo( this );
@@ -491,16 +639,20 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
491 639
492Launcher::~Launcher() 640Launcher::~Launcher()
493{ 641{
642 delete rootFolder;
643 delete docsFolder;
494} 644}
495 645
496static bool isVisibleWindow(int wid) 646static bool isVisibleWindow(int wid)
497{ 647{
648#ifdef QWS
498 const QList<QWSWindow> &list = qwsServer->clientWindows(); 649 const QList<QWSWindow> &list = qwsServer->clientWindows();
499 QWSWindow* w; 650 QWSWindow* w;
500 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 651 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
501 if ( w->winId() == wid ) 652 if ( w->winId() == wid )
502 return !w->isFullyObscured(); 653 return !w->isFullyObscured();
503 } 654 }
655#endif
504 return FALSE; 656 return FALSE;
505} 657}
506 658
@@ -527,13 +679,14 @@ void Launcher::updateMimeTypes(AppLnkSet* folder)
527{ 679{
528 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 680 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
529 AppLnk *app = it.current(); 681 AppLnk *app = it.current();
530 if ( app->type() == "Folder" ) 682 if ( app->type() == "Folder" ) // No tr
531 updateMimeTypes((AppLnkSet *)app); 683 updateMimeTypes((AppLnkSet *)app);
532 else { 684 else {
533 MimeType::registerApp(*app); 685 MimeType::registerApp(*app);
534 } 686 }
535 } 687 }
536} 688}
689
537/** This is a HACK.... 690/** This is a HACK....
538 * Reason: scanning huge mediums, microdirvers for examples 691 * Reason: scanning huge mediums, microdirvers for examples
539 * consomes time. To avoid that we invented the MediumMountCheck 692 * consomes time. To avoid that we invented the MediumMountCheck
@@ -675,7 +828,7 @@ void Launcher::nextView()
675 828
676void Launcher::select( const AppLnk *appLnk ) 829void Launcher::select( const AppLnk *appLnk )
677{ 830{
678 if ( appLnk->type() == "Folder" ) { 831 if ( appLnk->type() == "Folder" ) { // No tr
679 // Not supported: flat is simpler for the user 832 // Not supported: flat is simpler for the user
680 } else { 833 } else {
681 if ( appLnk->exec().isNull() ) { 834 if ( appLnk->exec().isNull() ) {
@@ -698,7 +851,7 @@ void Launcher::externalSelected(const AppLnk *appLnk)
698 851
699void Launcher::properties( AppLnk *appLnk ) 852void Launcher::properties( AppLnk *appLnk )
700{ 853{
701 if ( appLnk->type() == "Folder" ) { 854 if ( appLnk->type() == "Folder" ) { // No tr
702 // Not supported: flat is simpler for the user 855 // Not supported: flat is simpler for the user
703 } else { 856 } else {
704 in_lnk_props = TRUE; 857 in_lnk_props = TRUE;
@@ -727,12 +880,7 @@ void Launcher::updateLink(const QString& link)
727void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 880void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
728{ 881{
729 QDataStream stream( data, IO_ReadOnly ); 882 QDataStream stream( data, IO_ReadOnly );
730 if ( msg == "closing(QString)" ){ 883 if ( msg == "linkChanged(QString)" ) {
731 QString app;
732 stream >> app;
733 //qWarning("app closed %s", app.latin1() );
734 // MRUList::removeTask( app );
735 }else if ( msg == "linkChanged(QString)" ) {
736 QString link; 884 QString link;
737 stream >> link; 885 stream >> link;
738 if ( in_lnk_props ) { 886 if ( in_lnk_props ) {
@@ -770,8 +918,10 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
770 f.close(); 918 f.close();
771 } 919 }
772 QRsync::applyDiff( baseFile, deltaFile ); 920 QRsync::applyDiff( baseFile, deltaFile );
921#ifndef QT_NO_COP
773 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); 922 QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" );
774 e << baseFile; 923 e << baseFile;
924#endif
775 } else if ( msg == "rdiffCleanup()" ) { 925 } else if ( msg == "rdiffCleanup()" ) {
776 mkdir( "/tmp/rdiff" ); 926 mkdir( "/tmp/rdiff" );
777 QDir dir; 927 QDir dir;
@@ -781,12 +931,12 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
781 dir.remove( *it ); 931 dir.remove( *it );
782 } else if ( msg == "sendHandshakeInfo()" ) { 932 } else if ( msg == "sendHandshakeInfo()" ) {
783 QString home = getenv( "HOME" ); 933 QString home = getenv( "HOME" );
934#ifndef QT_NO_COP
784 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); 935 QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" );
785 e << home; 936 e << home;
786 int locked = (int) Desktop::screenLocked(); 937 int locked = (int) Desktop::screenLocked();
787 e << locked; 938 e << locked;
788 // register an app for autostart 939#endif
789 // if clear is send the list is cleared.
790 } else if ( msg == "autoStart(QString)" ) { 940 } else if ( msg == "autoStart(QString)" ) {
791 QString appName; 941 QString appName;
792 stream >> appName; 942 stream >> appName;
@@ -829,42 +979,58 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
829 } 979 }
830 } else { 980 } else {
831 } 981 }
982 } else if ( msg == "sendVersionInfo()" ) {
983 QCopEnvelope e( "QPE/Desktop", "versionInfo(QString)" );
984 QString v = QPE_VERSION;
985 QStringList l = QStringList::split( '.', v );
986 QString v2 = l[0] + '.' + l[1];
987 e << v2;
988 //qDebug("version %s\n", line.latin1());
832 } else if ( msg == "sendCardInfo()" ) { 989 } else if ( msg == "sendCardInfo()" ) {
990#ifndef QT_NO_COP
833 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); 991 QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" );
992#endif
834 const QList<FileSystem> &fs = storage->fileSystems(); 993 const QList<FileSystem> &fs = storage->fileSystems();
835 QListIterator<FileSystem> it ( fs ); 994 QListIterator<FileSystem> it ( fs );
836 QString s; 995 QString s;
837 QString homeDir = getenv("HOME"); 996 QString homeDir = getenv("HOME");
838 QString hardDiskHome; 997 QString hardDiskHome, hardDiskHomePath;
839 for ( ; it.current(); ++it ) { 998 for ( ; it.current(); ++it ) {
840 if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) 999 int k4 = (*it)->blockSize()/256;
1000 if ( (*it)->isRemovable() || (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs") {
841 s += (*it)->name() + "=" + (*it)->path() + "/Documents " 1001 s += (*it)->name() + "=" + (*it)->path() + "/Documents "
842 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 1002 + QString::number( (*it)->availBlocks() * k4/4 )
843 + " " + (*it)->options() + ";"; 1003 + "K " + (*it)->options() + ";";
844 else if ( (*it)->disk() == "/dev/mtdblock1" || 1004 } else if ( (*it)->disk() == "/dev/mtdblock1" ||
845 (*it)->disk() == "/dev/mtdblock/1" ) 1005 (*it)->disk() == "/dev/mtdblock/1" ) {
846 s += (*it)->name() + "=" + homeDir + "/Documents " 1006 s += (*it)->name() + "=" + homeDir + "/Documents "
847 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 1007 + QString::number( (*it)->availBlocks() * k4/4 )
848 + " " + (*it)->options() + ";"; 1008 + "K " + (*it)->options() + ";";
849 else if ( (*it)->name().contains( tr("Hard Disk") ) && 1009 } else if ( (*it)->name().contains( "Hard Disk") &&
850 homeDir.contains( (*it)->path() ) && 1010 homeDir.contains( (*it)->path() ) &&
851 (*it)->path().length() > hardDiskHome.length() ) 1011 (*it)->path().length() > hardDiskHomePath.length() ) {
1012 hardDiskHomePath = (*it)->path();
852 hardDiskHome = 1013 hardDiskHome =
853 (*it)->name() + "=" + homeDir + "/Documents " 1014 (*it)->name() + "=" + homeDir + "/Documents "
854 + QString::number( (*it)->availBlocks() * (*it)->blockSize() ) 1015 + QString::number( (*it)->availBlocks() * k4/4 )
855 + " " + (*it)->options() + ";"; 1016 + "K " + (*it)->options() + ";";
1017 }
856 } 1018 }
857 if ( !hardDiskHome.isEmpty() ) 1019 if ( !hardDiskHome.isEmpty() )
858 s += hardDiskHome; 1020 s += hardDiskHome;
859 1021
1022#ifndef QT_NO_COP
860 e << s; 1023 e << s;
1024#endif
861 } else if ( msg == "sendSyncDate(QString)" ) { 1025 } else if ( msg == "sendSyncDate(QString)" ) {
862 QString app; 1026 QString app;
863 stream >> app; 1027 stream >> app;
864 Config cfg( "qpe" ); 1028 Config cfg( "qpe" );
865 cfg.setGroup("SyncDate"); 1029 cfg.setGroup("SyncDate");
1030#ifndef QT_NO_COP
866 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); 1031 QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" );
867 e << app << cfg.readEntry( app ); 1032 e << app << cfg.readEntry( app );
1033#endif
868 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), 1034 //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(),
869 //cfg.readEntry( app ).latin1() ); 1035 //cfg.readEntry( app ).latin1() );
870 } else if ( msg == "setSyncDate(QString,QString)" ) { 1036 } else if ( msg == "setSyncDate(QString,QString)" ) {
@@ -892,6 +1058,7 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
892 1058
893 QString contents; 1059 QString contents;
894 1060
1061 //Categories cats;
895 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) { 1062 for ( QListIterator<DocLnk> it( docsFolder->children() ); it.current(); ++it ) {
896 DocLnk *doc = it.current(); 1063 DocLnk *doc = it.current();
897 QFileInfo fi( doc->file() ); 1064 QFileInfo fi( doc->file() );
@@ -911,38 +1078,99 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
911 } 1078 }
912 if (fake) { 1079 if (fake) {
913 contents += "[Desktop Entry]\n"; 1080 contents += "[Desktop Entry]\n";
914 contents += "Categories = " + Qtopia::Record::idsToString( doc->categories() ) + "\n"; 1081 contents += "Categories = " + // No tr
915 contents += "File = "+doc->file()+"\n"; 1082 // cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
916 contents += "Name = "+doc->name()+"\n"; 1083 Qtopia::Record::idsToString( doc->categories() ) + "\n";
917 contents += "Type = "+doc->type()+"\n"; 1084 contents += "Name = "+doc->name()+"\n"; // No tr
1085 contents += "Type = "+doc->type()+"\n"; // No tr
918 } 1086 }
919 contents += QString("Size = %1\n").arg( fi.size() ); 1087 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
1088 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
920 } 1089 }
921 1090
922 //qDebug( "sending length %d", contents.length() ); 1091 //qDebug( "sending length %d", contents.length() );
1092#ifndef QT_NO_COP
923 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 1093 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
924 e << contents; 1094 e << contents;
1095#endif
925 1096
926 qDebug( "================ \n\n%s\n\n===============", 1097 //qDebug( "================ \n\n%s\n\n===============",
927 contents.latin1() ); 1098 //contents.latin1() );
928 1099
929 delete docsFolder; 1100 delete docsFolder;
930 docsFolder = 0; 1101 docsFolder = 0;
1102#ifdef QWS
1103 } else if ( msg == "setMouseProto(QString)" ) {
1104 QString mice;
1105 stream >> mice;
1106 setenv("QWS_MOUSE_PROTO",mice.latin1(),1);
1107 qwsServer->openMouse();
1108 } else if ( msg == "setKeyboard(QString)" ) {
1109 QString kb;
1110 stream >> kb;
1111 setenv("QWS_KEYBOARD",kb.latin1(),1);
1112 qwsServer->openKeyboard();
1113#endif
931 } 1114 }
932} 1115}
933 1116
934void Launcher::cancelSync() 1117void Launcher::cancelSync()
935{ 1118{
1119#ifndef QT_NO_COP
936 QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); 1120 QCopEnvelope e( "QPE/Desktop", "cancelSync()" );
1121#endif
1122}
1123
1124void Launcher::launcherMessage( const QCString &msg, const QByteArray &data)
1125{
1126 QDataStream stream( data, IO_ReadOnly );
1127 if ( msg == "setTabView(QString,int)" ) {
1128 QString id;
1129 stream >> id;
1130 int mode;
1131 stream >> mode;
1132 if ( tabs->view(id) )
1133 tabs->view(id)->setViewMode( (LauncherView::ViewMode)mode );
1134 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
1135 QString id;
1136 stream >> id;
1137 int mode;
1138 stream >> mode;
1139 QString pixmapOrColor;
1140 stream >> pixmapOrColor;
1141 if ( tabs->view(id) )
1142 tabs->view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
1143 } else if ( msg == "setTextColor(QString,QString)" ) {
1144 QString id;
1145 stream >> id;
1146 QString color;
1147 stream >> color;
1148 if ( tabs->view(id) )
1149 tabs->view(id)->setTextColor( QColor(color) );
1150 } else if ( msg == "setFont(QString,QString,int,int,int)" ) {
1151 QString id;
1152 stream >> id;
1153 QString fam;
1154 stream >> fam;
1155 int size;
1156 stream >> size;
1157 int weight;
1158 stream >> weight;
1159 int italic;
1160 stream >> italic;
1161 if ( tabs->view(id) )
1162 tabs->view(id)->setViewFont( QFont(fam, size, weight, italic!=0) );
1163 qDebug( "setFont: %s, %d, %d, %d", fam.latin1(), size, weight, italic );
1164 }
937} 1165}
938 1166
939void Launcher::storageChanged() 1167void Launcher::storageChanged()
940{ 1168{
941 if ( in_lnk_props ) { 1169 if ( in_lnk_props ) {
942 got_lnk_change = TRUE; 1170 got_lnk_change = TRUE;
943 lnk_change = ""; 1171 lnk_change = QString::null;
944 } else { 1172 } else {
945 updateDocs(); 1173 updateLink( QString::null );
946 } 1174 }
947} 1175}
948 1176
@@ -998,6 +1226,8 @@ void Launcher::preloadApps()
998 cfg.setGroup("Preload"); 1226 cfg.setGroup("Preload");
999 QStringList apps = cfg.readListEntry("Apps",','); 1227 QStringList apps = cfg.readListEntry("Apps",',');
1000 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { 1228 for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) {
1229#ifndef QT_NO_COP
1001 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); 1230 QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()");
1231#endif
1002 } 1232 }
1003} 1233}