summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp91
-rw-r--r--core/launcher/launcherview.h5
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
@@ -1,1117 +1,1148 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
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> 32#include <qpe/qcopenvelope_qws.h>
33 33
34/* QT */ 34/* QT */
35#include <qtimer.h> 35#include <qtimer.h>
36#include <qfileinfo.h> 36#include <qfileinfo.h>
37#include <qiconview.h> 37#include <qiconview.h>
38#include <qobjectlist.h> 38#include <qobjectlist.h>
39 39
40 40
41// These define how the busy icon is animated and highlighted 41// These define how the busy icon is animated and highlighted
42#define BRIGHTEN_BUSY_ICON 42#define BRIGHTEN_BUSY_ICON
43//#define ALPHA_FADE_BUSY_ICON 43//#define ALPHA_FADE_BUSY_ICON
44//#define USE_ANIMATED_BUSY_ICON_OVERLAY 44//#define USE_ANIMATED_BUSY_ICON_OVERLAY
45#define BOUNCE_BUSY_ICON 45#define BOUNCE_BUSY_ICON
46 46
47 47
48class BgPixmap 48class BgPixmap
49{ 49{
50public: 50public:
51 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 51 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
52 QPixmap pm; 52 QPixmap pm;
53 int ref; 53 int ref;
54}; 54};
55 55
56 56
57static QMap<QString,BgPixmap*> *bgCache = 0; 57static QMap<QString,BgPixmap*> *bgCache = 0;
58 58
59static void cleanup_cache() 59static void cleanup_cache()
60{ 60{
61 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 61 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
62 while ( it != bgCache->end() ) { 62 while ( it != bgCache->end() ) {
63 QMap<QString,BgPixmap*>::Iterator curr = it; 63 QMap<QString,BgPixmap*>::Iterator curr = it;
64 ++it; 64 ++it;
65 delete (*curr); 65 delete (*curr);
66 bgCache->remove( curr ); 66 bgCache->remove( curr );
67 } 67 }
68 delete bgCache; 68 delete bgCache;
69 bgCache = 0; 69 bgCache = 0;
70} 70}
71 71
72 72
73class LauncherItem : public QIconViewItem 73class LauncherItem : public QIconViewItem
74{ 74{
75public: 75public:
76 enum iconstate_t {
77 BASE_ICON,
78 WAITING_ICON,
79 EYE_ICON
80 };
81
76 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 82 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
77 ~LauncherItem(); 83 ~LauncherItem();
78 84
79 AppLnk *appLnk() const { return app; } 85 AppLnk *appLnk() const { return app; }
80 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; } 86 AppLnk *takeAppLnk() { AppLnk* r=app; app=0; return r; }
81 87
82 void animateIcon(); 88 void animateIcon();
83 void resetIcon(); 89 void resetIcon();
84 bool isEyeImage()const{return m_EyeImage;} 90 bool isEyeImage()const{return m_EyeImage;}
85 91
86 virtual int compare ( QIconViewItem * i ) const; 92 virtual int compare ( QIconViewItem * i ) const;
87 void paintItem( QPainter *p, const QColorGroup &cg ); 93 void paintItem( QPainter *p, const QColorGroup &cg );
88 94
89 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 95 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
90 void setEyePixmap(const QPixmap&aIcon); 96 void setEyePixmap(const QPixmap&aIcon);
97 virtual QPixmap*pixmap()const;
98
91protected: 99protected:
92 bool isBigIcon; 100 bool isBigIcon;
93 int iteration; 101 int iteration;
94 AppLnk* app; 102 AppLnk* app;
95 103
96private: 104private:
97 void paintAnimatedIcon( QPainter *p ); 105 void paintAnimatedIcon( QPainter *p );
98 BusyIndicatorType busyType; 106 BusyIndicatorType busyType;
99 int psize; 107 int psize;
100 QPixmap m_iPixmap; 108 QPixmap m_iPixmap;
101 bool m_EyeImage; 109 bool m_EyeImage;
110 iconstate_t m_EyeImageSet;
102}; 111};
103 112
104
105bool LauncherView::bsy=FALSE;
106
107void LauncherView::setBusy(bool on)
108{
109 icons->setBusy(on);
110}
111
112void LauncherView::setBusyIndicatorType( const QString& type ) {
113 if ( type. lower ( ) == "animated" )
114 icons->setBusyIndicatorType( BIT_Animated ) ;
115 else
116 icons->setBusyIndicatorType( BIT_Normal ) ;
117}
118
119LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon ) 113LauncherItem::LauncherItem( QIconView *parent, AppLnk *applnk, bool bigIcon )
120 : QIconViewItem( parent, applnk->name(), 114 : QIconViewItem( parent, applnk->name(),
121 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ), 115 bigIcon ? applnk->bigPixmap() :applnk->pixmap() ),
122 isBigIcon( bigIcon ), 116 isBigIcon( bigIcon ),
123 iteration(0), 117 iteration(0),
124 app(applnk), // Takes ownership 118 app(applnk), // Takes ownership
125 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ), 119 psize( (bigIcon ? applnk->bigPixmap().width() :applnk->pixmap().width() ) ),
126 m_iPixmap(), 120 m_iPixmap(),
127 m_EyeImage(false) 121 m_EyeImage(false),
122 m_EyeImageSet(BASE_ICON)
128{ 123{
129 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) { 124 if (applnk->type().lower().startsWith("image/") && applnk->exec().contains("opie-eye",false)) {
130 m_EyeImage = true; 125 m_EyeImage = true;
131 m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap()); 126 m_iPixmap = (bigIcon ? applnk->bigPixmap():applnk->pixmap());
132 } 127 }
133} 128}
134 129
135LauncherItem::~LauncherItem() 130LauncherItem::~LauncherItem()
136{ 131{
137 LauncherIconView* liv = (LauncherIconView*)iconView(); 132 LauncherIconView* liv = (LauncherIconView*)iconView();
138 if ( liv->busyItem() == this ) 133 if ( liv->busyItem() == this )
139 liv->setBusy(FALSE); 134 liv->setBusy(FALSE);
140 delete app; 135 delete app;
141} 136}
142 137
138QPixmap*LauncherItem::pixmap()const
139{
140 if (m_EyeImage && m_EyeImageSet == BASE_ICON) {
141 LauncherIconView* liv = (LauncherIconView*)iconView();
142 liv->requestEyePix(this);
143 }
144 return QIconViewItem::pixmap();
145}
146
143int LauncherItem::compare ( QIconViewItem * i ) const 147int LauncherItem::compare ( QIconViewItem * i ) const
144{ 148{
145 LauncherIconView* view = (LauncherIconView*)iconView(); 149 LauncherIconView* view = (LauncherIconView*)iconView();
146 return view->compare(app,((LauncherItem *)i)->appLnk()); 150 return view->compare(app,((LauncherItem *)i)->appLnk());
147} 151}
148 152
149void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg ) 153void LauncherItem::paintItem( QPainter *p, const QColorGroup &cg )
150{ 154{
151 LauncherIconView* liv = (LauncherIconView*)iconView(); 155 LauncherIconView* liv = (LauncherIconView*)iconView();
152 QBrush oldBrush( liv->itemTextBackground() ); 156 QBrush oldBrush( liv->itemTextBackground() );
153 QColorGroup mycg( cg ); 157 QColorGroup mycg( cg );
154 if ( liv->currentItem() == this ) { 158 if ( liv->currentItem() == this ) {
155 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) ); 159 liv->setItemTextBackground( cg.brush( QColorGroup::Highlight ) );
156 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) ); 160 mycg.setColor( QColorGroup::Text, cg.color( QColorGroup::HighlightedText ) );
157 } 161 }
158 162
159 QIconViewItem::paintItem(p,mycg); 163 QIconViewItem::paintItem(p,mycg);
160 164
161 // Paint animation overlay 165 // Paint animation overlay
162 if ( liv->busyItem() == this ) 166 if ( liv->busyItem() == this )
163 paintAnimatedIcon(p); 167 paintAnimatedIcon(p);
164 168
165 if ( liv->currentItem() == this ) 169 if ( liv->currentItem() == this )
166 liv->setItemTextBackground( oldBrush ); 170 liv->setItemTextBackground( oldBrush );
167} 171}
168 172
169
170
171void LauncherItem::paintAnimatedIcon( QPainter *p ) 173void LauncherItem::paintAnimatedIcon( QPainter *p )
172{ 174{
173 LauncherIconView* liv = (LauncherIconView*)iconView(); 175 LauncherIconView* liv = (LauncherIconView*)iconView();
174 int pic = iteration % 16; 176 int pic = iteration % 16;
175 int w = pixmap()->width(), h = pixmap()->height(); 177 int w = pixmap()->width(), h = pixmap()->height();
176 QPixmap dblBuf( w, h + 4 ); 178 QPixmap dblBuf( w, h + 4 );
177 QPainter p2( &dblBuf ); 179 QPainter p2( &dblBuf );
178 int x1, y1; 180 int x1, y1;
179 if ( liv->itemTextPos() == QIconView::Bottom ) { 181 if ( liv->itemTextPos() == QIconView::Bottom ) {
180 x1 = x() + (width() - w) / 2 - liv->contentsX(); 182 x1 = x() + (width() - w) / 2 - liv->contentsX();
181 y1 = y() - liv->contentsY(); 183 y1 = y() - liv->contentsY();
182 } else { 184 } else {
183 x1 = x() - liv->contentsX(); 185 x1 = x() - liv->contentsX();
184 y1 = y() + (height() - h) / 2 - liv->contentsY(); 186 y1 = y() + (height() - h) / 2 - liv->contentsY();
185 } 187 }
186 y1 -= 2; 188 y1 -= 2;
187 p2.translate(-x1,-y1); 189 p2.translate(-x1,-y1);
188 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); 190 liv->drawBackground( &p2, QRect(x1,y1,w,h+4) );
189 int bounceY = 2; 191 int bounceY = 2;
190#ifdef BOUNCE_BUSY_ICON 192#ifdef BOUNCE_BUSY_ICON
191 if ( busyType == BIT_Animated ) { 193 if ( busyType == BIT_Animated ) {
192 bounceY = 4 - ((iteration+2)%8); 194 bounceY = 4 - ((iteration+2)%8);
193 bounceY = bounceY < 0 ? -bounceY : bounceY; 195 bounceY = bounceY < 0 ? -bounceY : bounceY;
194 } 196 }
195#endif 197#endif
196 p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); 198 p2.drawPixmap( x1, y1 + bounceY, *pixmap() );
197#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 199#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
198 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); 200 p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h );
199#else 201#else
200 Q_UNUSED( pic ) 202 Q_UNUSED( pic )
201#endif 203#endif
202 p->drawPixmap( x1, y1, dblBuf ); 204 p->drawPixmap( x1, y1, dblBuf );
203} 205}
204 206
205void LauncherItem::animateIcon() 207void LauncherItem::animateIcon()
206{ 208{
207 LauncherIconView* liv = (LauncherIconView*)iconView(); 209 LauncherIconView* liv = (LauncherIconView*)iconView();
208 210
209 if ( liv->busyItem() != this || !app ) 211 if ( liv->busyItem() != this || !app )
210 return; 212 return;
211 213
212 // Highlight the icon 214 // Highlight the icon
213 if ( iteration == 0 ) { 215 if ( iteration == 0 ) {
214 QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())); 216 QPixmap src = (isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()));
215 QImage img = src.convertToImage(); 217 QImage img = src.convertToImage();
216 QRgb *rgb; 218 QRgb *rgb;
217 int count; 219 int count;
218 if ( img.depth() == 32 ) { 220 if ( img.depth() == 32 ) {
219 rgb = (QRgb*)img.bits(); 221 rgb = (QRgb*)img.bits();
220 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 222 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
221 } else { 223 } else {
222 rgb = img.colorTable(); 224 rgb = img.colorTable();
223 count = img.numColors(); 225 count = img.numColors();
224 } 226 }
225 for ( int r = 0; r < count; r++, rgb++ ) { 227 for ( int r = 0; r < count; r++, rgb++ ) {
226#if defined(BRIGHTEN_BUSY_ICON) 228#if defined(BRIGHTEN_BUSY_ICON)
227 QColor c(*rgb); 229 QColor c(*rgb);
228 int h, s, v; 230 int h, s, v;
229 c.hsv(&h,&s,&v); 231 c.hsv(&h,&s,&v);
230 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); 232 c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255));
231 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); 233 *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb));
232#elif defined(ALPHA_FADE_BUSY_ICON) 234#elif defined(ALPHA_FADE_BUSY_ICON)
233 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); 235 *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2);
234#endif 236#endif
235 } 237 }
236 src.convertFromImage( img ); 238 src.convertFromImage( img );
237 setPixmap( src ); 239 setPixmap( src );
238 } 240 }
239 241
240 iteration++; 242 iteration++;
241 243
242 // Paint animation overlay 244 // Paint animation overlay
243 QPainter p( liv->viewport() ); 245 QPainter p( liv->viewport() );
244 paintAnimatedIcon( &p ); 246 paintAnimatedIcon( &p );
245} 247}
246 248
247void LauncherItem::resetIcon() 249void LauncherItem::resetIcon()
248{ 250{
249 iteration = 0; 251 iteration = 0;
250 setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap()))); 252 setPixmap((isEyeImage()?m_iPixmap:(isBigIcon ? app->bigPixmap() : app->pixmap())));
251} 253}
252 254
253void LauncherItem::setEyePixmap(const QPixmap&aIcon) 255void LauncherItem::setEyePixmap(const QPixmap&aIcon)
254{ 256{
255 if (!isEyeImage()) return; 257 if (!isEyeImage()) return;
256 m_iPixmap = aIcon; 258 m_iPixmap = aIcon;
257 setPixmap(aIcon); 259 setPixmap(aIcon);
260 m_EyeImageSet = EYE_ICON;
258} 261}
259 262
260//=========================================================================== 263//===========================================================================
261// Implemantation of LauncherIconview start 264// Implemantation of LauncherIconview start
262//=========================================================================== 265//===========================================================================
263LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) 266LauncherIconView::LauncherIconView( QWidget* parent, const char* name )
264 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) 267 : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white)
265{ 268{
266 m_EyeCallBack = 0; 269 m_EyeCallBack = 0;
267 sortmeth = Name; 270 sortmeth = Name;
268 hidden.setAutoDelete(TRUE); 271 hidden.setAutoDelete(TRUE);
269 ike = FALSE; 272 ike = FALSE;
270 calculateGrid( Bottom ); 273 calculateGrid( Bottom );
271} 274}
272 275
273LauncherIconView::~LauncherIconView() 276LauncherIconView::~LauncherIconView()
274{ 277{
275#if 0 // debuggery 278#if 0 // debuggery
276 QListIterator<AppLnk> it(hidden); 279 QListIterator<AppLnk> it(hidden);
277 AppLnk* l; 280 AppLnk* l;
278 while ((l=it.current())) { 281 while ((l=it.current())) {
279 ++it; 282 ++it;
280 //odebug << "" << l << ": hidden (should remove)" << oendl; 283 //odebug << "" << l << ": hidden (should remove)" << oendl;
281 } 284 }
282#endif 285#endif
283} 286}
284 287
285int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) 288int LauncherIconView::compare(const AppLnk* a, const AppLnk* b)
286{ 289{
287 switch (sortmeth) { 290 switch (sortmeth) {
288 case Name: 291 case Name:
289 return a->name().lower().compare(b->name().lower()); 292 return a->name().lower().compare(b->name().lower());
290 case Date: { 293 case Date: {
291 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); 294 QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file());
292 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); 295 QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file());
293 return fa.lastModified().secsTo(fb.lastModified()); 296 return fa.lastModified().secsTo(fb.lastModified());
294 } 297 }
295 case Type: 298 case Type:
296 return a->type().compare(b->type()); 299 return a->type().compare(b->type());
297 } 300 }
298 return 0; 301 return 0;
299} 302}
300 303
301void LauncherIconView::setSortMethod( SortMethod m ) 304void LauncherIconView::setSortMethod( SortMethod m )
302{ 305{
303 if ( sortmeth != m ) { 306 if ( sortmeth != m ) {
304 sortmeth = m; 307 sortmeth = m;
305 sort(); 308 sort();
306 } 309 }
307} 310}
308 311
309void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) 312void LauncherIconView::setCategoryFilter( int catfilter, bool resort )
310{ 313{
311 Categories cat; 314 Categories cat;
312 cat.load( categoryFileName() ); 315 cat.load( categoryFileName() );
313 QString str; 316 QString str;
314 if ( catfilter == -2 ) 317 if ( catfilter == -2 )
315 cf = 0; 318 cf = 0;
316 else 319 else
317 cf = catfilter; 320 cf = catfilter;
318 hideOrShowItems(resort); 321 hideOrShowItems(resort);
319} 322}
320 323
321void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) 324void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort)
322{ 325{
323 tf = QRegExp(typefilter,FALSE,TRUE); 326 tf = QRegExp(typefilter,FALSE,TRUE);
324 hideOrShowItems(resort); 327 hideOrShowItems(resort);
325} 328}
326 329
327void LauncherIconView::setItemTextPos( ItemTextPos pos ) 330void LauncherIconView::setItemTextPos( ItemTextPos pos )
328{ 331{
329 calculateGrid( pos ); 332 calculateGrid( pos );
330 QIconView::setItemTextPos( pos ); 333 QIconView::setItemTextPos( pos );
331} 334}
332 335
333void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) 336void LauncherIconView::drawBackground( QPainter *p, const QRect &r )
334{ 337{
335 if ( !bgPixmap.isNull() ) { 338 if ( !bgPixmap.isNull() ) {
336 p->drawTiledPixmap( r, bgPixmap, 339 p->drawTiledPixmap( r, bgPixmap,
337 QPoint( (r.x() + contentsX()) % bgPixmap.width(), 340 QPoint( (r.x() + contentsX()) % bgPixmap.width(),
338 (r.y() + contentsY()) % bgPixmap.height() ) ); 341 (r.y() + contentsY()) % bgPixmap.height() ) );
339 } else { 342 } else {
340 p->fillRect( r, bgColor ); 343 p->fillRect( r, bgColor );
341 } 344 }
342} 345}
343 346
344void LauncherIconView::addCatsAndMimes(AppLnk* app) 347void LauncherIconView::addCatsAndMimes(AppLnk* app)
345 { 348 {
346 // QStringList c = app->categories(); 349 // QStringList c = app->categories();
347 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { 350 // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) {
348 // cats.replace(*cit,(void*)1); 351 // cats.replace(*cit,(void*)1);
349 // } 352 // }
350 QString maj=app->type(); 353 QString maj=app->type();
351 int sl=maj.find('/'); 354 int sl=maj.find('/');
352 if (sl>=0) { 355 if (sl>=0) {
353 QString k; 356 QString k;
354 k = maj.left(12) == "application/" ? maj : maj.left(sl); 357 k = maj.left(12) == "application/" ? maj : maj.left(sl);
355 mimes.replace(k,(void*)1); 358 mimes.replace(k,(void*)1);
356 } 359 }
357} 360}
358 361
359void LauncherIconView::setBusy(bool on) 362void LauncherIconView::setBusy(bool on)
360{ 363{
361#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 364#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
362 if ( busyPix.isNull() ) { 365 if ( busyPix.isNull() ) {
363 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 366 int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
364 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); 367 busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) );
365 } 368 }
366#endif 369#endif
367 370
368 if ( on ) { 371 if ( on ) {
369 busyTimer = startTimer( 100 ); 372 busyTimer = startTimer( 100 );
370 } else { 373 } else {
371 if ( busyTimer ) { 374 if ( busyTimer ) {
372 killTimer( busyTimer ); 375 killTimer( busyTimer );
373 busyTimer = 0; 376 busyTimer = 0;
374 } 377 }
375 } 378 }
376 379
377 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; 380 LauncherItem *c = on ? (LauncherItem*)currentItem() : 0;
378 381
379 if ( bsy != c ) { 382 if ( bsy != c ) {
380 LauncherItem *oldBusy = bsy; 383 LauncherItem *oldBusy = bsy;
381 bsy = c; 384 bsy = c;
382 if ( oldBusy ) { 385 if ( oldBusy ) {
383 oldBusy->resetIcon(); 386 oldBusy->resetIcon();
384 } 387 }
385 if ( bsy ) { 388 if ( bsy ) {
386 bsy->setBusyIndicatorType( busyType ) ; 389 bsy->setBusyIndicatorType( busyType ) ;
387 bsy->animateIcon(); 390 bsy->animateIcon();
388 } 391 }
389 } 392 }
390} 393}
391 394
392void LauncherIconView::clear() 395void LauncherIconView::clear()
393{ 396{
394 mimes.clear(); 397 mimes.clear();
395 cats.clear(); 398 cats.clear();
396 QIconView::clear(); 399 QIconView::clear();
397 hidden.clear(); 400 hidden.clear();
398} 401}
399 402
400QStringList LauncherIconView::mimeTypes() const 403QStringList LauncherIconView::mimeTypes() const
401{ 404{
402 QStringList r; 405 QStringList r;
403 QDictIterator<void> it(mimes); 406 QDictIterator<void> it(mimes);
404 while (it.current()) { 407 while (it.current()) {
405 r.append(it.currentKey()); 408 r.append(it.currentKey());
406 ++it; 409 ++it;
407 } 410 }
408 r.sort(); 411 r.sort();
409 return r; 412 return r;
410} 413}
411 414
412LauncherItem*LauncherIconView::findDocItem(const QString&fname) 415LauncherItem*LauncherIconView::findDocItem(const QString&fname)
413{ 416{
414 LauncherItem* item = (LauncherItem*)firstItem(); 417 LauncherItem* item = (LauncherItem*)firstItem();
415 while (item) { 418 while (item) {
416 if (item->appLnk()->file()==fname) { 419 if (item->appLnk()->file()==fname) {
417 break; 420 break;
418 } 421 }
419 item = (LauncherItem*)item->nextItem(); 422 item = (LauncherItem*)item->nextItem();
420 } 423 }
421 return item; 424 return item;
422} 425}
423 426
424void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile) 427void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width)
425{ 428{
429 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
430 if (s!=width) return;
426 LauncherItem*item = findDocItem(aFile); 431 LauncherItem*item = findDocItem(aFile);
427 if (!item||!item->isEyeImage()) return; 432 if (!item||!item->isEyeImage()) return;
428
429 item->setEyePixmap(aPixmap); 433 item->setEyePixmap(aPixmap);
430} 434}
431 435
432void LauncherIconView::checkCallback() 436void LauncherIconView::checkCallback()
433{ 437{
434 if (m_EyeCallBack) { 438 if (m_EyeCallBack) {
435 return; 439 return;
436 } 440 }
437 m_EyeCallBack = new LauncherThumbReceiver(); 441 m_EyeCallBack = new LauncherThumbReceiver();
438 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&)), 442 connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)),
439 this,SLOT(setEyePixmap(const QPixmap&,const QString&))); 443 this,SLOT(setEyePixmap(const QPixmap&,const QString&,int)));
440} 444}
441 445
442void LauncherIconView::addCheckItem(AppLnk* app) 446void LauncherIconView::addCheckItem(AppLnk* app)
443{ 447{
444 LauncherItem*item = new LauncherItem( this, app, bigIcns ); 448 LauncherItem*item = new LauncherItem( this, app, bigIcns );
445 if (item->isEyeImage()) { 449 if (item->isEyeImage()) {
446 checkCallback(); 450 checkCallback();
451 }
452}
453
454void LauncherIconView::requestEyePix(const LauncherItem*item)
455{
456 if (!item) return;
457 if (item->isEyeImage()) {
458 checkCallback();
447 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); 459 int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize();
448 m_EyeCallBack->requestThumb(app->file(),s,s); 460 m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s);
449 } 461 }
450} 462}
451 463
452void LauncherIconView::addItem(AppLnk* app, bool resort) 464void LauncherIconView::addItem(AppLnk* app, bool resort)
453{ 465{
454 addCatsAndMimes(app); 466 addCatsAndMimes(app);
455 if ( (tf.isEmpty() || tf.match(app->type()) >= 0) 467 if ( (tf.isEmpty() || tf.match(app->type()) >= 0)
456 && (cf == 0 || app->categories().contains(cf) 468 && (cf == 0 || app->categories().contains(cf)
457 || cf == -1 && app->categories().count() == 0 ) ) { 469 || cf == -1 && app->categories().count() == 0 ) ) {
458 addCheckItem(app); 470 addCheckItem(app);
459 } else { 471 } else {
460 hidden.append(app); 472 hidden.append(app);
461 } 473 }
462 if ( resort ){ 474 if ( resort ){
463 sort(); 475 sort();
464 } 476 }
465} 477}
466 478
467void LauncherIconView::updateCategoriesAndMimeTypes() 479void LauncherIconView::updateCategoriesAndMimeTypes()
468{ 480{
469 mimes.clear(); 481 mimes.clear();
470 cats.clear(); 482 cats.clear();
471 LauncherItem* item = (LauncherItem*)firstItem(); 483 LauncherItem* item = (LauncherItem*)firstItem();
472 while (item) { 484 while (item) {
473 addCatsAndMimes(item->appLnk()); 485 addCatsAndMimes(item->appLnk());
474 item = (LauncherItem*)item->nextItem(); 486 item = (LauncherItem*)item->nextItem();
475 } 487 }
476 QListIterator<AppLnk> it(hidden); 488 QListIterator<AppLnk> it(hidden);
477 AppLnk* l; 489 AppLnk* l;
478 while ((l=it.current())) { 490 while ((l=it.current())) {
479 addCatsAndMimes(l); 491 addCatsAndMimes(l);
480 ++it; 492 ++it;
481 } 493 }
482} 494}
483 495
484void LauncherIconView::hideOrShowItems(bool resort) 496void LauncherIconView::hideOrShowItems(bool resort)
485{ 497{
486 viewport()->setUpdatesEnabled( FALSE ); 498 viewport()->setUpdatesEnabled( FALSE );
487 hidden.setAutoDelete(FALSE); 499 hidden.setAutoDelete(FALSE);
488 QList<AppLnk> links=hidden; 500 QList<AppLnk> links=hidden;
489 hidden.clear(); 501 hidden.clear();
490 hidden.setAutoDelete(TRUE); 502 hidden.setAutoDelete(TRUE);
491 LauncherItem* item = (LauncherItem*)firstItem(); 503 LauncherItem* item = (LauncherItem*)firstItem();
492 while (item) { 504 while (item) {
493 links.append(item->takeAppLnk()); 505 links.append(item->takeAppLnk());
494 item = (LauncherItem*)item->nextItem(); 506 item = (LauncherItem*)item->nextItem();
495 } 507 }
496 clear(); 508 clear();
497 QListIterator<AppLnk> it(links); 509 QListIterator<AppLnk> it(links);
498 AppLnk* l; 510 AppLnk* l;
499 while ((l=it.current())) { 511 while ((l=it.current())) {
500 addItem(l,FALSE); 512 addItem(l,FALSE);
501 ++it; 513 ++it;
502 } 514 }
503 if ( resort && !autoArrange() ) 515 if ( resort && !autoArrange() )
504 sort(); 516 sort();
505 viewport()->setUpdatesEnabled( TRUE ); 517 viewport()->setUpdatesEnabled( TRUE );
506} 518}
507 519
508bool LauncherIconView::removeLink(const QString& linkfile) 520bool LauncherIconView::removeLink(const QString& linkfile)
509{ 521{
510 LauncherItem* item = (LauncherItem*)firstItem(); 522 LauncherItem* item = (LauncherItem*)firstItem();
511 AppLnk* l; 523 AppLnk* l;
512 bool did = FALSE; 524 bool did = FALSE;
513 DocLnk dl(linkfile); 525 DocLnk dl(linkfile);
514 while (item) { 526 while (item) {
515 l = item->appLnk(); 527 l = item->appLnk();
516 LauncherItem *nextItem = (LauncherItem *)item->nextItem(); 528 LauncherItem *nextItem = (LauncherItem *)item->nextItem();
517 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && 529 if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() &&
518 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { 530 ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) {
519 delete item; 531 delete item;
520 did = TRUE; 532 did = TRUE;
521 } 533 }
522 item = nextItem; 534 item = nextItem;
523 } 535 }
524 QListIterator<AppLnk> it(hidden); 536 QListIterator<AppLnk> it(hidden);
525 while ((l=it.current())) { 537 while ((l=it.current())) {
526 ++it; 538 ++it;
527 if ( l->linkFileKnown() && l->linkFile() == linkfile 539 if ( l->linkFileKnown() && l->linkFile() == linkfile
528 || l->file() == linkfile 540 || l->file() == linkfile
529 || dl.isValid() && dl.file() == l->file() ) { 541 || dl.isValid() && dl.file() == l->file() ) {
530 hidden.removeRef(l); 542 hidden.removeRef(l);
531 did = TRUE; 543 did = TRUE;
532 } 544 }
533 } 545 }
534 return did; 546 return did;
535} 547}
536 548
537void LauncherIconView::timerEvent( QTimerEvent *te ) 549void LauncherIconView::timerEvent( QTimerEvent *te )
538{ 550{
539 if ( te->timerId() == busyTimer ) { 551 if ( te->timerId() == busyTimer ) {
540 if ( bsy ) 552 if ( bsy )
541 bsy->animateIcon(); 553 bsy->animateIcon();
542 } else { 554 } else {
543 QIconView::timerEvent( te ); 555 QIconView::timerEvent( te );
544 } 556 }
545} 557}
546 558
547void LauncherIconView::setBigIcons( bool bi ) 559void LauncherIconView::setBigIcons( bool bi )
548{ 560{
549 bigIcns = bi; 561 bigIcns = bi;
550#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 562#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
551 busyPix.resize(0,0); 563 busyPix.resize(0,0);
552#endif 564#endif
553} 565}
554 566
555QIconViewItem* LauncherIconView::busyItem() const 567QIconViewItem* LauncherIconView::busyItem() const
556{ 568{
557 return bsy; 569 return bsy;
558} 570}
559 571
560void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } 572void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
561 573
562void LauncherIconView::calculateGrid( ItemTextPos pos ) 574void LauncherIconView::calculateGrid( ItemTextPos pos )
563{ 575{
564 int dw = QApplication::desktop()->width(); 576 int dw = QApplication::desktop()->width();
565 int viewerWidth = dw-style().scrollBarExtent().width(); 577 int viewerWidth = dw-style().scrollBarExtent().width();
566 if ( pos == Bottom ) { 578 if ( pos == Bottom ) {
567 int cols = 3; 579 int cols = 3;
568 if ( viewerWidth <= 200 ) 580 if ( viewerWidth <= 200 )
569 cols = 2; 581 cols = 2;
570 else if ( viewerWidth >= 400 ) 582 else if ( viewerWidth >= 400 )
571 cols = viewerWidth/96; 583 cols = viewerWidth/96;
572 setSpacing( 4 ); 584 setSpacing( 4 );
573 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 585 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
574 setGridY( fontMetrics().height()*2+24 ); 586 setGridY( fontMetrics().height()*2+24 );
575 } else { 587 } else {
576 int cols = 2; 588 int cols = 2;
577 if ( viewerWidth < 150 ) 589 if ( viewerWidth < 150 )
578 cols = 1; 590 cols = 1;
579 else if ( viewerWidth >= 400 ) 591 else if ( viewerWidth >= 400 )
580 cols = viewerWidth/150; 592 cols = viewerWidth/150;
581 setSpacing( 2 ); 593 setSpacing( 2 );
582 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 594 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
583 setGridY( fontMetrics().height()+2 ); 595 setGridY( fontMetrics().height()+2 );
584 } 596 }
585} 597}
586 598
587void LauncherIconView::styleChange( QStyle &old ) 599void LauncherIconView::styleChange( QStyle &old )
588{ 600{
589 QIconView::styleChange( old ); 601 QIconView::styleChange( old );
590 calculateGrid( itemTextPos() ); 602 calculateGrid( itemTextPos() );
591} 603}
592//=========================================================================== 604//===========================================================================
593// Implemantation of LauncherIconview end 605// Implemantation of LauncherIconview end
594//=========================================================================== 606//===========================================================================
595 607
596 608
597//=========================================================================== 609//===========================================================================
598LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) 610LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl )
599 : QVBox( parent, name, fl ) 611 : QVBox( parent, name, fl )
600{ 612{
601 catmb = 0; 613 catmb = 0;
602 icons = new LauncherIconView( this ); 614 icons = new LauncherIconView( this );
603 setFocusProxy(icons); 615 setFocusProxy(icons);
604 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); 616 QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold );
605 617
606 icons->setItemsMovable( FALSE ); 618 icons->setItemsMovable( FALSE );
607 icons->setAutoArrange( TRUE ); 619 icons->setAutoArrange( TRUE );
608 icons->setSorting( TRUE ); 620 icons->setSorting( TRUE );
609 icons->setFrameStyle( QFrame::NoFrame ); 621 icons->setFrameStyle( QFrame::NoFrame );
610 icons->setMargin( 0 ); 622 icons->setMargin( 0 );
611 icons->setSelectionMode( QIconView::NoSelection ); 623 icons->setSelectionMode( QIconView::NoSelection );
612 icons->setBackgroundMode( PaletteBase ); 624 icons->setBackgroundMode( PaletteBase );
613 icons->setResizeMode( QIconView::Fixed ); 625 icons->setResizeMode( QIconView::Fixed );
614 vmode = (ViewMode)-1; 626 vmode = (ViewMode)-1;
615 setViewMode( Icon ); 627 setViewMode( Icon );
616 628
617 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), 629 connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)),
618 SLOT(itemClicked(int,QIconViewItem*)) ); 630 SLOT(itemClicked(int,QIconViewItem*)) );
619 connect( icons, SIGNAL(selectionChanged()), 631 connect( icons, SIGNAL(selectionChanged()),
620 SLOT(selectionChanged()) ); 632 SLOT(selectionChanged()) );
621 connect( icons, SIGNAL(returnPressed(QIconViewItem*)), 633 connect( icons, SIGNAL(returnPressed(QIconViewItem*)),
622 SLOT(returnPressed(QIconViewItem*)) ); 634 SLOT(returnPressed(QIconViewItem*)) );
623 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), 635 connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)),
624 SLOT(itemPressed(int,QIconViewItem*)) ); 636 SLOT(itemPressed(int,QIconViewItem*)) );
625 637
626 tools = 0; 638 tools = 0;
627 setBackgroundType( Ruled, QString::null ); 639 setBackgroundType( Ruled, QString::null );
628} 640}
629 641
630LauncherView::~LauncherView() 642LauncherView::~LauncherView()
631{ 643{
632 if ( bgCache && bgCache->contains( bgName ) ) 644 if ( bgCache && bgCache->contains( bgName ) )
633 (*bgCache)[bgName]->ref--; 645 (*bgCache)[bgName]->ref--;
634} 646}
635 647
648
649bool LauncherView::bsy=FALSE;
650
651void LauncherView::setBusy(bool on)
652{
653 icons->setBusy(on);
654}
655
656void LauncherView::setBusyIndicatorType( const QString& type ) {
657 if ( type. lower ( ) == "animated" )
658 icons->setBusyIndicatorType( BIT_Animated ) ;
659 else
660 icons->setBusyIndicatorType( BIT_Normal ) ;
661}
662
636void LauncherView::hideIcons() 663void LauncherView::hideIcons()
637{ 664{
638 icons->hide(); 665 icons->hide();
639} 666}
640 667
641void LauncherView::setToolsEnabled(bool y) 668void LauncherView::setToolsEnabled(bool y)
642{ 669{
643 if ( !y != !tools ) { 670 if ( !y != !tools ) {
644 if ( y ) { 671 if ( y ) {
645 tools = new QHBox(this); 672 tools = new QHBox(this);
646 673
647 // Type filter 674 // Type filter
648 typemb = new QComboBox(tools); 675 typemb = new QComboBox(tools);
649 QSizePolicy p = typemb->sizePolicy(); 676 QSizePolicy p = typemb->sizePolicy();
650 p.setHorData(QSizePolicy::Expanding); 677 p.setHorData(QSizePolicy::Expanding);
651 typemb->setSizePolicy(p); 678 typemb->setSizePolicy(p);
652 679
653 // Category filter 680 // Category filter
654 updateTools(); 681 updateTools();
655 tools->show(); 682 tools->show();
656 683
657 } else { 684 } else {
658 delete tools; 685 delete tools;
659 tools = 0; 686 tools = 0;
660 } 687 }
661 } 688 }
662} 689}
663 690
664void LauncherView::updateTools() 691void LauncherView::updateTools()
665{ 692{
666 disconnect( typemb, SIGNAL(activated(int)), 693 disconnect( typemb, SIGNAL(activated(int)),
667 this, SLOT(showType(int)) ); 694 this, SLOT(showType(int)) );
668 if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)), 695 if ( catmb ) disconnect( catmb, SIGNAL(signalSelected(int)),
669 this, SLOT(showCategory(int)) ); 696 this, SLOT(showCategory(int)) );
670 697
671 // ### I want to remove this 698 // ### I want to remove this
672 icons->updateCategoriesAndMimeTypes(); 699 icons->updateCategoriesAndMimeTypes();
673 700
674 QString prev; 701 QString prev;
675 702
676 // Type filter 703 // Type filter
677 QStringList types; 704 QStringList types;
678 typelist = icons->mimeTypes(); 705 typelist = icons->mimeTypes();
679 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { 706 for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) {
680 QString t = *it; 707 QString t = *it;
681 if ( t.left(12) == "application/" ) { 708 if ( t.left(12) == "application/" ) {
682 MimeType mt(t); 709 MimeType mt(t);
683 const AppLnk* app = mt.application(); 710 const AppLnk* app = mt.application();
684 if ( app ) 711 if ( app )
685 t = app->name(); 712 t = app->name();
686 else 713 else
687 t = t.mid(12); 714 t = t.mid(12);
688 } else { 715 } else {
689 t[0] = t[0].upper(); 716 t[0] = t[0].upper();
690 } 717 }
691 types += t; 718 types += t;
692 } 719 }
693 types << tr("All types"); 720 types << tr("All types");
694 prev = typemb->currentText(); 721 prev = typemb->currentText();
695 typemb->clear(); 722 typemb->clear();
696 typemb->insertStringList(types); 723 typemb->insertStringList(types);
697 for (int i=0; i<typemb->count(); i++) { 724 for (int i=0; i<typemb->count(); i++) {
698 if ( typemb->text(i) == prev ) { 725 if ( typemb->text(i) == prev ) {
699 typemb->setCurrentItem(i); 726 typemb->setCurrentItem(i);
700 break; 727 break;
701 } 728 }
702 } 729 }
703 if ( prev.isNull() ) 730 if ( prev.isNull() )
704 typemb->setCurrentItem(typemb->count()-1); 731 typemb->setCurrentItem(typemb->count()-1);
705 732
706 int pcat = catmb ? catmb->currentCategory() : -2; 733 int pcat = catmb ? catmb->currentCategory() : -2;
707 if ( !catmb ) 734 if ( !catmb )
708 catmb = new CategorySelect(tools); 735 catmb = new CategorySelect(tools);
709 Categories cats( 0 ); 736 Categories cats( 0 );
710 cats.load( categoryFileName() ); 737 cats.load( categoryFileName() );
711 QArray<int> vl( 0 ); 738 QArray<int> vl( 0 );
712 catmb->setCategories( vl, "Document View", // No tr 739 catmb->setCategories( vl, "Document View", // No tr
713 tr("Document View") ); 740 tr("Document View") );
714 catmb->setRemoveCategoryEdit( TRUE ); 741 catmb->setRemoveCategoryEdit( TRUE );
715 catmb->setAllCategories( TRUE ); 742 catmb->setAllCategories( TRUE );
716 catmb->setCurrentCategory(pcat); 743 catmb->setCurrentCategory(pcat);
717 744
718 // if type has changed we need to redisplay 745 // if type has changed we need to redisplay
719 if ( typemb->currentText() != prev ) 746 if ( typemb->currentText() != prev )
720 showType( typemb->currentItem() ); 747 showType( typemb->currentItem() );
721 748
722 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); 749 connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int)));
723 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); 750 connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int)));
724} 751}
725 752
726void LauncherView::sortBy(int s) 753void LauncherView::sortBy(int s)
727{ 754{
728 icons->setSortMethod((LauncherIconView::SortMethod)s); 755 icons->setSortMethod((LauncherIconView::SortMethod)s);
729} 756}
730 757
731void LauncherView::showType(int t) 758void LauncherView::showType(int t)
732{ 759{
733 if ( t >= (int)typelist.count() ) { 760 if ( t >= (int)typelist.count() ) {
734 icons->setTypeFilter("",TRUE); 761 icons->setTypeFilter("",TRUE);
735 } else { 762 } else {
736 QString ty = typelist[t]; 763 QString ty = typelist[t];
737 if ( !ty.contains('/') ) 764 if ( !ty.contains('/') )
738 ty += "/*"; 765 ty += "/*";
739 icons->setTypeFilter(ty,TRUE); 766 icons->setTypeFilter(ty,TRUE);
740 } 767 }
741} 768}
742 769
743void LauncherView::showCategory( int c ) 770void LauncherView::showCategory( int c )
744{ 771{
745 icons->setCategoryFilter( c, TRUE ); 772 icons->setCategoryFilter( c, TRUE );
746} 773}
747 774
748void LauncherView::setViewMode( ViewMode m ) 775void LauncherView::setViewMode( ViewMode m )
749{ 776{
750 if ( vmode != m ) { 777 if ( vmode != m ) {
751 bool bigIcons = m == Icon; 778 bool bigIcons = m == Icon;
752 icons->viewport()->setUpdatesEnabled( FALSE ); 779 icons->viewport()->setUpdatesEnabled( FALSE );
753 icons->setBigIcons( bigIcons ); 780 icons->setBigIcons( bigIcons );
754 switch ( m ) { 781 switch ( m ) {
755 case List: 782 case List:
756 icons->setItemTextPos( QIconView::Right ); 783 icons->setItemTextPos( QIconView::Right );
757 break; 784 break;
758 case Icon: 785 case Icon:
759 icons->setItemTextPos( QIconView::Bottom ); 786 icons->setItemTextPos( QIconView::Bottom );
760 break; 787 break;
761 } 788 }
762 icons->hideOrShowItems( FALSE ); 789 icons->hideOrShowItems( FALSE );
763 icons->viewport()->setUpdatesEnabled( TRUE ); 790 icons->viewport()->setUpdatesEnabled( TRUE );
764 vmode = m; 791 vmode = m;
765 } 792 }
766} 793}
767 794
768// 795//
769// User images may require scaling. 796// User images may require scaling.
770// 797//
771QImage LauncherView::loadBackgroundImage(QString &bgName) 798QImage LauncherView::loadBackgroundImage(QString &bgName)
772{ 799{
773 QImageIO imgio; 800 QImageIO imgio;
774 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop 801 QSize ds = qApp->desktop()->size(); // should be launcher, not desktop
775 bool further_scaling = TRUE; 802 bool further_scaling = TRUE;
776 803
777 imgio.setFileName( bgName ); 804 imgio.setFileName( bgName );
778 imgio.setParameters("GetHeaderInformation"); 805 imgio.setParameters("GetHeaderInformation");
779 806
780 if (imgio.read() == FALSE) { 807 if (imgio.read() == FALSE) {
781 return imgio.image(); 808 return imgio.image();
782 } 809 }
783 810
784 if (imgio.image().width() < ds.width() && 811 if (imgio.image().width() < ds.width() &&
785 imgio.image().height() < ds.height()) { 812 imgio.image().height() < ds.height()) {
786 further_scaling = FALSE; 813 further_scaling = FALSE;
787 } 814 }
788 815
789 if (!imgio.image().bits()) { 816 if (!imgio.image().bits()) {
790 // 817 //
791 // Scale and load. Note we don't scale up. 818 // Scale and load. Note we don't scale up.
792 // 819 //
793 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr 820 QString param( "Scale( %1, %2, ScaleMin )" ); // No tr
794 imgio.setParameters(further_scaling ? 821 imgio.setParameters(further_scaling ?
795 param.arg(ds.width()).arg(ds.height()).latin1() : 822 param.arg(ds.width()).arg(ds.height()).latin1() :
796 ""); 823 "");
797 imgio.read(); 824 imgio.read();
798 } else { 825 } else {
799 if (further_scaling) { 826 if (further_scaling) {
800 int t1 = imgio.image().width() * ds.height(); 827 int t1 = imgio.image().width() * ds.height();
801 int t2 = imgio.image().height() * ds.width(); 828 int t2 = imgio.image().height() * ds.width();
802 int dsth = ds.height(); 829 int dsth = ds.height();
803 int dstw = ds.width(); 830 int dstw = ds.width();
804 831
805 if (t1 > t2) { 832 if (t1 > t2) {
806 dsth = t2 / imgio.image().width(); 833 dsth = t2 / imgio.image().width();
807 } else { 834 } else {
808 dstw = t1 / imgio.image().height(); 835 dstw = t1 / imgio.image().height();
809 } 836 }
810 837
811 // 838 //
812 // Loader didn't scale for us. Do it manually. 839 // Loader didn't scale for us. Do it manually.
813 // 840 //
814 return imgio.image().smoothScale(dstw, dsth); 841 return imgio.image().smoothScale(dstw, dsth);
815 } 842 }
816 } 843 }
817 844
818 return imgio.image(); 845 return imgio.image();
819} 846}
820 847
821void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) 848void LauncherView::setBackgroundType( BackgroundType t, const QString &val )
822{ 849{
823 if ( !bgCache ) { 850 if ( !bgCache ) {
824 bgCache = new QMap<QString,BgPixmap*>; 851 bgCache = new QMap<QString,BgPixmap*>;
825 qAddPostRoutine( cleanup_cache ); 852 qAddPostRoutine( cleanup_cache );
826 } 853 }
827 854
828 if ( bgCache->contains( bgName ) ) 855 if ( bgCache->contains( bgName ) )
829 (*bgCache)[bgName]->ref--; 856 (*bgCache)[bgName]->ref--;
830 bgName = ""; 857 bgName = "";
831 858
832 QPixmap bg; 859 QPixmap bg;
833 860
834 switch ( t ) { 861 switch ( t ) {
835 case Ruled: { 862 case Ruled: {
836 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr 863 bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr
837 if ( bgCache->contains( bgName ) ) { 864 if ( bgCache->contains( bgName ) ) {
838 (*bgCache)[bgName]->ref++; 865 (*bgCache)[bgName]->ref++;
839 bg = (*bgCache)[bgName]->pm; 866 bg = (*bgCache)[bgName]->pm;
840 } else { 867 } else {
841 bg.resize( width(), 9 ); 868 bg.resize( width(), 9 );
842 QPainter painter( &bg ); 869 QPainter painter( &bg );
843 for ( int i = 0; i < 3; i++ ) { 870 for ( int i = 0; i < 3; i++ ) {
844 painter.setPen( white ); 871 painter.setPen( white );
845 painter.drawLine( 0, i*3, width()-1, i*3 ); 872 painter.drawLine( 0, i*3, width()-1, i*3 );
846 painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); 873 painter.drawLine( 0, i*3+1, width()-1, i*3+1 );
847 painter.setPen( colorGroup().background().light(105) ); 874 painter.setPen( colorGroup().background().light(105) );
848 painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); 875 painter.drawLine( 0, i*3+2, width()-1, i*3+2 );
849 } 876 }
850 painter.end(); 877 painter.end();
851 bgCache->insert( bgName, new BgPixmap(bg) ); 878 bgCache->insert( bgName, new BgPixmap(bg) );
852 } 879 }
853 break; 880 break;
854 } 881 }
855 882
856 case Image: 883 case Image:
857 if (!val.isEmpty()) { 884 if (!val.isEmpty()) {
858 bgName = val; 885 bgName = val;
859 if ( bgCache->contains( bgName ) ) { 886 if ( bgCache->contains( bgName ) ) {
860 (*bgCache)[bgName]->ref++; 887 (*bgCache)[bgName]->ref++;
861 bg = (*bgCache)[bgName]->pm; 888 bg = (*bgCache)[bgName]->pm;
862 } else { 889 } else {
863 QString imgFile = bgName; 890 QString imgFile = bgName;
864 bool tile = FALSE; 891 bool tile = FALSE;
865 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { 892 if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) {
866 imgFile = Resource::findPixmap( imgFile ); 893 imgFile = Resource::findPixmap( imgFile );
867 tile = TRUE; 894 tile = TRUE;
868 } 895 }
869 QImage img = loadBackgroundImage(imgFile); 896 QImage img = loadBackgroundImage(imgFile);
870 897
871 898
872 if ( img.depth() == 1 ) 899 if ( img.depth() == 1 )
873 img = img.convertDepth(8); 900 img = img.convertDepth(8);
874 img.setAlphaBuffer(FALSE); 901 img.setAlphaBuffer(FALSE);
875 bg.convertFromImage(img); 902 bg.convertFromImage(img);
876 bgCache->insert( bgName, new BgPixmap(bg) ); 903 bgCache->insert( bgName, new BgPixmap(bg) );
877 } 904 }
878 } 905 }
879 break; 906 break;
880 907
881 case SolidColor: 908 case SolidColor:
882 default: 909 default:
883 break; 910 break;
884 } 911 }
885 912
886 const QObjectList *list = queryList( "QWidget", 0, FALSE ); 913 const QObjectList *list = queryList( "QWidget", 0, FALSE );
887 QObject *obj; 914 QObject *obj;
888 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { 915 for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) {
889 if ( obj->isWidgetType() ) { 916 if ( obj->isWidgetType() ) {
890 QWidget *w = (QWidget*)obj; 917 QWidget *w = (QWidget*)obj;
891 w->setBackgroundPixmap( bg ); 918 w->setBackgroundPixmap( bg );
892 if ( bgName.isEmpty() ) { 919 if ( bgName.isEmpty() ) {
893 // Solid Color 920 // Solid Color
894 if ( val.isEmpty() ) 921 if ( val.isEmpty() )
895 w->setBackgroundColor( colorGroup().base() ); 922 w->setBackgroundColor( colorGroup().base() );
896 else 923 else
897 w->setBackgroundColor( val ); 924 w->setBackgroundColor( val );
898 } else { 925 } else {
899 // Ruled or Image pixmap 926 // Ruled or Image pixmap
900 w->setBackgroundOrigin( ParentOrigin ); 927 w->setBackgroundOrigin( ParentOrigin );
901 } 928 }
902 } 929 }
903 } 930 }
904 delete list; 931 delete list;
905 932
906 bgType = t; 933 bgType = t;
907 icons->viewport()->update(); 934 icons->viewport()->update();
908 935
909 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); 936 QTimer::singleShot( 1000, this, SLOT(flushBgCache()) );
910} 937}
911 938
912void LauncherView::setTextColor( const QColor &tc ) 939void LauncherView::setTextColor( const QColor &tc )
913{ 940{
914 textCol = tc; 941 textCol = tc;
915 QColorGroup cg = icons->colorGroup(); 942 QColorGroup cg = icons->colorGroup();
916 cg.setColor( QColorGroup::Text, tc ); 943 cg.setColor( QColorGroup::Text, tc );
917 icons->setPalette( QPalette(cg,cg,cg) ); 944 icons->setPalette( QPalette(cg,cg,cg) );
918 icons->viewport()->update(); 945 icons->viewport()->update();
919} 946}
920 947
921void LauncherView::setViewFont( const QFont &f ) 948void LauncherView::setViewFont( const QFont &f )
922{ 949{
923 icons->setFont( f ); 950 icons->setFont( f );
924 icons->hideOrShowItems( FALSE ); 951 icons->hideOrShowItems( FALSE );
925} 952}
926 953
927void LauncherView::clearViewFont() 954void LauncherView::clearViewFont()
928{ 955{
929 icons->unsetFont(); 956 icons->unsetFont();
930 icons->hideOrShowItems( FALSE ); 957 icons->hideOrShowItems( FALSE );
931} 958}
932 959
933void LauncherView::resizeEvent(QResizeEvent *e) 960void LauncherView::resizeEvent(QResizeEvent *e)
934{ 961{
935// qDebug("LauncherView resize event"); 962// qDebug("LauncherView resize event");
936 QVBox::resizeEvent( e ); 963 QVBox::resizeEvent( e );
937// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... 964// commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere...
938// if ( e->size().width() != e->oldSize().width() ) 965// if ( e->size().width() != e->oldSize().width() )
939 sort(); 966 sort();
940} 967}
941 968
942void LauncherView::selectionChanged() 969void LauncherView::selectionChanged()
943{ 970{
944 QIconViewItem* item = icons->currentItem(); 971 QIconViewItem* item = icons->currentItem();
945 if ( item && item->isSelected() ) { 972 if ( item && item->isSelected() ) {
946 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 973 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
947 if ( icons->inKeyEvent() ) // not for mouse press 974 if ( icons->inKeyEvent() ) // not for mouse press
948 emit clicked( appLnk ); 975 emit clicked( appLnk );
949 item->setSelected(FALSE); 976 item->setSelected(FALSE);
950 } 977 }
951} 978}
952 979
953void LauncherView::returnPressed( QIconViewItem *item ) 980void LauncherView::returnPressed( QIconViewItem *item )
954{ 981{
955 if ( item ) { 982 if ( item ) {
956 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 983 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
957 emit clicked( appLnk ); 984 emit clicked( appLnk );
958 } 985 }
959} 986}
960 987
961void LauncherView::itemClicked( int btn, QIconViewItem *item ) 988void LauncherView::itemClicked( int btn, QIconViewItem *item )
962{ 989{
963 if ( item ) { 990 if ( item ) {
964 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 991 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
965 if ( btn == LeftButton ) { 992 if ( btn == LeftButton ) {
966 // Make sure it's the item we execute that gets highlighted 993 // Make sure it's the item we execute that gets highlighted
967 icons->setCurrentItem( item ); 994 icons->setCurrentItem( item );
968 emit clicked( appLnk ); 995 emit clicked( appLnk );
969 } 996 }
970 item->setSelected(FALSE); 997 item->setSelected(FALSE);
971 } 998 }
972} 999}
973 1000
974void LauncherView::itemPressed( int btn, QIconViewItem *item ) 1001void LauncherView::itemPressed( int btn, QIconViewItem *item )
975{ 1002{
976 if ( item ) { 1003 if ( item ) {
977 AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); 1004 AppLnk *appLnk = ((LauncherItem *)item)->appLnk();
978 if ( btn == RightButton ) 1005 if ( btn == RightButton )
979 emit rightPressed( appLnk ); 1006 emit rightPressed( appLnk );
980 else if ( btn == ShiftButton ) 1007 else if ( btn == ShiftButton )
981 emit rightPressed( appLnk ); 1008 emit rightPressed( appLnk );
982 item->setSelected(FALSE); 1009 item->setSelected(FALSE);
983 } 1010 }
984} 1011}
985 1012
986void LauncherView::removeAllItems() 1013void LauncherView::removeAllItems()
987{ 1014{
988 icons->clear(); 1015 icons->clear();
989} 1016}
990 1017
991bool LauncherView::removeLink(const QString& linkfile) 1018bool LauncherView::removeLink(const QString& linkfile)
992{ 1019{
993 return icons->removeLink(linkfile); 1020 return icons->removeLink(linkfile);
994} 1021}
995 1022
996void LauncherView::setSortEnabled( bool v ) 1023void LauncherView::setSortEnabled( bool v )
997{ 1024{
998 icons->setSorting( v ); 1025 icons->setSorting( v );
999 if ( v ) 1026 if ( v )
1000 sort(); 1027 sort();
1001} 1028}
1002 1029
1003void LauncherView::setUpdatesEnabled( bool u ) 1030void LauncherView::setUpdatesEnabled( bool u )
1004{ 1031{
1005 icons->setUpdatesEnabled( u ); 1032 icons->setUpdatesEnabled( u );
1006} 1033}
1007 1034
1008void LauncherView::sort() 1035void LauncherView::sort()
1009{ 1036{
1010 icons->sort(); 1037 icons->sort();
1011} 1038}
1012 1039
1013void LauncherView::addItem(AppLnk* app, bool resort) 1040void LauncherView::addItem(AppLnk* app, bool resort)
1014{ 1041{
1015 icons->addItem(app,resort); 1042 icons->addItem(app,resort);
1016} 1043}
1017 1044
1018void LauncherView::paletteChange( const QPalette &p ) 1045void LauncherView::paletteChange( const QPalette &p )
1019{ 1046{
1020 icons->unsetPalette(); 1047 icons->unsetPalette();
1021 QVBox::paletteChange( p ); 1048 QVBox::paletteChange( p );
1022 if ( bgType == Ruled ) 1049 if ( bgType == Ruled )
1023 setBackgroundType( Ruled, QString::null ); 1050 setBackgroundType( Ruled, QString::null );
1024 QColorGroup cg = icons->colorGroup(); 1051 QColorGroup cg = icons->colorGroup();
1025 cg.setColor( QColorGroup::Text, textCol ); 1052 cg.setColor( QColorGroup::Text, textCol );
1026 icons->setPalette( QPalette(cg,cg,cg) ); 1053 icons->setPalette( QPalette(cg,cg,cg) );
1027} 1054}
1028 1055
1029void LauncherView::fontChanged(const QFont&) 1056void LauncherView::fontChanged(const QFont&)
1030{ 1057{
1031 odebug << "LauncherView::fontChanged()" << oendl; 1058 odebug << "LauncherView::fontChanged()" << oendl;
1032 icons->hideOrShowItems( FALSE ); 1059 icons->hideOrShowItems( FALSE );
1033} 1060}
1034 1061
1035void LauncherView::relayout(void) 1062void LauncherView::relayout(void)
1036{ 1063{
1037 icons->hideOrShowItems(FALSE); 1064 icons->hideOrShowItems(FALSE);
1038} 1065}
1039 1066
1040void LauncherView::flushBgCache() 1067void LauncherView::flushBgCache()
1041{ 1068{
1042 if ( !bgCache ) 1069 if ( !bgCache )
1043 return; 1070 return;
1044 // remove unreferenced backgrounds. 1071 // remove unreferenced backgrounds.
1045 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); 1072 QMap<QString,BgPixmap*>::Iterator it = bgCache->begin();
1046 while ( it != bgCache->end() ) { 1073 while ( it != bgCache->end() ) {
1047 QMap<QString,BgPixmap*>::Iterator curr = it; 1074 QMap<QString,BgPixmap*>::Iterator curr = it;
1048 ++it; 1075 ++it;
1049 if ( (*curr)->ref == 0 ) { 1076 if ( (*curr)->ref == 0 ) {
1050 delete (*curr); 1077 delete (*curr);
1051 bgCache->remove( curr ); 1078 bgCache->remove( curr );
1052 } 1079 }
1053 } 1080 }
1054} 1081}
1055 1082
1083/*
1084 * Launcherthumbnail handling for image files
1085 */
1086
1056/* special image handling - based on opie eye */ 1087/* special image handling - based on opie eye */
1057QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { 1088QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) {
1058 s >> inf.file >> inf.pixmap >> inf.width >> inf.height; 1089 s >> inf.file >> inf.pixmap >> inf.width >> inf.height;
1059 return s; 1090 return s;
1060} 1091}
1061 1092
1062QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { 1093QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) {
1063 return s << inf.file << inf.width << inf.height; 1094 return s << inf.file << inf.width << inf.height;
1064} 1095}
1065 1096
1066LauncherThumbReceiver::LauncherThumbReceiver() 1097LauncherThumbReceiver::LauncherThumbReceiver()
1067 :QObject() 1098 :QObject()
1068{ 1099{
1069 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); 1100 QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this );
1070 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), 1101 connect(chan, SIGNAL(received(const QCString&,const QByteArray&)),
1071 this, SLOT(recieve(const QCString&,const QByteArray&)) ); 1102 this, SLOT(recieve(const QCString&,const QByteArray&)) );
1072 1103
1073 { 1104 {
1074 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); 1105 QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" );
1075 } 1106 }
1076} 1107}
1077 1108
1078LauncherThumbReceiver::~LauncherThumbReceiver() 1109LauncherThumbReceiver::~LauncherThumbReceiver()
1079{ 1110{
1080 { 1111 {
1081 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); 1112 QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" );
1082 } 1113 }
1083} 1114}
1084 1115
1085void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) 1116void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at )
1086{ 1117{
1087 PixmapInfos pixinfos; 1118 PixmapInfos pixinfos;
1088 QDataStream stream( at, IO_ReadOnly ); 1119 QDataStream stream( at, IO_ReadOnly );
1089 1120
1090 /* we are just interested in thumbmails */ 1121 /* we are just interested in thumbmails */
1091 if ( str == "pixmapsHandled(PixmapList)" ) 1122 if ( str == "pixmapsHandled(PixmapList)" )
1092 stream >> pixinfos; 1123 stream >> pixinfos;
1093 1124
1094 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { 1125 for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) {
1095 odebug << "Pixinfos: " << (*it).file << " - " << (*it).width << oendl; 1126 odebug << "Pixinfos: " << (*it).file << " - " << (*it).width << oendl;
1096 emit sig_Thumbnail((*it).pixmap,(*it).file); 1127 emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width);
1097 } 1128 }
1098} 1129}
1099 1130
1100void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height) 1131void LauncherThumbReceiver::requestThumb(const QString&file,int width,int height)
1101{ 1132{
1102 PixmapInfo rItem; 1133 PixmapInfo rItem;
1103 rItem.file = file; 1134 rItem.file = file;
1104 rItem.width = width; 1135 rItem.width = width;
1105 rItem.height = height; 1136 rItem.height = height;
1106 m_inThumbNail.append(rItem); 1137 m_inThumbNail.append(rItem);
1107 QTimer::singleShot(2, this, SLOT(sendRequest())); 1138 QTimer::singleShot(0, this, SLOT(sendRequest()));
1108} 1139}
1109 1140
1110void LauncherThumbReceiver::sendRequest() 1141void LauncherThumbReceiver::sendRequest()
1111{ 1142{
1112 if (m_inThumbNail.count()>0) { 1143 if (m_inThumbNail.count()>0) {
1113 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" ); 1144 QCopEnvelope env("QPE/opie-eye_slave", "pixmapInfos(PixmapInfos)" );
1114 env << m_inThumbNail; 1145 env << m_inThumbNail;
1146 m_inThumbNail.clear();
1115 } 1147 }
1116 m_inThumbNail.clear();
1117} 1148}
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
@@ -1,253 +1,254 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
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#include <qiconview.h> 27#include <qiconview.h>
28 28
29class CategorySelect; 29class CategorySelect;
30class LauncherIconView; 30class LauncherIconView;
31class LauncherItem; 31class LauncherItem;
32class QIconViewItem; 32class QIconViewItem;
33class QLabel; 33class QLabel;
34class QWidgetStack; 34class QWidgetStack;
35class MenuButton; 35class MenuButton;
36class QComboBox; 36class QComboBox;
37 37
38 38
39 39
40enum BusyIndicatorType { 40enum BusyIndicatorType {
41 BIT_Normal = 0, 41 BIT_Normal = 0,
42 BIT_Animated 42 BIT_Animated
43}; 43};
44 44
45class LauncherView : public QVBox 45class LauncherView : public QVBox
46{ 46{
47 Q_OBJECT 47 Q_OBJECT
48 48
49public: 49public:
50 LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 50 LauncherView( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
51 ~LauncherView(); 51 ~LauncherView();
52 52
53 void hideIcons(); 53 void hideIcons();
54 54
55 bool removeLink(const QString& linkfile); 55 bool removeLink(const QString& linkfile);
56 void addItem(AppLnk* app, bool resort=TRUE); 56 void addItem(AppLnk* app, bool resort=TRUE);
57 void removeAllItems(); 57 void removeAllItems();
58 void setSortEnabled(bool); 58 void setSortEnabled(bool);
59 void setUpdatesEnabled(bool); 59 void setUpdatesEnabled(bool);
60 void sort(); 60 void sort();
61 61
62 void setToolsEnabled(bool); 62 void setToolsEnabled(bool);
63 void updateTools(); 63 void updateTools();
64 64
65 void setBusy(bool); 65 void setBusy(bool);
66 void setBusyIndicatorType( const QString& ); 66 void setBusyIndicatorType( const QString& );
67 67
68 enum ViewMode { Icon, List }; 68 enum ViewMode { Icon, List };
69 void setViewMode( ViewMode m ); 69 void setViewMode( ViewMode m );
70 ViewMode viewMode() const { return vmode; } 70 ViewMode viewMode() const { return vmode; }
71 71
72 enum BackgroundType { Ruled, SolidColor, Image }; 72 enum BackgroundType { Ruled, SolidColor, Image };
73 void setBackgroundType( BackgroundType t, const QString & ); 73 void setBackgroundType( BackgroundType t, const QString & );
74 BackgroundType backgroundType() const { return bgType; } 74 BackgroundType backgroundType() const { return bgType; }
75 75
76 void setTextColor( const QColor & ); 76 void setTextColor( const QColor & );
77 QColor textColor() const { return textCol; } 77 QColor textColor() const { return textCol; }
78 78
79 void setViewFont( const QFont & ); 79 void setViewFont( const QFont & );
80 void clearViewFont(); 80 void clearViewFont();
81 81
82 void relayout(void); 82 void relayout(void);
83 83
84signals: 84signals:
85 void clicked( const AppLnk * ); 85 void clicked( const AppLnk * );
86 void rightPressed( AppLnk * ); 86 void rightPressed( AppLnk * );
87 87
88protected slots: 88protected slots:
89 void selectionChanged(); 89 void selectionChanged();
90 void returnPressed( QIconViewItem *item ); 90 void returnPressed( QIconViewItem *item );
91 void itemClicked( int, QIconViewItem * ); 91 void itemClicked( int, QIconViewItem * );
92 void itemPressed( int, QIconViewItem * ); 92 void itemPressed( int, QIconViewItem * );
93 void sortBy(int); 93 void sortBy(int);
94 void showType(int); 94 void showType(int);
95 void showCategory( int ); 95 void showCategory( int );
96 void resizeEvent(QResizeEvent *); 96 void resizeEvent(QResizeEvent *);
97 void flushBgCache(); 97 void flushBgCache();
98 98
99protected: 99protected:
100 void paletteChange( const QPalette & ); 100 void paletteChange( const QPalette & );
101 101
102 void fontChanged(const QFont &); 102 void fontChanged(const QFont &);
103 103
104private: 104private:
105 static bool bsy; 105 static bool bsy;
106 QWidget* tools; 106 QWidget* tools;
107 LauncherIconView* icons; 107 LauncherIconView* icons;
108 QComboBox *typemb; 108 QComboBox *typemb;
109 QStringList typelist; 109 QStringList typelist;
110 CategorySelect *catmb; 110 CategorySelect *catmb;
111 ViewMode vmode; 111 ViewMode vmode;
112 BackgroundType bgType; 112 BackgroundType bgType;
113 QString bgName; 113 QString bgName;
114 QColor textCol; 114 QColor textCol;
115 115
116 QImage loadBackgroundImage(QString &fname); 116 QImage loadBackgroundImage(QString &fname);
117 117
118}; 118};
119 119
120/* from opie-eye */ 120/* from opie-eye */
121struct PixmapInfo { 121struct PixmapInfo {
122 PixmapInfo() : width( -1 ), height( -1 ) {} 122 PixmapInfo() : width( -1 ), height( -1 ) {}
123 bool operator==( const PixmapInfo& r ) { 123 bool operator==( const PixmapInfo& r ) {
124 if ( width != r.width ) return false; 124 if ( width != r.width ) return false;
125 if ( height != r.height ) return false; 125 if ( height != r.height ) return false;
126 if ( file != r.file ) return false; 126 if ( file != r.file ) return false;
127 return true; 127 return true;
128 } 128 }
129 int width, height; 129 int width, height;
130 QString file; 130 QString file;
131 QPixmap pixmap; 131 QPixmap pixmap;
132}; 132};
133 133
134class LauncherThumbReceiver:public QObject 134class LauncherThumbReceiver:public QObject
135{ 135{
136 Q_OBJECT 136 Q_OBJECT
137 typedef QValueList<PixmapInfo> PixmapInfos; 137 typedef QValueList<PixmapInfo> PixmapInfos;
138public: 138public:
139 LauncherThumbReceiver(); 139 LauncherThumbReceiver();
140 ~LauncherThumbReceiver(); 140 ~LauncherThumbReceiver();
141 void requestThumb(const QString&file,int width,int height); 141 void requestThumb(const QString&file,int width,int height);
142 142
143public slots: 143public slots:
144 void recieve( const QCString&, const QByteArray& ); 144 void recieve( const QCString&, const QByteArray& );
145protected slots: 145protected slots:
146 virtual void sendRequest(); 146 virtual void sendRequest();
147 147
148signals: 148signals:
149 void sig_Thumbnail(const QPixmap&,const QString&); 149 void sig_Thumbnail(const QPixmap&,const QString&,int);
150 150
151protected: 151protected:
152 PixmapInfos m_inThumbNail; 152 PixmapInfos m_inThumbNail;
153}; 153};
154 154
155class LauncherIconView : public QIconView { 155class LauncherIconView : public QIconView {
156 Q_OBJECT 156 Q_OBJECT
157public: 157public:
158 LauncherIconView( QWidget* parent, const char* name=0 ); 158 LauncherIconView( QWidget* parent, const char* name=0 );
159 ~LauncherIconView(); 159 ~LauncherIconView();
160 QIconViewItem* busyItem() const; 160 QIconViewItem* busyItem() const;
161 161
162#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 162#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
163 QPixmap busyPixmap() const { return busyPix; } 163 QPixmap busyPixmap() const { return busyPix; }
164#endif 164#endif
165 void setBigIcons( bool bi ); 165 void setBigIcons( bool bi );
166 void updateCategoriesAndMimeTypes(); 166 void updateCategoriesAndMimeTypes();
167 void setBusyIndicatorType ( BusyIndicatorType t ); 167 void setBusyIndicatorType ( BusyIndicatorType t );
168 void doAutoScroll() 168 void doAutoScroll()
169 { 169 {
170 // We don't want rubberbanding (yet) 170 // We don't want rubberbanding (yet)
171 } 171 }
172 172
173 void setBusy(bool on); 173 void setBusy(bool on);
174 bool inKeyEvent() const { return ike; } 174 bool inKeyEvent() const { return ike; }
175 175
176 void keyPressEvent(QKeyEvent* e) 176 void keyPressEvent(QKeyEvent* e)
177 { 177 {
178 ike = TRUE; 178 ike = TRUE;
179 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { 179 if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) {
180 if ( (e->state() & ShiftButton) ) 180 if ( (e->state() & ShiftButton) )
181 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); 181 emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() );
182 else 182 else
183 returnPressed(currentItem()); 183 returnPressed(currentItem());
184 } 184 }
185 185
186 QIconView::keyPressEvent(e); 186 QIconView::keyPressEvent(e);
187 ike = FALSE; 187 ike = FALSE;
188 } 188 }
189 189
190 void addItem(AppLnk* app, bool resort=TRUE); 190 void addItem(AppLnk* app, bool resort=TRUE);
191 bool removeLink(const QString& linkfile); 191 bool removeLink(const QString& linkfile);
192 192
193 QStringList mimeTypes() const; 193 QStringList mimeTypes() const;
194 QStringList categories() const; 194 QStringList categories() const;
195 void clear(); 195 void clear();
196 void addCatsAndMimes(AppLnk* app); 196 void addCatsAndMimes(AppLnk* app);
197 197
198 void setBackgroundOrigin( QWidget::BackgroundOrigin ) {} 198 void setBackgroundOrigin( QWidget::BackgroundOrigin ) {}
199 199
200 void setBackgroundPixmap( const QPixmap &pm ) { 200 void setBackgroundPixmap( const QPixmap &pm ) {
201 bgPixmap = pm; 201 bgPixmap = pm;
202 } 202 }
203 203
204 void setBackgroundColor( const QColor &c ) { 204 void setBackgroundColor( const QColor &c ) {
205 bgColor = c; 205 bgColor = c;
206 } 206 }
207 207
208 void drawBackground( QPainter *p, const QRect &r ); 208 void drawBackground( QPainter *p, const QRect &r );
209 void setItemTextPos( ItemTextPos pos ); 209 void setItemTextPos( ItemTextPos pos );
210 void hideOrShowItems(bool resort); 210 void hideOrShowItems(bool resort);
211 211
212 void setTypeFilter(const QString& typefilter, bool resort); 212 void setTypeFilter(const QString& typefilter, bool resort);
213 void setCategoryFilter( int catfilter, bool resort ); 213 void setCategoryFilter( int catfilter, bool resort );
214 214
215 enum SortMethod { Name, Date, Type }; 215 enum SortMethod { Name, Date, Type };
216 216
217 void setSortMethod( SortMethod m ); 217 void setSortMethod( SortMethod m );
218 int compare(const AppLnk* a, const AppLnk* b); 218 int compare(const AppLnk* a, const AppLnk* b);
219 void requestEyePix(const LauncherItem*which);
219 220
220protected: 221protected:
221 void timerEvent( QTimerEvent *te ); 222 void timerEvent( QTimerEvent *te );
222 void styleChange( QStyle &old ); 223 void styleChange( QStyle &old );
223 void calculateGrid( ItemTextPos pos ); 224 void calculateGrid( ItemTextPos pos );
224 void focusInEvent( QFocusEvent * ) {} 225 void focusInEvent( QFocusEvent * ) {}
225 void focusOutEvent( QFocusEvent * ) {} 226 void focusOutEvent( QFocusEvent * ) {}
226 LauncherItem*findDocItem(const QString&); 227 LauncherItem*findDocItem(const QString&);
227 void addCheckItem(AppLnk* app); 228 void addCheckItem(AppLnk* app);
228 void checkCallback(); 229 void checkCallback();
229 230
230protected slots: 231protected slots:
231 void setEyePixmap(const QPixmap&,const QString&); 232 void setEyePixmap(const QPixmap&,const QString&,int width);
232 233
233private: 234private:
234 QList<AppLnk> hidden; 235 QList<AppLnk> hidden;
235 QDict<void> mimes; 236 QDict<void> mimes;
236 QDict<void> cats; 237 QDict<void> cats;
237 SortMethod sortmeth; 238 SortMethod sortmeth;
238 QRegExp tf; 239 QRegExp tf;
239 int cf; 240 int cf;
240 LauncherItem* bsy; 241 LauncherItem* bsy;
241 int busyTimer; 242 int busyTimer;
242 bool ike; 243 bool ike;
243 bool bigIcns; 244 bool bigIcns;
244 QPixmap bgPixmap; 245 QPixmap bgPixmap;
245 QColor bgColor; 246 QColor bgColor;
246 LauncherThumbReceiver*m_EyeCallBack; 247 LauncherThumbReceiver*m_EyeCallBack;
247#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY 248#ifdef USE_ANIMATED_BUSY_ICON_OVERLAY
248 QPixmap busyPix; 249 QPixmap busyPix;
249#endif 250#endif
250 BusyIndicatorType busyType; 251 BusyIndicatorType busyType;
251}; 252};
252 253
253#endif // LAUNCHERVIEW_H 254#endif // LAUNCHERVIEW_H