summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp18
-rw-r--r--core/launcher/launcherview.cpp127
-rw-r--r--core/launcher/launcherview.h1
3 files changed, 70 insertions, 76 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 010a2e9..5ec1cf8 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -312,102 +312,102 @@ void LauncherTabWidget::setTabAppearance( LauncherTab *tab, Config &cfg )
312 if ( tabTextCol.isEmpty() ) 312 if ( tabTextCol.isEmpty() )
313 tab->fgColor = QColor(); 313 tab->fgColor = QColor();
314 else 314 else
315 tab->fgColor = QColor(tabTextCol); 315 tab->fgColor = QColor(tabTextCol);
316} 316}
317 317
318void LauncherTabWidget::paletteChange( const QPalette &p ) 318void LauncherTabWidget::paletteChange( const QPalette &p )
319{ 319{
320 QVBox::paletteChange( p ); 320 QVBox::paletteChange( p );
321 QPalette pal = palette(); 321 QPalette pal = palette();
322 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); 322 pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) );
323 pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); 323 pal.setColor( QColorGroup::Background, pal.active().background().light(110) );
324 categoryBar->setPalette( pal ); 324 categoryBar->setPalette( pal );
325 categoryBar->update(); 325 categoryBar->update();
326} 326}
327 327
328void LauncherTabWidget::styleChange( QStyle & ) 328void LauncherTabWidget::styleChange( QStyle & )
329{ 329{
330 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) ); 330 QTimer::singleShot( 0, this, SLOT(setProgressStyle()) );
331} 331}
332 332
333void LauncherTabWidget::setProgressStyle() 333void LauncherTabWidget::setProgressStyle()
334{ 334{
335 if (docLoadingWidgetProgress) { 335 if (docLoadingWidgetProgress) {
336 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box ); 336 docLoadingWidgetProgress->setFrameShape( QProgressBar::Box );
337 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain ); 337 docLoadingWidgetProgress->setFrameShadow( QProgressBar::Plain );
338 docLoadingWidgetProgress->setMargin( 1 ); 338 docLoadingWidgetProgress->setMargin( 1 );
339 docLoadingWidgetProgress->setLineWidth( 1 ); 339 docLoadingWidgetProgress->setLineWidth( 1 );
340 } 340 }
341} 341}
342 342
343/* 343/*
344 * FIXME 344 * FIXME
345 * The following NULL check is triggered by inserting, then removing a tab on the fly 345 * The following NULL check is triggered by inserting, then removing a tab on the fly
346 * as you would if you had removable media (which I do). Without this check 346 * as you would if you had removable media (which I do). Without this check
347 * the first app launched after a tab removal causes qpe to Segfault. 347 * the first app launched after a tab removal causes qpe to Segfault.
348 * This obviously has a more sinister cause, but this works around it with no 348 * This obviously has a more sinister cause, but this works around it with no
349 * obvious adverse effects. Please FIXME 349 * obvious adverse effects. Please FIXME
350 * bkc - 17/6/2004 350 * bkc - 17/6/2004
351 * 351 *
352 */ 352 */
353 353
354void LauncherTabWidget::setBusy(bool on) 354void LauncherTabWidget::setBusy(bool on)
355{ 355{
356 if ( on ) 356 if ( on )
357 currentView()->setBusy(TRUE); 357 currentView()->setBusy(TRUE);
358 else { 358 else {
359 for ( int i = 0; i < categoryBar->count(); i++ ) { 359 for ( int i = 0; i < categoryBar->count(); i++ ) {
360 if (categoryBar->tab(i)) { 360 if (categoryBar->tab(i)) {
361 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; 361 LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view;
362 view->setBusy( FALSE ); 362 view->setBusy( FALSE );
363 } else { 363 } else {
364 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; 364 odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl;
365 } 365 }
366 } 366 }
367 } 367 }
368} 368}
369 369
370void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { 370void LauncherTabWidget::setBusyIndicatorType( const QString& str ) {
371 for (int i = 0; i < categoryBar->count(); i++ ) { 371 for (int i = 0; i < categoryBar->count(); i++ ) {
372 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; 372 LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view;
373 view->setBusyIndicatorType( str ); 373 view->setBusyIndicatorType( str );
374 } 374 }
375} 375}
376 376
377LauncherView *LauncherTabWidget::currentView(void) 377LauncherView *LauncherTabWidget::currentView(void)
378{ 378{
379 return (LauncherView*)stack->visibleWidget(); 379 return (LauncherView*)stack->visibleWidget();
380} 380}
381 381
382 382
383 383
384void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) 384void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data)
385{ 385{
386 QDataStream stream( data, IO_ReadOnly ); 386 QDataStream stream( data, IO_ReadOnly );
387 if ( msg == "setTabView(QString,int)" ) { 387 if ( msg == "setTabView(QString,int)" ) {
388 QString id; 388 QString id;
389 stream >> id; 389 stream >> id;
390 int mode; 390 int mode;
391 stream >> mode; 391 stream >> mode;
392 if ( view(id) ) 392 if ( view(id) )
393 view(id)->setViewMode( (LauncherView::ViewMode)mode ); 393 view(id)->setViewMode( (LauncherView::ViewMode)mode );
394 } else if ( msg == "setTabBackground(QString,int,QString)" ) { 394 } else if ( msg == "setTabBackground(QString,int,QString)" ) {
395 QString id; 395 QString id;
396 stream >> id; 396 stream >> id;
397 int mode; 397 int mode;
398 stream >> mode; 398 stream >> mode;
399 QString pixmapOrColor; 399 QString pixmapOrColor;
400 stream >> pixmapOrColor; 400 stream >> pixmapOrColor;
401 if ( view(id) ) 401 if ( view(id) )
402 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 402 view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
403 if ( id == "Documents" ) 403 if ( id == "Documents" )
404 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); 404 docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor );
405 } else if ( msg == "setTextColor(QString,QString)" ) { 405 } else if ( msg == "setTextColor(QString,QString)" ) {
406 QString id; 406 QString id;
407 stream >> id; 407 stream >> id;
408 QString color; 408 QString color;
409 stream >> color; 409 stream >> color;
410 if ( view(id) ) 410 if ( view(id) )
411 view(id)->setTextColor( QColor(color) ); 411 view(id)->setTextColor( QColor(color) );
412 if ( id == "Documents" ) 412 if ( id == "Documents" )
413 docLoadingWidget->setTextColor( QColor(color) ); 413 docLoadingWidget->setTextColor( QColor(color) );
@@ -556,99 +556,101 @@ static bool isVisibleWindow(int wid)
556 QWSWindow* w; 556 QWSWindow* w;
557 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 557 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
558 if ( w->winId() == wid ) 558 if ( w->winId() == wid )
559 return !w->isFullyObscured(); 559 return !w->isFullyObscured();
560 } 560 }
561#endif 561#endif
562 return FALSE; 562 return FALSE;
563} 563}
564 564
565void Launcher::viewSelected(const QString& s) 565void Launcher::viewSelected(const QString& s)
566{ 566{
567 setCaption( s + tr(" - Launcher") ); 567 setCaption( s + tr(" - Launcher") );
568} 568}
569 569
570void Launcher::showTab(const QString& id) 570void Launcher::showTab(const QString& id)
571{ 571{
572 tabs->categoryBar->showTab(id); 572 tabs->categoryBar->showTab(id);
573 raise(); 573 raise();
574} 574}
575 575
576void Launcher::select( const AppLnk *appLnk ) 576void Launcher::select( const AppLnk *appLnk )
577{ 577{
578 if ( appLnk->type() == "Folder" ) { // No tr 578 if ( appLnk->type() == "Folder" ) { // No tr
579 // Not supported: flat is simpler for the user 579 // Not supported: flat is simpler for the user
580 } else { 580 } else {
581 if ( appLnk->exec().isNull() ) { 581 if ( appLnk->exec().isNull() ) {
582 int i = QMessageBox::information(this,tr("No application"), 582 int i = QMessageBox::information(this,tr("No application"),
583 tr("<p>No application is defined for this document." 583 tr("<p>No application is defined for this document."
584 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1); 584 "<p>Type is %1.").arg(appLnk->type()), tr("OK"), tr("View as text"), 0, 0, 1);
585 585
586 /* ### Fixme */ 586 /* ### Fixme */
587 if ( i == 1 ) 587 if ( i == 1 )
588 Global::execute("textedit",appLnk->file()); 588 Global::execute("textedit",appLnk->file());
589 589
590 return; 590 return;
591 } 591 }
592 tabs->setBusy(TRUE); 592 tabs->setBusy(TRUE);
593 emit executing( appLnk ); 593 emit executing( appLnk );
594 appLnk->execute(); 594 appLnk->execute();
595 } 595 }
596} 596}
597 597
598void Launcher::properties( AppLnk *appLnk ) 598void Launcher::properties( AppLnk *appLnk )
599{ 599{
600 if ( appLnk->type() == "Folder" ) { // No tr 600 if ( appLnk->type() == "Folder" ) { // No tr
601 // Not supported: flat is simpler for the user 601 // Not supported: flat is simpler for the user
602 } else { 602 } else {
603/* ### libqtopia FIXME also moving docLnks... */ 603/* ### libqtopia FIXME also moving docLnks... */
604 LnkProperties prop(appLnk,0 ); 604 LnkProperties prop(appLnk,0 );
605 605
606 QPEApplication::execDialog( &prop ); 606 if (QPEApplication::execDialog( &prop )==QDialog::Accepted && tabs->currentView()==tabs->docView()) {
607 tabs->docView()->updateTools();
608 }
607 } 609 }
608} 610}
609 611
610void Launcher::storageChanged( const QList<FileSystem> & ) 612void Launcher::storageChanged( const QList<FileSystem> & )
611{ 613{
612 // ### update combo boxes if we had a combo box for the storage type 614 // ### update combo boxes if we had a combo box for the storage type
613} 615}
614 616
615void Launcher::systemMessage( const QCString &msg, const QByteArray &data) 617void Launcher::systemMessage( const QCString &msg, const QByteArray &data)
616{ 618{
617 QDataStream stream( data, IO_ReadOnly ); 619 QDataStream stream( data, IO_ReadOnly );
618 if ( msg == "busy()" ) { 620 if ( msg == "busy()" ) {
619 tb->startWait(); 621 tb->startWait();
620 } else if ( msg == "notBusy(QString)" ) { 622 } else if ( msg == "notBusy(QString)" ) {
621 QString app; 623 QString app;
622 stream >> app; 624 stream >> app;
623 tabs->setBusy(FALSE); 625 tabs->setBusy(FALSE);
624 tb->stopWait(app); 626 tb->stopWait(app);
625 } else if (msg == "applyStyle()") { 627 } else if (msg == "applyStyle()") {
626 tabs->currentView()->relayout(); 628 tabs->currentView()->relayout();
627 } 629 }
628} 630}
629 631
630// These are the update functions from the server 632// These are the update functions from the server
631void Launcher::typeAdded( const QString& type, const QString& name, 633void Launcher::typeAdded( const QString& type, const QString& name,
632 const QPixmap& pixmap, const QPixmap& ) 634 const QPixmap& pixmap, const QPixmap& )
633{ 635{
634 tabs->newView( type, pixmap, name ); 636 tabs->newView( type, pixmap, name );
635 ids.append( type ); 637 ids.append( type );
636 /* this will be called in applicationScanningProgress with value 100! */ 638 /* this will be called in applicationScanningProgress with value 100! */
637// tb->refreshStartMenu(); 639// tb->refreshStartMenu();
638 640
639 static bool first = TRUE; 641 static bool first = TRUE;
640 if ( first ) { 642 if ( first ) {
641 first = FALSE; 643 first = FALSE;
642 tabs->categoryBar->showTab(type); 644 tabs->categoryBar->showTab(type);
643 } 645 }
644 646
645 tabs->view( type )->setUpdatesEnabled( FALSE ); 647 tabs->view( type )->setUpdatesEnabled( FALSE );
646 tabs->view( type )->setSortEnabled( FALSE ); 648 tabs->view( type )->setSortEnabled( FALSE );
647} 649}
648 650
649void Launcher::typeRemoved( const QString& type ) 651void Launcher::typeRemoved( const QString& type )
650{ 652{
651 tabs->view( type )->removeAllItems(); 653 tabs->view( type )->removeAllItems();
652 tabs->deleteView( type ); 654 tabs->deleteView( type );
653 ids.remove( type ); 655 ids.remove( type );
654 /* this will be called in applicationScanningProgress with value 100! */ 656 /* this will be called in applicationScanningProgress with value 100! */
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index 72313e3..ff26133 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -86,97 +86,97 @@ public:
86 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } 86 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; }
87 87
88 void animateIcon(); 88 void animateIcon();
89 void resetIcon(); 89 void resetIcon();
90 bool isEyeImage()const{return m_EyeImage;} 90 bool isEyeImage()const{return m_EyeImage;}
91 91
92 virtual int compare ( QIconViewItem * i ) const; 92 virtual int compare ( QIconViewItem * i ) const;
93 void paintItem( QPainter *p, const QColorGroup &cg ); 93 void paintItem( QPainter *p, const QColorGroup &cg );
94 94
95 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 95 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
96 void setEyePixmap(const QPixmap&aIcon); 96 void setEyePixmap(const QPixmap&aIcon);
97 virtual QPixmap*pixmap()const; 97 virtual QPixmap*pixmap()const;
98 98
99protected: 99protected:
100 bool isBigIcon; 100 bool isBigIcon;
101 int iteration; 101 int iteration;
102 AppLnk* app; 102 AppLnk* app;
103 103
104private: 104private:
105 void paintAnimatedIcon( QPainter *p ); 105 void paintAnimatedIcon( QPainter *p );
106 BusyIndicatorType busyType; 106 BusyIndicatorType busyType;
107 int psize; 107 int psize;
108 QPixmap m_iPixmap; 108 QPixmap m_iPixmap;
109 bool m_EyeImage; 109 bool m_EyeImage;
110 iconstate_t m_EyeImageSet; 110 iconstate_t m_EyeImageSet;
111}; 111};
112 112
113LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 113LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
114 : QIconViewItem( parent, applnk->name(), 114 : QIconViewItem( parent, applnk->name(),
115 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 115 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
116 isBigIcon( bigIcon ), 116 isBigIcon( bigIcon ),
117 iteration(0), 117 iteration(0),
118 app(applnk), // Takes ownership 118 app(applnk), // Takes ownership
119 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), 119 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
120 m_iPixmap(), 120 m_iPixmap(),
121 m_EyeImage(false), 121 m_EyeImage(false),
122 m_EyeImageSet(BASE_ICON) 122 m_EyeImageSet(BASE_ICON)
123{ 123{
124 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { 124 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) {
125 m_EyeImage = true; 125 m_EyeImage = true;
126 m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); 126 m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap());
127 } 127 }
128} 128}
129 129
130LauncherItem::~LauncherItem() 130LauncherItem::~LauncherItem()
131{ 131{
132 LauncherIconView* liv = (LauncherIconView*)iconView(); 132 LauncherIconView* liv = (LauncherIconView*)iconView();
133 if ( liv->busyItem() == this ) 133 if ( liv->busyItem() == this )
134 liv->setBusy(FALSE); 134 liv->setBusy(FALSE);
135 delete app; 135 delete app;
136} 136}
137 137
138QPixmap*LauncherItem::pixmap()const 138QPixmap*LauncherItem::pixmap()const
139{ 139{
140 if (m_EyeImage && m_EyeImageSet == BASE_ICON) { 140 if (m_EyeImage && m_EyeImageSet == BASE_ICON) {
141 LauncherIconView* liv = (LauncherIconView*)iconView(); 141 LauncherIconView* liv = (LauncherIconView*)iconView();
142 liv->requestEyePix(this); 142 liv->requestEyePix(this);
143 } 143 }
144 return QIconViewItem::pixmap(); 144 return QIconViewItem::pixmap();
145} 145}
146 146
147int LauncherItem::compare ( QIconViewItem * i ) const 147int LauncherItem::compare ( QIconViewItem * i ) const
148{ 148{
149 LauncherIconView* view = (LauncherIconView*)iconView(); 149 LauncherIconView* view = (LauncherIconView*)iconView();
150 return view->compare(app,((LauncherItem *)i)->appLnk()); 150 return view->compare(app,((LauncherItem *)i)->appLnk());
151} 151}
152 152
153void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 153void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
154{ 154{
155 LauncherIconView* liv = (LauncherIconView*)iconView(); 155 LauncherIconView* liv = (LauncherIconView*)iconView();
156 QBrush oldBrush( liv->itemTextBackground() ); 156 QBrush oldBrush( liv->itemTextBackground() );
157 QColorGroup mycg( cg ); 157 QColorGroup mycg( cg );
158 if ( liv->currentItem() == this ) { 158 if ( liv->currentItem() == this ) {
159 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 159 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
160 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 160 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
161 } 161 }
162 162
163 QIconViewItem::paintItem(p,mycg); 163 QIconViewItem::paintItem(p,mycg);
164 164
165 // Paint animation overlay 165 // Paint animation overlay
166 if ( liv->busyItem() == this ) 166 if ( liv->busyItem() == this )
167 paintAnimatedIcon(p); 167 paintAnimatedIcon(p);
168 168
169 if ( liv->currentItem() == this ) 169 if ( liv->currentItem() == this )
170 liv->setItemTextBackground( oldBrush ); 170 liv->setItemTextBackground( oldBrush );
171} 171}
172 172
173void LauncherItem::paintAnimatedIcon( QPainter *p ) 173void LauncherItem::paintAnimatedIcon( QPainter *p )
174{ 174{
175 LauncherIconView* liv = (LauncherIconView*)iconView(); 175 LauncherIconView* liv = (LauncherIconView*)iconView();
176 int pic = iteration % 16; 176 int pic = iteration % 16;
177 int w = pixmap()->width(), h = pixmap()->height(); 177 int w = pixmap()->width(), h = pixmap()->height();
178 QPixmap dblBuf( w, h + 4 ); 178 QPixmap dblBuf( w, h + 4 );
179 QPainter p2( &dblBuf ); 179 QPainter p2( &dblBuf );
180 int x1, y1; 180 int x1, y1;
181 if ( liv->itemTextPos() == QIconView::Bottom ) { 181 if ( liv->itemTextPos() == QIconView::Bottom ) {
182 x1 = x() + (width() - w) / 2 - liv->contentsX(); 182 x1 = x() + (width() - w) / 2 - liv->contentsX();
@@ -231,96 +231,97 @@ void LauncherItem::animateIcon()
231 c.hsv(&h,&s,&v); 231 c.hsv(&h,&s,&v);
232 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); 232 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255));
233 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); 233 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb));
234#elif defined(ALPHA_FADE_BUSY_ICON) 234#elif defined(ALPHA_FADE_BUSY_ICON)
235 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); 235 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2);
236#endif 236#endif
237 } 237 }
238 src.convertFromImage( img ); 238 src.convertFromImage( img );
239 setPixmap( src ); 239 setPixmap( src );
240 } 240 }
241 241
242 iteration++; 242 iteration++;
243 243
244 // Paint animation overlay 244 // Paint animation overlay
245 QPainter p( liv->viewport() ); 245 QPainter p( liv->viewport() );
246 paintAnimatedIcon( &p ); 246 paintAnimatedIcon( &p );
247} 247}
248 248
249void LauncherItem::resetIcon() 249void LauncherItem::resetIcon()
250{ 250{
251 iteration = 0; 251 iteration = 0;
252 setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); 252 setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())));
253} 253}
254 254
255void LauncherItem::setEyePixmap(const QPixmap&aIcon) 255void LauncherItem::setEyePixmap(const QPixmap&aIcon)
256{ 256{
257 if (!isEyeImage()) return; 257 if (!isEyeImage()) return;
258 m_iPixmap = aIcon; 258 m_iPixmap = aIcon;
259 setPixmap(aIcon); 259 setPixmap(aIcon);
260 m_EyeImageSet = EYE_ICON; 260 m_EyeImageSet = EYE_ICON;
261} 261}
262 262
263//=========================================================================== 263//===========================================================================
264// Implemantation of LauncherIconview start 264// Implemantation of LauncherIconview start
265//=========================================================================== 265//===========================================================================
266LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) 266LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
267 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) 267 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white)
268{ 268{
269 m_EyeCallBack = 0; 269 m_EyeCallBack = 0;
270 sortmeth = Name; 270 sortmeth = Name;
271 hidden.setAutoDelete(TRUE); 271 hidden.setAutoDelete(TRUE);
272 ike = FALSE; 272 ike = FALSE;
273 calculateGrid( Bottom ); 273 calculateGrid( Bottom );
274 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); 274 connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer()));
275} 275}
276 276
277LauncherIconView::~LauncherIconView() 277LauncherIconView::~LauncherIconView()
278{ 278{
279 odebug << "LauncherIconView::~LauncherIconView()" << oendl;
279#if 0 // debuggery 280#if 0 // debuggery
280 QListIterator<AppLnk> it(hidden); 281 QListIterator<AppLnk> it(hidden);
281 AppLnk* l; 282 AppLnk* l;
282 while ((l=it.current())) { 283 while ((l=it.current())) {
283 ++it; 284 ++it;
284 //odebug << "" << l << ": hidden (should remove)" << oendl; 285 //odebug << "" << l << ": hidden (should remove)" << oendl;
285 } 286 }
286#endif 287#endif
287} 288}
288 289
289int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) 290int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
290{ 291{
291 switch (sortmeth) { 292 switch (sortmeth) {
292 case Name: 293 case Name:
293 return a->name().lower().compare(b->name().lower()); 294 return a->name().lower().compare(b->name().lower());
294 case Date: { 295 case Date: {
295 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 296 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
296 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 297 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
297 return fa.lastModified().secsTo(fb.lastModified()); 298 return fa.lastModified().secsTo(fb.lastModified());
298 } 299 }
299 case Type: 300 case Type:
300 return a->type().compare(b->type()); 301 return a->type().compare(b->type());
301 } 302 }
302 return 0; 303 return 0;
303} 304}
304 305
305void LauncherIconView::setSortMethod( SortMethod m ) 306void LauncherIconView::setSortMethod( SortMethod m )
306{ 307{
307 if ( sortmeth != m ) { 308 if ( sortmeth != m ) {
308 sortmeth = m; 309 sortmeth = m;
309 sort(); 310 sort();
310 } 311 }
311} 312}
312 313
313void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) 314void LauncherIconView::setCategoryFilter( int catfilter, bool resort )
314{ 315{
315 Categories cat; 316 Categories cat;
316 cat.load( categoryFileName() ); 317 cat.load( categoryFileName() );
317 QString str; 318 QString str;
318 if ( catfilter == -2 ) 319 if ( catfilter == -2 )
319 cf = 0; 320 cf = 0;
320 else 321 else
321 cf = catfilter; 322 cf = catfilter;
322 hideOrShowItems(resort); 323 hideOrShowItems(resort);
323} 324}
324 325
325void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) 326void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort)
326{ 327{
@@ -384,144 +385,135 @@ void LauncherIconView::setBusy(bool on)
384 LauncherItem *oldBusy = bsy; 385 LauncherItem *oldBusy = bsy;
385 bsy = c; 386 bsy = c;
386 if ( oldBusy ) { 387 if ( oldBusy ) {
387 oldBusy->resetIcon(); 388 oldBusy->resetIcon();
388 } 389 }
389 if ( bsy ) { 390 if ( bsy ) {
390 bsy->setBusyIndicatorType( busyType ) ; 391 bsy->setBusyIndicatorType( busyType ) ;
391 bsy->animateIcon(); 392 bsy->animateIcon();
392 } 393 }
393 } 394 }
394} 395}
395 396
396void LauncherIconView::clear() 397void LauncherIconView::clear()
397{ 398{
398 mimes.clear(); 399 mimes.clear();
399 cats.clear(); 400 cats.clear();
400 QIconView::clear(); 401 QIconView::clear();
401 hidden.clear(); 402 hidden.clear();
402} 403}
403 404
404QStringList LauncherIconView::mimeTypes() const 405QStringList LauncherIconView::mimeTypes() const
405{ 406{
406 QStringList r; 407 QStringList r;
407 QDictIterator<void> it(mimes); 408 QDictIterator<void> it(mimes);
408 while (it.current()) { 409 while (it.current()) {
409 r.append(it.currentKey()); 410 r.append(it.currentKey());
410 ++it; 411 ++it;
411 } 412 }
412 r.sort(); 413 r.sort();
413 return r; 414 return r;
414} 415}
415 416
416LauncherItem*LauncherIconView::findDocItem(const QString&fname) 417LauncherItem*LauncherIconView::findDocItem(const QString&fname)
417{ 418{
418 LauncherItem* item = (LauncherItem*)firstItem(); 419 LauncherItem* item = (LauncherItem*)firstItem();
419 while (item) { 420 while (item) {
420 if (item->appLnk()->file()==fname) { 421 if (item->appLnk()->file()==fname) {
421 break; 422 break;
422 } 423 }
423 item = (LauncherItem*)item->nextItem(); 424 item = (LauncherItem*)item->nextItem();
424 } 425 }
425 return item; 426 return item;
426} 427}
427 428
428void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) 429void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
429{ 430{
430 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 431 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
431 if (s!=width) return; 432 if (s!=width) return;
432 LauncherItem*item = 0; 433 LauncherItem*item = findDocItem(aFile);
433 QMap<QString,LauncherItem*>::Iterator it;
434 if ( ( it = m_itemCache.find(aFile))!=m_itemCache.end()) {
435 item = it.data();
436 m_itemCache.remove(it);
437 } else {
438 item = findDocItem(aFile);
439 }
440 if (!item||!item->isEyeImage()) return; 434 if (!item||!item->isEyeImage()) return;
441 item->setEyePixmap(aPixmap); 435 item->setEyePixmap(aPixmap);
442} 436}
443 437
444void LauncherIconView::checkCallback() 438void LauncherIconView::checkCallback()
445{ 439{
446 if (!m_EyeCallBack) { 440 if (!m_EyeCallBack) {
447 m_EyeCallBack = new LauncherThumbReceiver(); 441 m_EyeCallBack = new LauncherThumbReceiver();
448 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), 442 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
449 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); 443 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
450 m_eyeTimer.changeInterval(600000); 444 m_eyeTimer.changeInterval(600000);
451 } 445 }
452} 446}
453 447
454void LauncherIconView::addCheckItem(AppLnk* app) 448void LauncherIconView::addCheckItem(AppLnk* app)
455{ 449{
456 LauncherItem*item = new LauncherItem( this, app, bigIcns ); 450 LauncherItem*item = new LauncherItem( this, app, bigIcns );
457 if (item->isEyeImage()) { 451 if (item->isEyeImage()) {
458 checkCallback(); 452 checkCallback();
459 } 453 }
460} 454}
461 455
462void LauncherIconView::requestEyePix(const LauncherItem*item) 456void LauncherIconView::requestEyePix(const LauncherItem*item)
463{ 457{
464 if (!item) return; 458 if (!item) return;
465 if (item->isEyeImage()) { 459 if (item->isEyeImage()) {
466 checkCallback(); 460 checkCallback();
467 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 461 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
468 m_itemCache[item->appLnk()->file()]=(LauncherItem*)item;
469 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); 462 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
470 } 463 }
471} 464}
472 465
473void LauncherIconView::stopEyeTimer() 466void LauncherIconView::stopEyeTimer()
474{ 467{
475 if (m_EyeCallBack) { 468 if (m_EyeCallBack) {
476 delete m_EyeCallBack; 469 delete m_EyeCallBack;
477 m_EyeCallBack=0; 470 m_EyeCallBack=0;
478 } 471 }
479 m_itemCache.clear();
480 m_eyeTimer.stop(); 472 m_eyeTimer.stop();
481} 473}
482 474
483void LauncherIconView::addItem(AppLnk* app, bool resort) 475void LauncherIconView::addItem(AppLnk* app, bool resort)
484{ 476{
485 addCatsAndMimes(app); 477 addCatsAndMimes(app);
486 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 478 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
487 && (cf == 0 || app->categories().contains(cf) 479 && (cf == 0 || app->categories().contains(cf)
488 || cf == -1 && app->categories().count() == 0 ) ) { 480 || cf == -1 && app->categories().count() == 0 ) ) {
489 addCheckItem(app); 481 addCheckItem(app);
490 } else { 482 } else {
491 hidden.append(app); 483 hidden.append(app);
492 } 484 }
493 if ( resort ){ 485 if ( resort ){
494 sort(); 486 sort();
495 } 487 }
496} 488}
497 489
498void LauncherIconView::updateCategoriesAndMimeTypes() 490void LauncherIconView::updateCategoriesAndMimeTypes()
499{ 491{
500 mimes.clear(); 492 mimes.clear();
501 cats.clear(); 493 cats.clear();
502 LauncherItem* item = (LauncherItem*)firstItem(); 494 LauncherItem* item = (LauncherItem*)firstItem();
503 while (item) { 495 while (item) {
504 addCatsAndMimes(item->appLnk()); 496 addCatsAndMimes(item->appLnk());
505 item = (LauncherItem*)item->nextItem(); 497 item = (LauncherItem*)item->nextItem();
506 } 498 }
507 QListIterator<AppLnk> it(hidden); 499 QListIterator<AppLnk> it(hidden);
508 AppLnk* l; 500 AppLnk* l;
509 while ((l=it.current())) { 501 while ((l=it.current())) {
510 addCatsAndMimes(l); 502 addCatsAndMimes(l);
511 ++it; 503 ++it;
512 } 504 }
513} 505}
514 506
515void LauncherIconView::hideOrShowItems(bool resort) 507void LauncherIconView::hideOrShowItems(bool resort)
516{ 508{
517 viewport()->setUpdatesEnabled( FALSE ); 509 viewport()->setUpdatesEnabled( FALSE );
518 hidden.setAutoDelete(FALSE); 510 hidden.setAutoDelete(FALSE);
519 QList<AppLnk> links=hidden; 511 QList<AppLnk> links=hidden;
520 hidden.clear(); 512 hidden.clear();
521 hidden.setAutoDelete(TRUE); 513 hidden.setAutoDelete(TRUE);
522 LauncherItem* item = (LauncherItem*)firstItem(); 514 LauncherItem* item = (LauncherItem*)firstItem();
523 while (item) { 515 while (item) {
524 links.append(item->takeAppLnk()); 516 links.append(item->takeAppLnk());
525 item = (LauncherItem*)item->nextItem(); 517 item = (LauncherItem*)item->nextItem();
526 } 518 }
527 clear(); 519 clear();
@@ -657,217 +649,217 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
657 icons->setSelectionMode( QIconView::NoSelection ); 649 icons->setSelectionMode( QIconView::NoSelection );
658 icons->setBackgroundMode( PaletteBase ); 650 icons->setBackgroundMode( PaletteBase );
659 icons->setResizeMode( QIconView::Fixed ); 651 icons->setResizeMode( QIconView::Fixed );
660 vmode = (ViewMode)-1; 652 vmode = (ViewMode)-1;
661 setViewMode( Icon ); 653 setViewMode( Icon );
662 654
663 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), 655 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
664 SLOT(itemClicked(int,QIconViewItem*)) ); 656 SLOT(itemClicked(int,QIconViewItem*)) );
665 connect( icons, SIGNAL(selectionChanged()), 657 connect( icons, SIGNAL(selectionChanged()),
666 SLOT(selectionChanged()) ); 658 SLOT(selectionChanged()) );
667 connect( icons, SIGNAL(returnPressed(QIconViewItem*)), 659 connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
668 SLOT(returnPressed(QIconViewItem*)) ); 660 SLOT(returnPressed(QIconViewItem*)) );
669 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), 661 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
670 SLOT(itemPressed(int,QIconViewItem*)) ); 662 SLOT(itemPressed(int,QIconViewItem*)) );
671 663
672 tools = 0; 664 tools = 0;
673 setBackgroundType( Ruled, QString::null ); 665 setBackgroundType( Ruled, QString::null );
674} 666}
675 667
676LauncherView::~LauncherView() 668LauncherView::~LauncherView()
677{ 669{
678 if ( bgCache && bgCache->contains( bgName ) ) 670 if ( bgCache && bgCache->contains( bgName ) )
679 (*bgCache)[bgName]->ref--; 671 (*bgCache)[bgName]->ref--;
680} 672}
681 673
682 674
683bool LauncherView::bsy=FALSE; 675bool LauncherView::bsy=FALSE;
684 676
685void LauncherView::setBusy(bool on) 677void LauncherView::setBusy(bool on)
686{ 678{
687 icons->setBusy(on); 679 icons->setBusy(on);
688} 680}
689 681
690void LauncherView::setBusyIndicatorType( const QString& type ) { 682void LauncherView::setBusyIndicatorType( const QString& type ) {
691 if ( type. lower ( ) == "animated" ) 683 if ( type. lower ( ) == "animated" )
692 icons->setBusyIndicatorType( BIT_Animated ) ; 684 icons->setBusyIndicatorType( BIT_Animated ) ;
693 else 685 else
694 icons->setBusyIndicatorType( BIT_Normal ) ; 686 icons->setBusyIndicatorType( BIT_Normal ) ;
695} 687}
696 688
697void LauncherView::hideIcons() 689void LauncherView::hideIcons()
698{ 690{
699 icons->hide(); 691 icons->hide();
700} 692}
701 693
702void LauncherView::setToolsEnabled(bool y) 694void LauncherView::setToolsEnabled(bool y)
703{ 695{
704 if ( !y != !tools ) { 696 if ( !y != !tools ) {
705 if ( y ) { 697 if ( y ) {
706 tools = new QHBox(this); 698 tools = new QHBox(this);
707 699 // Type filter
708 // Type filter 700 typemb = new QComboBox(tools);
709 typemb = new QComboBox(tools); 701 QSizePolicy p = typemb->sizePolicy();
710 QSizePolicy p = typemb->sizePolicy(); 702 p.setHorData(QSizePolicy::Expanding);
711 p.setHorData(QSizePolicy::Expanding); 703 typemb->setSizePolicy(p);
712 typemb->setSizePolicy(p); 704 // Category filter
713 705 updateTools();
714 // Category filter 706 tools->show();
715 updateTools(); 707 } else {
716 tools->show(); 708 delete tools;
717 709 tools = 0;
718 } else { 710 }
719 delete tools;
720 tools = 0;
721 }
722 } 711 }
723} 712}
724 713
725void LauncherView::updateTools() 714void LauncherView::updateTools()
726{ 715{
727 disconnect( typemb, SIGNAL(activated(int)), 716 disconnect( typemb, SIGNAL(activated(int)),
728 this, SLOT(showType(int)) ); 717 this, SLOT(showType(int)) );
729 if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), 718 if ( catmb ) {
730 this, SLOT(showCategory(int)) ); 719 disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int)));
720 }
731 721
732 // ### I want to remove this 722 // ### I want to remove this
733 icons->updateCategoriesAndMimeTypes(); 723 icons->updateCategoriesAndMimeTypes();
734 724
735 QString prev; 725 QString prev;
736 726
737 // Type filter 727 // Type filter
738 QStringList types; 728 QStringList types;
739 typelist = icons->mimeTypes(); 729 typelist = icons->mimeTypes();
740 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 730 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
741 QString t = *it; 731 QString t = *it;
742 if ( t.left(12) == "application/" ) { 732 if ( t.left(12) == "application/" ) {
743 MimeType mt(t); 733 MimeType mt(t);
744 const AppLnk* app = mt.application(); 734 const AppLnk* app = mt.application();
745 if ( app ) 735 if ( app )
746 t = app->name(); 736 t = app->name();
747 else 737 else
748 t = t.mid(12); 738 t = t.mid(12);
749 } else { 739 } else {
750 t[0] = t[0].upper(); 740 t[0] = t[0].upper();
751 } 741 }
752 types += t; 742 types += t;
753 } 743 }
754 types << tr("All types"); 744 types << tr("All types");
755 prev = typemb->currentText(); 745 prev = typemb->currentText();
756 typemb->clear(); 746 typemb->clear();
757 typemb->insertStringList(types); 747 typemb->insertStringList(types);
758 for (int i=0; i<typemb->count(); i++) { 748 for (int i=0; i<typemb->count(); i++) {
759 if ( typemb->text(i) == prev ) { 749 if ( typemb->text(i) == prev ) {
760 typemb->setCurrentItem(i); 750 typemb->setCurrentItem(i);
761 break; 751 break;
752 }
762 } 753 }
754 if ( prev.isNull() ) {
755 typemb->setCurrentItem(typemb->count()-1);
763 } 756 }
764 if ( prev.isNull() )
765 typemb->setCurrentItem(typemb->count()-1);
766 757
767 int pcat = catmb ? catmb->currentCategory() : -2; 758 int pcat = catmb ? catmb->currentCategory() : -2;
768 if ( !catmb ) 759 if ( !catmb )
769 catmb = new CategorySelect(tools); 760 catmb = new CategorySelect(tools);
770 Categories cats( 0 ); 761 Categories cats( 0 );
771 cats.load( categoryFileName() ); 762 cats.load( categoryFileName() );
772 QArray<int> vl( 0 ); 763 QArray<int> vl( 0 );
773 catmb->setCategories( vl, "Document View", // No tr 764 catmb->setCategories( vl, "Document View", // No tr
774 tr("Document View") ); 765 tr("Document View") );
775 catmb->setRemoveCategoryEdit( TRUE ); 766 catmb->setRemoveCategoryEdit( TRUE );
776 catmb->setAllCategories( TRUE ); 767 catmb->setAllCategories( TRUE );
777 catmb->setCurrentCategory(pcat); 768 catmb->setCurrentCategory(pcat);
778 769
779 // if type has changed we need to redisplay 770 // if type has changed we need to redisplay
780 if ( typemb->currentText() != prev ) 771 if ( typemb->currentText() != prev )
781 showType( typemb->currentItem() ); 772 showType( typemb->currentItem() );
782 773
783 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 774 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
784 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 775 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
785} 776}
786 777
787void LauncherView::sortBy(int s) 778void LauncherView::sortBy(int s)
788{ 779{
789 icons->setSortMethod((LauncherIconView::SortMethod)s); 780 icons->setSortMethod((LauncherIconView::SortMethod)s);
790} 781}
791 782
792void LauncherView::showType(int t) 783void LauncherView::showType(int t)
793{ 784{
794 if ( t >= (int)typelist.count() ) { 785 if ( t >= (int)typelist.count() ) {
795 icons->setTypeFilter("",TRUE); 786 icons->setTypeFilter("",TRUE);
796 } else { 787 } else {
797 QString ty = typelist[t]; 788 QString ty = typelist[t];
798 if ( !ty.contains('/') ) 789 if ( !ty.contains('/') )
799 ty += "/*"; 790 ty += "/*";
800 icons->setTypeFilter(ty,TRUE); 791 icons->setTypeFilter(ty,TRUE);
801 } 792 }
802} 793}
803 794
804void LauncherView::showCategory( int c ) 795void LauncherView::showCategory( int c )
805{ 796{
806 icons->setCategoryFilter( c, TRUE ); 797 icons->setCategoryFilter( c, TRUE );
807} 798}
808 799
809void LauncherView::setViewMode( ViewMode m ) 800void LauncherView::setViewMode( ViewMode m )
810{ 801{
802 odebug << "LauncherView::setViewMode( ViewMode m )" << oendl;
811 if ( vmode != m ) { 803 if ( vmode != m ) {
812 bool bigIcons = m == Icon; 804 bool bigIcons = m == Icon;
813 icons->viewport()->setUpdatesEnabled( FALSE ); 805 icons->viewport()->setUpdatesEnabled( FALSE );
814 icons->setBigIcons( bigIcons ); 806 icons->setBigIcons( bigIcons );
815 switch ( m ) { 807 switch ( m ) {
816 case List: 808 case List:
817 icons->setItemTextPos( QIconView::Right ); 809 icons->setItemTextPos( QIconView::Right );
818 break; 810 break;
819 case Icon: 811 case Icon:
820 icons->setItemTextPos( QIconView::Bottom ); 812 icons->setItemTextPos( QIconView::Bottom );
821 break; 813 break;
822 } 814 }
823 icons->hideOrShowItems( FALSE ); 815 icons->hideOrShowItems( FALSE );
824 icons->viewport()->setUpdatesEnabled( TRUE ); 816 icons->viewport()->setUpdatesEnabled( TRUE );
825 vmode = m; 817 vmode = m;
826 } 818 }
827} 819}
828 820
829// 821//
830// User images may require scaling. 822// User images may require scaling.
831// 823//
832QImage LauncherView::loadBackgroundImage(QString &bgName) 824QImage LauncherView::loadBackgroundImage(QString &bgName)
833{ 825{
834 QImageIO imgio; 826 QImageIO imgio;
835 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop 827 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop
836 bool further_scaling = TRUE; 828 bool further_scaling = TRUE;
837 829
838 imgio.setFileName( bgName ); 830 imgio.setFileName( bgName );
839 imgio.setParameters("GetHeaderInformation"); 831 imgio.setParameters("GetHeaderInformation");
840 832
841 if (imgio.read() == FALSE) { 833 if (imgio.read() == FALSE) {
842 return imgio.image(); 834 return imgio.image();
843 } 835 }
844 836
845 if (imgio.image().width() < ds.width() && 837 if (imgio.image().width() < ds.width() &&
846 imgio.image().height() < ds.height()) { 838 imgio.image().height() < ds.height()) {
847 further_scaling = FALSE; 839 further_scaling = FALSE;
848 } 840 }
849 841
850 if (!imgio.image().bits()) { 842 if (!imgio.image().bits()) {
851 // 843 //
852 // Scale and load. Note we don't scale up. 844 // Scale and load. Note we don't scale up.
853 // 845 //
854 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 846 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
855 imgio.setParameters(further_scaling ? 847 imgio.setParameters(further_scaling ?
856 param.arg(ds.width()).arg(ds.height()).latin1() : 848 param.arg(ds.width()).arg(ds.height()).latin1() :
857 ""); 849 "");
858 imgio.read(); 850 imgio.read();
859 } else { 851 } else {
860 if (further_scaling) { 852 if (further_scaling) {
861 int t1 = imgio.image().width() * ds.height(); 853 int t1 = imgio.image().width() * ds.height();
862 int t2 = imgio.image().height() * ds.width(); 854 int t2 = imgio.image().height() * ds.width();
863 int dsth = ds.height(); 855 int dsth = ds.height();
864 int dstw = ds.width(); 856 int dstw = ds.width();
865 857
866 if (t1 > t2) { 858 if (t1 > t2) {
867 dsth = t2 / imgio.image().width(); 859 dsth = t2 / imgio.image().width();
868 } else { 860 } else {
869 dstw = t1 / imgio.image().height(); 861 dstw = t1 / imgio.image().height();
870 } 862 }
871 863
872 // 864 //
873 // Loader didn't scale for us. Do it manually. 865 // Loader didn't scale for us. Do it manually.
@@ -1001,96 +993,97 @@ void LauncherView::resizeEvent(QResizeEvent *e)
1001} 993}
1002 994
1003void LauncherView::selectionChanged() 995void LauncherView::selectionChanged()
1004{ 996{
1005 QIconViewItem* item = icons->currentItem(); 997 QIconViewItem* item = icons->currentItem();
1006 if ( item && item->isSelected() ) { 998 if ( item && item->isSelected() ) {
1007 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 999 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1008 if ( icons->inKeyEvent() ) // not for mouse press 1000 if ( icons->inKeyEvent() ) // not for mouse press
1009 emit clicked( appLnk ); 1001 emit clicked( appLnk );
1010 item->setSelected(FALSE); 1002 item->setSelected(FALSE);
1011 } 1003 }
1012} 1004}
1013 1005
1014void LauncherView::returnPressed( QIconViewItem *item ) 1006void LauncherView::returnPressed( QIconViewItem *item )
1015{ 1007{
1016 if ( item ) { 1008 if ( item ) {
1017 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1009 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1018 emit clicked( appLnk ); 1010 emit clicked( appLnk );
1019 } 1011 }
1020} 1012}
1021 1013
1022void LauncherView::itemClicked( int btn, QIconViewItem *item ) 1014void LauncherView::itemClicked( int btn, QIconViewItem *item )
1023{ 1015{
1024 if ( item ) { 1016 if ( item ) {
1025 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1017 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1026 if ( btn == LeftButton ) { 1018 if ( btn == LeftButton ) {
1027 // Make sure it's the item we execute that gets highlighted 1019 // Make sure it's the item we execute that gets highlighted
1028 icons->setCurrentItem( item ); 1020 icons->setCurrentItem( item );
1029 emit clicked( appLnk ); 1021 emit clicked( appLnk );
1030 } 1022 }
1031 item->setSelected(FALSE); 1023 item->setSelected(FALSE);
1032 } 1024 }
1033} 1025}
1034 1026
1035void LauncherView::itemPressed( int btn, QIconViewItem *item ) 1027void LauncherView::itemPressed( int btn, QIconViewItem *item )
1036{ 1028{
1037 if ( item ) { 1029 if ( item ) {
1038 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1030 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
1039 if ( btn == RightButton ) 1031 if ( btn == RightButton )
1040 emit rightPressed( appLnk ); 1032 emit rightPressed( appLnk );
1041 else if ( btn == ShiftButton ) 1033 else if ( btn == ShiftButton )
1042 emit rightPressed( appLnk ); 1034 emit rightPressed( appLnk );
1043 item->setSelected(FALSE); 1035 item->setSelected(FALSE);
1044 } 1036 }
1045} 1037}
1046 1038
1047void LauncherView::removeAllItems() 1039void LauncherView::removeAllItems()
1048{ 1040{
1041 odebug << "LauncherView::removeAllItems()" << oendl;
1049 icons->clear(); 1042 icons->clear();
1050} 1043}
1051 1044
1052bool LauncherView::removeLink(const QString& linkfile) 1045bool LauncherView::removeLink(const QString& linkfile)
1053{ 1046{
1054 return icons->removeLink(linkfile); 1047 return icons->removeLink(linkfile);
1055} 1048}
1056 1049
1057void LauncherView::setSortEnabled( bool v ) 1050void LauncherView::setSortEnabled( bool v )
1058{ 1051{
1059 icons->setSorting( v ); 1052 icons->setSorting( v );
1060 if ( v ) 1053 if ( v )
1061 sort(); 1054 sort();
1062} 1055}
1063 1056
1064void LauncherView::setUpdatesEnabled( bool u ) 1057void LauncherView::setUpdatesEnabled( bool u )
1065{ 1058{
1066 icons->setUpdatesEnabled( u ); 1059 icons->setUpdatesEnabled( u );
1067} 1060}
1068 1061
1069void LauncherView::sort() 1062void LauncherView::sort()
1070{ 1063{
1071 icons->sort(); 1064 icons->sort();
1072} 1065}
1073 1066
1074void LauncherView::addItem(AppLnk* app, bool resort) 1067void LauncherView::addItem(AppLnk* app, bool resort)
1075{ 1068{
1076 icons->addItem(app,resort); 1069 icons->addItem(app,resort);
1077} 1070}
1078 1071
1079void LauncherView::paletteChange( const QPalette &p ) 1072void LauncherView::paletteChange( const QPalette &p )
1080{ 1073{
1081 icons->unsetPalette(); 1074 icons->unsetPalette();
1082 QVBox::paletteChange( p ); 1075 QVBox::paletteChange( p );
1083 if ( bgType == Ruled ) 1076 if ( bgType == Ruled )
1084 setBackgroundType( Ruled, QString::null ); 1077 setBackgroundType( Ruled, QString::null );
1085 QColorGroup cg = icons->colorGroup(); 1078 QColorGroup cg = icons->colorGroup();
1086 cg.setColor( QColorGroup::Text, textCol ); 1079 cg.setColor( QColorGroup::Text, textCol );
1087 icons->setPalette( QPalette(cg,cg,cg) ); 1080 icons->setPalette( QPalette(cg,cg,cg) );
1088} 1081}
1089 1082
1090void LauncherView::fontChanged(const QFont&) 1083void LauncherView::fontChanged(const QFont&)
1091{ 1084{
1092 odebug << "LauncherView::fontChanged()" << oendl; 1085 odebug << "LauncherView::fontChanged()" << oendl;
1093 icons->hideOrShowItems( FALSE ); 1086 icons->hideOrShowItems( FALSE );
1094} 1087}
1095 1088
1096void LauncherView::relayout(void) 1089void LauncherView::relayout(void)
@@ -1123,59 +1116,59 @@ QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1123 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 1116 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1124 return s; 1117 return s;
1125} 1118}
1126 1119
1127QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 1120QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1128 return s << inf.file << inf.width << inf.height; 1121 return s << inf.file << inf.width << inf.height;
1129} 1122}
1130 1123
1131LauncherThumbReceiver::LauncherThumbReceiver() 1124LauncherThumbReceiver::LauncherThumbReceiver()
1132 :QObject() 1125 :QObject()
1133{ 1126{
1134 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); 1127 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this );
1135 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 1128 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
1136 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 1129 this, SLOT(recieve(const QCString&,const QByteArray&)) );
1137 1130
1138 { 1131 {
1139 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 1132 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
1140 } 1133 }
1141} 1134}
1142 1135
1143LauncherThumbReceiver::~LauncherThumbReceiver() 1136LauncherThumbReceiver::~LauncherThumbReceiver()
1144{ 1137{
1145 { 1138 {
1146 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 1139 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1147 } 1140 }
1148} 1141}
1149 1142
1150void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) 1143void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
1151{ 1144{
1152 PixmapInfos pixinfos; 1145 PixmapInfos pixinfos;
1153 QDataStream stream( at, IO_ReadOnly ); 1146 QDataStream stream( at, IO_ReadOnly );
1154 1147
1155 /* we are just interested in thumbmails */ 1148 /* we are just interested in thumbmails */
1156 if ( str == "pixmapsHandled(PixmapList)" ) 1149 if ( str == "pixmapsHandled(PixmapList)" )
1157 stream >> pixinfos; 1150 stream >> pixinfos;
1158 1151
1159 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { 1152 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
1160 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); 1153 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width);
1161 } 1154 }
1162} 1155}
1163 1156
1164void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) 1157void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
1165{ 1158{
1166 PixmapInfo rItem; 1159 PixmapInfo rItem;
1167 rItem.file = file; 1160 rItem.file = file;
1168 rItem.width = width; 1161 rItem.width = width;
1169 rItem.height = height; 1162 rItem.height = height;
1170 m_inThumbNail.append(rItem); 1163 m_inThumbNail.append(rItem);
1171 QTimer::singleShot(0, this, SLOT(sendRequest())); 1164 QTimer::singleShot(2, this, SLOT(sendRequest()));
1172} 1165}
1173 1166
1174void LauncherThumbReceiver::sendRequest() 1167void LauncherThumbReceiver::sendRequest()
1175{ 1168{
1176 if (m_inThumbNail.count()>0) { 1169 if (m_inThumbNail.count()>0) {
1177 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); 1170 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
1178 env << m_inThumbNail; 1171 env << m_inThumbNail;
1179 m_inThumbNail.clear(); 1172 m_inThumbNail.clear();
1180 } 1173 }
1181} 1174}
diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h
index 94c367c..6d94539 100644
--- a/core/launcher/launcherview.h
+++ b/core/launcher/launcherview.h
@@ -195,52 +195,51 @@ public:
195 195
196 void drawBackground( QPainter *p, const QRect &r ); 196 void drawBackground( QPainter *p, const QRect &r );
197 void setItemTextPos( ItemTextPos pos ); 197 void setItemTextPos( ItemTextPos pos );
198 void hideOrShowItems(bool resort); 198 void hideOrShowItems(bool resort);
199 199
200 void setTypeFilter(const QString& typefilter, bool resort); 200 void setTypeFilter(const QString& typefilter, bool resort);
201 void setCategoryFilter( int catfilter, bool resort ); 201 void setCategoryFilter( int catfilter, bool resort );
202 202
203 enum SortMethod { Name, Date, Type }; 203 enum SortMethod { Name, Date, Type };
204 204
205 void setSortMethod( SortMethod m ); 205 void setSortMethod( SortMethod m );
206 int compare(const AppLnk* a, const AppLnk* b); 206 int compare(const AppLnk* a, const AppLnk* b);
207 void requestEyePix(const LauncherItem*which); 207 void requestEyePix(const LauncherItem*which);
208 208
209protected: 209protected:
210 virtual void timerEvent( QTimerEvent *te ); 210 virtual void timerEvent( QTimerEvent *te );
211 void styleChange( QStyle &old ); 211 void styleChange( QStyle &old );
212 void calculateGrid( ItemTextPos pos ); 212 void calculateGrid( ItemTextPos pos );
213 void focusInEvent( QFocusEvent * ) {} 213 void focusInEvent( QFocusEvent * ) {}
214 void focusOutEvent( QFocusEvent * ) {} 214 void focusOutEvent( QFocusEvent * ) {}
215 LauncherItem*findDocItem(const QString&); 215 LauncherItem*findDocItem(const QString&);
216 void addCheckItem(AppLnk* app); 216 void addCheckItem(AppLnk* app);
217 void checkCallback(); 217 void checkCallback();
218 virtual void keyPressEvent(QKeyEvent* e); 218 virtual void keyPressEvent(QKeyEvent* e);
219 219
220protected slots: 220protected slots:
221 void setEyePixmap(const QPixmap&,const QString&,int width); 221 void setEyePixmap(const QPixmap&,const QString&,int width);
222 void stopEyeTimer(); 222 void stopEyeTimer();
223 223
224private: 224private:
225 QList<AppLnk> hidden; 225 QList<AppLnk> hidden;
226 QDict<void> mimes; 226 QDict<void> mimes;
227 QDict<void> cats; 227 QDict<void> cats;
228 SortMethod sortmeth; 228 SortMethod sortmeth;
229 QRegExp tf; 229 QRegExp tf;
230 int cf; 230 int cf;
231 LauncherItem* bsy; 231 LauncherItem* bsy;
232 int busyTimer; 232 int busyTimer;
233 bool ike; 233 bool ike;
234 bool bigIcns; 234 bool bigIcns;
235 QPixmap bgPixmap; 235 QPixmap bgPixmap;
236 QColor bgColor; 236 QColor bgColor;
237 LauncherThumbReceiver*m_EyeCallBack; 237 LauncherThumbReceiver*m_EyeCallBack;
238#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 238#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
239 QPixmap busyPix; 239 QPixmap busyPix;
240#endif 240#endif
241 BusyIndicatorType busyType; 241 BusyIndicatorType busyType;
242 QTimer m_eyeTimer; 242 QTimer m_eyeTimer;
243 QMap<QString,LauncherItem*> m_itemCache;
244}; 243};
245 244
246#endif // LAUNCHERVIEW_H 245#endif // LAUNCHERVIEW_H