summaryrefslogtreecommitdiff
path: root/core/launcher
Unidiff
Diffstat (limited to 'core/launcher') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcher.cpp354
-rw-r--r--core/launcher/launcher.h13
-rw-r--r--core/launcher/launcherview.cpp470
-rw-r--r--core/launcher/launcherview.h29
4 files changed, 679 insertions, 187 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,6 +1,5 @@
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**
@@ -25,4 +24,5 @@
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>
@@ -36,5 +36,8 @@
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>
@@ -54,2 +57,3 @@
54#include <qtextstream.h> 57#include <qtextstream.h>
58#include <qpopupmenu.h>
55 59
@@ -73,7 +77,3 @@
73#include "mediummountgui.h" 77#include "mediummountgui.h"
74//#define SHOW_ALL
75
76// uidGen
77 78
78// uidGen
79namespace { 79namespace {
@@ -110,2 +110,19 @@ namespace {
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 ) :
@@ -142,5 +159,5 @@ void CategoryTabWidget::addItem( const QString& linkfile )
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
@@ -148,5 +165,11 @@ void CategoryTabWidget::addItem( const QString& linkfile )
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) {
@@ -161,2 +184,4 @@ void CategoryTabWidget::addItem( const QString& linkfile )
161 } 184 }
185
186 QCopEnvelope e("QPE/TaskBar","reloadApps()");
162} 187}
@@ -179,2 +204,4 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
179 204
205 Config cfg("Launcher");
206
180 QStringList types = rootFolder->types(); 207 QStringList types = rootFolder->types();
@@ -182,3 +209,4 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
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 }
@@ -188,3 +216,3 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
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);
@@ -206,3 +234,7 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
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 );
@@ -211,2 +243,3 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
211 docview->setToolsEnabled(TRUE); 243 docview->setToolsEnabled(TRUE);
244 setTabAppearance( "Documents", cfg ); // No tr
212 245
@@ -220,2 +253,44 @@ void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder,
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)
@@ -228,2 +303,22 @@ void CategoryTabWidget::updateDocs(AppLnkSet* docFolder, const QList<FileSystem>
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 )
@@ -236,3 +331,3 @@ LauncherView* CategoryTabWidget::newView( const QString& id, const QPixmap& pm,
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++ );
@@ -272,2 +367,9 @@ void CategoryTabWidget::setBusy(bool on)
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
@@ -290,2 +392,4 @@ void CategoryTabBar::layoutTabs()
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;
@@ -294,3 +398,2 @@ void CategoryTabBar::layoutTabs()
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;
@@ -298,9 +401,9 @@ void CategoryTabBar::layoutTabs()
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;
@@ -308,12 +411,33 @@ void CategoryTabBar::layoutTabs()
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;
@@ -334,6 +458,4 @@ void CategoryTabBar::layoutTabs()
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();
@@ -344,5 +466,3 @@ void CategoryTabBar::layoutTabs()
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) );
@@ -369,2 +489,15 @@ void 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
@@ -385,2 +518,9 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
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;
@@ -401,2 +541,6 @@ void CategoryTabBar::paint( QPainter * p, QTab * t, bool selected ) const
401 ); 541 );
542 if ( setPal ) {
543 that->unsetPalette();
544 that->setUpdatesEnabled( TRUE );
545 }
402} 546}
@@ -459,2 +603,3 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
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
@@ -478,2 +623,5 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
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
@@ -493,2 +641,4 @@ Launcher::~Launcher()
493{ 641{
642 delete rootFolder;
643 delete docsFolder;
494} 644}
@@ -497,2 +647,3 @@ static bool isVisibleWindow(int wid)
497{ 647{
648#ifdef QWS
498 const QList<QWSWindow> &list = qwsServer->clientWindows(); 649 const QList<QWSWindow> &list = qwsServer->clientWindows();
@@ -503,2 +654,3 @@ static bool isVisibleWindow(int wid)
503 } 654 }
655#endif
504 return FALSE; 656 return FALSE;
@@ -529,3 +681,3 @@ void Launcher::updateMimeTypes(AppLnkSet* folder)
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);
@@ -536,2 +688,3 @@ void Launcher::updateMimeTypes(AppLnkSet* folder)
536} 688}
689
537/** This is a HACK.... 690/** This is a HACK....
@@ -677,3 +830,3 @@ void 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
@@ -700,3 +853,3 @@ void 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
@@ -729,8 +882,3 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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;
@@ -772,4 +920,6 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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()" ) {
@@ -783,2 +933,3 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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)" );
@@ -787,4 +938,3 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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)" ) {
@@ -831,4 +981,13 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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();
@@ -837,20 +996,23 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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 }
@@ -859,3 +1021,5 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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)" ) {
@@ -865,4 +1029,6 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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(),
@@ -894,2 +1060,3 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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 ) {
@@ -913,8 +1080,10 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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 }
@@ -922,7 +1091,9 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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
@@ -930,2 +1101,14 @@ void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
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 }
@@ -935,3 +1118,48 @@ void 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}
@@ -942,5 +1170,5 @@ void Launcher::storageChanged()
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 }
@@ -1000,3 +1228,5 @@ void Launcher::preloadApps()
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 }
diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h
index d2efa58..e3881ea 100644
--- a/core/launcher/launcher.h
+++ b/core/launcher/launcher.h
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -22,2 +22,3 @@
22 22
23#include <qpe/config.h>
23#include <qmainwindow.h> 24#include <qmainwindow.h>
@@ -62,2 +63,4 @@ public:
62 void setBusy(bool on); 63 void setBusy(bool on);
64 QString getAllDocLinkInfo() const;
65 LauncherView *view( const QString &id );
63 66
@@ -72,3 +75,7 @@ public slots:
72 75
76protected slots:
77 void tabProperties();
78
73protected: 79protected:
80 void setTabAppearance( const QString &id, Config &cfg );
74 void paletteChange( const QPalette &p ); 81 void paletteChange( const QPalette &p );
@@ -113,2 +120,3 @@ private slots:
113 void systemMessage( const QCString &, const QByteArray &); 120 void systemMessage( const QCString &, const QByteArray &);
121 void launcherMessage( const QCString &, const QByteArray &);
114 void storageChanged(); 122 void storageChanged();
@@ -134,2 +142,3 @@ private:
134 QString lnk_change; 142 QString lnk_change;
143
135 QString m_timeStamp; 144 QString m_timeStamp;
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index c54a00f..047fe45 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -25,3 +25,2 @@
25#include <qpe/qpedebug.h> 25#include <qpe/qpedebug.h>
26#include <qpe/config.h>
27#include <qpe/categories.h> 26#include <qpe/categories.h>
@@ -29,6 +28,9 @@
29#include <qpe/menubutton.h> 28#include <qpe/menubutton.h>
29#include <qpe/mimetype.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
32//#include <qtopia/private/palmtoprecord.h>
32 33
33#include <qtimer.h> 34#include <qtimer.h>
35#include <qtextstream.h>
34#include <qdict.h> 36#include <qdict.h>
@@ -41,8 +43,17 @@
41#include <qtoolbutton.h> 43#include <qtoolbutton.h>
44#include <qimage.h>
42 45
43class LauncherIconView : public QIconView { 46
47class BgPixmap
48{
44public: 49public:
45 QColor iconText; 50 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
46 QColor background; 51 QPixmap pm;
52 int ref;
53};
47 54
55static QMap<QString,BgPixmap*> *bgCache = 0;
56
57class LauncherIconView : public QIconView {
58public:
48 LauncherIconView( QWidget* parent, const char* name=0 ) : 59 LauncherIconView( QWidget* parent, const char* name=0 ) :
@@ -51,3 +62,5 @@ public:
51 cf(0), 62 cf(0),
52 bsy(0) 63 bsy(0),
64 bigIcns(TRUE),
65 bgColor(white)
53 { 66 {
@@ -56,7 +69,3 @@ public:
56 ike = FALSE; 69 ike = FALSE;
57 70 calculateGrid( Bottom );
58 Config config( "qpe" );
59 config.setGroup( "Appearance" );
60 iconText = QColor( config.readEntry( "LauncherIconText", "#000000" ) );
61 background = QColor( config.readEntry( "LauncherBackground", "#FFFFFF" ) );
62 } 71 }
@@ -75,3 +84,5 @@ public:
75 84
85 QPixmap* busyPixmap() const { return (QPixmap*)&bpm; }
76 QIconViewItem* busyItem() const { return bsy; } 86 QIconViewItem* busyItem() const { return bsy; }
87 void setBigIcons( bool bi ) { bigIcns = bi; }
77 88
@@ -88,2 +99,27 @@ public:
88 if ( bsy != c ) { 99 if ( bsy != c ) {
100 if ( c ) {
101 QPixmap *src = c->pixmap();
102 QImage img = src->convertToImage();
103 QRgb* rgb;
104 int count;
105 if ( img.depth() == 32 ) {
106 rgb = (QRgb*)img.bits();
107 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
108 } else {
109 rgb = img.colorTable();
110 count = img.numColors();
111 }
112 int rc, gc, bc;
113 colorGroup().highlight().rgb( &rc, &gc, &bc );
114 int ri, gi, bi;
115 for ( int r = 0; r < count; r++, rgb++ ) {
116 int ri = (rc+qRed(*rgb))/2;
117 int gi = (gc+qGreen(*rgb))/2;
118 int bi = (bc+qBlue(*rgb))/2;
119 int ai = qAlpha(*rgb);
120 *rgb = qRgba(ri,gi,bi,ai);
121 }
122
123 bpm.convertFromImage( img );
124 }
89 QIconViewItem* o = bsy; 125 QIconViewItem* o = bsy;
@@ -99,6 +135,4 @@ public:
99 ike = TRUE; 135 ike = TRUE;
100 if ( e->key() == Key_F33 ) { 136 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space )
101 // "OK" button
102 returnPressed(currentItem()); 137 returnPressed(currentItem());
103 }
104 QIconView::keyPressEvent(e); 138 QIconView::keyPressEvent(e);
@@ -130,3 +164,4 @@ public:
130 if (sl>=0) { 164 if (sl>=0) {
131 QString k = maj.left(sl); 165 QString k;
166 k = maj.left(12) == "application/" ? maj : maj.left(sl);
132 mimes.replace(k,(void*)1); 167 mimes.replace(k,(void*)1);
@@ -135,61 +170,25 @@ public:
135 170
171 void setBackgroundPixmap( const QPixmap &pm ) {
172 bgPixmap = pm;
173 }
174
175 void setBackgroundColor( const QColor &c ) {
176 bgColor = c;
177 }
178
136 void drawBackground( QPainter *p, const QRect &r ) 179 void drawBackground( QPainter *p, const QRect &r )
137 { 180 {
138 Config config("qpe"); 181 if ( !bgPixmap.isNull() ) {
139 config.setGroup("Appearance"); 182 p->drawTiledPixmap( r, bgPixmap,
140 QString backgroundImage = config.readEntry("BackgroundImage","launcher/opie-background"); 183 QPoint( (r.x() + contentsX()) % bgPixmap.width(),
141 // if (backgroundImage.isNull()) backgroundImage="launcher/opie-background"; 184 (r.y() + contentsY()) % bgPixmap.height() ) );
142 int backgroundMode = QPixmap::defaultDepth() >= 12 ? 1 : 0;
143 //int backgroundMode = 2;
144
145 if ( backgroundMode == 1 ) {
146
147 // Double buffer the background
148 static QPixmap *bg = NULL;
149 static QColor bgColor;
150
151 if ( (bg == NULL) || (bgColor != colorGroup().button()) ) {
152 // Create a new background double buffer
153 if (bg == NULL)
154 bg = new QPixmap( width(), height() );
155 bgColor = colorGroup().button();
156 QPainter painter( bg );
157
158// painter.fillRect( QRect( 0, 0, width(), height() ), colorGroup().background().light(110));
159 painter.fillRect( QRect( 0, 0, width(), height() ), background);
160 // Overlay the Qtopia logo in the center
161 QImage logo;
162 if (QFile::exists(backgroundImage)) {
163 logo = QImage(backgroundImage);
164 } else { 185 } else {
165 logo = Resource::loadImage(backgroundImage ); 186 p->fillRect( r, bgColor );
166 }
167 if ( !logo.isNull() && config.readBoolEntry( "UseBackgroundImage", TRUE ) )
168 painter.drawImage( (width() - logo.width()) / 2,
169 (height() - logo.height()) / 2, logo );
170 }
171
172 // Draw the double buffer to the widget (it is tiled for when the icon view is large)
173 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
174 (r.y() + contentsY()) % bg->height() ) );
175 } else if ( backgroundMode == 2 ) {
176 static QPixmap *bg = 0;
177 static QColor bgColor;
178 if ( !bg || (bgColor != colorGroup().background()) ) {
179 bgColor = colorGroup().background();
180 bg = new QPixmap( width(), 9 );
181 QPainter painter( bg );
182 for ( int i = 0; i < 3; i++ ) {
183 painter.setPen( colorGroup().background().light(130) );
184 painter.drawLine( 0, i*3, width()-1, i*3 );
185 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
186 painter.setPen( colorGroup().background().light(105) );
187 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
188 }
189 } 187 }
190 p->drawTiledPixmap( r, *bg, QPoint( (r.x() + contentsX()) % bg->width(),
191 (r.y() + contentsY()) % bg->height() ) );
192 } else {
193 p->fillRect( r, QBrush( colorGroup().background().light(110) ) );
194 } 188 }
189
190 void setItemTextPos( ItemTextPos pos )
191 {
192 calculateGrid( pos );
193 QIconView::setItemTextPos( pos );
195 } 194 }
@@ -242,2 +241,4 @@ public:
242 241
242 QString getAllDocLinkInfo() const;
243
243protected: 244protected:
@@ -247,5 +248,28 @@ protected:
247 QIconView::styleChange( old ); 248 QIconView::styleChange( old );
248 //### duplicated code from LauncherView constructor 249 calculateGrid( itemTextPos() );
250 }
251
252 void calculateGrid( ItemTextPos pos )
253 {
249 int dw = QApplication::desktop()->width(); 254 int dw = QApplication::desktop()->width();
250 setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240 255 int viewerWidth = dw-style().scrollBarExtent().width();
256 if ( pos == Bottom ) {
257 int cols = 3;
258 if ( viewerWidth <= 200 )
259 cols = 2;
260 else if ( viewerWidth >= 400 )
261 cols = viewerWidth/96;
262 setSpacing( 4 );
263 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
264 setGridY( fontMetrics().height()*2+24 );
265 } else {
266 int cols = 2;
267 if ( viewerWidth < 150 )
268 cols = 1;
269 else if ( viewerWidth >= 400 )
270 cols = viewerWidth/150;
271 setSpacing( 2 );
272 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
273 setGridY( fontMetrics().height()+2 );
274 }
251 } 275 }
@@ -261,3 +285,6 @@ private:
261 bool ike; 285 bool ike;
262 286 bool bigIcns;
287 QPixmap bgPixmap;
288 QPixmap bpm;
289 QColor bgColor;
263}; 290};
@@ -275,3 +302,3 @@ class LauncherItem : public QIconViewItem
275public: 302public:
276 LauncherItem( QIconView *parent, AppLnk* applnk ); 303 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
277 ~LauncherItem() 304 ~LauncherItem()
@@ -298,6 +325,2 @@ public:
298 } 325 }
299 else {
300 mycg.setColor( QColorGroup::Text, liv->iconText );
301 }
302
303 QIconViewItem::paintItem(p,mycg); 326 QIconViewItem::paintItem(p,mycg);
@@ -305,8 +328,10 @@ public:
305 liv->setItemTextBackground( oldBrush ); 328 liv->setItemTextBackground( oldBrush );
306 if ( liv->busyItem() == this ) {
307 static QPixmap* busypm=0;
308 if ( !busypm )
309 busypm = new QPixmap(Resource::loadPixmap("launching"));
310 p->drawPixmap(x()+(width()-busypm->width())/2, y(),*busypm);
311 } 329 }
330
331 virtual QPixmap* pixmap () const
332 {
333 const LauncherIconView* liv = (LauncherIconView*)iconView();
334 if ( (const LauncherItem *)liv->busyItem() == this )
335 return liv->busyPixmap();
336 return QIconViewItem::pixmap();
312 } 337 }
@@ -318,4 +343,5 @@ protected:
318 343
319LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk ) 344LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
320 : QIconViewItem( parent, applnk->name(), applnk->bigPixmap() ), 345 : QIconViewItem( parent, applnk->name(),
346 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
321 app(applnk) // Takes ownership 347 app(applnk) // Takes ownership
@@ -349,3 +375,3 @@ void LauncherIconView::addItem(AppLnk* app, bool resort)
349 || cf == -1 && app->categories().count() == 0 ) ) 375 || cf == -1 && app->categories().count() == 0 ) )
350 (void) new LauncherItem( this, app ); 376 (void) new LauncherItem( this, app, bigIcns );
351 else 377 else
@@ -384,4 +410,3 @@ void LauncherIconView::hideOrShowItems(bool resort)
384 } 410 }
385 bool oldAutoArrange = autoArrange(); 411 viewport()->setUpdatesEnabled( FALSE );
386 setAutoArrange( FALSE );
387 clear(); 412 clear();
@@ -393,5 +418,5 @@ void LauncherIconView::hideOrShowItems(bool resort)
393 } 418 }
394 if ( resort ) 419 viewport()->setUpdatesEnabled( TRUE );
420 if ( resort && !autoArrange() )
395 sort(); 421 sort();
396 setAutoArrange( oldAutoArrange );
397} 422}
@@ -406,3 +431,6 @@ bool LauncherIconView::removeLink(const QString& linkfile)
406 l = item->appLnk(); 431 l = item->appLnk();
407 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) { 432 if ( l->linkFileKnown() && l->linkFile() == linkfile
433 || l->fileKnown() && (
434 l->file() == linkfile
435 || dl.isValid() && dl.file() == l->file() ) ) {
408 delete item; 436 delete item;
@@ -415,3 +443,5 @@ bool LauncherIconView::removeLink(const QString& linkfile)
415 ++it; 443 ++it;
416 if ( l->linkFileKnown() && l->linkFile() == linkfile/* || l->file() == linkfile || dl.isValid() && dl.file() == l->file()*/ ) { 444 if ( l->linkFileKnown() && l->linkFile() == linkfile
445 || l->file() == linkfile
446 || dl.isValid() && dl.file() == l->file() ) {
417 hidden.removeRef(l); 447 hidden.removeRef(l);
@@ -423,2 +453,55 @@ bool LauncherIconView::removeLink(const QString& linkfile)
423 453
454static QString docLinkInfo(const Categories& cats, DocLnk* doc)
455{
456 QString contents;
457
458 QFileInfo fi( doc->file() );
459 if ( !fi.exists() )
460 return contents;
461
462 if ( doc->linkFileKnown() ) {
463 QString lfn = doc->linkFile();
464 QFile f( lfn );
465 if ( f.open( IO_ReadOnly ) ) {
466 QTextStream ts( &f );
467 ts.setEncoding( QTextStream::UnicodeUTF8 );
468 contents += ts.read();
469 f.close();
470 goto calcsize;
471 }
472 }
473
474 contents += "[Desktop Entry]\n";
475 contents += "Categories = " // No tr
476 + cats.labels("Document View", doc->categories()).join(";") + "\n"; // No tr
477 contents += "File = "+doc->file()+"\n"; // No tr
478 contents += "Name = "+doc->name()+"\n"; // No tr
479 contents += "Type = "+doc->type()+"\n"; // No tr
480
481calcsize:
482 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
483 return contents;
484}
485
486QString LauncherIconView::getAllDocLinkInfo() const
487{
488 QString contents;
489 LauncherItem* item = (LauncherItem*)firstItem();
490 Categories cats;
491 while (item) {
492 DocLnk* doc = (DocLnk*)item->appLnk();
493 contents += docLinkInfo(cats,doc);
494 item = (LauncherItem*)item->nextItem();
495 }
496 QListIterator<AppLnk> it(hidden);
497 DocLnk* doc;
498 while ((doc=(DocLnk*)it.current())) {
499 contents += docLinkInfo(cats,doc);
500 ++it;
501 }
502 return contents;
503}
504
505//===========================================================================
506
424LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 507LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
@@ -430,3 +513,2 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
430 513
431 int dw = QApplication::desktop()->width();
432 icons->setItemsMovable( FALSE ); 514 icons->setItemsMovable( FALSE );
@@ -434,9 +516,9 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
434 icons->setSorting( TRUE ); 516 icons->setSorting( TRUE );
435 icons->setGridX( (dw-13-style().scrollBarExtent().width())/ (dw/80) ); // tweaked for 8pt+dw=176 and 10pt+dw=240
436 icons->setGridY( fontMetrics().height()*2+24 );
437 icons->setFrameStyle( QFrame::NoFrame ); 517 icons->setFrameStyle( QFrame::NoFrame );
438 icons->setSpacing( 4 );
439 icons->setMargin( 0 ); 518 icons->setMargin( 0 );
440 icons->setSelectionMode( QIconView::Multi ); 519 icons->setSelectionMode( QIconView::NoSelection );
441 icons->setBackgroundMode( PaletteBase ); 520 icons->setBackgroundMode( PaletteBase );
521 icons->setResizeMode( QIconView::Fixed );
522 vmode = (ViewMode)-1;
523 setViewMode( Icon );
442 524
@@ -452,2 +534,3 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
452 tools = 0; 534 tools = 0;
535 setBackgroundType( Ruled, QString::null );
453} 536}
@@ -465,5 +548,3 @@ void LauncherView::setToolsEnabled(bool y)
465 // Type filter 548 // Type filter
466 typemb = new MenuButton(tools); 549 typemb = new QComboBox(tools);
467 typemb->setLabel(tr("Type: %1"));
468 typemb->setFixedHeight ( 20 );
469 550
@@ -471,3 +552,2 @@ void LauncherView::setToolsEnabled(bool y)
471 catmb = new CategorySelect(tools); 552 catmb = new CategorySelect(tools);
472 catmb->setFixedHeight ( 20 );
473 553
@@ -484,4 +564,4 @@ void LauncherView::updateTools()
484{ 564{
485 disconnect( typemb, SIGNAL(selected(const QString&)), 565 disconnect( typemb, SIGNAL(activated(int)),
486 this, SLOT(showType(const QString&)) ); 566 this, SLOT(showType(int)) );
487 disconnect( catmb, SIGNAL(signalSelected(int)), 567 disconnect( catmb, SIGNAL(signalSelected(int)),
@@ -495,9 +575,29 @@ void LauncherView::updateTools()
495 QStringList types; 575 QStringList types;
496 types << tr("All"); 576 typelist = icons->mimeTypes();
497 types << "--"; 577 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
498 types += icons->mimeTypes(); 578 QString t = *it;
579 if ( t.left(12) == "application/" ) {
580 MimeType mt(t);
581 const AppLnk* app = mt.application();
582 if ( app )
583 t = app->name();
584 else
585 t = t.mid(12);
586 } else {
587 t[0] = t[0].upper();
588 }
589 types += tr("%1 files").arg(t);
590 }
591 types << tr("All types of file");
499 prev = typemb->currentText(); 592 prev = typemb->currentText();
500 typemb->clear(); 593 typemb->clear();
501 typemb->insertItems(types); 594 typemb->insertStringList(types);
502 typemb->select(prev); 595 for (int i=0; i<typemb->count(); i++) {
596 if ( typemb->text(i) == prev ) {
597 typemb->setCurrentItem(i);
598 break;
599 }
600 }
601 if ( prev.isNull() )
602 typemb->setCurrentItem(typemb->count()-1);
503 603
@@ -506,3 +606,4 @@ void LauncherView::updateTools()
506 QArray<int> vl( 0 ); 606 QArray<int> vl( 0 );
507 catmb->setCategories( vl, "Document View", tr("Document View") ); 607 catmb->setCategories( vl, "Document View", // No tr
608 tr("Document View") );
508 catmb->setRemoveCategoryEdit( TRUE ); 609 catmb->setRemoveCategoryEdit( TRUE );
@@ -510,3 +611,3 @@ void LauncherView::updateTools()
510 611
511 connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&))); 612 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
512 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 613 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
@@ -519,8 +620,11 @@ void LauncherView::sortBy(int s)
519 620
520void LauncherView::showType(const QString& t) 621void LauncherView::showType(int t)
521{ 622{
522 if ( t == tr("All") ) { 623 if ( t >= (int)typelist.count() ) {
523 icons->setTypeFilter("",TRUE); 624 icons->setTypeFilter("",TRUE);
524 } else { 625 } else {
525 icons->setTypeFilter(t+"/*",TRUE); 626 QString ty = typelist[t];
627 if ( !ty.contains('/') )
628 ty += "/*";
629 icons->setTypeFilter(ty,TRUE);
526 } 630 }
@@ -533,2 +637,115 @@ void LauncherView::showCategory( int c )
533 637
638void LauncherView::setViewMode( ViewMode m )
639{
640 if ( vmode != m ) {
641 bool bigIcons = m == Icon;
642 icons->viewport()->setUpdatesEnabled( FALSE );
643 icons->setBigIcons( bigIcons );
644 switch ( m ) {
645 case List:
646 icons->setItemTextPos( QIconView::Right );
647 break;
648 case Icon:
649 icons->setItemTextPos( QIconView::Bottom );
650 break;
651 }
652 icons->hideOrShowItems( FALSE );
653 icons->viewport()->setUpdatesEnabled( TRUE );
654 vmode = m;
655 }
656}
657
658void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
659{
660 if ( !bgCache )
661 bgCache = new QMap<QString,BgPixmap*>;
662 if ( bgCache->contains( bgName ) )
663 (*bgCache)[bgName]->ref--;
664
665 switch ( t ) {
666 case Ruled: {
667 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
668 QPixmap bg;
669 if ( bgCache->contains( bgName ) ) {
670 (*bgCache)[bgName]->ref++;
671 bg = (*bgCache)[bgName]->pm;
672 } else {
673 bg.resize( width(), 9 );
674 QPainter painter( &bg );
675 for ( int i = 0; i < 3; i++ ) {
676 painter.setPen( white );
677 painter.drawLine( 0, i*3, width()-1, i*3 );
678 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
679 painter.setPen( colorGroup().background().light(105) );
680 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
681 }
682 painter.end();
683 bgCache->insert( bgName, new BgPixmap(bg) );
684 }
685 icons->setBackgroundPixmap( bg );
686 break;
687 }
688
689 case SolidColor:
690 icons->setBackgroundPixmap( QPixmap() );
691 if ( val.isEmpty() ) {
692 icons->setBackgroundColor( colorGroup().base() );
693 } else {
694 icons->setBackgroundColor( val );
695 }
696 bgName = "";
697 break;
698
699 case Image:
700 bgName = val;
701 if ( bgCache->contains( bgName ) ) {
702 (*bgCache)[bgName]->ref++;
703 icons->setBackgroundPixmap( (*bgCache)[bgName]->pm );
704 } else {
705 qDebug( "Loading image: %s", val.latin1() );
706 QPixmap bg( Resource::loadPixmap( "wallpaper/" + val ) );
707 if ( bg.isNull() ) {
708 QImageIO imgio;
709 imgio.setFileName( bgName );
710 QSize ds = qApp->desktop()->size();
711 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
712 imgio.setParameters( param.arg(ds.width()).arg(ds.height()).latin1() );
713 imgio.read();
714 bg = imgio.image();
715 }
716 bgCache->insert( bgName, new BgPixmap(bg) );
717 icons->setBackgroundPixmap( bg );
718 }
719 break;
720 }
721
722 // remove unreferenced backgrounds.
723 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
724 while ( it != bgCache->end() ) {
725 QMap<QString,BgPixmap*>::Iterator curr = it;
726 ++it;
727 if ( (*curr)->ref == 0 ) {
728 delete (*curr);
729 bgCache->remove( curr );
730 }
731 }
732
733 bgType = t;
734 icons->viewport()->update();
735}
736
737void LauncherView::setTextColor( const QColor &tc )
738{
739 textCol = tc;
740 QColorGroup cg = icons->colorGroup();
741 cg.setColor( QColorGroup::Text, tc );
742 icons->setPalette( QPalette(cg,cg,cg) );
743 icons->viewport()->update();
744}
745
746void LauncherView::setViewFont( const QFont &f )
747{
748 icons->setFont( f );
749}
750
534void LauncherView::resizeEvent(QResizeEvent *e) 751void LauncherView::resizeEvent(QResizeEvent *e)
@@ -546,2 +763,7 @@ void LauncherView::populate( AppLnkSet *folder, const QString& typefilter )
546 763
764QString LauncherView::getAllDocLinkInfo() const
765{
766 return icons->getAllDocLinkInfo();
767}
768
547void LauncherView::selectionChanged() 769void LauncherView::selectionChanged()
@@ -599,4 +821,6 @@ void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilte
599 // show only the icons for existing files 821 // show only the icons for existing files
600 if (!QFile(it.current()->file()).exists() & it.current()->file().left(4) != "http") 822 if (QFile(it.current()->file()).exists() || ( it.current()->file().left(4) == "http" )) {
601 { 823 icons->addItem(*it,FALSE);
824 }
825 else {
602 //maybe insert some .desktop file deletion code later 826 //maybe insert some .desktop file deletion code later
@@ -604,6 +828,2 @@ void LauncherView::internalPopulate( AppLnkSet *folder, const QString& typefilte
604 } 828 }
605 else
606 {
607 icons->addItem(*it,FALSE);
608 }
609 ++it; 829 ++it;
@@ -633 +853,13 @@ void LauncherView::setFileSystems(const QList<FileSystem> &)
633} 853}
854
855void LauncherView::paletteChange( const QPalette &p )
856{
857 icons->unsetPalette();
858 QVBox::paletteChange( p );
859 if ( bgType == Ruled )
860 setBackgroundType( Ruled, QString::null );
861 QColorGroup cg = icons->colorGroup();
862 cg.setColor( QColorGroup::Text, textCol );
863 icons->setPalette( QPalette(cg,cg,cg) );
864}
865
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index 3aaef7e..2fb37b6 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
@@ -33,2 +33,3 @@ class QIconViewItem;
33class MenuButton; 33class MenuButton;
34class QComboBox;
34 35
@@ -52,2 +53,16 @@ public:
52 53
54 QString getAllDocLinkInfo() const;
55 enum ViewMode { Icon, List };
56 void setViewMode( ViewMode m );
57 ViewMode viewMode() const { return vmode; }
58
59 enum BackgroundType { Ruled, SolidColor, Image };
60 void setBackgroundType( BackgroundType t, const QString & );
61 BackgroundType backgroundType() const { return bgType; }
62
63 void setTextColor( const QColor & );
64 QColor textColor() const { return textCol; }
65
66 void setViewFont( const QFont & );
67
53public slots: 68public slots:
@@ -65,3 +80,3 @@ protected slots:
65 void sortBy(int); 80 void sortBy(int);
66 void showType(const QString&); 81 void showType(int);
67 void showCategory( int ); 82 void showCategory( int );
@@ -71,2 +86,3 @@ protected:
71 void internalPopulate( AppLnkSet *, const QString& categoryfilter ); 86 void internalPopulate( AppLnkSet *, const QString& categoryfilter );
87 void paletteChange( const QPalette & );
72 88
@@ -76,4 +92,9 @@ private:
76 LauncherIconView* icons; 92 LauncherIconView* icons;
77 MenuButton *typemb; 93 QComboBox *typemb;
94 QStringList typelist;
78 CategorySelect *catmb; 95 CategorySelect *catmb;
96 ViewMode vmode;
97 BackgroundType bgType;
98 QString bgName;
99 QColor textCol;
79}; 100};