author | zecke <zecke> | 2004-12-20 22:49:19 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-12-20 22:49:19 (UTC) |
commit | 3d9ea198ea8046d3f2c5b88efd721ffb00df2c22 (patch) (unidiff) | |
tree | 14ae80693ed5faadd7d8a177f8a86ecefff476b6 | |
parent | 21b825786deeb195fa73462f09fe70709aa5a628 (diff) | |
download | opie-3d9ea198ea8046d3f2c5b88efd721ffb00df2c22.zip opie-3d9ea198ea8046d3f2c5b88efd721ffb00df2c22.tar.gz opie-3d9ea198ea8046d3f2c5b88efd721ffb00df2c22.tar.bz2 |
Patch from Hrw for 1493
"Launcher starts in one column mode"
Set the QIconView to adjust its layout on resize
-rw-r--r-- | core/launcher/launcherview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 2783423..dc4c57f 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -177,1025 +177,1025 @@ void LauncherItem::paintAnimatedIcon( QPainter *p ) | |||
177 | { | 177 | { |
178 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 178 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
179 | int pic = iteration % 16; | 179 | int pic = iteration % 16; |
180 | int w = pixmap()->width(), h = pixmap()->height(); | 180 | int w = pixmap()->width(), h = pixmap()->height(); |
181 | QPixmap dblBuf( w, h + 4 ); | 181 | QPixmap dblBuf( w, h + 4 ); |
182 | QPainter p2( &dblBuf ); | 182 | QPainter p2( &dblBuf ); |
183 | int x1, y1; | 183 | int x1, y1; |
184 | if ( liv->itemTextPos() == QIconView::Bottom ) { | 184 | if ( liv->itemTextPos() == QIconView::Bottom ) { |
185 | x1 = x() + (width() - w) / 2 - liv->contentsX(); | 185 | x1 = x() + (width() - w) / 2 - liv->contentsX(); |
186 | y1 = y() - liv->contentsY(); | 186 | y1 = y() - liv->contentsY(); |
187 | } else { | 187 | } else { |
188 | x1 = x() - liv->contentsX(); | 188 | x1 = x() - liv->contentsX(); |
189 | y1 = y() + (height() - h) / 2 - liv->contentsY(); | 189 | y1 = y() + (height() - h) / 2 - liv->contentsY(); |
190 | } | 190 | } |
191 | y1 -= 2; | 191 | y1 -= 2; |
192 | p2.translate(-x1,-y1); | 192 | p2.translate(-x1,-y1); |
193 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); | 193 | liv->drawBackground( &p2, QRect(x1,y1,w,h+4) ); |
194 | int bounceY = 2; | 194 | int bounceY = 2; |
195 | #ifdef BOUNCE_BUSY_ICON | 195 | #ifdef BOUNCE_BUSY_ICON |
196 | if ( busyType == BIT_Animated ) { | 196 | if ( busyType == BIT_Animated ) { |
197 | bounceY = 4 - ((iteration+2)%8); | 197 | bounceY = 4 - ((iteration+2)%8); |
198 | bounceY = bounceY < 0 ? -bounceY : bounceY; | 198 | bounceY = bounceY < 0 ? -bounceY : bounceY; |
199 | } | 199 | } |
200 | #endif | 200 | #endif |
201 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); | 201 | p2.drawPixmap( x1, y1 + bounceY, *pixmap() ); |
202 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 202 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
203 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); | 203 | p2.drawPixmap( x1, y1 + bounceY, liv->busyPixmap(), w * pic, 0, w, h ); |
204 | #else | 204 | #else |
205 | Q_UNUSED( pic ) | 205 | Q_UNUSED( pic ) |
206 | #endif | 206 | #endif |
207 | p->drawPixmap( x1, y1, dblBuf ); | 207 | p->drawPixmap( x1, y1, dblBuf ); |
208 | } | 208 | } |
209 | 209 | ||
210 | void LauncherItem::animateIcon() | 210 | void LauncherItem::animateIcon() |
211 | { | 211 | { |
212 | LauncherIconView* liv = (LauncherIconView*)iconView(); | 212 | LauncherIconView* liv = (LauncherIconView*)iconView(); |
213 | 213 | ||
214 | if ( liv->busyItem() != this || !app ) | 214 | if ( liv->busyItem() != this || !app ) |
215 | return; | 215 | return; |
216 | 216 | ||
217 | // Highlight the icon | 217 | // Highlight the icon |
218 | if ( iteration == 0 ) { | 218 | if ( iteration == 0 ) { |
219 | QPixmap src; | 219 | QPixmap src; |
220 | pixiter it; | 220 | pixiter it; |
221 | if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) { | 221 | if (isEyeImage() && (it=LauncherIconView::sm_EyeCache->find(appLnk()->file()))!=LauncherIconView::sm_EyeCache->end()) { |
222 | src = (*it); | 222 | src = (*it); |
223 | } else { | 223 | } else { |
224 | src = ((isBigIcon ? app->bigPixmap() : app->pixmap())); | 224 | src = ((isBigIcon ? app->bigPixmap() : app->pixmap())); |
225 | } | 225 | } |
226 | QImage img = src.convertToImage(); | 226 | QImage img = src.convertToImage(); |
227 | QRgb *rgb; | 227 | QRgb *rgb; |
228 | int count; | 228 | int count; |
229 | if ( img.depth() == 32 ) { | 229 | if ( img.depth() == 32 ) { |
230 | rgb = (QRgb*)img.bits(); | 230 | rgb = (QRgb*)img.bits(); |
231 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); | 231 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); |
232 | } else { | 232 | } else { |
233 | rgb = img.colorTable(); | 233 | rgb = img.colorTable(); |
234 | count = img.numColors(); | 234 | count = img.numColors(); |
235 | } | 235 | } |
236 | for ( int r = 0; r < count; r++, rgb++ ) { | 236 | for ( int r = 0; r < count; r++, rgb++ ) { |
237 | #if defined(BRIGHTEN_BUSY_ICON) | 237 | #if defined(BRIGHTEN_BUSY_ICON) |
238 | QColor c(*rgb); | 238 | QColor c(*rgb); |
239 | int h, s, v; | 239 | int h, s, v; |
240 | c.hsv(&h,&s,&v); | 240 | c.hsv(&h,&s,&v); |
241 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); | 241 | c.setHsv(h,QMAX(s-24,0),QMIN(v+48,255)); |
242 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); | 242 | *rgb = qRgba(c.red(),c.green(),c.blue(),qAlpha(*rgb)); |
243 | #elif defined(ALPHA_FADE_BUSY_ICON) | 243 | #elif defined(ALPHA_FADE_BUSY_ICON) |
244 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); | 244 | *rgb = qRgba(qRed(*rgb),qGreen(*rgb),qBlue(*rgb),qAlpha(*rgb)/2); |
245 | #endif | 245 | #endif |
246 | } | 246 | } |
247 | src.convertFromImage( img ); | 247 | src.convertFromImage( img ); |
248 | setPixmap( src ); | 248 | setPixmap( src ); |
249 | } | 249 | } |
250 | 250 | ||
251 | iteration++; | 251 | iteration++; |
252 | 252 | ||
253 | // Paint animation overlay | 253 | // Paint animation overlay |
254 | QPainter p( liv->viewport() ); | 254 | QPainter p( liv->viewport() ); |
255 | paintAnimatedIcon( &p ); | 255 | paintAnimatedIcon( &p ); |
256 | } | 256 | } |
257 | 257 | ||
258 | void LauncherItem::resetIcon() | 258 | void LauncherItem::resetIcon() |
259 | { | 259 | { |
260 | iteration = 0; | 260 | iteration = 0; |
261 | if (isEyeImage()) { | 261 | if (isEyeImage()) { |
262 | QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file()); | 262 | QMap<QString,QPixmap>::Iterator it = LauncherIconView::sm_EyeCache->find(appLnk()->file()); |
263 | if (it != LauncherIconView::sm_EyeCache->end()) { | 263 | if (it != LauncherIconView::sm_EyeCache->end()) { |
264 | setPixmap(*it); | 264 | setPixmap(*it); |
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | } | 267 | } |
268 | setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap()); | 268 | setPixmap(isBigIcon ? app->bigPixmap() : app->pixmap()); |
269 | } | 269 | } |
270 | 270 | ||
271 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) | 271 | void LauncherItem::setEyePixmap(const QPixmap&aIcon) |
272 | { | 272 | { |
273 | if (!isEyeImage()) return; | 273 | if (!isEyeImage()) return; |
274 | setPixmap(aIcon); | 274 | setPixmap(aIcon); |
275 | m_EyeImageSet = EYE_ICON; | 275 | m_EyeImageSet = EYE_ICON; |
276 | } | 276 | } |
277 | 277 | ||
278 | //=========================================================================== | 278 | //=========================================================================== |
279 | // Implemantation of LauncherIconview start | 279 | // Implemantation of LauncherIconview start |
280 | //=========================================================================== | 280 | //=========================================================================== |
281 | 281 | ||
282 | QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; | 282 | QMap<QString,QPixmap>* LauncherIconView::sm_EyeCache=0; |
283 | 283 | ||
284 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) | 284 | LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) |
285 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) | 285 | : QIconView(parent,name),tf(""),cf(0),bsy(0),busyTimer(0),bigIcns(TRUE),bgColor(white) |
286 | { | 286 | { |
287 | m_EyeCallBack = 0; | 287 | m_EyeCallBack = 0; |
288 | if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); | 288 | if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); |
289 | sortmeth = Name; | 289 | sortmeth = Name; |
290 | hidden.setAutoDelete(TRUE); | 290 | hidden.setAutoDelete(TRUE); |
291 | ike = FALSE; | 291 | ike = FALSE; |
292 | calculateGrid( Bottom ); | 292 | calculateGrid( Bottom ); |
293 | connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); | 293 | connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); |
294 | } | 294 | } |
295 | 295 | ||
296 | LauncherIconView::~LauncherIconView() | 296 | LauncherIconView::~LauncherIconView() |
297 | { | 297 | { |
298 | odebug << "LauncherIconView::~LauncherIconView()" << oendl; | 298 | odebug << "LauncherIconView::~LauncherIconView()" << oendl; |
299 | #if 0 // debuggery | 299 | #if 0 // debuggery |
300 | QListIterator<AppLnk> it(hidden); | 300 | QListIterator<AppLnk> it(hidden); |
301 | AppLnk* l; | 301 | AppLnk* l; |
302 | while ((l=it.current())) { | 302 | while ((l=it.current())) { |
303 | ++it; | 303 | ++it; |
304 | //odebug << "" << l << ": hidden (should remove)" << oendl; | 304 | //odebug << "" << l << ": hidden (should remove)" << oendl; |
305 | } | 305 | } |
306 | #endif | 306 | #endif |
307 | } | 307 | } |
308 | 308 | ||
309 | int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) | 309 | int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) |
310 | { | 310 | { |
311 | switch (sortmeth) { | 311 | switch (sortmeth) { |
312 | case Name: | 312 | case Name: |
313 | return a->name().lower().compare(b->name().lower()); | 313 | return a->name().lower().compare(b->name().lower()); |
314 | case Date: { | 314 | case Date: { |
315 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); | 315 | QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); |
316 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); | 316 | QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); |
317 | return fa.lastModified().secsTo(fb.lastModified()); | 317 | return fa.lastModified().secsTo(fb.lastModified()); |
318 | } | 318 | } |
319 | case Type: | 319 | case Type: |
320 | return a->type().compare(b->type()); | 320 | return a->type().compare(b->type()); |
321 | } | 321 | } |
322 | return 0; | 322 | return 0; |
323 | } | 323 | } |
324 | 324 | ||
325 | void LauncherIconView::setSortMethod( SortMethod m ) | 325 | void LauncherIconView::setSortMethod( SortMethod m ) |
326 | { | 326 | { |
327 | if ( sortmeth != m ) { | 327 | if ( sortmeth != m ) { |
328 | sortmeth = m; | 328 | sortmeth = m; |
329 | sort(); | 329 | sort(); |
330 | } | 330 | } |
331 | } | 331 | } |
332 | 332 | ||
333 | void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) | 333 | void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) |
334 | { | 334 | { |
335 | if ( catfilter == -2 ) | 335 | if ( catfilter == -2 ) |
336 | cf = 0; | 336 | cf = 0; |
337 | else | 337 | else |
338 | cf = catfilter; | 338 | cf = catfilter; |
339 | hideOrShowItems(resort); | 339 | hideOrShowItems(resort); |
340 | } | 340 | } |
341 | 341 | ||
342 | void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) | 342 | void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) |
343 | { | 343 | { |
344 | tf = QRegExp(typefilter,FALSE,TRUE); | 344 | tf = QRegExp(typefilter,FALSE,TRUE); |
345 | hideOrShowItems(resort); | 345 | hideOrShowItems(resort); |
346 | } | 346 | } |
347 | 347 | ||
348 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) | 348 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) |
349 | { | 349 | { |
350 | calculateGrid( pos ); | 350 | calculateGrid( pos ); |
351 | QIconView::setItemTextPos( pos ); | 351 | QIconView::setItemTextPos( pos ); |
352 | } | 352 | } |
353 | 353 | ||
354 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) | 354 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) |
355 | { | 355 | { |
356 | if ( !bgPixmap.isNull() ) { | 356 | if ( !bgPixmap.isNull() ) { |
357 | p->drawTiledPixmap( r, bgPixmap, | 357 | p->drawTiledPixmap( r, bgPixmap, |
358 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), | 358 | QPoint( (r.x() + contentsX()) % bgPixmap.width(), |
359 | (r.y() + contentsY()) % bgPixmap.height() ) ); | 359 | (r.y() + contentsY()) % bgPixmap.height() ) ); |
360 | } else { | 360 | } else { |
361 | p->fillRect( r, bgColor ); | 361 | p->fillRect( r, bgColor ); |
362 | } | 362 | } |
363 | } | 363 | } |
364 | 364 | ||
365 | void LauncherIconView::addCatsAndMimes(AppLnk* app) | 365 | void LauncherIconView::addCatsAndMimes(AppLnk* app) |
366 | { | 366 | { |
367 | // QStringList c = app->categories(); | 367 | // QStringList c = app->categories(); |
368 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { | 368 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { |
369 | // cats.replace(*cit,(void*)1); | 369 | // cats.replace(*cit,(void*)1); |
370 | // } | 370 | // } |
371 | QString maj=app->type(); | 371 | QString maj=app->type(); |
372 | int sl=maj.find('/'); | 372 | int sl=maj.find('/'); |
373 | if (sl>=0) { | 373 | if (sl>=0) { |
374 | QString k; | 374 | QString k; |
375 | k = maj.left(12) == "application/" ? maj : maj.left(sl); | 375 | k = maj.left(12) == "application/" ? maj : maj.left(sl); |
376 | mimes.replace(k,(void*)1); | 376 | mimes.replace(k,(void*)1); |
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | void LauncherIconView::setBusy(bool on) | 380 | void LauncherIconView::setBusy(bool on) |
381 | { | 381 | { |
382 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 382 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
383 | if ( busyPix.isNull() ) { | 383 | if ( busyPix.isNull() ) { |
384 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 384 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
385 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); | 385 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); |
386 | } | 386 | } |
387 | #endif | 387 | #endif |
388 | 388 | ||
389 | if ( on ) { | 389 | if ( on ) { |
390 | busyTimer = startTimer( 100 ); | 390 | busyTimer = startTimer( 100 ); |
391 | } else { | 391 | } else { |
392 | if ( busyTimer ) { | 392 | if ( busyTimer ) { |
393 | killTimer( busyTimer ); | 393 | killTimer( busyTimer ); |
394 | busyTimer = 0; | 394 | busyTimer = 0; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | 397 | ||
398 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; | 398 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; |
399 | 399 | ||
400 | if ( bsy != c ) { | 400 | if ( bsy != c ) { |
401 | LauncherItem *oldBusy = bsy; | 401 | LauncherItem *oldBusy = bsy; |
402 | bsy = c; | 402 | bsy = c; |
403 | if ( oldBusy ) { | 403 | if ( oldBusy ) { |
404 | oldBusy->resetIcon(); | 404 | oldBusy->resetIcon(); |
405 | } | 405 | } |
406 | if ( bsy ) { | 406 | if ( bsy ) { |
407 | bsy->setBusyIndicatorType( busyType ) ; | 407 | bsy->setBusyIndicatorType( busyType ) ; |
408 | bsy->animateIcon(); | 408 | bsy->animateIcon(); |
409 | } | 409 | } |
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | void LauncherIconView::clear() | 413 | void LauncherIconView::clear() |
414 | { | 414 | { |
415 | mimes.clear(); | 415 | mimes.clear(); |
416 | cats.clear(); | 416 | cats.clear(); |
417 | QIconView::clear(); | 417 | QIconView::clear(); |
418 | hidden.clear(); | 418 | hidden.clear(); |
419 | } | 419 | } |
420 | 420 | ||
421 | QStringList LauncherIconView::mimeTypes() const | 421 | QStringList LauncherIconView::mimeTypes() const |
422 | { | 422 | { |
423 | QStringList r; | 423 | QStringList r; |
424 | QDictIterator<void> it(mimes); | 424 | QDictIterator<void> it(mimes); |
425 | while (it.current()) { | 425 | while (it.current()) { |
426 | r.append(it.currentKey()); | 426 | r.append(it.currentKey()); |
427 | ++it; | 427 | ++it; |
428 | } | 428 | } |
429 | r.sort(); | 429 | r.sort(); |
430 | return r; | 430 | return r; |
431 | } | 431 | } |
432 | 432 | ||
433 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) | 433 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) |
434 | { | 434 | { |
435 | LauncherItem* item = (LauncherItem*)firstItem(); | 435 | LauncherItem* item = (LauncherItem*)firstItem(); |
436 | while (item) { | 436 | while (item) { |
437 | if (item->appLnk()->file()==fname) { | 437 | if (item->appLnk()->file()==fname) { |
438 | break; | 438 | break; |
439 | } | 439 | } |
440 | item = (LauncherItem*)item->nextItem(); | 440 | item = (LauncherItem*)item->nextItem(); |
441 | } | 441 | } |
442 | return item; | 442 | return item; |
443 | } | 443 | } |
444 | 444 | ||
445 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) | 445 | void LauncherIconView::setEyePixmap(const QPixmap&aPixmap,const QString&aFile,int width) |
446 | { | 446 | { |
447 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 447 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
448 | if (s!=width) return; | 448 | if (s!=width) return; |
449 | LauncherItem*item = findDocItem(aFile); | 449 | LauncherItem*item = findDocItem(aFile); |
450 | if (!item||!item->isEyeImage()) return; | 450 | if (!item||!item->isEyeImage()) return; |
451 | (*sm_EyeCache)[aFile]=aPixmap; | 451 | (*sm_EyeCache)[aFile]=aPixmap; |
452 | item->setEyePixmap(aPixmap); | 452 | item->setEyePixmap(aPixmap); |
453 | } | 453 | } |
454 | 454 | ||
455 | void LauncherIconView::checkCallback() | 455 | void LauncherIconView::checkCallback() |
456 | { | 456 | { |
457 | if (!m_EyeCallBack) { | 457 | if (!m_EyeCallBack) { |
458 | m_EyeCallBack = new LauncherThumbReceiver(); | 458 | m_EyeCallBack = new LauncherThumbReceiver(); |
459 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), | 459 | connect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), |
460 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); | 460 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); |
461 | } | 461 | } |
462 | m_eyeTimer.changeInterval(600000); | 462 | m_eyeTimer.changeInterval(600000); |
463 | } | 463 | } |
464 | 464 | ||
465 | void LauncherIconView::addCheckItem(AppLnk* app) | 465 | void LauncherIconView::addCheckItem(AppLnk* app) |
466 | { | 466 | { |
467 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); | 467 | LauncherItem*item = new LauncherItem( this, app, bigIcns ); |
468 | if (item->isEyeImage()) { | 468 | if (item->isEyeImage()) { |
469 | checkCallback(); | 469 | checkCallback(); |
470 | } | 470 | } |
471 | } | 471 | } |
472 | 472 | ||
473 | void LauncherIconView::requestEyePix(const LauncherItem*item) | 473 | void LauncherIconView::requestEyePix(const LauncherItem*item) |
474 | { | 474 | { |
475 | if (!item) return; | 475 | if (!item) return; |
476 | if (item->isEyeImage()) { | 476 | if (item->isEyeImage()) { |
477 | checkCallback(); | 477 | checkCallback(); |
478 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 478 | int s = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
479 | m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); | 479 | m_EyeCallBack->requestThumb(item->appLnk()->file(),s,s); |
480 | } | 480 | } |
481 | } | 481 | } |
482 | 482 | ||
483 | void LauncherIconView::stopEyeTimer() | 483 | void LauncherIconView::stopEyeTimer() |
484 | { | 484 | { |
485 | if (m_EyeCallBack) { | 485 | if (m_EyeCallBack) { |
486 | disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), | 486 | disconnect(m_EyeCallBack,SIGNAL(sig_Thumbnail(const QPixmap&,const QString&,int)), |
487 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); | 487 | this,SLOT(setEyePixmap(const QPixmap&,const QString&,int))); |
488 | delete m_EyeCallBack; | 488 | delete m_EyeCallBack; |
489 | m_EyeCallBack=0; | 489 | m_EyeCallBack=0; |
490 | } | 490 | } |
491 | m_eyeTimer.stop(); | 491 | m_eyeTimer.stop(); |
492 | } | 492 | } |
493 | 493 | ||
494 | void LauncherIconView::updateCategoriesAndMimeTypes() | 494 | void LauncherIconView::updateCategoriesAndMimeTypes() |
495 | { | 495 | { |
496 | mimes.clear(); | 496 | mimes.clear(); |
497 | cats.clear(); | 497 | cats.clear(); |
498 | LauncherItem* item = (LauncherItem*)firstItem(); | 498 | LauncherItem* item = (LauncherItem*)firstItem(); |
499 | while (item) { | 499 | while (item) { |
500 | addCatsAndMimes(item->appLnk()); | 500 | addCatsAndMimes(item->appLnk()); |
501 | item = (LauncherItem*)item->nextItem(); | 501 | item = (LauncherItem*)item->nextItem(); |
502 | } | 502 | } |
503 | QListIterator<AppLnk> it(hidden); | 503 | QListIterator<AppLnk> it(hidden); |
504 | AppLnk* l; | 504 | AppLnk* l; |
505 | while ((l=it.current())) { | 505 | while ((l=it.current())) { |
506 | addCatsAndMimes(l); | 506 | addCatsAndMimes(l); |
507 | ++it; | 507 | ++it; |
508 | } | 508 | } |
509 | } | 509 | } |
510 | 510 | ||
511 | void LauncherIconView::hideOrShowItems(bool resort) | 511 | void LauncherIconView::hideOrShowItems(bool resort) |
512 | { | 512 | { |
513 | viewport()->setUpdatesEnabled( FALSE ); | 513 | viewport()->setUpdatesEnabled( FALSE ); |
514 | hidden.setAutoDelete(FALSE); | 514 | hidden.setAutoDelete(FALSE); |
515 | QList<AppLnk> links=hidden; | 515 | QList<AppLnk> links=hidden; |
516 | hidden.clear(); | 516 | hidden.clear(); |
517 | hidden.setAutoDelete(TRUE); | 517 | hidden.setAutoDelete(TRUE); |
518 | LauncherItem* item = (LauncherItem*)firstItem(); | 518 | LauncherItem* item = (LauncherItem*)firstItem(); |
519 | while (item) { | 519 | while (item) { |
520 | links.append(item->takeAppLnk()); | 520 | links.append(item->takeAppLnk()); |
521 | item = (LauncherItem*)item->nextItem(); | 521 | item = (LauncherItem*)item->nextItem(); |
522 | } | 522 | } |
523 | clear(); | 523 | clear(); |
524 | QListIterator<AppLnk> it(links); | 524 | QListIterator<AppLnk> it(links); |
525 | AppLnk* l; | 525 | AppLnk* l; |
526 | while ((l=it.current())) { | 526 | while ((l=it.current())) { |
527 | addItem(l,FALSE); | 527 | addItem(l,FALSE); |
528 | ++it; | 528 | ++it; |
529 | } | 529 | } |
530 | if ( resort && !autoArrange() ) | 530 | if ( resort && !autoArrange() ) |
531 | sort(); | 531 | sort(); |
532 | viewport()->setUpdatesEnabled( TRUE ); | 532 | viewport()->setUpdatesEnabled( TRUE ); |
533 | } | 533 | } |
534 | 534 | ||
535 | bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache) | 535 | bool LauncherIconView::removeLink(const QString& linkfile,bool removeCache) |
536 | { | 536 | { |
537 | LauncherItem* item = (LauncherItem*)firstItem(); | 537 | LauncherItem* item = (LauncherItem*)firstItem(); |
538 | AppLnk* l; | 538 | AppLnk* l; |
539 | bool did = FALSE; | 539 | bool did = FALSE; |
540 | DocLnk dl(linkfile); | 540 | DocLnk dl(linkfile); |
541 | while (item) { | 541 | while (item) { |
542 | l = item->appLnk(); | 542 | l = item->appLnk(); |
543 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); | 543 | LauncherItem *nextItem = (LauncherItem *)item->nextItem(); |
544 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && | 544 | if ( l->linkFileKnown() && l->linkFile() == linkfile || l->fileKnown() && |
545 | ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { | 545 | ( l->file() == linkfile || dl.isValid() && dl.file() == l->file() ) ) { |
546 | if (removeCache) sm_EyeCache->remove(l->file()); | 546 | if (removeCache) sm_EyeCache->remove(l->file()); |
547 | delete item; | 547 | delete item; |
548 | did = TRUE; | 548 | did = TRUE; |
549 | } | 549 | } |
550 | item = nextItem; | 550 | item = nextItem; |
551 | } | 551 | } |
552 | QListIterator<AppLnk> it(hidden); | 552 | QListIterator<AppLnk> it(hidden); |
553 | while ((l=it.current())) { | 553 | while ((l=it.current())) { |
554 | ++it; | 554 | ++it; |
555 | if ( l->linkFileKnown() && l->linkFile() == linkfile | 555 | if ( l->linkFileKnown() && l->linkFile() == linkfile |
556 | || l->file() == linkfile | 556 | || l->file() == linkfile |
557 | || dl.isValid() && dl.file() == l->file() ) { | 557 | || dl.isValid() && dl.file() == l->file() ) { |
558 | hidden.removeRef(l); | 558 | hidden.removeRef(l); |
559 | did = TRUE; | 559 | did = TRUE; |
560 | } | 560 | } |
561 | } | 561 | } |
562 | return did; | 562 | return did; |
563 | } | 563 | } |
564 | 564 | ||
565 | void LauncherIconView::addItem(AppLnk* app, bool resort) | 565 | void LauncherIconView::addItem(AppLnk* app, bool resort) |
566 | { | 566 | { |
567 | addCatsAndMimes(app); | 567 | addCatsAndMimes(app); |
568 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) | 568 | if ( (tf.isEmpty() || tf.match(app->type()) >= 0) |
569 | && (cf == 0 || app->categories().contains(cf) | 569 | && (cf == 0 || app->categories().contains(cf) |
570 | || cf == -1 && app->categories().count() == 0 ) ) { | 570 | || cf == -1 && app->categories().count() == 0 ) ) { |
571 | addCheckItem(app); | 571 | addCheckItem(app); |
572 | } else { | 572 | } else { |
573 | hidden.append(app); | 573 | hidden.append(app); |
574 | } | 574 | } |
575 | if ( resort ){ | 575 | if ( resort ){ |
576 | sort(); | 576 | sort(); |
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||
580 | void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink) | 580 | void LauncherIconView::changeItem(const AppLnk&old,AppLnk*nlink) |
581 | { | 581 | { |
582 | QString oldfile = old.file(); | 582 | QString oldfile = old.file(); |
583 | QString newfile = nlink->file(); | 583 | QString newfile = nlink->file(); |
584 | 584 | ||
585 | if (newfile != oldfile) { | 585 | if (newfile != oldfile) { |
586 | QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile); | 586 | QMap<QString,QPixmap>::Iterator it = sm_EyeCache->find(oldfile); |
587 | if (it != sm_EyeCache->end()) { | 587 | if (it != sm_EyeCache->end()) { |
588 | (*sm_EyeCache)[newfile]=(*it); | 588 | (*sm_EyeCache)[newfile]=(*it); |
589 | } | 589 | } |
590 | removeLink(old.linkFile()); | 590 | removeLink(old.linkFile()); |
591 | } else { | 591 | } else { |
592 | removeLink(old.linkFile(),false); | 592 | removeLink(old.linkFile(),false); |
593 | } | 593 | } |
594 | addItem(nlink,false); | 594 | addItem(nlink,false); |
595 | } | 595 | } |
596 | 596 | ||
597 | void LauncherIconView::timerEvent( QTimerEvent *te ) | 597 | void LauncherIconView::timerEvent( QTimerEvent *te ) |
598 | { | 598 | { |
599 | if ( te->timerId() == busyTimer ) { | 599 | if ( te->timerId() == busyTimer ) { |
600 | if ( bsy ) | 600 | if ( bsy ) |
601 | bsy->animateIcon(); | 601 | bsy->animateIcon(); |
602 | } else { | 602 | } else { |
603 | QIconView::timerEvent( te ); | 603 | QIconView::timerEvent( te ); |
604 | } | 604 | } |
605 | } | 605 | } |
606 | 606 | ||
607 | void LauncherIconView::setBigIcons( bool bi ) | 607 | void LauncherIconView::setBigIcons( bool bi ) |
608 | { | 608 | { |
609 | sm_EyeCache->clear(); | 609 | sm_EyeCache->clear(); |
610 | bigIcns = bi; | 610 | bigIcns = bi; |
611 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 611 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
612 | busyPix.resize(0,0); | 612 | busyPix.resize(0,0); |
613 | #endif | 613 | #endif |
614 | } | 614 | } |
615 | 615 | ||
616 | QIconViewItem* LauncherIconView::busyItem() const | 616 | QIconViewItem* LauncherIconView::busyItem() const |
617 | { | 617 | { |
618 | return bsy; | 618 | return bsy; |
619 | } | 619 | } |
620 | 620 | ||
621 | void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | 621 | void LauncherIconView::setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } |
622 | 622 | ||
623 | void LauncherIconView::calculateGrid( ItemTextPos pos ) | 623 | void LauncherIconView::calculateGrid( ItemTextPos pos ) |
624 | { | 624 | { |
625 | int dw = QApplication::desktop()->width(); | 625 | int dw = QApplication::desktop()->width(); |
626 | int viewerWidth = dw-style().scrollBarExtent().width(); | 626 | int viewerWidth = dw-style().scrollBarExtent().width(); |
627 | if ( pos == Bottom ) { | 627 | if ( pos == Bottom ) { |
628 | int cols = 3; | 628 | int cols = 3; |
629 | if ( viewerWidth <= 200 ) | 629 | if ( viewerWidth <= 200 ) |
630 | cols = 2; | 630 | cols = 2; |
631 | else if ( viewerWidth >= 400 ) | 631 | else if ( viewerWidth >= 400 ) |
632 | cols = viewerWidth/96; | 632 | cols = viewerWidth/96; |
633 | setSpacing( 4 ); | 633 | setSpacing( 4 ); |
634 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 634 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
635 | setGridY( fontMetrics().height()*2+24 ); | 635 | setGridY( fontMetrics().height()*2+24 ); |
636 | } else { | 636 | } else { |
637 | int cols = 2; | 637 | int cols = 2; |
638 | if ( viewerWidth < 150 ) | 638 | if ( viewerWidth < 150 ) |
639 | cols = 1; | 639 | cols = 1; |
640 | else if ( viewerWidth >= 400 ) | 640 | else if ( viewerWidth >= 400 ) |
641 | cols = viewerWidth/150; | 641 | cols = viewerWidth/150; |
642 | setSpacing( 2 ); | 642 | setSpacing( 2 ); |
643 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 643 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
644 | setGridY( fontMetrics().height()+2 ); | 644 | setGridY( fontMetrics().height()+2 ); |
645 | } | 645 | } |
646 | } | 646 | } |
647 | 647 | ||
648 | void LauncherIconView::styleChange( QStyle &old ) | 648 | void LauncherIconView::styleChange( QStyle &old ) |
649 | { | 649 | { |
650 | QIconView::styleChange( old ); | 650 | QIconView::styleChange( old ); |
651 | calculateGrid( itemTextPos() ); | 651 | calculateGrid( itemTextPos() ); |
652 | } | 652 | } |
653 | 653 | ||
654 | void LauncherIconView::keyPressEvent(QKeyEvent* e) | 654 | void LauncherIconView::keyPressEvent(QKeyEvent* e) |
655 | { | 655 | { |
656 | ike = TRUE; | 656 | ike = TRUE; |
657 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { | 657 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) { |
658 | if ( (e->state() & ShiftButton) ) | 658 | if ( (e->state() & ShiftButton) ) |
659 | emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); | 659 | emit mouseButtonPressed(ShiftButton, currentItem(), QPoint() ); |
660 | else | 660 | else |
661 | returnPressed(currentItem()); | 661 | returnPressed(currentItem()); |
662 | } | 662 | } |
663 | 663 | ||
664 | QIconView::keyPressEvent(e); | 664 | QIconView::keyPressEvent(e); |
665 | ike = FALSE; | 665 | ike = FALSE; |
666 | } | 666 | } |
667 | 667 | ||
668 | //=========================================================================== | 668 | //=========================================================================== |
669 | // Implemantation of LauncherIconview end | 669 | // Implemantation of LauncherIconview end |
670 | //=========================================================================== | 670 | //=========================================================================== |
671 | 671 | ||
672 | 672 | ||
673 | //=========================================================================== | 673 | //=========================================================================== |
674 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) | 674 | LauncherView::LauncherView( QWidget* parent, const char* name, WFlags fl ) |
675 | : QVBox( parent, name, fl ) | 675 | : QVBox( parent, name, fl ) |
676 | { | 676 | { |
677 | catmb = 0; | 677 | catmb = 0; |
678 | icons = new LauncherIconView( this ); | 678 | icons = new LauncherIconView( this ); |
679 | setFocusProxy(icons); | 679 | setFocusProxy(icons); |
680 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); | 680 | QPEApplication::setStylusOperation( icons->viewport(), QPEApplication::RightOnHold ); |
681 | 681 | ||
682 | icons->setItemsMovable( FALSE ); | 682 | icons->setItemsMovable( FALSE ); |
683 | icons->setAutoArrange( TRUE ); | 683 | icons->setAutoArrange( TRUE ); |
684 | icons->setSorting( TRUE ); | 684 | icons->setSorting( TRUE ); |
685 | icons->setFrameStyle( QFrame::NoFrame ); | 685 | icons->setFrameStyle( QFrame::NoFrame ); |
686 | icons->setMargin( 0 ); | 686 | icons->setMargin( 0 ); |
687 | icons->setSelectionMode( QIconView::NoSelection ); | 687 | icons->setSelectionMode( QIconView::NoSelection ); |
688 | icons->setBackgroundMode( PaletteBase ); | 688 | icons->setBackgroundMode( PaletteBase ); |
689 | icons->setResizeMode( QIconView::Fixed ); | 689 | icons->setResizeMode( QIconView::Adjust ); |
690 | vmode = (ViewMode)-1; | 690 | vmode = (ViewMode)-1; |
691 | setViewMode( Icon ); | 691 | setViewMode( Icon ); |
692 | 692 | ||
693 | connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), | 693 | connect( icons, SIGNAL(mouseButtonClicked(int,QIconViewItem*,const QPoint&)), |
694 | SLOT(itemClicked(int,QIconViewItem*)) ); | 694 | SLOT(itemClicked(int,QIconViewItem*)) ); |
695 | connect( icons, SIGNAL(selectionChanged()), | 695 | connect( icons, SIGNAL(selectionChanged()), |
696 | SLOT(selectionChanged()) ); | 696 | SLOT(selectionChanged()) ); |
697 | connect( icons, SIGNAL(returnPressed(QIconViewItem*)), | 697 | connect( icons, SIGNAL(returnPressed(QIconViewItem*)), |
698 | SLOT(returnPressed(QIconViewItem*)) ); | 698 | SLOT(returnPressed(QIconViewItem*)) ); |
699 | connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), | 699 | connect( icons, SIGNAL(mouseButtonPressed(int,QIconViewItem*,const QPoint&)), |
700 | SLOT(itemPressed(int,QIconViewItem*)) ); | 700 | SLOT(itemPressed(int,QIconViewItem*)) ); |
701 | 701 | ||
702 | tools = 0; | 702 | tools = 0; |
703 | setBackgroundType( Ruled, QString::null ); | 703 | setBackgroundType( Ruled, QString::null ); |
704 | } | 704 | } |
705 | 705 | ||
706 | LauncherView::~LauncherView() | 706 | LauncherView::~LauncherView() |
707 | { | 707 | { |
708 | if ( bgCache && bgCache->contains( bgName ) ) | 708 | if ( bgCache && bgCache->contains( bgName ) ) |
709 | (*bgCache)[bgName]->ref--; | 709 | (*bgCache)[bgName]->ref--; |
710 | } | 710 | } |
711 | 711 | ||
712 | 712 | ||
713 | bool LauncherView::bsy=FALSE; | 713 | bool LauncherView::bsy=FALSE; |
714 | 714 | ||
715 | void LauncherView::setBusy(bool on) | 715 | void LauncherView::setBusy(bool on) |
716 | { | 716 | { |
717 | icons->setBusy(on); | 717 | icons->setBusy(on); |
718 | } | 718 | } |
719 | 719 | ||
720 | void LauncherView::setBusyIndicatorType( const QString& type ) { | 720 | void LauncherView::setBusyIndicatorType( const QString& type ) { |
721 | if ( type. lower ( ) == "animated" ) | 721 | if ( type. lower ( ) == "animated" ) |
722 | icons->setBusyIndicatorType( BIT_Animated ) ; | 722 | icons->setBusyIndicatorType( BIT_Animated ) ; |
723 | else | 723 | else |
724 | icons->setBusyIndicatorType( BIT_Normal ) ; | 724 | icons->setBusyIndicatorType( BIT_Normal ) ; |
725 | } | 725 | } |
726 | 726 | ||
727 | void LauncherView::hideIcons() | 727 | void LauncherView::hideIcons() |
728 | { | 728 | { |
729 | icons->hide(); | 729 | icons->hide(); |
730 | } | 730 | } |
731 | 731 | ||
732 | void LauncherView::setToolsEnabled(bool y) | 732 | void LauncherView::setToolsEnabled(bool y) |
733 | { | 733 | { |
734 | if ( !y != !tools ) { | 734 | if ( !y != !tools ) { |
735 | if ( y ) { | 735 | if ( y ) { |
736 | tools = new QHBox(this); | 736 | tools = new QHBox(this); |
737 | // Type filter | 737 | // Type filter |
738 | typemb = new QComboBox(tools); | 738 | typemb = new QComboBox(tools); |
739 | QSizePolicy p = typemb->sizePolicy(); | 739 | QSizePolicy p = typemb->sizePolicy(); |
740 | p.setHorData(QSizePolicy::Expanding); | 740 | p.setHorData(QSizePolicy::Expanding); |
741 | typemb->setSizePolicy(p); | 741 | typemb->setSizePolicy(p); |
742 | // Category filter | 742 | // Category filter |
743 | updateTools(); | 743 | updateTools(); |
744 | tools->show(); | 744 | tools->show(); |
745 | } else { | 745 | } else { |
746 | delete tools; | 746 | delete tools; |
747 | tools = 0; | 747 | tools = 0; |
748 | } | 748 | } |
749 | } | 749 | } |
750 | } | 750 | } |
751 | 751 | ||
752 | void LauncherView::updateTools() | 752 | void LauncherView::updateTools() |
753 | { | 753 | { |
754 | disconnect( typemb, SIGNAL(activated(int)), | 754 | disconnect( typemb, SIGNAL(activated(int)), |
755 | this, SLOT(showType(int)) ); | 755 | this, SLOT(showType(int)) ); |
756 | if ( catmb ) { | 756 | if ( catmb ) { |
757 | disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int))); | 757 | disconnect( catmb, SIGNAL(signalSelected(int)),this,SLOT(showCategory(int))); |
758 | } | 758 | } |
759 | 759 | ||
760 | // ### I want to remove this | 760 | // ### I want to remove this |
761 | icons->updateCategoriesAndMimeTypes(); | 761 | icons->updateCategoriesAndMimeTypes(); |
762 | 762 | ||
763 | QString prev; | 763 | QString prev; |
764 | 764 | ||
765 | // Type filter | 765 | // Type filter |
766 | QStringList types; | 766 | QStringList types; |
767 | typelist = icons->mimeTypes(); | 767 | typelist = icons->mimeTypes(); |
768 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { | 768 | for (QStringList::ConstIterator it = typelist.begin(); it!=typelist.end(); ++it) { |
769 | QString t = *it; | 769 | QString t = *it; |
770 | if ( t.left(12) == "application/" ) { | 770 | if ( t.left(12) == "application/" ) { |
771 | MimeType mt(t); | 771 | MimeType mt(t); |
772 | const AppLnk* app = mt.application(); | 772 | const AppLnk* app = mt.application(); |
773 | if ( app ) | 773 | if ( app ) |
774 | t = app->name(); | 774 | t = app->name(); |
775 | else | 775 | else |
776 | t = t.mid(12); | 776 | t = t.mid(12); |
777 | } else { | 777 | } else { |
778 | t[0] = t[0].upper(); | 778 | t[0] = t[0].upper(); |
779 | } | 779 | } |
780 | types += t; | 780 | types += t; |
781 | } | 781 | } |
782 | types << tr("All types"); | 782 | types << tr("All types"); |
783 | prev = typemb->currentText(); | 783 | prev = typemb->currentText(); |
784 | typemb->clear(); | 784 | typemb->clear(); |
785 | typemb->insertStringList(types); | 785 | typemb->insertStringList(types); |
786 | for (int i=0; i<typemb->count(); i++) { | 786 | for (int i=0; i<typemb->count(); i++) { |
787 | if ( typemb->text(i) == prev ) { | 787 | if ( typemb->text(i) == prev ) { |
788 | typemb->setCurrentItem(i); | 788 | typemb->setCurrentItem(i); |
789 | break; | 789 | break; |
790 | } | 790 | } |
791 | } | 791 | } |
792 | if ( prev.isNull() ) { | 792 | if ( prev.isNull() ) { |
793 | typemb->setCurrentItem(typemb->count()-1); | 793 | typemb->setCurrentItem(typemb->count()-1); |
794 | } | 794 | } |
795 | 795 | ||
796 | int pcat = catmb ? catmb->currentCategory() : -2; | 796 | int pcat = catmb ? catmb->currentCategory() : -2; |
797 | if ( !catmb ) { | 797 | if ( !catmb ) { |
798 | catmb = new CategorySelect(tools); | 798 | catmb = new CategorySelect(tools); |
799 | } else if (pcat!=-2) { | 799 | } else if (pcat!=-2) { |
800 | 800 | ||
801 | } | 801 | } |
802 | Categories cats( 0 ); | 802 | Categories cats( 0 ); |
803 | cats.load( categoryFileName() ); | 803 | cats.load( categoryFileName() ); |
804 | QArray<int> vl( 0 ); | 804 | QArray<int> vl( 0 ); |
805 | catmb->setCategories( vl, "Document View", // No tr | 805 | catmb->setCategories( vl, "Document View", // No tr |
806 | tr("Document View") ); | 806 | tr("Document View") ); |
807 | catmb->setRemoveCategoryEdit( TRUE ); | 807 | catmb->setRemoveCategoryEdit( TRUE ); |
808 | catmb->setAllCategories( TRUE ); | 808 | catmb->setAllCategories( TRUE ); |
809 | catmb->setCurrentCategory(pcat); | 809 | catmb->setCurrentCategory(pcat); |
810 | 810 | ||
811 | // if type has changed we need to redisplay | 811 | // if type has changed we need to redisplay |
812 | if ( typemb->currentText() != prev ) | 812 | if ( typemb->currentText() != prev ) |
813 | showType( typemb->currentItem() ); | 813 | showType( typemb->currentItem() ); |
814 | 814 | ||
815 | connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); | 815 | connect(typemb, SIGNAL(activated(int)), this, SLOT(showType(int))); |
816 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); | 816 | connect(catmb, SIGNAL(signalSelected(int)), this, SLOT(showCategory(int))); |
817 | } | 817 | } |
818 | 818 | ||
819 | void LauncherView::sortBy(int s) | 819 | void LauncherView::sortBy(int s) |
820 | { | 820 | { |
821 | icons->setSortMethod((LauncherIconView::SortMethod)s); | 821 | icons->setSortMethod((LauncherIconView::SortMethod)s); |
822 | } | 822 | } |
823 | 823 | ||
824 | void LauncherView::showType(int t) | 824 | void LauncherView::showType(int t) |
825 | { | 825 | { |
826 | if ( t >= (int)typelist.count() ) { | 826 | if ( t >= (int)typelist.count() ) { |
827 | icons->setTypeFilter("",TRUE); | 827 | icons->setTypeFilter("",TRUE); |
828 | } else { | 828 | } else { |
829 | QString ty = typelist[t]; | 829 | QString ty = typelist[t]; |
830 | if ( !ty.contains('/') ) | 830 | if ( !ty.contains('/') ) |
831 | ty += "/*"; | 831 | ty += "/*"; |
832 | icons->setTypeFilter(ty,TRUE); | 832 | icons->setTypeFilter(ty,TRUE); |
833 | } | 833 | } |
834 | } | 834 | } |
835 | 835 | ||
836 | void LauncherView::showCategory( int c ) | 836 | void LauncherView::showCategory( int c ) |
837 | { | 837 | { |
838 | icons->setCategoryFilter( c, TRUE ); | 838 | icons->setCategoryFilter( c, TRUE ); |
839 | } | 839 | } |
840 | 840 | ||
841 | void LauncherView::setViewMode( ViewMode m ) | 841 | void LauncherView::setViewMode( ViewMode m ) |
842 | { | 842 | { |
843 | odebug << "LauncherView::setViewMode( ViewMode m )" << oendl; | 843 | odebug << "LauncherView::setViewMode( ViewMode m )" << oendl; |
844 | if ( vmode != m ) { | 844 | if ( vmode != m ) { |
845 | bool bigIcons = m == Icon; | 845 | bool bigIcons = m == Icon; |
846 | icons->viewport()->setUpdatesEnabled( FALSE ); | 846 | icons->viewport()->setUpdatesEnabled( FALSE ); |
847 | icons->setBigIcons( bigIcons ); | 847 | icons->setBigIcons( bigIcons ); |
848 | switch ( m ) { | 848 | switch ( m ) { |
849 | case List: | 849 | case List: |
850 | icons->setItemTextPos( QIconView::Right ); | 850 | icons->setItemTextPos( QIconView::Right ); |
851 | break; | 851 | break; |
852 | case Icon: | 852 | case Icon: |
853 | icons->setItemTextPos( QIconView::Bottom ); | 853 | icons->setItemTextPos( QIconView::Bottom ); |
854 | break; | 854 | break; |
855 | } | 855 | } |
856 | icons->hideOrShowItems( FALSE ); | 856 | icons->hideOrShowItems( FALSE ); |
857 | icons->viewport()->setUpdatesEnabled( TRUE ); | 857 | icons->viewport()->setUpdatesEnabled( TRUE ); |
858 | vmode = m; | 858 | vmode = m; |
859 | } | 859 | } |
860 | } | 860 | } |
861 | 861 | ||
862 | // | 862 | // |
863 | // User images may require scaling. | 863 | // User images may require scaling. |
864 | // | 864 | // |
865 | QImage LauncherView::loadBackgroundImage(QString &bgName) | 865 | QImage LauncherView::loadBackgroundImage(QString &bgName) |
866 | { | 866 | { |
867 | QImageIO imgio; | 867 | QImageIO imgio; |
868 | QSize ds = qApp->desktop()->size(); // should be launcher, not desktop | 868 | QSize ds = qApp->desktop()->size(); // should be launcher, not desktop |
869 | bool further_scaling = TRUE; | 869 | bool further_scaling = TRUE; |
870 | 870 | ||
871 | imgio.setFileName( bgName ); | 871 | imgio.setFileName( bgName ); |
872 | imgio.setParameters("GetHeaderInformation"); | 872 | imgio.setParameters("GetHeaderInformation"); |
873 | 873 | ||
874 | if (imgio.read() == FALSE) { | 874 | if (imgio.read() == FALSE) { |
875 | return imgio.image(); | 875 | return imgio.image(); |
876 | } | 876 | } |
877 | 877 | ||
878 | if (imgio.image().width() < ds.width() && | 878 | if (imgio.image().width() < ds.width() && |
879 | imgio.image().height() < ds.height()) { | 879 | imgio.image().height() < ds.height()) { |
880 | further_scaling = FALSE; | 880 | further_scaling = FALSE; |
881 | } | 881 | } |
882 | 882 | ||
883 | if (!imgio.image().bits()) { | 883 | if (!imgio.image().bits()) { |
884 | // | 884 | // |
885 | // Scale and load. Note we don't scale up. | 885 | // Scale and load. Note we don't scale up. |
886 | // | 886 | // |
887 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr | 887 | QString param( "Scale( %1, %2, ScaleMin )" ); // No tr |
888 | imgio.setParameters(further_scaling ? | 888 | imgio.setParameters(further_scaling ? |
889 | param.arg(ds.width()).arg(ds.height()).latin1() : | 889 | param.arg(ds.width()).arg(ds.height()).latin1() : |
890 | ""); | 890 | ""); |
891 | imgio.read(); | 891 | imgio.read(); |
892 | } else { | 892 | } else { |
893 | if (further_scaling) { | 893 | if (further_scaling) { |
894 | int t1 = imgio.image().width() * ds.height(); | 894 | int t1 = imgio.image().width() * ds.height(); |
895 | int t2 = imgio.image().height() * ds.width(); | 895 | int t2 = imgio.image().height() * ds.width(); |
896 | int dsth = ds.height(); | 896 | int dsth = ds.height(); |
897 | int dstw = ds.width(); | 897 | int dstw = ds.width(); |
898 | 898 | ||
899 | if (t1 > t2) { | 899 | if (t1 > t2) { |
900 | dsth = t2 / imgio.image().width(); | 900 | dsth = t2 / imgio.image().width(); |
901 | } else { | 901 | } else { |
902 | dstw = t1 / imgio.image().height(); | 902 | dstw = t1 / imgio.image().height(); |
903 | } | 903 | } |
904 | 904 | ||
905 | // | 905 | // |
906 | // Loader didn't scale for us. Do it manually. | 906 | // Loader didn't scale for us. Do it manually. |
907 | // | 907 | // |
908 | return imgio.image().smoothScale(dstw, dsth); | 908 | return imgio.image().smoothScale(dstw, dsth); |
909 | } | 909 | } |
910 | } | 910 | } |
911 | 911 | ||
912 | return imgio.image(); | 912 | return imgio.image(); |
913 | } | 913 | } |
914 | 914 | ||
915 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) | 915 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) |
916 | { | 916 | { |
917 | if ( !bgCache ) { | 917 | if ( !bgCache ) { |
918 | bgCache = new QMap<QString,BgPixmap*>; | 918 | bgCache = new QMap<QString,BgPixmap*>; |
919 | qAddPostRoutine( cleanup_cache ); | 919 | qAddPostRoutine( cleanup_cache ); |
920 | } | 920 | } |
921 | 921 | ||
922 | if ( bgCache->contains( bgName ) ) | 922 | if ( bgCache->contains( bgName ) ) |
923 | (*bgCache)[bgName]->ref--; | 923 | (*bgCache)[bgName]->ref--; |
924 | bgName = ""; | 924 | bgName = ""; |
925 | 925 | ||
926 | QPixmap bg; | 926 | QPixmap bg; |
927 | 927 | ||
928 | switch ( t ) { | 928 | switch ( t ) { |
929 | case Ruled: { | 929 | case Ruled: { |
930 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr | 930 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr |
931 | if ( bgCache->contains( bgName ) ) { | 931 | if ( bgCache->contains( bgName ) ) { |
932 | (*bgCache)[bgName]->ref++; | 932 | (*bgCache)[bgName]->ref++; |
933 | bg = (*bgCache)[bgName]->pm; | 933 | bg = (*bgCache)[bgName]->pm; |
934 | } else { | 934 | } else { |
935 | bg.resize( width(), 9 ); | 935 | bg.resize( width(), 9 ); |
936 | QPainter painter( &bg ); | 936 | QPainter painter( &bg ); |
937 | for ( int i = 0; i < 3; i++ ) { | 937 | for ( int i = 0; i < 3; i++ ) { |
938 | painter.setPen( white ); | 938 | painter.setPen( white ); |
939 | painter.drawLine( 0, i*3, width()-1, i*3 ); | 939 | painter.drawLine( 0, i*3, width()-1, i*3 ); |
940 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); | 940 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); |
941 | painter.setPen( colorGroup().background().light(105) ); | 941 | painter.setPen( colorGroup().background().light(105) ); |
942 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); | 942 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); |
943 | } | 943 | } |
944 | painter.end(); | 944 | painter.end(); |
945 | bgCache->insert( bgName, new BgPixmap(bg) ); | 945 | bgCache->insert( bgName, new BgPixmap(bg) ); |
946 | } | 946 | } |
947 | break; | 947 | break; |
948 | } | 948 | } |
949 | 949 | ||
950 | case Image: | 950 | case Image: |
951 | if (!val.isEmpty()) { | 951 | if (!val.isEmpty()) { |
952 | bgName = val; | 952 | bgName = val; |
953 | if ( bgCache->contains( bgName ) ) { | 953 | if ( bgCache->contains( bgName ) ) { |
954 | (*bgCache)[bgName]->ref++; | 954 | (*bgCache)[bgName]->ref++; |
955 | bg = (*bgCache)[bgName]->pm; | 955 | bg = (*bgCache)[bgName]->pm; |
956 | } else { | 956 | } else { |
957 | QString imgFile = bgName; | 957 | QString imgFile = bgName; |
958 | bool tile = FALSE; | 958 | bool tile = FALSE; |
959 | if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { | 959 | if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { |
960 | imgFile = Resource::findPixmap( imgFile ); | 960 | imgFile = Resource::findPixmap( imgFile ); |
961 | tile = TRUE; | 961 | tile = TRUE; |
962 | } | 962 | } |
963 | QImage img = loadBackgroundImage(imgFile); | 963 | QImage img = loadBackgroundImage(imgFile); |
964 | 964 | ||
965 | 965 | ||
966 | if ( img.depth() == 1 ) | 966 | if ( img.depth() == 1 ) |
967 | img = img.convertDepth(8); | 967 | img = img.convertDepth(8); |
968 | img.setAlphaBuffer(FALSE); | 968 | img.setAlphaBuffer(FALSE); |
969 | bg.convertFromImage(img); | 969 | bg.convertFromImage(img); |
970 | bgCache->insert( bgName, new BgPixmap(bg) ); | 970 | bgCache->insert( bgName, new BgPixmap(bg) ); |
971 | } | 971 | } |
972 | } | 972 | } |
973 | break; | 973 | break; |
974 | 974 | ||
975 | case SolidColor: | 975 | case SolidColor: |
976 | default: | 976 | default: |
977 | break; | 977 | break; |
978 | } | 978 | } |
979 | 979 | ||
980 | const QObjectList *list = queryList( "QWidget", 0, FALSE ); | 980 | const QObjectList *list = queryList( "QWidget", 0, FALSE ); |
981 | QObject *obj; | 981 | QObject *obj; |
982 | for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { | 982 | for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { |
983 | if ( obj->isWidgetType() ) { | 983 | if ( obj->isWidgetType() ) { |
984 | QWidget *w = (QWidget*)obj; | 984 | QWidget *w = (QWidget*)obj; |
985 | w->setBackgroundPixmap( bg ); | 985 | w->setBackgroundPixmap( bg ); |
986 | if ( bgName.isEmpty() ) { | 986 | if ( bgName.isEmpty() ) { |
987 | // Solid Color | 987 | // Solid Color |
988 | if ( val.isEmpty() ) | 988 | if ( val.isEmpty() ) |
989 | w->setBackgroundColor( colorGroup().base() ); | 989 | w->setBackgroundColor( colorGroup().base() ); |
990 | else | 990 | else |
991 | w->setBackgroundColor( val ); | 991 | w->setBackgroundColor( val ); |
992 | } else { | 992 | } else { |
993 | // Ruled or Image pixmap | 993 | // Ruled or Image pixmap |
994 | w->setBackgroundOrigin( ParentOrigin ); | 994 | w->setBackgroundOrigin( ParentOrigin ); |
995 | } | 995 | } |
996 | } | 996 | } |
997 | } | 997 | } |
998 | delete list; | 998 | delete list; |
999 | 999 | ||
1000 | bgType = t; | 1000 | bgType = t; |
1001 | icons->viewport()->update(); | 1001 | icons->viewport()->update(); |
1002 | 1002 | ||
1003 | QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); | 1003 | QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); |
1004 | } | 1004 | } |
1005 | 1005 | ||
1006 | void LauncherView::setTextColor( const QColor &tc ) | 1006 | void LauncherView::setTextColor( const QColor &tc ) |
1007 | { | 1007 | { |
1008 | textCol = tc; | 1008 | textCol = tc; |
1009 | QColorGroup cg = icons->colorGroup(); | 1009 | QColorGroup cg = icons->colorGroup(); |
1010 | cg.setColor( QColorGroup::Text, tc ); | 1010 | cg.setColor( QColorGroup::Text, tc ); |
1011 | icons->setPalette( QPalette(cg,cg,cg) ); | 1011 | icons->setPalette( QPalette(cg,cg,cg) ); |
1012 | icons->viewport()->update(); | 1012 | icons->viewport()->update(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | void LauncherView::setViewFont( const QFont &f ) | 1015 | void LauncherView::setViewFont( const QFont &f ) |
1016 | { | 1016 | { |
1017 | icons->setFont( f ); | 1017 | icons->setFont( f ); |
1018 | icons->hideOrShowItems( FALSE ); | 1018 | icons->hideOrShowItems( FALSE ); |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | void LauncherView::clearViewFont() | 1021 | void LauncherView::clearViewFont() |
1022 | { | 1022 | { |
1023 | icons->unsetFont(); | 1023 | icons->unsetFont(); |
1024 | icons->hideOrShowItems( FALSE ); | 1024 | icons->hideOrShowItems( FALSE ); |
1025 | } | 1025 | } |
1026 | 1026 | ||
1027 | void LauncherView::resizeEvent(QResizeEvent *e) | 1027 | void LauncherView::resizeEvent(QResizeEvent *e) |
1028 | { | 1028 | { |
1029 | // qDebug("LauncherView resize event"); | 1029 | // qDebug("LauncherView resize event"); |
1030 | QVBox::resizeEvent( e ); | 1030 | QVBox::resizeEvent( e ); |
1031 | // commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... | 1031 | // commented out for launcherview and qt/e 2.3.8 problems, probably needs real fixing somewhere... |
1032 | // if ( e->size().width() != e->oldSize().width() ) | 1032 | // if ( e->size().width() != e->oldSize().width() ) |
1033 | sort(); | 1033 | sort(); |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | void LauncherView::selectionChanged() | 1036 | void LauncherView::selectionChanged() |
1037 | { | 1037 | { |
1038 | QIconViewItem* item = icons->currentItem(); | 1038 | QIconViewItem* item = icons->currentItem(); |
1039 | if ( item && item->isSelected() ) { | 1039 | if ( item && item->isSelected() ) { |
1040 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1040 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1041 | if ( icons->inKeyEvent() ) // not for mouse press | 1041 | if ( icons->inKeyEvent() ) // not for mouse press |
1042 | emit clicked( appLnk ); | 1042 | emit clicked( appLnk ); |
1043 | item->setSelected(FALSE); | 1043 | item->setSelected(FALSE); |
1044 | } | 1044 | } |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | void LauncherView::returnPressed( QIconViewItem *item ) | 1047 | void LauncherView::returnPressed( QIconViewItem *item ) |
1048 | { | 1048 | { |
1049 | if ( item ) { | 1049 | if ( item ) { |
1050 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1050 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1051 | emit clicked( appLnk ); | 1051 | emit clicked( appLnk ); |
1052 | } | 1052 | } |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) | 1055 | void LauncherView::itemClicked( int btn, QIconViewItem *item ) |
1056 | { | 1056 | { |
1057 | if ( item ) { | 1057 | if ( item ) { |
1058 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1058 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1059 | if ( btn == LeftButton ) { | 1059 | if ( btn == LeftButton ) { |
1060 | // Make sure it's the item we execute that gets highlighted | 1060 | // Make sure it's the item we execute that gets highlighted |
1061 | icons->setCurrentItem( item ); | 1061 | icons->setCurrentItem( item ); |
1062 | emit clicked( appLnk ); | 1062 | emit clicked( appLnk ); |
1063 | } | 1063 | } |
1064 | item->setSelected(FALSE); | 1064 | item->setSelected(FALSE); |
1065 | } | 1065 | } |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) | 1068 | void LauncherView::itemPressed( int btn, QIconViewItem *item ) |
1069 | { | 1069 | { |
1070 | if ( item ) { | 1070 | if ( item ) { |
1071 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); | 1071 | AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); |
1072 | if ( btn == RightButton ) | 1072 | if ( btn == RightButton ) |
1073 | emit rightPressed( appLnk ); | 1073 | emit rightPressed( appLnk ); |
1074 | else if ( btn == ShiftButton ) | 1074 | else if ( btn == ShiftButton ) |
1075 | emit rightPressed( appLnk ); | 1075 | emit rightPressed( appLnk ); |
1076 | item->setSelected(FALSE); | 1076 | item->setSelected(FALSE); |
1077 | } | 1077 | } |
1078 | } | 1078 | } |
1079 | 1079 | ||
1080 | void LauncherView::removeAllItems() | 1080 | void LauncherView::removeAllItems() |
1081 | { | 1081 | { |
1082 | odebug << "LauncherView::removeAllItems()" << oendl; | 1082 | odebug << "LauncherView::removeAllItems()" << oendl; |
1083 | if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear(); | 1083 | if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear(); |
1084 | icons->clear(); | 1084 | icons->clear(); |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | bool LauncherView::removeLink(const QString& linkfile) | 1087 | bool LauncherView::removeLink(const QString& linkfile) |
1088 | { | 1088 | { |
1089 | return icons->removeLink(linkfile); | 1089 | return icons->removeLink(linkfile); |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | void LauncherView::addItem(AppLnk* app, bool resort) | 1092 | void LauncherView::addItem(AppLnk* app, bool resort) |
1093 | { | 1093 | { |
1094 | icons->addItem(app,resort); | 1094 | icons->addItem(app,resort); |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink) | 1097 | void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink) |
1098 | { | 1098 | { |
1099 | icons->changeItem(old,nlink); | 1099 | icons->changeItem(old,nlink); |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void LauncherView::setSortEnabled( bool v ) | 1102 | void LauncherView::setSortEnabled( bool v ) |
1103 | { | 1103 | { |
1104 | icons->setSorting( v ); | 1104 | icons->setSorting( v ); |
1105 | if ( v ) | 1105 | if ( v ) |
1106 | sort(); | 1106 | sort(); |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | void LauncherView::setUpdatesEnabled( bool u ) | 1109 | void LauncherView::setUpdatesEnabled( bool u ) |
1110 | { | 1110 | { |
1111 | icons->setUpdatesEnabled( u ); | 1111 | icons->setUpdatesEnabled( u ); |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | void LauncherView::sort() | 1114 | void LauncherView::sort() |
1115 | { | 1115 | { |
1116 | icons->sort(); | 1116 | icons->sort(); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | void LauncherView::paletteChange( const QPalette &p ) | 1119 | void LauncherView::paletteChange( const QPalette &p ) |
1120 | { | 1120 | { |
1121 | icons->unsetPalette(); | 1121 | icons->unsetPalette(); |
1122 | QVBox::paletteChange( p ); | 1122 | QVBox::paletteChange( p ); |
1123 | if ( bgType == Ruled ) | 1123 | if ( bgType == Ruled ) |
1124 | setBackgroundType( Ruled, QString::null ); | 1124 | setBackgroundType( Ruled, QString::null ); |
1125 | QColorGroup cg = icons->colorGroup(); | 1125 | QColorGroup cg = icons->colorGroup(); |
1126 | cg.setColor( QColorGroup::Text, textCol ); | 1126 | cg.setColor( QColorGroup::Text, textCol ); |
1127 | icons->setPalette( QPalette(cg,cg,cg) ); | 1127 | icons->setPalette( QPalette(cg,cg,cg) ); |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | void LauncherView::fontChanged(const QFont&) | 1130 | void LauncherView::fontChanged(const QFont&) |
1131 | { | 1131 | { |
1132 | odebug << "LauncherView::fontChanged()" << oendl; | 1132 | odebug << "LauncherView::fontChanged()" << oendl; |
1133 | icons->hideOrShowItems( FALSE ); | 1133 | icons->hideOrShowItems( FALSE ); |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | void LauncherView::relayout(void) | 1136 | void LauncherView::relayout(void) |
1137 | { | 1137 | { |
1138 | icons->hideOrShowItems(FALSE); | 1138 | icons->hideOrShowItems(FALSE); |
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | void LauncherView::flushBgCache() | 1141 | void LauncherView::flushBgCache() |
1142 | { | 1142 | { |
1143 | if ( !bgCache ) | 1143 | if ( !bgCache ) |
1144 | return; | 1144 | return; |
1145 | // remove unreferenced backgrounds. | 1145 | // remove unreferenced backgrounds. |
1146 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 1146 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
1147 | while ( it != bgCache->end() ) { | 1147 | while ( it != bgCache->end() ) { |
1148 | QMap<QString,BgPixmap*>::Iterator curr = it; | 1148 | QMap<QString,BgPixmap*>::Iterator curr = it; |
1149 | ++it; | 1149 | ++it; |
1150 | if ( (*curr)->ref == 0 ) { | 1150 | if ( (*curr)->ref == 0 ) { |
1151 | delete (*curr); | 1151 | delete (*curr); |
1152 | bgCache->remove( curr ); | 1152 | bgCache->remove( curr ); |
1153 | } | 1153 | } |
1154 | } | 1154 | } |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | /* | 1157 | /* |
1158 | * Launcherthumbnail handling for image files | 1158 | * Launcherthumbnail handling for image files |
1159 | */ | 1159 | */ |
1160 | 1160 | ||
1161 | /* special image handling - based on opie eye */ | 1161 | /* special image handling - based on opie eye */ |
1162 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { | 1162 | QDataStream &operator>>( QDataStream& s, PixmapInfo& inf ) { |
1163 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; | 1163 | s >> inf.file >> inf.pixmap >> inf.width >> inf.height; |
1164 | return s; | 1164 | return s; |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { | 1167 | QDataStream &operator<<( QDataStream& s, const PixmapInfo& inf) { |
1168 | return s << inf.file << inf.width << inf.height; | 1168 | return s << inf.file << inf.width << inf.height; |
1169 | } | 1169 | } |
1170 | 1170 | ||
1171 | LauncherThumbReceiver::LauncherThumbReceiver() | 1171 | LauncherThumbReceiver::LauncherThumbReceiver() |
1172 | :QObject() | 1172 | :QObject() |
1173 | { | 1173 | { |
1174 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); | 1174 | QCopChannel * chan = new QCopChannel( "QPE/opie-eye",this ); |
1175 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), | 1175 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&)), |
1176 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); | 1176 | this, SLOT(recieve(const QCString&,const QByteArray&)) ); |
1177 | 1177 | ||
1178 | { | 1178 | { |
1179 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); | 1179 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refUp()" ); |
1180 | } | 1180 | } |
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | LauncherThumbReceiver::~LauncherThumbReceiver() | 1183 | LauncherThumbReceiver::~LauncherThumbReceiver() |
1184 | { | 1184 | { |
1185 | { | 1185 | { |
1186 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); | 1186 | QCopEnvelope( "QPE/Application/opie-eye_slave", "refDown()" ); |
1187 | } | 1187 | } |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) | 1190 | void LauncherThumbReceiver::recieve( const QCString&str, const QByteArray&at ) |
1191 | { | 1191 | { |
1192 | PixmapInfos pixinfos; | 1192 | PixmapInfos pixinfos; |
1193 | QDataStream stream( at, IO_ReadOnly ); | 1193 | QDataStream stream( at, IO_ReadOnly ); |
1194 | 1194 | ||
1195 | /* we are just interested in thumbmails */ | 1195 | /* we are just interested in thumbmails */ |
1196 | if ( str == "pixmapsHandled(PixmapList)" ) | 1196 | if ( str == "pixmapsHandled(PixmapList)" ) |
1197 | stream >> pixinfos; | 1197 | stream >> pixinfos; |
1198 | 1198 | ||
1199 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { | 1199 | for ( PixmapInfos::Iterator it = pixinfos.begin(); it != pixinfos.end(); ++it ) { |
1200 | emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); | 1200 | emit sig_Thumbnail((*it).pixmap,(*it).file,(*it).width); |
1201 | } | 1201 | } |