author | alwin <alwin> | 2004-11-08 15:22:07 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-08 15:22:07 (UTC) |
commit | cce0a7a0d315993645870e88591b4afd647480a7 (patch) (side-by-side diff) | |
tree | beb8886020fe12a0f77bbb22bf0da76d4a73a3d5 | |
parent | 40bbaace5492ce6420a2d4a353b24df64c142287 (diff) | |
download | opie-cce0a7a0d315993645870e88591b4afd647480a7.zip opie-cce0a7a0d315993645870e88591b4afd647480a7.tar.gz opie-cce0a7a0d315993645870e88591b4afd647480a7.tar.bz2 |
image preview for documenttab again, I think, for first shot it is
working fine now.
-rw-r--r-- | core/launcher/launcherview.cpp | 91 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 5 |
2 files changed, 64 insertions, 32 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 673e53c..506c11e 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp @@ -74,4 +74,10 @@ class LauncherItem : public QIconViewItem { public: + enum iconstate_t { + BASE_ICON, + WAITING_ICON, + EYE_ICON + }; + LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); ~LauncherItem(); @@ -89,4 +95,6 @@ public: void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } void setEyePixmap(const QPixmap&aIcon); + virtual QPixmap*pixmap()const; + protected: bool isBigIcon; @@ -100,21 +108,7 @@ private: QPixmap m_iPixmap; bool m_EyeImage; + iconstate_t m_EyeImageSet; }; - -bool LauncherView::bsy=FALSE; - -void LauncherView::setBusy(bool on) -{ - icons->setBusy(on); -} - -void LauncherView::setBusyIndicatorType( const QString& type ) { - if ( type. lower ( ) == "animated" ) - icons->setBusyIndicatorType( BIT_Animated ) ; - else - icons->setBusyIndicatorType( BIT_Normal ) ; -} - LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) : QIconViewItem( parent, applnk->name(), @@ -125,5 +119,6 @@ LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), m_iPixmap(), - m_EyeImage(false) + m_EyeImage(false), + m_EyeImageSet(BASE_ICON) { if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { @@ -141,4 +136,13 @@ LauncherItem::~LauncherItem() } +QPixmap*LauncherItem::pixmap()const +{ + if (m_EyeImage && m_EyeImageSet == BASE_ICON) { + LauncherIconView* liv = (LauncherIconView*)iconView(); + liv->requestEyePix(this); + } + return QIconViewItem::pixmap(); +} + int LauncherItem::compare ( QIconViewItem * i ) const { @@ -153,6 +157,6 @@ void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) QColorGroup mycg( 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 ) ); } @@ -161,12 +165,10 @@ void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) // Paint animation overlay if ( liv->busyItem() == this ) - paintAnimatedIcon(p); + paintAnimatedIcon(p); if ( liv->currentItem() == this ) - liv->setItemTextBackground( oldBrush ); + liv->setItemTextBackground( oldBrush ); } - - void LauncherItem::paintAnimatedIcon( QPainter *p ) { @@ -256,4 +258,5 @@ void LauncherItem::setEyePixmap(const QPixmap&aIcon) m_iPixmap = aIcon; setPixmap(aIcon); + m_EyeImageSet = EYE_ICON; } @@ -422,9 +425,10 @@ LauncherItem*LauncherIconView::findDocItem(const QString&fname) } -void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile) +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; - item->setEyePixmap(aPixmap); } @@ -436,6 +440,6 @@ void LauncherIconView::checkCallback() } m_EyeCallBack = new LauncherThumbReceiver(); - connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&)), - this,SLOT(setEyePixmap(const QPixmap&,const QString&))); + connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), + this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); } @@ -445,6 +449,14 @@ void LauncherIconView::addCheckItem(AppLnk* app) if (item->isEyeImage()) { checkCallback(); + } +} + +void LauncherIconView::requestEyePix(const LauncherItem*item) +{ + if (!item) return; + if (item->isEyeImage()) { + checkCallback(); int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); - m_EyeCallBack->requestThumb(app->file(),s,s); + m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); } } @@ -634,4 +646,19 @@ LauncherView::~LauncherView() } + +bool LauncherView::bsy=FALSE; + +void LauncherView::setBusy(bool on) +{ + icons->setBusy(on); +} + +void LauncherView::setBusyIndicatorType( const QString& type ) { + if ( type. lower ( ) == "animated" ) + icons->setBusyIndicatorType( BIT_Animated ) ; + else + icons->setBusyIndicatorType( BIT_Normal ) ; +} + void LauncherView::hideIcons() { @@ -1054,4 +1081,8 @@ void LauncherView::flushBgCache() } +/* + * Launcherthumbnail handling for image files + */ + /* special image handling - based on opie eye */ QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { @@ -1094,5 +1125,5 @@ void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { odebug << "Pixinfos: " << (*it).file << " - " << (*it).width << oendl; - emit sig_Thumbnail((*it).pixmap,(*it).file); + emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); } } @@ -1105,5 +1136,5 @@ void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height rItem.height = height; m_inThumbNail.append(rItem); - QTimer::singleShot(2, this, SLOT(sendRequest())); + QTimer::singleShot(0, this, SLOT(sendRequest())); } @@ -1113,5 +1144,5 @@ void LauncherThumbReceiver::sendRequest() QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); env << m_inThumbNail; + m_inThumbNail.clear(); } - m_inThumbNail.clear(); } diff --git a/core/launcher/launcherview.h b/core/launcher/launcherview.h index 3cca7f7..0be9a1f 100644 --- a/core/launcher/launcherview.h +++ b/core/launcher/launcherview.h @@ -147,5 +147,5 @@ protected slots: signals: - void sig_Thumbnail(const QPixmap&,const QString&); + void sig_Thumbnail(const QPixmap&,const QString&,int); protected: @@ -217,4 +217,5 @@ public: void setSortMethod( SortMethod m ); int compare(const AppLnk* a, const AppLnk* b); + void requestEyePix(const LauncherItem*which); protected: @@ -229,5 +230,5 @@ protected: protected slots: - void setEyePixmap(const QPixmap&,const QString&); + void setEyePixmap(const QPixmap&,const QString&,int width); private: |