summaryrefslogtreecommitdiff
path: root/core/launcher
Unidiff
Diffstat (limited to 'core/launcher') (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
@@ -20,24 +20,26 @@
20 20
21#include "launcherview.h" 21#include "launcherview.h"
22 22
23/* OPIE */ 23/* OPIE */
24#include <opie2/odebug.h> 24#include <opie2/odebug.h>
25#include <qtopia/qpeapplication.h> 25#include <qtopia/qpeapplication.h>
26#include <qtopia/private/categories.h> 26#include <qtopia/private/categories.h>
27#include <qtopia/categoryselect.h> 27#include <qtopia/categoryselect.h>
28#include <qtopia/mimetype.h> 28#include <qtopia/mimetype.h>
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>
35#include <qiconview.h> 37#include <qiconview.h>
36#include <qobjectlist.h> 38#include <qobjectlist.h>
37 39
38 40
39// These define how the busy icon is animated and highlighted 41// These define how the busy icon is animated and highlighted
40#define BRIGHTEN_BUSY_ICON 42#define BRIGHTEN_BUSY_ICON
41//#define ALPHA_FADE_BUSY_ICON 43//#define ALPHA_FADE_BUSY_ICON
42//#define USE_ANIMATED_BUSY_ICON_OVERLAY 44//#define USE_ANIMATED_BUSY_ICON_OVERLAY
43#define BOUNCE_BUSY_ICON 45#define BOUNCE_BUSY_ICON
@@ -70,36 +72,43 @@ static void cleanup_cache()
70 72
71class LauncherItem : public QIconViewItem 73class LauncherItem : public QIconViewItem
72{ 74{
73public: 75public:
74 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 76 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
75 ~LauncherItem(); 77 ~LauncherItem();
76 78
77 AppLnk *appLnk() const { return app; } 79 AppLnk *appLnk() const { return app; }
78 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } 80 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; }
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
97class LauncherIconView : public QIconView { 106class LauncherIconView : public QIconView {
98public: 107public:
99 LauncherIconView( QWidget* parent, const char* name=0 ) : 108 LauncherIconView( QWidget* parent, const char* name=0 ) :
100 QIconView(parent,name), 109 QIconView(parent,name),
101 tf(""), 110 tf(""),
102 cf(0), 111 cf(0),
103 bsy(0), 112 bsy(0),
104 busyTimer(0), 113 busyTimer(0),
105 bigIcns(TRUE), 114 bigIcns(TRUE),
@@ -368,34 +377,44 @@ void LauncherView::setBusy(bool on)
368void LauncherView::setBusyIndicatorType( const QString& type ) { 377void LauncherView::setBusyIndicatorType( const QString& type ) {
369 if ( type. lower ( ) == "animated" ) 378 if ( type. lower ( ) == "animated" )
370 icons->setBusyIndicatorType( BIT_Animated ) ; 379 icons->setBusyIndicatorType( BIT_Animated ) ;
371 else 380 else
372 icons->setBusyIndicatorType( BIT_Normal ) ; 381 icons->setBusyIndicatorType( BIT_Normal ) ;
373} 382}
374 383
375LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 384LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
376 : QIconViewItem( parent, applnk->name(), 385 : QIconViewItem( parent, applnk->name(),
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()
385{ 403{
386 LauncherIconView* liv = (LauncherIconView*)iconView(); 404 LauncherIconView* liv = (LauncherIconView*)iconView();
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
393{ 412{
394 LauncherIconView* view = (LauncherIconView*)iconView(); 413 LauncherIconView* view = (LauncherIconView*)iconView();
395 return view->compare(app,((LauncherItem *)i)->appLnk()); 414 return view->compare(app,((LauncherItem *)i)->appLnk());
396} 415}
397 416
398void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 417void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
399{ 418{
400 LauncherIconView* liv = (LauncherIconView*)iconView(); 419 LauncherIconView* liv = (LauncherIconView*)iconView();
401 QBrush oldBrush( liv->itemTextBackground() ); 420 QBrush oldBrush( liv->itemTextBackground() );
@@ -451,25 +470,25 @@ void LauncherItem::paintAnimatedIcon( QPainter *p )
451 p->drawPixmap( x1, y1, dblBuf ); 470 p->drawPixmap( x1, y1, dblBuf );
452} 471}
453 472
454void LauncherItem::animateIcon() 473void LauncherItem::animateIcon()
455{ 474{
456 LauncherIconView* liv = (LauncherIconView*)iconView(); 475 LauncherIconView* liv = (LauncherIconView*)iconView();
457 476
458 if ( liv->busyItem() != this || !app ) 477 if ( liv->busyItem() != this || !app )
459 return; 478 return;
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;
467 if ( img.depth() == 32 ) { 486 if ( img.depth() == 32 ) {
468 rgb = (QRgb*)img.bits(); 487 rgb = (QRgb*)img.bits();
469 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 488 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
470 } else { 489 } else {
471 rgb = img.colorTable(); 490 rgb = img.colorTable();
472 count = img.numColors(); 491 count = img.numColors();
473 } 492 }
474 for ( int r = 0; r < count; r++, rgb++ ) { 493 for ( int r = 0; r < count; r++, rgb++ ) {
475#if defined(BRIGHTEN_BUSY_ICON) 494#if defined(BRIGHTEN_BUSY_ICON)
@@ -487,25 +506,32 @@ void LauncherItem::animateIcon()
487 } 506 }
488 507
489 iteration++; 508 iteration++;
490 509
491 // Paint animation overlay 510 // Paint animation overlay
492 QPainter p( liv->viewport() ); 511 QPainter p( liv->viewport() );
493 paintAnimatedIcon( &p ); 512 paintAnimatedIcon( &p );
494} 513}
495 514
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//===========================================================================
503 529
504QStringList LauncherIconView::mimeTypes() const 530QStringList LauncherIconView::mimeTypes() const
505{ 531{
506 QStringList r; 532 QStringList r;
507 QDictIterator<void> it(mimes); 533 QDictIterator<void> it(mimes);
508 while (it.current()) { 534 while (it.current()) {
509 r.append(it.currentKey()); 535 r.append(it.currentKey());
510 ++it; 536 ++it;
511 } 537 }
@@ -1050,12 +1076,78 @@ void LauncherView::flushBgCache()
1050 // remove unreferenced backgrounds. 1076 // remove unreferenced backgrounds.
1051 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 1077 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
1052 while ( it != bgCache->end() ) { 1078 while ( it != bgCache->end() ) {
1053 QMap<QString,BgPixmap*>::Iterator curr = it; 1079 QMap<QString,BgPixmap*>::Iterator curr = it;
1054 ++it; 1080 ++it;
1055 if ( (*curr)->ref == 0 ) { 1081 if ( (*curr)->ref == 0 ) {
1056 delete (*curr); 1082 delete (*curr);
1057 bgCache->remove( curr ); 1083 bgCache->remove( curr );
1058 } 1084 }
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
@@ -18,24 +18,25 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef LAUNCHERVIEW_H 20#ifndef LAUNCHERVIEW_H
21#define LAUNCHERVIEW_H 21#define LAUNCHERVIEW_H
22 22
23#include <qtopia/storage.h> 23#include <qtopia/storage.h>
24#include <qtopia/applnk.h> 24#include <qtopia/applnk.h>
25 25
26#include <qvbox.h> 26#include <qvbox.h>
27 27
28class CategorySelect; 28class CategorySelect;
29class LauncherIconView; 29class LauncherIconView;
30class LauncherItem;
30class QIconView; 31class QIconView;
31class QIconViewItem; 32class QIconViewItem;
32class QLabel; 33class QLabel;
33class QWidgetStack; 34class QWidgetStack;
34class MenuButton; 35class MenuButton;
35class QComboBox; 36class QComboBox;
36 37
37 38
38 39
39enum BusyIndicatorType { 40enum BusyIndicatorType {
40 BIT_Normal = 0, 41 BIT_Normal = 0,
41 BIT_Animated 42 BIT_Animated
@@ -107,13 +108,48 @@ private:
107 QComboBox *typemb; 108 QComboBox *typemb;
108 QStringList typelist; 109 QStringList typelist;
109 CategorySelect *catmb; 110 CategorySelect *catmb;
110 ViewMode vmode; 111 ViewMode vmode;
111 BackgroundType bgType; 112 BackgroundType bgType;
112 QString bgName; 113 QString bgName;
113 QColor textCol; 114 QColor textCol;
114 115
115 QImage loadBackgroundImage(QString &fname); 116 QImage loadBackgroundImage(QString &fname);
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