-rw-r--r-- | core/launcher/launcherview.cpp | 34 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 4 |
2 files changed, 31 insertions, 7 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index a4c7561..d960908 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp @@ -98,63 +98,65 @@ public: void setEyePixmap(const QPixmap&aIcon); virtual QPixmap*pixmap()const; protected: bool isBigIcon; int iteration; AppLnk* app; private: void paintAnimatedIcon( QPainter *p ); BusyIndicatorType busyType; int psize; bool m_EyeImage; iconstate_t m_EyeImageSet; }; +static bool s_IgnoreNextPix = false; + LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) : QIconViewItem( parent, applnk->name(), bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), isBigIcon( bigIcon ), iteration(0), app(applnk), // Takes ownership psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), m_EyeImage(false), m_EyeImageSet(BASE_ICON) { if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { m_EyeImage = true; QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(applnk->file()); if (it != LauncherIconView::sm_EyeCache->end()) { m_EyeImageSet = EYE_ICON; setPixmap(*it); } } } LauncherItem::~LauncherItem() { LauncherIconView* liv = (LauncherIconView*)iconView(); if ( liv->busyItem() == this ) liv->setBusy(FALSE); delete app; } QPixmap*LauncherItem::pixmap()const { - if (m_EyeImage && m_EyeImageSet == BASE_ICON) { + if (m_EyeImage && m_EyeImageSet == BASE_ICON && s_IgnoreNextPix==false) { LauncherIconView* liv = (LauncherIconView*)iconView(); liv->requestEyePix(this); } return QIconViewItem::pixmap(); } int LauncherItem::compare ( QIconViewItem * i ) const { LauncherIconView* view = (LauncherIconView*)iconView(); return view->compare(app,((LauncherItem *)i)->appLnk()); } void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) { LauncherIconView* liv = (LauncherIconView*)iconView(); QBrush oldBrush( liv->itemTextBackground() ); @@ -281,62 +283,76 @@ void LauncherItem::setEyePixmap(const QPixmap&aIcon) //=========================================================================== QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white),numColumns(0) { m_EyeCallBack = 0; if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); sortmeth = Name; hidden.setAutoDelete(TRUE); ike = FALSE; calculateGrid( Bottom ); connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); Config config( "Launcher" ); config.setGroup( "GUI" ); - setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) ); + setStaticBackgroundPicture( config.readBoolEntry( "StaticBackground", true ) ); } LauncherIconView::~LauncherIconView() { odebug << "LauncherIconView::~LauncherIconView()" << oendl; #if 0 // debuggery QListIterator<AppLnk> it(hidden); AppLnk* l; while ((l=it.current())) { ++it; //odebug << "" << l << ": hidden (should remove)" << oendl; } #endif } +void LauncherIconView::unsetPalette() +{ + s_IgnoreNextPix = true; + QIconView::unsetPalette(); + s_IgnoreNextPix = false; +} + +void LauncherIconView::setPalette(const QPalette & palette) +{ + s_IgnoreNextPix = true; + QIconView::setPalette(palette); + s_IgnoreNextPix = false; +} + void LauncherIconView::setStaticBackgroundPicture( bool enable ) { staticBackground = enable; if ( staticBackground ) { setStaticBackground( true ); verticalScrollBar()->setTracking( false ); } else { setStaticBackground( false ); verticalScrollBar()->setTracking( true ); - } -} + } +} int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) { 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; } @@ -473,34 +489,34 @@ LauncherItem*LauncherIconView::findDocItem(const QString&fname) void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) { int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); if (s!=width) return; LauncherItem*item = findDocItem(aFile); if (!item||!item->isEyeImage()) return; (*sm_EyeCache)[aFile]=aPixmap; item->setEyePixmap(aPixmap); } void LauncherIconView::checkCallback() { if (!m_EyeCallBack) { m_EyeCallBack = new LauncherThumbReceiver(); connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); + m_eyeTimer.changeInterval(600000); } - m_eyeTimer.changeInterval(600000); } void LauncherIconView::addCheckItem(AppLnk* app) { LauncherItem*item = new LauncherItem( this, app, bigIcns ); if (item->isEyeImage()) { checkCallback(); } } void LauncherIconView::requestEyePix(const LauncherItem*item) { if (!item) return; if (item->isEyeImage()) { checkCallback(); int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); @@ -1195,34 +1211,36 @@ void LauncherView::flushBgCache() /* * Launcherthumbnail handling for image files */ /* 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() - :QObject() + :QObject(),requestTimer(this) { + + connect(&requestTimer,SIGNAL(timeout()),SLOT(sendRequest())); 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()" ); } } LauncherThumbReceiver::~LauncherThumbReceiver() { { QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); } } @@ -1234,27 +1252,29 @@ void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) /* we are just interested in thumbmails */ if ( str == "pixmapsHandled(PixmapList)" ) stream >> pixinfos; for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); } } void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) { PixmapInfo rItem; rItem.file = file; rItem.width = width; rItem.height = height; m_inThumbNail.append(rItem); - QTimer::singleShot(2, this, SLOT(sendRequest())); + if (!requestTimer.isActive()) { + requestTimer.start(100,true); + } } void LauncherThumbReceiver::sendRequest() { if (m_inThumbNail.count()>0) { QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); env << m_inThumbNail; m_inThumbNail.clear(); } } diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 6a2d197..792c6d1 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h @@ -140,32 +140,33 @@ class LauncherThumbReceiver:public QObject Q_OBJECT typedef QValueList<PixmapInfo> PixmapInfos; public: LauncherThumbReceiver(); ~LauncherThumbReceiver(); void requestThumb(const QString&file,int width,int height); public slots: void recieve( const QCString&, const QByteArray& ); protected slots: virtual void sendRequest(); signals: void sig_Thumbnail(const QPixmap&,const QString&,int); protected: + QTimer requestTimer; PixmapInfos m_inThumbNail; }; class LauncherIconView : public QIconView { Q_OBJECT public: LauncherIconView( QWidget* parent, const char* name=0 ); ~LauncherIconView(); QIconViewItem* busyItem() const; #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY QPixmap busyPixmap() const { return busyPix; } #endif void setBigIcons( bool bi ); void updateCategoriesAndMimeTypes(); void setBusyIndicatorType ( BusyIndicatorType t ); @@ -201,32 +202,35 @@ public: void drawBackground( QPainter *p, const QRect &r ); void setItemTextPos( ItemTextPos pos ); void hideOrShowItems(bool resort); void setTypeFilter(const QString& typefilter, bool resort); void setCategoryFilter( int catfilter, bool resort ); enum SortMethod { Name, Date, Type }; void setSortMethod( SortMethod m ); int compare(const AppLnk* a, const AppLnk* b); void requestEyePix(const LauncherItem*which); static QMap<QString,QPixmap>* sm_EyeCache; + virtual void setPalette(const QPalette & palette); + virtual void unsetPalette(); + protected: virtual void timerEvent( QTimerEvent *te ); void styleChange( QStyle &old ); void calculateGrid( ItemTextPos pos ); void focusInEvent( QFocusEvent * ) {} void focusOutEvent( QFocusEvent * ) {} LauncherItem*findDocItem(const QString&); void addCheckItem(AppLnk* app); void checkCallback(); virtual void keyPressEvent(QKeyEvent* e); protected slots: void setEyePixmap(const QPixmap&,const QString&,int width); void stopEyeTimer(); private: |