-rw-r--r-- | core/launcher/launcherview.cpp | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 5daaeff..33717bc 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp @@ -52,205 +52,212 @@ public: int ref; }; static QMap<QString,BgPixmap*> *bgCache = 0; class LauncherIconView : public QIconView { public: LauncherIconView( QWidget* parent, const char* name=0 ) : QIconView(parent,name), tf(""), cf(0), bsy(0), bigIcns(TRUE), bgColor(white) { sortmeth = Name; hidden.setAutoDelete(TRUE); ike = FALSE; busytimer = 0; calculateGrid( Bottom ); } ~LauncherIconView() { #if 0 // debuggery QListIterator<AppLnk> it(hidden); AppLnk* l; while ((l=it.current())) { ++it; //qDebug("%p: hidden (should remove)",l); } #endif } QPixmap* busyPixmap() const { return (QPixmap*)&bpm[::abs(busystate)]; } QIconViewItem* busyItem() const { return bsy; } void setBigIcons( bool bi ) { bigIcns = bi; } void updateCategoriesAndMimeTypes(); void doAutoScroll() { // We don't want rubberbanding (yet) } void setBusy(bool on) { QIconViewItem *c = on ? currentItem() : 0; + qDebug ( "set busy %d -> %s", on, c ? c-> text ().latin1() : "(null)" ); + if ( bsy != c ) { - if ( bsy ) - bsy-> repaint ( ); + QIconViewItem *oldbsy = bsy; bsy = c; - if ( bsy ) { - busystate = 5; - for ( int i = 0; i <= 5; i++ ) - bpm [i] = QPixmap ( ); - timerEvent ( 0 ); - busytimer = startTimer ( 150 ); - } - else - killTimer ( busytimer ); - } - } + if ( oldbsy ) + oldbsy-> repaint ( ); - virtual void timerEvent ( QTimerEvent *te ) - { - if ( !te || ( te-> timerId ( ) == busytimer )) { if ( bsy ) { - if ( bpm [::abs(busystate)]. isNull ( )) { QPixmap *src = bsy-> QIconViewItem::pixmap(); + for ( int i = 0; i <= 5; i++ ) { 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(); } int rc, gc, bc; - int bs = ::abs ( busystate * 10 ) + 25; + int bs = ::abs ( i * 10 ) + 25; colorGroup().highlight().rgb( &rc, &gc, &bc ); rc = rc * bs / 100; gc = gc * bs / 100; bc = bc * bs / 100; for ( int r = 0; r < count; r++, rgb++ ) { int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100; int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100; int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100; int ai = qAlpha ( *rgb ); *rgb = qRgba ( ri, gi, bi, ai ); } - bpm [::abs(busystate)].convertFromImage( img ); + bpm [i].convertFromImage( img ); + } + busystate = 0; + if ( busytimer ) + killTimer ( busytimer ); + timerEvent ( 0 ); + busytimer = startTimer ( 180 ); + } + else { + killTimer ( busytimer ); + busytimer = 0; + } + } } - bsy-> repaint ( ); + virtual void timerEvent ( QTimerEvent *te ) + { + if ( !te || ( te-> timerId ( ) == busytimer )) { + if ( bsy ) { busystate++; if ( busystate > 5 ) busystate = -4; + + bsy-> repaint ( ); } } } bool inKeyEvent() const { return ike; } void keyPressEvent(QKeyEvent* e) { ike = TRUE; if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) returnPressed(currentItem()); QIconView::keyPressEvent(e); ike = FALSE; } void addItem(AppLnk* app, bool resort=TRUE); bool removeLink(const QString& linkfile); QStringList mimeTypes() const; QStringList categories() const; void clear() { mimes.clear(); cats.clear(); QIconView::clear(); hidden.clear(); } void addCatsAndMimes(AppLnk* app) { // 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); } } void setBackgroundPixmap( const QPixmap &pm ) { bgPixmap = pm; } void setBackgroundColor( const QColor &c ) { bgColor = c; } void drawBackground( QPainter *p, const QRect &r ) { if ( !bgPixmap.isNull() ) { + p-> fillRect ( r, bgColor ); p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(), (r.y() + contentsY()) % bgPixmap.height() ) ); } else { p->fillRect( r, bgColor ); } } void setItemTextPos( ItemTextPos pos ) { calculateGrid( pos ); QIconView::setItemTextPos( pos ); } void hideOrShowItems(bool resort); void setTypeFilter(const QString& typefilter, bool resort) { tf = QRegExp(typefilter,FALSE,TRUE); hideOrShowItems(resort); } void setCategoryFilter( int catfilter, bool resort ) { Categories cat; cat.load( categoryFileName() ); QString str; if ( catfilter == -2 ) cf = 0; else cf = catfilter; hideOrShowItems(resort); } enum SortMethod { Name, Date, Type }; void setSortMethod( SortMethod m ) { if ( sortmeth != m ) { sortmeth = m; sort(); } } int compare(const AppLnk* a, const AppLnk* b) { switch (sortmeth) { case Name: |