summaryrefslogtreecommitdiff
authoralwin <alwin>2004-11-08 02:27:03 (UTC)
committer alwin <alwin>2004-11-08 02:27:03 (UTC)
commit18875a0d90d0425c066e6fa2cda81a6140fe8606 (patch) (unidiff)
tree778844c7dd2acb9f387a3228b3d3bd9df647c1a7
parent9218d2bf841e1f999475c86ba602dc1cd7e338f6 (diff)
downloadopie-18875a0d90d0425c066e6fa2cda81a6140fe8606.zip
opie-18875a0d90d0425c066e6fa2cda81a6140fe8606.tar.gz
opie-18875a0d90d0425c066e6fa2cda81a6140fe8606.tar.bz2
first try getting small imagethumbs in document-tab.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp98
-rw-r--r--core/launcher/launcherview.h36
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>
30using namespace Opie::Core; 30using 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);
87protected: 91protected:
88 bool isBigIcon; 92 bool isBigIcon;
89 int iteration; 93 int iteration;
90 AppLnk* app; 94 AppLnk* app;
95
91private: 96private:
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
384LauncherItem::~LauncherItem() 402LauncherItem::~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
392int LauncherItem::compare ( QIconViewItem * i ) const 411int 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()
496void LauncherItem::resetIcon() 515void 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
521void 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 */
1089QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1090 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1091 return s;
1092}
1093
1094QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1095 return s << inf.file << inf.width << inf.height;
1096}
1097
1098LauncherThumbReceiver::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
1112LauncherThumbReceiver::~LauncherThumbReceiver()
1113{
1114 {
1115 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1116 }
1117}
1118
1119void 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
1137void 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
1146void 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
28class CategorySelect; 28class CategorySelect;
29class LauncherIconView; 29class LauncherIconView;
30class LauncherItem;
30class QIconView; 31class QIconView;
31class QIconViewItem; 32class QIconViewItem;
32class QLabel; 33class QLabel;
@@ -116,4 +117,39 @@ private:
116 117
117}; 118};
118 119
120/* taken from opie-eye */
121
122struct 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
135class LauncherThumbReceiver:public QObject
136{
137 Q_OBJECT
138 typedef QValueList<PixmapInfo> PixmapInfos;
139public:
140 LauncherThumbReceiver(LauncherItem*parent);
141 ~LauncherThumbReceiver();
142 void requestThumb(const QString&file,int width,int height);
143
144public slots:
145 void recieve( const QCString&, const QByteArray& );
146protected slots:
147 virtual void sendRequest();
148protected:
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