-rw-r--r-- | core/launcher/launcherview.cpp | 866 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 40 |
2 files changed, 517 insertions, 389 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index cd9c14b..1317bda 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp @@ -31,2 +31,4 @@ using namespace Opie::Core; +#include <qpe/qcopenvelope_qws.h> + /* QT */ @@ -60,6 +62,6 @@ static void cleanup_cache() while ( it != bgCache->end() ) { - QMap<QString,BgPixmap*>::Iterator curr = it; - ++it; - delete (*curr); - bgCache->remove( curr ); + QMap<QString,BgPixmap*>::Iterator curr = it; + ++it; + delete (*curr); + bgCache->remove( curr ); } @@ -81,2 +83,3 @@ public: void resetIcon(); + bool isEyeImage()const{return m_EyeImage;} @@ -86,2 +89,3 @@ public: void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } + void setEyePixmap(const QPixmap&aIcon); protected: @@ -90,2 +94,3 @@ protected: AppLnk* app; + private: @@ -93,2 +98,6 @@ private: BusyIndicatorType busyType; + int psize; + QPixmap m_iPixmap; + bool m_EyeImage; + LauncherThumbReceiver*m_EyeCallback; }; @@ -99,14 +108,14 @@ public: LauncherIconView( QWidget* parent, const char* name=0 ) : - QIconView(parent,name), - tf(""), - cf(0), - bsy(0), - busyTimer(0), - bigIcns(TRUE), - bgColor(white) + QIconView(parent,name), + tf(""), + cf(0), + bsy(0), + busyTimer(0), + bigIcns(TRUE), + bgColor(white) { - sortmeth = Name; - hidden.setAutoDelete(TRUE); - ike = FALSE; - calculateGrid( Bottom ); + sortmeth = Name; + hidden.setAutoDelete(TRUE); + ike = FALSE; + calculateGrid( Bottom ); } @@ -116,8 +125,8 @@ public: #if 0 // debuggery - QListIterator<AppLnk> it(hidden); - AppLnk* l; - while ((l=it.current())) { - ++it; + QListIterator<AppLnk> it(hidden); + AppLnk* l; + while ((l=it.current())) { + ++it; //odebug << "" << l << ": hidden (should remove)" << oendl; - } + } #endif @@ -130,5 +139,5 @@ public: void setBigIcons( bool bi ) { - bigIcns = bi; + bigIcns = bi; #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY - busyPix.resize(0,0); + busyPix.resize(0,0); #endif @@ -140,3 +149,3 @@ public: { - // We don't want rubberbanding (yet) + // We don't want rubberbanding (yet) } @@ -146,30 +155,30 @@ public: #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY - if ( busyPix.isNull() ) { - int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); - busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); - } + if ( busyPix.isNull() ) { + int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); + busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); + } #endif - if ( on ) { - busyTimer = startTimer( 100 ); - } else { - if ( busyTimer ) { - killTimer( busyTimer ); - busyTimer = 0; - } - } - - LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; - - if ( bsy != c ) { - LauncherItem *oldBusy = bsy; - bsy = c; - if ( oldBusy ) { - oldBusy->resetIcon(); + if ( on ) { + busyTimer = startTimer( 100 ); + } else { + if ( busyTimer ) { + killTimer( busyTimer ); + busyTimer = 0; + } + } + + LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; + + if ( bsy != c ) { + LauncherItem *oldBusy = bsy; + bsy = c; + if ( oldBusy ) { + oldBusy->resetIcon(); } - if ( bsy ) { + if ( bsy ) { bsy->setBusyIndicatorType( busyType ) ; - bsy->animateIcon(); + bsy->animateIcon(); } - } + } } @@ -179,12 +188,12 @@ public: { - ike = TRUE; - if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { - if ( (e->state() & ShiftButton) ) - emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); - else - returnPressed(currentItem()); - } + ike = TRUE; + if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { + if ( (e->state() & ShiftButton) ) + emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); + else + returnPressed(currentItem()); + } - QIconView::keyPressEvent(e); - ike = FALSE; + QIconView::keyPressEvent(e); + ike = FALSE; } @@ -199,6 +208,6 @@ public: { - mimes.clear(); - cats.clear(); - QIconView::clear(); - hidden.clear(); + mimes.clear(); + cats.clear(); + QIconView::clear(); + hidden.clear(); } @@ -207,13 +216,13 @@ public: { - // QStringList c = app->categories(); - // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { - // cats.replace(*cit,(void*)1); - // } - QString maj=app->type(); - int sl=maj.find('/'); - if (sl>=0) { - QString k; - k = maj.left(12) == "application/" ? maj : maj.left(sl); - mimes.replace(k,(void*)1); - } + // QStringList c = app->categories(); + // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { + // cats.replace(*cit,(void*)1); + // } + QString maj=app->type(); + int sl=maj.find('/'); + if (sl>=0) { + QString k; + k = maj.left(12) == "application/" ? maj : maj.left(sl); + mimes.replace(k,(void*)1); + } } @@ -224,3 +233,3 @@ public: void setBackgroundPixmap( const QPixmap &pm ) { - bgPixmap = pm; + bgPixmap = pm; } @@ -228,3 +237,3 @@ public: void setBackgroundColor( const QColor &c ) { - bgColor = c; + bgColor = c; } @@ -233,3 +242,3 @@ public: { - if ( !bgPixmap.isNull() ) { + if ( !bgPixmap.isNull() ) { p->drawTiledPixmap( r, bgPixmap, @@ -237,5 +246,5 @@ public: (r.y() + contentsY()) % bgPixmap.height() ) ); - } else { - p->fillRect( r, bgColor ); - } + } else { + p->fillRect( r, bgColor ); + } } @@ -244,4 +253,4 @@ public: { - calculateGrid( pos ); - QIconView::setItemTextPos( pos ); + calculateGrid( pos ); + QIconView::setItemTextPos( pos ); } @@ -252,4 +261,4 @@ public: { - tf = QRegExp(typefilter,FALSE,TRUE); - hideOrShowItems(resort); + tf = QRegExp(typefilter,FALSE,TRUE); + hideOrShowItems(resort); } @@ -258,10 +267,10 @@ public: { - Categories cat; - cat.load( categoryFileName() ); - QString str; - if ( catfilter == -2 ) - cf = 0; - else - cf = catfilter; - hideOrShowItems(resort); + Categories cat; + cat.load( categoryFileName() ); + QString str; + if ( catfilter == -2 ) + cf = 0; + else + cf = catfilter; + hideOrShowItems(resort); } @@ -272,6 +281,6 @@ public: { - if ( sortmeth != m ) { - sortmeth = m; - sort(); - } + if ( sortmeth != m ) { + sortmeth = m; + sort(); + } } @@ -280,14 +289,14 @@ public: { - switch (sortmeth) { - case Name: - return a->name().lower().compare(b->name().lower()); - case Date: { - QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); - QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); - return fa.lastModified().secsTo(fb.lastModified()); - } - case Type: - return a->type().compare(b->type()); - } - return 0; + switch (sortmeth) { + case Name: + return a->name().lower().compare(b->name().lower()); + case Date: { + QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); + QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); + return fa.lastModified().secsTo(fb.lastModified()); + } + case Type: + return a->type().compare(b->type()); + } + return 0; } @@ -298,8 +307,8 @@ protected: { - if ( te->timerId() == busyTimer ) { - if ( bsy ) - bsy->animateIcon(); - } else { - QIconView::timerEvent( te ); - } + if ( te->timerId() == busyTimer ) { + if ( bsy ) + bsy->animateIcon(); + } else { + QIconView::timerEvent( te ); + } } @@ -308,4 +317,4 @@ protected: { - QIconView::styleChange( old ); - calculateGrid( itemTextPos() ); + QIconView::styleChange( old ); + calculateGrid( itemTextPos() ); } @@ -314,23 +323,23 @@ protected: { - int dw = QApplication::desktop()->width(); - int viewerWidth = dw-style().scrollBarExtent().width(); - if ( pos == Bottom ) { - int cols = 3; - if ( viewerWidth <= 200 ) - cols = 2; - else if ( viewerWidth >= 400 ) - cols = viewerWidth/96; - setSpacing( 4 ); - setGridX( (viewerWidth-(cols+1)*spacing())/cols ); - setGridY( fontMetrics().height()*2+24 ); - } else { - int cols = 2; - if ( viewerWidth < 150 ) - cols = 1; - else if ( viewerWidth >= 400 ) - cols = viewerWidth/150; - setSpacing( 2 ); - setGridX( (viewerWidth-(cols+1)*spacing())/cols ); - setGridY( fontMetrics().height()+2 ); - } + int dw = QApplication::desktop()->width(); + int viewerWidth = dw-style().scrollBarExtent().width(); + if ( pos == Bottom ) { + int cols = 3; + if ( viewerWidth <= 200 ) + cols = 2; + else if ( viewerWidth >= 400 ) + cols = viewerWidth/96; + setSpacing( 4 ); + setGridX( (viewerWidth-(cols+1)*spacing())/cols ); + setGridY( fontMetrics().height()*2+24 ); + } else { + int cols = 2; + if ( viewerWidth < 150 ) + cols = 1; + else if ( viewerWidth >= 400 ) + cols = viewerWidth/150; + setSpacing( 2 ); + setGridX( (viewerWidth-(cols+1)*spacing())/cols ); + setGridY( fontMetrics().height()+2 ); + } } @@ -369,5 +378,5 @@ void LauncherView::setBusyIndicatorType( const QString& type ) { if ( type. lower ( ) == "animated" ) - icons->setBusyIndicatorType( BIT_Animated ) ; + icons->setBusyIndicatorType( BIT_Animated ) ; else - icons->setBusyIndicatorType( BIT_Normal ) ; + icons->setBusyIndicatorType( BIT_Normal ) ; } @@ -377,6 +386,15 @@ LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), - isBigIcon( bigIcon ), - iteration(0), - app(applnk) // Takes ownership + isBigIcon( bigIcon ), + iteration(0), + app(applnk), // Takes ownership + psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), + m_iPixmap(), + m_EyeImage(false) { + m_EyeCallback = new LauncherThumbReceiver(this); + if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { + m_EyeImage = true; + m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); + m_EyeCallback->requestThumb(applnk->file(),m_iPixmap.width(),m_iPixmap.height()); + } } @@ -387,4 +405,5 @@ LauncherItem::~LauncherItem() if ( liv->busyItem() == this ) - liv->setBusy(FALSE); + liv->setBusy(FALSE); delete app; + if (m_EyeCallback) delete m_EyeCallback; } @@ -403,4 +422,4 @@ void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) if ( liv->currentItem() == this ) { - liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); - mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); + liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); + mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); } @@ -411,6 +430,6 @@ void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) if ( liv->busyItem() == this ) - paintAnimatedIcon(p); + paintAnimatedIcon(p); if ( liv->currentItem() == this ) - liv->setItemTextBackground( oldBrush ); + liv->setItemTextBackground( oldBrush ); } @@ -428,7 +447,7 @@ void LauncherItem::paintAnimatedIcon( QPainter *p ) if ( liv->itemTextPos() == QIconView::Bottom ) { - x1 = x() + (width() - w) / 2 - liv->contentsX(); - y1 = y() - liv->contentsY(); + x1 = x() + (width() - w) / 2 - liv->contentsX(); + y1 = y() - liv->contentsY(); } else { - x1 = x() - liv->contentsX(); - y1 = y() + (height() - h) / 2 - liv->contentsY(); + x1 = x() - liv->contentsX(); + y1 = y() + (height() - h) / 2 - liv->contentsY(); } @@ -458,3 +477,3 @@ void LauncherItem::animateIcon() if ( liv->busyItem() != this || !app ) - return; + return; @@ -462,26 +481,26 @@ void LauncherItem::animateIcon() if ( iteration == 0 ) { - QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap(); - QImage img = src.convertToImage(); - QRgb *rgb; - int count; - if ( img.depth() == 32 ) { - rgb = (QRgb*)img.bits(); - count = img.bytesPerLine()/sizeof(QRgb)*img.height(); - } else { - rgb = img.colorTable(); - count = img.numColors(); - } - for ( int r = 0; r < count; r++, rgb++ ) { + QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())); + QImage img = src.convertToImage(); + QRgb *rgb; + int count; + if ( img.depth() == 32 ) { + rgb = (QRgb*)img.bits(); + count = img.bytesPerLine()/sizeof(QRgb)*img.height(); + } else { + rgb = img.colorTable(); + count = img.numColors(); + } + for ( int r = 0; r < count; r++, rgb++ ) { #if defined(BRIGHTEN_BUSY_ICON) - QColor c(*rgb); - int h, s, v; - c.hsv(&h,&s,&v); - c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); - *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); + QColor c(*rgb); + int h, s, v; + c.hsv(&h,&s,&v); + c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); + *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); #elif defined(ALPHA_FADE_BUSY_ICON) - *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); + *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); #endif - } - src.convertFromImage( img ); - setPixmap( src ); + } + src.convertFromImage( img ); + setPixmap( src ); } @@ -498,3 +517,10 @@ void LauncherItem::resetIcon() iteration = 0; - setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() ); + setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); +} + +void LauncherItem::setEyePixmap(const QPixmap&aIcon) +{ + if (!isEyeImage()) return; + m_iPixmap = aIcon; + setPixmap(aIcon); } @@ -508,4 +534,4 @@ QStringList LauncherIconView::mimeTypes() const while (it.current()) { - r.append(it.currentKey()); - ++it; + r.append(it.currentKey()); + ++it; } @@ -520,9 +546,9 @@ void LauncherIconView::addItem(AppLnk* app, bool resort) if ( (tf.isEmpty() || tf.match(app->type()) >= 0) - && (cf == 0 || app->categories().contains(cf) - || cf == -1 && app->categories().count() == 0 ) ) - (void) new LauncherItem( this, app, bigIcns ); + && (cf == 0 || app->categories().contains(cf) + || cf == -1 && app->categories().count() == 0 ) ) + (void) new LauncherItem( this, app, bigIcns ); else - hidden.append(app); + hidden.append(app); if ( resort ) - sort(); + sort(); } @@ -535,4 +561,4 @@ void LauncherIconView::updateCategoriesAndMimeTypes() while (item) { - addCatsAndMimes(item->appLnk()); - item = (LauncherItem*)item->nextItem(); + addCatsAndMimes(item->appLnk()); + item = (LauncherItem*)item->nextItem(); } @@ -541,4 +567,4 @@ void LauncherIconView::updateCategoriesAndMimeTypes() while ((l=it.current())) { - addCatsAndMimes(l); - ++it; + addCatsAndMimes(l); + ++it; } @@ -555,4 +581,4 @@ void LauncherIconView::hideOrShowItems(bool resort) while (item) { - links.append(item->takeAppLnk()); - item = (LauncherItem*)item->nextItem(); + links.append(item->takeAppLnk()); + item = (LauncherItem*)item->nextItem(); } @@ -562,7 +588,7 @@ void LauncherIconView::hideOrShowItems(bool resort) while ((l=it.current())) { - addItem(l,FALSE); - ++it; + addItem(l,FALSE); + ++it; } if ( resort && !autoArrange() ) - sort(); + sort(); viewport()->setUpdatesEnabled( TRUE ); @@ -577,12 +603,12 @@ bool LauncherIconView::removeLink(const QString& linkfile) while (item) { - l = item->appLnk(); - LauncherItem *nextItem = (LauncherItem *)item->nextItem(); - if ( l->linkFileKnown() && l->linkFile() == linkfile - || l->fileKnown() && ( - l->file() == linkfile - || dl.isValid() && dl.file() == l->file() ) ) { - delete item; - did = TRUE; - } - item = nextItem; + l = item->appLnk(); + LauncherItem *nextItem = (LauncherItem *)item->nextItem(); + if ( l->linkFileKnown() && l->linkFile() == linkfile + || l->fileKnown() && ( + l->file() == linkfile + || dl.isValid() && dl.file() == l->file() ) ) { + delete item; + did = TRUE; + } + item = nextItem; } @@ -590,9 +616,9 @@ bool LauncherIconView::removeLink(const QString& linkfile) while ((l=it.current())) { - ++it; - if ( l->linkFileKnown() && l->linkFile() == linkfile - || l->file() == linkfile - || dl.isValid() && dl.file() == l->file() ) { - hidden.removeRef(l); - did = TRUE; - } + ++it; + if ( l->linkFileKnown() && l->linkFile() == linkfile + || l->file() == linkfile + || dl.isValid() && dl.file() == l->file() ) { + hidden.removeRef(l); + did = TRUE; + } } @@ -623,9 +649,9 @@ LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), - SLOT(itemClicked(int,QIconViewItem*)) ); + SLOT(itemClicked(int,QIconViewItem*)) ); connect( icons, SIGNAL(selectionChanged()), - SLOT(selectionChanged()) ); + SLOT(selectionChanged()) ); connect( icons, SIGNAL(returnPressed(QIconViewItem*)), - SLOT(returnPressed(QIconViewItem*)) ); + SLOT(returnPressed(QIconViewItem*)) ); connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), - SLOT(itemPressed(int,QIconViewItem*)) ); + SLOT(itemPressed(int,QIconViewItem*)) ); @@ -638,3 +664,3 @@ LauncherView::~LauncherView() if ( bgCache && bgCache->contains( bgName ) ) - (*bgCache)[bgName]->ref--; + (*bgCache)[bgName]->ref--; } @@ -649,19 +675,19 @@ void LauncherView::setToolsEnabled(bool y) if ( !y != !tools ) { - if ( y ) { - tools = new QHBox(this); + if ( y ) { + tools = new QHBox(this); - // Type filter - typemb = new QComboBox(tools); - QSizePolicy p = typemb->sizePolicy(); - p.setHorData(QSizePolicy::Expanding); - typemb->setSizePolicy(p); + // Type filter + typemb = new QComboBox(tools); + QSizePolicy p = typemb->sizePolicy(); + p.setHorData(QSizePolicy::Expanding); + typemb->setSizePolicy(p); - // Category filter - updateTools(); - tools->show(); + // Category filter + updateTools(); + tools->show(); - } else { - delete tools; - tools = 0; - } + } else { + delete tools; + tools = 0; + } } @@ -672,5 +698,5 @@ void LauncherView::updateTools() disconnect( typemb, SIGNAL(activated(int)), - this, SLOT(showType(int)) ); + this, SLOT(showType(int)) ); if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), - this, SLOT(showCategory(int)) ); + this, SLOT(showCategory(int)) ); @@ -685,14 +711,14 @@ void LauncherView::updateTools() for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { - QString t = *it; - if ( t.left(12) == "application/" ) { - MimeType mt(t); - const AppLnk* app = mt.application(); - if ( app ) - t = app->name(); - else - t = t.mid(12); - } else { - t[0] = t[0].upper(); - } - types += t; + QString t = *it; + if ( t.left(12) == "application/" ) { + MimeType mt(t); + const AppLnk* app = mt.application(); + if ( app ) + t = app->name(); + else + t = t.mid(12); + } else { + t[0] = t[0].upper(); + } + types += t; } @@ -703,9 +729,9 @@ void LauncherView::updateTools() for (int i=0; i<typemb->count(); i++) { - if ( typemb->text(i) == prev ) { - typemb->setCurrentItem(i); - break; - } + if ( typemb->text(i) == prev ) { + typemb->setCurrentItem(i); + break; + } } if ( prev.isNull() ) - typemb->setCurrentItem(typemb->count()-1); + typemb->setCurrentItem(typemb->count()-1); @@ -713,3 +739,3 @@ void LauncherView::updateTools() if ( !catmb ) - catmb = new CategorySelect(tools); + catmb = new CategorySelect(tools); Categories cats( 0 ); @@ -718,3 +744,3 @@ void LauncherView::updateTools() catmb->setCategories( vl, "Document View", // No tr - tr("Document View") ); + tr("Document View") ); catmb->setRemoveCategoryEdit( TRUE ); @@ -725,3 +751,3 @@ void LauncherView::updateTools() if ( typemb->currentText() != prev ) - showType( typemb->currentItem() ); + showType( typemb->currentItem() ); @@ -739,8 +765,8 @@ void LauncherView::showType(int t) if ( t >= (int)typelist.count() ) { - icons->setTypeFilter("",TRUE); + icons->setTypeFilter("",TRUE); } else { - QString ty = typelist[t]; - if ( !ty.contains('/') ) - ty += "/*"; - icons->setTypeFilter(ty,TRUE); + QString ty = typelist[t]; + if ( !ty.contains('/') ) + ty += "/*"; + icons->setTypeFilter(ty,TRUE); } @@ -756,16 +782,16 @@ void LauncherView::setViewMode( ViewMode m ) if ( vmode != m ) { - bool bigIcons = m == Icon; - icons->viewport()->setUpdatesEnabled( FALSE ); - icons->setBigIcons( bigIcons ); - switch ( m ) { - case List: - icons->setItemTextPos( QIconView::Right ); - break; - case Icon: - icons->setItemTextPos( QIconView::Bottom ); - break; - } - icons->hideOrShowItems( FALSE ); - icons->viewport()->setUpdatesEnabled( TRUE ); - vmode = m; + bool bigIcons = m == Icon; + icons->viewport()->setUpdatesEnabled( FALSE ); + icons->setBigIcons( bigIcons ); + switch ( m ) { + case List: + icons->setItemTextPos( QIconView::Right ); + break; + case Icon: + icons->setItemTextPos( QIconView::Bottom ); + break; + } + icons->hideOrShowItems( FALSE ); + icons->viewport()->setUpdatesEnabled( TRUE ); + vmode = m; } @@ -786,3 +812,3 @@ QImage LauncherView::loadBackgroundImage(QString &bgName) if (imgio.read() == FALSE) { - return imgio.image(); + return imgio.image(); } @@ -790,4 +816,4 @@ QImage LauncherView::loadBackgroundImage(QString &bgName) if (imgio.image().width() < ds.width() && - imgio.image().height() < ds.height()) { - further_scaling = FALSE; + imgio.image().height() < ds.height()) { + further_scaling = FALSE; } @@ -795,28 +821,28 @@ QImage LauncherView::loadBackgroundImage(QString &bgName) if (!imgio.image().bits()) { - // - // Scale and load. Note we don't scale up. - // - QString param( "Scale( %1, %2, ScaleMin )" ); // No tr - imgio.setParameters(further_scaling ? - param.arg(ds.width()).arg(ds.height()).latin1() : - ""); - imgio.read(); + // + // Scale and load. Note we don't scale up. + // + QString param( "Scale( %1, %2, ScaleMin )" ); // No tr + imgio.setParameters(further_scaling ? + param.arg(ds.width()).arg(ds.height()).latin1() : + ""); + imgio.read(); } else { - if (further_scaling) { - int t1 = imgio.image().width() * ds.height(); - int t2 = imgio.image().height() * ds.width(); - int dsth = ds.height(); - int dstw = ds.width(); - - if (t1 > t2) { - dsth = t2 / imgio.image().width(); - } else { - dstw = t1 / imgio.image().height(); - } - - // - // Loader didn't scale for us. Do it manually. - // - return imgio.image().smoothScale(dstw, dsth); - } + if (further_scaling) { + int t1 = imgio.image().width() * ds.height(); + int t2 = imgio.image().height() * ds.width(); + int dsth = ds.height(); + int dstw = ds.width(); + + if (t1 > t2) { + dsth = t2 / imgio.image().width(); + } else { + dstw = t1 / imgio.image().height(); + } + + // + // Loader didn't scale for us. Do it manually. + // + return imgio.image().smoothScale(dstw, dsth); + } } @@ -829,4 +855,4 @@ void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) if ( !bgCache ) { - bgCache = new QMap<QString,BgPixmap*>; - qAddPostRoutine( cleanup_cache ); + bgCache = new QMap<QString,BgPixmap*>; + qAddPostRoutine( cleanup_cache ); } @@ -834,3 +860,3 @@ void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) if ( bgCache->contains( bgName ) ) - (*bgCache)[bgName]->ref--; + (*bgCache)[bgName]->ref--; bgName = ""; @@ -840,51 +866,51 @@ void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) switch ( t ) { - case Ruled: { - bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr - if ( bgCache->contains( bgName ) ) { - (*bgCache)[bgName]->ref++; - bg = (*bgCache)[bgName]->pm; - } else { - bg.resize( width(), 9 ); - QPainter painter( &bg ); - for ( int i = 0; i < 3; i++ ) { - painter.setPen( white ); - painter.drawLine( 0, i*3, width()-1, i*3 ); - painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); - painter.setPen( colorGroup().background().light(105) ); - painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); - } - painter.end(); - bgCache->insert( bgName, new BgPixmap(bg) ); - } - break; - } - - case Image: - if (!val.isEmpty()) { - bgName = val; - if ( bgCache->contains( bgName ) ) { - (*bgCache)[bgName]->ref++; - bg = (*bgCache)[bgName]->pm; - } else { - QString imgFile = bgName; - bool tile = FALSE; - if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { - imgFile = Resource::findPixmap( imgFile ); - tile = TRUE; - } - QImage img = loadBackgroundImage(imgFile); - - - if ( img.depth() == 1 ) - img = img.convertDepth(8); - img.setAlphaBuffer(FALSE); - bg.convertFromImage(img); - bgCache->insert( bgName, new BgPixmap(bg) ); - } - } - break; - - case SolidColor: - default: - break; + case Ruled: { + bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr + if ( bgCache->contains( bgName ) ) { + (*bgCache)[bgName]->ref++; + bg = (*bgCache)[bgName]->pm; + } else { + bg.resize( width(), 9 ); + QPainter painter( &bg ); + for ( int i = 0; i < 3; i++ ) { + painter.setPen( white ); + painter.drawLine( 0, i*3, width()-1, i*3 ); + painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); + painter.setPen( colorGroup().background().light(105) ); + painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); + } + painter.end(); + bgCache->insert( bgName, new BgPixmap(bg) ); + } + break; + } + + case Image: + if (!val.isEmpty()) { + bgName = val; + if ( bgCache->contains( bgName ) ) { + (*bgCache)[bgName]->ref++; + bg = (*bgCache)[bgName]->pm; + } else { + QString imgFile = bgName; + bool tile = FALSE; + if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { + imgFile = Resource::findPixmap( imgFile ); + tile = TRUE; + } + QImage img = loadBackgroundImage(imgFile); + + + if ( img.depth() == 1 ) + img = img.convertDepth(8); + img.setAlphaBuffer(FALSE); + bg.convertFromImage(img); + bgCache->insert( bgName, new BgPixmap(bg) ); + } + } + break; + + case SolidColor: + default: + break; } @@ -894,16 +920,16 @@ void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { - if ( obj->isWidgetType() ) { - QWidget *w = (QWidget*)obj; - w->setBackgroundPixmap( bg ); - if ( bgName.isEmpty() ) { - // Solid Color - if ( val.isEmpty() ) - w->setBackgroundColor( colorGroup().base() ); - else - w->setBackgroundColor( val ); - } else { - // Ruled or Image pixmap - w->setBackgroundOrigin( ParentOrigin ); - } - } + if ( obj->isWidgetType() ) { + QWidget *w = (QWidget*)obj; + w->setBackgroundPixmap( bg ); + if ( bgName.isEmpty() ) { + // Solid Color + if ( val.isEmpty() ) + w->setBackgroundColor( colorGroup().base() ); + else + w->setBackgroundColor( val ); + } else { + // Ruled or Image pixmap + w->setBackgroundOrigin( ParentOrigin ); + } + } } @@ -940,3 +966,3 @@ void LauncherView::resizeEvent(QResizeEvent *e) { -// qDebug("LauncherView resize event"); +// qDebug("LauncherView resize event"); QVBox::resizeEvent( e ); @@ -944,3 +970,3 @@ void LauncherView::resizeEvent(QResizeEvent *e) // if ( e->size().width() != e->oldSize().width() ) - sort(); + sort(); } @@ -951,6 +977,6 @@ void LauncherView::selectionChanged() if ( item && item->isSelected() ) { - AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); - if ( icons->inKeyEvent() ) // not for mouse press - emit clicked( appLnk ); - item->setSelected(FALSE); + AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); + if ( icons->inKeyEvent() ) // not for mouse press + emit clicked( appLnk ); + item->setSelected(FALSE); } @@ -961,4 +987,4 @@ void LauncherView::returnPressed( QIconViewItem *item ) if ( item ) { - AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); - emit clicked( appLnk ); + AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); + emit clicked( appLnk ); } @@ -969,9 +995,9 @@ void LauncherView::itemClicked( int btn, QIconViewItem *item ) if ( item ) { - AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); - if ( btn == LeftButton ) { - // Make sure it's the item we execute that gets highlighted - icons->setCurrentItem( item ); - emit clicked( appLnk ); - } - item->setSelected(FALSE); + AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); + if ( btn == LeftButton ) { + // Make sure it's the item we execute that gets highlighted + icons->setCurrentItem( item ); + emit clicked( appLnk ); + } + item->setSelected(FALSE); } @@ -982,8 +1008,8 @@ void LauncherView::itemPressed( int btn, QIconViewItem *item ) if ( item ) { - AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); - if ( btn == RightButton ) - emit rightPressed( appLnk ); - else if ( btn == ShiftButton ) - emit rightPressed( appLnk ); - item->setSelected(FALSE); + AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); + if ( btn == RightButton ) + emit rightPressed( appLnk ); + else if ( btn == ShiftButton ) + emit rightPressed( appLnk ); + item->setSelected(FALSE); } @@ -1005,3 +1031,3 @@ void LauncherView::setSortEnabled( bool v ) if ( v ) - sort(); + sort(); } @@ -1028,3 +1054,3 @@ void LauncherView::paletteChange( const QPalette &p ) if ( bgType == Ruled ) - setBackgroundType( Ruled, QString::null ); + setBackgroundType( Ruled, QString::null ); QColorGroup cg = icons->colorGroup(); @@ -1048,3 +1074,3 @@ void LauncherView::flushBgCache() if ( !bgCache ) - return; + return; // remove unreferenced backgrounds. @@ -1052,8 +1078,8 @@ void LauncherView::flushBgCache() while ( it != bgCache->end() ) { - QMap<QString,BgPixmap*>::Iterator curr = it; - ++it; - if ( (*curr)->ref == 0 ) { - delete (*curr); - bgCache->remove( curr ); - } + QMap<QString,BgPixmap*>::Iterator curr = it; + ++it; + if ( (*curr)->ref == 0 ) { + delete (*curr); + bgCache->remove( curr ); + } } @@ -1061 +1087,67 @@ void LauncherView::flushBgCache() +/* special image handling - based on opie eye */ +QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { + s >> inf.file >> inf.pixmap >> inf.width >> inf.height; + return s; +} + +QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { + return s << inf.file << inf.width << inf.height; +} + +LauncherThumbReceiver::LauncherThumbReceiver(LauncherItem*parent) + :QObject() +{ + m_parent = parent; + QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); + connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), + this, SLOT(recieve(const QCString&,const QByteArray&)) ); + + { + QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); + } + m_waiting = false; +} + +LauncherThumbReceiver::~LauncherThumbReceiver() +{ + { + QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); + } +} + +void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) +{ + PixmapInfos pixinfos; + QDataStream stream( at, IO_ReadOnly ); + if (!m_parent || !m_waiting) return; + /* we are just interested in thumbmails */ + if ( str == "pixmapsHandled(PixmapList)" ) + stream >> pixinfos; + + for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { + if ((*it).file==m_reqFile) { + m_parent->setEyePixmap((*it).pixmap); + m_waiting = false; + break; + } + } +} + +void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) +{ + m_reqFile = file; + rItem.file = file; + rItem.width = width; + rItem.height = height; + QTimer::singleShot(1, this, SLOT(sendRequest())); +} + +void LauncherThumbReceiver::sendRequest() +{ + PixmapInfos m_inThumbNail; + m_inThumbNail.append(rItem); + QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); + env << m_inThumbNail; + m_waiting = true; +} diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index e40a006..a9ff9eb 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h @@ -29,2 +29,3 @@ class CategorySelect; class LauncherIconView; +class LauncherItem; class QIconView; @@ -39,4 +40,4 @@ class QComboBox; enum BusyIndicatorType { - BIT_Normal = 0, - BIT_Animated + BIT_Normal = 0, + BIT_Animated }; @@ -118,2 +119,37 @@ private: +/* taken from opie-eye */ + +struct PixmapInfo { + PixmapInfo() : width( -1 ), height( -1 ) {} + bool operator==( const PixmapInfo& r ) { + if ( width != r.width ) return false; + if ( height != r.height ) return false; + if ( file != r.file ) return false; + return true; + } + int width, height; + QString file; + QPixmap pixmap; +}; + +class LauncherThumbReceiver:public QObject +{ + Q_OBJECT + typedef QValueList<PixmapInfo> PixmapInfos; +public: + LauncherThumbReceiver(LauncherItem*parent); + ~LauncherThumbReceiver(); + void requestThumb(const QString&file,int width,int height); + +public slots: + void recieve( const QCString&, const QByteArray& ); +protected slots: + virtual void sendRequest(); +protected: + LauncherItem*m_parent; + QString m_reqFile; + PixmapInfo rItem; + bool m_waiting:1; +}; + #endif // LAUNCHERVIEW_H |