author | alwin <alwin> | 2004-11-08 02:27:03 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-08 02:27:03 (UTC) |
commit | 18875a0d90d0425c066e6fa2cda81a6140fe8606 (patch) (unidiff) | |
tree | 778844c7dd2acb9f387a3228b3d3bd9df647c1a7 | |
parent | 9218d2bf841e1f999475c86ba602dc1cd7e338f6 (diff) | |
download | opie-18875a0d90d0425c066e6fa2cda81a6140fe8606.zip opie-18875a0d90d0425c066e6fa2cda81a6140fe8606.tar.gz opie-18875a0d90d0425c066e6fa2cda81a6140fe8606.tar.bz2 |
first try getting small imagethumbs in document-tab.
-rw-r--r-- | core/launcher/launcherview.cpp | 98 | ||||
-rw-r--r-- | core/launcher/launcherview.h | 36 |
2 files changed, 131 insertions, 3 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 | |||
@@ -29,6 +29,8 @@ | |||
29 | #include <qtopia/resource.h> | 29 | #include <qtopia/resource.h> |
30 | using namespace Opie::Core; | 30 | using namespace Opie::Core; |
31 | 31 | ||
32 | #include <qpe/qcopenvelope_qws.h> | ||
33 | |||
32 | /* QT */ | 34 | /* QT */ |
33 | #include <qtimer.h> | 35 | #include <qtimer.h> |
34 | #include <qfileinfo.h> | 36 | #include <qfileinfo.h> |
@@ -79,18 +81,25 @@ public: | |||
79 | 81 | ||
80 | void animateIcon(); | 82 | void animateIcon(); |
81 | void resetIcon(); | 83 | void resetIcon(); |
84 | bool isEyeImage()const{return m_EyeImage;} | ||
82 | 85 | ||
83 | virtual int compare ( QIconViewItem * i ) const; | 86 | virtual int compare ( QIconViewItem * i ) const; |
84 | void paintItem( QPainter *p, const QColorGroup &cg ); | 87 | void paintItem( QPainter *p, const QColorGroup &cg ); |
85 | 88 | ||
86 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | 89 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } |
90 | void setEyePixmap(const QPixmap&aIcon); | ||
87 | protected: | 91 | protected: |
88 | bool isBigIcon; | 92 | bool isBigIcon; |
89 | int iteration; | 93 | int iteration; |
90 | AppLnk* app; | 94 | AppLnk* app; |
95 | |||
91 | private: | 96 | private: |
92 | void paintAnimatedIcon( QPainter *p ); | 97 | void paintAnimatedIcon( QPainter *p ); |
93 | BusyIndicatorType busyType; | 98 | BusyIndicatorType busyType; |
99 | int psize; | ||
100 | QPixmap m_iPixmap; | ||
101 | bool m_EyeImage; | ||
102 | LauncherThumbReceiver*m_EyeCallback; | ||
94 | }; | 103 | }; |
95 | 104 | ||
96 | 105 | ||
@@ -377,8 +386,17 @@ LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) | |||
377 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), | 386 | bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), |
378 | isBigIcon( bigIcon ), | 387 | isBigIcon( bigIcon ), |
379 | iteration(0), | 388 | iteration(0), |
380 | app(applnk) // Takes ownership | 389 | app(applnk), // Takes ownership |
390 | psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), | ||
391 | m_iPixmap(), | ||
392 | m_EyeImage(false) | ||
381 | { | 393 | { |
394 | m_EyeCallback = new LauncherThumbReceiver(this); | ||
395 | if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { | ||
396 | m_EyeImage = true; | ||
397 | m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); | ||
398 | m_EyeCallback->requestThumb(applnk->file(),m_iPixmap.width(),m_iPixmap.height()); | ||
399 | } | ||
382 | } | 400 | } |
383 | 401 | ||
384 | LauncherItem::~LauncherItem() | 402 | LauncherItem::~LauncherItem() |
@@ -387,6 +405,7 @@ LauncherItem::~LauncherItem() | |||
387 | if ( liv->busyItem() == this ) | 405 | if ( liv->busyItem() == this ) |
388 | liv->setBusy(FALSE); | 406 | liv->setBusy(FALSE); |
389 | delete app; | 407 | delete app; |
408 | if (m_EyeCallback) delete m_EyeCallback; | ||
390 | } | 409 | } |
391 | 410 | ||
392 | int LauncherItem::compare ( QIconViewItem * i ) const | 411 | int LauncherItem::compare ( QIconViewItem * i ) const |
@@ -460,7 +479,7 @@ void LauncherItem::animateIcon() | |||
460 | 479 | ||
461 | // Highlight the icon | 480 | // Highlight the icon |
462 | if ( iteration == 0 ) { | 481 | if ( iteration == 0 ) { |
463 | QPixmap src = isBigIcon ? app->bigPixmap() : app->pixmap(); | 482 | QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())); |
464 | QImage img = src.convertToImage(); | 483 | QImage img = src.convertToImage(); |
465 | QRgb *rgb; | 484 | QRgb *rgb; |
466 | int count; | 485 | int count; |
@@ -496,7 +515,14 @@ void LauncherItem::animateIcon() | |||
496 | void LauncherItem::resetIcon() | 515 | void LauncherItem::resetIcon() |
497 | { | 516 | { |
498 | iteration = 0; | 517 | iteration = 0; |
499 | setPixmap( isBigIcon ? app->bigPixmap() : app->pixmap() ); | 518 | setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); |
519 | } | ||
520 | |||
521 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) | ||
522 | { | ||
523 | if (!isEyeImage()) return; | ||
524 | m_iPixmap = aIcon; | ||
525 | setPixmap(aIcon); | ||
500 | } | 526 | } |
501 | 527 | ||
502 | //=========================================================================== | 528 | //=========================================================================== |
@@ -1059,3 +1085,69 @@ void LauncherView::flushBgCache() | |||
1059 | } | 1085 | } |
1060 | } | 1086 | } |
1061 | 1087 | ||
1088 | /* special image handling - based on opie eye */ | ||
1089 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | ||
1090 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; | ||
1091 | return s; | ||
1092 | } | ||
1093 | |||
1094 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | ||
1095 | return s << inf.file << inf.width << inf.height; | ||
1096 | } | ||
1097 | |||
1098 | LauncherThumbReceiver::LauncherThumbReceiver(LauncherItem*parent) | ||
1099 | :QObject() | ||
1100 | { | ||
1101 | m_parent = parent; | ||
1102 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); | ||
1103 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), | ||
1104 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); | ||
1105 | |||
1106 | { | ||
1107 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | ||
1108 | } | ||
1109 | m_waiting = false; | ||
1110 | } | ||
1111 | |||
1112 | LauncherThumbReceiver::~LauncherThumbReceiver() | ||
1113 | { | ||
1114 | { | ||
1115 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | ||
1116 | } | ||
1117 | } | ||
1118 | |||
1119 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) | ||
1120 | { | ||
1121 | PixmapInfos pixinfos; | ||
1122 | QDataStream stream( at, IO_ReadOnly ); | ||
1123 | if (!m_parent || !m_waiting) return; | ||
1124 | /* we are just interested in thumbmails */ | ||
1125 | if ( str == "pixmapsHandled(PixmapList)" ) | ||
1126 | stream >> pixinfos; | ||
1127 | |||
1128 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { | ||
1129 | if ((*it).file==m_reqFile) { | ||
1130 | m_parent->setEyePixmap((*it).pixmap); | ||
1131 | m_waiting = false; | ||
1132 | break; | ||
1133 | } | ||
1134 | } | ||
1135 | } | ||
1136 | |||
1137 | void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) | ||
1138 | { | ||
1139 | m_reqFile = file; | ||
1140 | rItem.file = file; | ||
1141 | rItem.width = width; | ||
1142 | rItem.height = height; | ||
1143 | QTimer::singleShot(1, this, SLOT(sendRequest())); | ||
1144 | } | ||
1145 | |||
1146 | void LauncherThumbReceiver::sendRequest() | ||
1147 | { | ||
1148 | PixmapInfos m_inThumbNail; | ||
1149 | m_inThumbNail.append(rItem); | ||
1150 | QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); | ||
1151 | env << m_inThumbNail; | ||
1152 | m_waiting = true; | ||
1153 | } | ||
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 | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | class CategorySelect; | 28 | class CategorySelect; |
29 | class LauncherIconView; | 29 | class LauncherIconView; |
30 | class LauncherItem; | ||
30 | class QIconView; | 31 | class QIconView; |
31 | class QIconViewItem; | 32 | class QIconViewItem; |
32 | class QLabel; | 33 | class QLabel; |
@@ -116,4 +117,39 @@ private: | |||
116 | 117 | ||
117 | }; | 118 | }; |
118 | 119 | ||
120 | /* taken from opie-eye */ | ||
121 | |||
122 | struct PixmapInfo { | ||
123 | PixmapInfo() : width( -1 ), height( -1 ) {} | ||
124 | bool operator==( const PixmapInfo& r ) { | ||
125 | if ( width != r.width ) return false; | ||
126 | if ( height != r.height ) return false; | ||
127 | if ( file != r.file ) return false; | ||
128 | return true; | ||
129 | } | ||
130 | int width, height; | ||
131 | QString file; | ||
132 | QPixmap pixmap; | ||
133 | }; | ||
134 | |||
135 | class LauncherThumbReceiver:public QObject | ||
136 | { | ||
137 | Q_OBJECT | ||
138 | typedef QValueList<PixmapInfo> PixmapInfos; | ||
139 | public: | ||
140 | LauncherThumbReceiver(LauncherItem*parent); | ||
141 | ~LauncherThumbReceiver(); | ||
142 | void requestThumb(const QString&file,int width,int height); | ||
143 | |||
144 | public slots: | ||
145 | void recieve( const QCString&, const QByteArray& ); | ||
146 | protected slots: | ||
147 | virtual void sendRequest(); | ||
148 | protected: | ||
149 | LauncherItem*m_parent; | ||
150 | QString m_reqFile; | ||
151 | PixmapInfo rItem; | ||
152 | bool m_waiting:1; | ||
153 | }; | ||
154 | |||
119 | #endif // LAUNCHERVIEW_H | 155 | #endif // LAUNCHERVIEW_H |