author | mickeyl <mickeyl> | 2005-07-03 22:13:00 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-07-03 22:13:00 (UTC) |
commit | 2cabd9ad4b49eefccdf99ad59550c76546b473c9 (patch) (unidiff) | |
tree | 00bab275ac356aecc5a39b86ca22ce172d01f622 /core/launcher/launcherview.cpp | |
parent | 47011752d4457a1055894479e5bf855e100fddac (diff) | |
download | opie-2cabd9ad4b49eefccdf99ad59550c76546b473c9.zip opie-2cabd9ad4b49eefccdf99ad59550c76546b473c9.tar.gz opie-2cabd9ad4b49eefccdf99ad59550c76546b473c9.tar.bz2 |
Resource -> OResource
This is a large diff and I'd appreciate some additional pairs of eyes checking it
Diffstat (limited to 'core/launcher/launcherview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/launcher/launcherview.cpp | 53 |
1 files changed, 30 insertions, 23 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index d960908..6275fcb 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -1,78 +1,85 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | =. (C) 2000-2002 Trolltech AS |
4 | ** This file is part of the Qtopia Environment. | 4 | .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | .>+-= |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | _;:, .> :=|. This program is free software; you can |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | ** packaging of this file. | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | ** | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ._= =} : |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | .%`+i> _;_. |
13 | ** | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | ** | 15 | : .. .:, . . . without even the implied warranty of |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | ** not clear to you. | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ** | 18 | ..}^=.= = ; Library General Public License for more |
19 | **********************************************************************/ | 19 | ++= -. .` .: details. |
20 | 20 | : = ...= . :.=- | |
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | */ | ||
21 | #include "launcherview.h" | 28 | #include "launcherview.h" |
22 | 29 | ||
23 | /* OPIE */ | 30 | /* OPIE */ |
24 | #include <opie2/odebug.h> | 31 | #include <opie2/odebug.h> |
32 | #include <opie2/oresource.h> | ||
25 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
26 | #include <qtopia/qpeapplication.h> | 34 | #include <qtopia/qpeapplication.h> |
27 | #include <qtopia/private/categories.h> | 35 | #include <qtopia/private/categories.h> |
28 | #include <qtopia/categoryselect.h> | 36 | #include <qtopia/categoryselect.h> |
29 | #include <qtopia/mimetype.h> | 37 | #include <qtopia/mimetype.h> |
30 | #include <qtopia/resource.h> | ||
31 | using namespace Opie::Core; | 38 | using namespace Opie::Core; |
32 | 39 | ||
33 | #include <qpe/qcopenvelope_qws.h> | 40 | #include <qpe/qcopenvelope_qws.h> |
34 | 41 | ||
35 | /* QT */ | 42 | /* QT */ |
36 | #include <qtimer.h> | 43 | #include <qtimer.h> |
37 | #include <qfileinfo.h> | 44 | #include <qfileinfo.h> |
38 | #include <qiconview.h> | 45 | #include <qiconview.h> |
39 | #include <qobjectlist.h> | 46 | #include <qobjectlist.h> |
40 | 47 | ||
41 | 48 | ||
42 | // These define how the busy icon is animated and highlighted | 49 | // These define how the busy icon is animated and highlighted |
43 | #define BRIGHTEN_BUSY_ICON | 50 | #define BRIGHTEN_BUSY_ICON |
44 | //#define ALPHA_FADE_BUSY_ICON | 51 | //#define ALPHA_FADE_BUSY_ICON |
45 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY | 52 | //#define USE_ANIMATED_BUSY_ICON_OVERLAY |
46 | #define BOUNCE_BUSY_ICON | 53 | #define BOUNCE_BUSY_ICON |
47 | 54 | ||
48 | typedef QMap<QString,QPixmap>::Iterator pixiter; | 55 | typedef QMap<QString,QPixmap>::Iterator pixiter; |
49 | 56 | ||
50 | class BgPixmap | 57 | class BgPixmap |
51 | { | 58 | { |
52 | public: | 59 | public: |
53 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} | 60 | BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} |
54 | QPixmap pm; | 61 | QPixmap pm; |
55 | int ref; | 62 | int ref; |
56 | }; | 63 | }; |
57 | 64 | ||
58 | 65 | ||
59 | static QMap<QString,BgPixmap*> *bgCache = 0; | 66 | static QMap<QString,BgPixmap*> *bgCache = 0; |
60 | 67 | ||
61 | static void cleanup_cache() | 68 | static void cleanup_cache() |
62 | { | 69 | { |
63 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); | 70 | QMap<QString,BgPixmap*>::Iterator it = bgCache->begin(); |
64 | while ( it != bgCache->end() ) { | 71 | while ( it != bgCache->end() ) { |
65 | QMap<QString,BgPixmap*>::Iterator curr = it; | 72 | QMap<QString,BgPixmap*>::Iterator curr = it; |
66 | ++it; | 73 | ++it; |
67 | delete (*curr); | 74 | delete (*curr); |
68 | bgCache->remove( curr ); | 75 | bgCache->remove( curr ); |
69 | } | 76 | } |
70 | delete bgCache; | 77 | delete bgCache; |
71 | bgCache = 0; | 78 | bgCache = 0; |
72 | } | 79 | } |
73 | 80 | ||
74 | 81 | ||
75 | class LauncherItem : public QIconViewItem | 82 | class LauncherItem : public QIconViewItem |
76 | { | 83 | { |
77 | public: | 84 | public: |
78 | enum iconstate_t { | 85 | enum iconstate_t { |
@@ -381,97 +388,97 @@ void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) | |||
381 | } | 388 | } |
382 | 389 | ||
383 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) | 390 | void LauncherIconView::setItemTextPos( ItemTextPos pos ) |
384 | { | 391 | { |
385 | calculateGrid( pos ); | 392 | calculateGrid( pos ); |
386 | QIconView::setItemTextPos( pos ); | 393 | QIconView::setItemTextPos( pos ); |
387 | } | 394 | } |
388 | 395 | ||
389 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) | 396 | void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) |
390 | { | 397 | { |
391 | if ( bgPixmap.isNull() ) | 398 | if ( bgPixmap.isNull() ) |
392 | { | 399 | { |
393 | p->fillRect( r, bgColor ); | 400 | p->fillRect( r, bgColor ); |
394 | } | 401 | } |
395 | else | 402 | else |
396 | { | 403 | { |
397 | if ( staticBackground ) | 404 | if ( staticBackground ) |
398 | { | 405 | { |
399 | p->drawTiledPixmap( r, bgPixmap, QPoint( r.x() % bgPixmap.width(), r.y() % bgPixmap.height() ) ); | 406 | p->drawTiledPixmap( r, bgPixmap, QPoint( r.x() % bgPixmap.width(), r.y() % bgPixmap.height() ) ); |
400 | } | 407 | } |
401 | else | 408 | else |
402 | { | 409 | { |
403 | p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(), | 410 | p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(), |
404 | (r.y() + contentsY()) % bgPixmap.height() ) ); | 411 | (r.y() + contentsY()) % bgPixmap.height() ) ); |
405 | } | 412 | } |
406 | } | 413 | } |
407 | } | 414 | } |
408 | 415 | ||
409 | void LauncherIconView::addCatsAndMimes(AppLnk* app) | 416 | void LauncherIconView::addCatsAndMimes(AppLnk* app) |
410 | { | 417 | { |
411 | // QStringList c = app->categories(); | 418 | // QStringList c = app->categories(); |
412 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { | 419 | // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { |
413 | // cats.replace(*cit,(void*)1); | 420 | // cats.replace(*cit,(void*)1); |
414 | // } | 421 | // } |
415 | QString maj=app->type(); | 422 | QString maj=app->type(); |
416 | int sl=maj.find('/'); | 423 | int sl=maj.find('/'); |
417 | if (sl>=0) { | 424 | if (sl>=0) { |
418 | QString k; | 425 | QString k; |
419 | k = maj.left(12) == "application/" ? maj : maj.left(sl); | 426 | k = maj.left(12) == "application/" ? maj : maj.left(sl); |
420 | mimes.replace(k,(void*)1); | 427 | mimes.replace(k,(void*)1); |
421 | } | 428 | } |
422 | } | 429 | } |
423 | 430 | ||
424 | void LauncherIconView::setBusy(bool on) | 431 | void LauncherIconView::setBusy(bool on) |
425 | { | 432 | { |
426 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY | 433 | #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY |
427 | if ( busyPix.isNull() ) { | 434 | if ( busyPix.isNull() ) { |
428 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); | 435 | int size = ( bigIcns ) ? AppLnk::bigIconSize() : AppLnk::smallIconSize(); |
429 | busyPix.convertFromImage( Resource::loadImage( "busy" ).smoothScale( size * 16, size ) ); | 436 | busyPix.convertFromImage( OResource::loadImage( "busy", OResource::NoScale ).smoothScale( size * 16, size ) ); |
430 | } | 437 | } |
431 | #endif | 438 | #endif |
432 | 439 | ||
433 | if ( on ) { | 440 | if ( on ) { |
434 | busyTimer = startTimer( 100 ); | 441 | busyTimer = startTimer( 100 ); |
435 | } else { | 442 | } else { |
436 | if ( busyTimer ) { | 443 | if ( busyTimer ) { |
437 | killTimer( busyTimer ); | 444 | killTimer( busyTimer ); |
438 | busyTimer = 0; | 445 | busyTimer = 0; |
439 | } | 446 | } |
440 | } | 447 | } |
441 | 448 | ||
442 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; | 449 | LauncherItem *c = on ? (LauncherItem*)currentItem() : 0; |
443 | 450 | ||
444 | if ( bsy != c ) { | 451 | if ( bsy != c ) { |
445 | LauncherItem *oldBusy = bsy; | 452 | LauncherItem *oldBusy = bsy; |
446 | bsy = c; | 453 | bsy = c; |
447 | if ( oldBusy ) { | 454 | if ( oldBusy ) { |
448 | oldBusy->resetIcon(); | 455 | oldBusy->resetIcon(); |
449 | } | 456 | } |
450 | if ( bsy ) { | 457 | if ( bsy ) { |
451 | bsy->setBusyIndicatorType( busyType ) ; | 458 | bsy->setBusyIndicatorType( busyType ) ; |
452 | bsy->animateIcon(); | 459 | bsy->animateIcon(); |
453 | } | 460 | } |
454 | } | 461 | } |
455 | } | 462 | } |
456 | 463 | ||
457 | void LauncherIconView::clear() | 464 | void LauncherIconView::clear() |
458 | { | 465 | { |
459 | mimes.clear(); | 466 | mimes.clear(); |
460 | cats.clear(); | 467 | cats.clear(); |
461 | QIconView::clear(); | 468 | QIconView::clear(); |
462 | hidden.clear(); | 469 | hidden.clear(); |
463 | } | 470 | } |
464 | 471 | ||
465 | QStringList LauncherIconView::mimeTypes() const | 472 | QStringList LauncherIconView::mimeTypes() const |
466 | { | 473 | { |
467 | QStringList r; | 474 | QStringList r; |
468 | QDictIterator<void> it(mimes); | 475 | QDictIterator<void> it(mimes); |
469 | while (it.current()) { | 476 | while (it.current()) { |
470 | r.append(it.currentKey()); | 477 | r.append(it.currentKey()); |
471 | ++it; | 478 | ++it; |
472 | } | 479 | } |
473 | r.sort(); | 480 | r.sort(); |
474 | return r; | 481 | return r; |
475 | } | 482 | } |
476 | 483 | ||
477 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) | 484 | LauncherItem*LauncherIconView::findDocItem(const QString&fname) |
@@ -956,97 +963,97 @@ QImage LauncherView::loadBackgroundImage(QString &bgName) | |||
956 | return imgio.image(); | 963 | return imgio.image(); |
957 | } | 964 | } |
958 | 965 | ||
959 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) | 966 | void LauncherView::setBackgroundType( BackgroundType t, const QString &val ) |
960 | { | 967 | { |
961 | if ( !bgCache ) { | 968 | if ( !bgCache ) { |
962 | bgCache = new QMap<QString,BgPixmap*>; | 969 | bgCache = new QMap<QString,BgPixmap*>; |
963 | qAddPostRoutine( cleanup_cache ); | 970 | qAddPostRoutine( cleanup_cache ); |
964 | } | 971 | } |
965 | 972 | ||
966 | if ( bgCache->contains( bgName ) ) | 973 | if ( bgCache->contains( bgName ) ) |
967 | (*bgCache)[bgName]->ref--; | 974 | (*bgCache)[bgName]->ref--; |
968 | bgName = ""; | 975 | bgName = ""; |
969 | 976 | ||
970 | QPixmap bg; | 977 | QPixmap bg; |
971 | 978 | ||
972 | switch ( t ) { | 979 | switch ( t ) { |
973 | case Ruled: { | 980 | case Ruled: { |
974 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr | 981 | bgName = QString("Ruled_%1").arg(colorGroup().background().name()); // No tr |
975 | if ( bgCache->contains( bgName ) ) { | 982 | if ( bgCache->contains( bgName ) ) { |
976 | (*bgCache)[bgName]->ref++; | 983 | (*bgCache)[bgName]->ref++; |
977 | bg = (*bgCache)[bgName]->pm; | 984 | bg = (*bgCache)[bgName]->pm; |
978 | } else { | 985 | } else { |
979 | bg.resize( width(), 9 ); | 986 | bg.resize( width(), 9 ); |
980 | QPainter painter( &bg ); | 987 | QPainter painter( &bg ); |
981 | for ( int i = 0; i < 3; i++ ) { | 988 | for ( int i = 0; i < 3; i++ ) { |
982 | painter.setPen( white ); | 989 | painter.setPen( white ); |
983 | painter.drawLine( 0, i*3, width()-1, i*3 ); | 990 | painter.drawLine( 0, i*3, width()-1, i*3 ); |
984 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); | 991 | painter.drawLine( 0, i*3+1, width()-1, i*3+1 ); |
985 | painter.setPen( colorGroup().background().light(105) ); | 992 | painter.setPen( colorGroup().background().light(105) ); |
986 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); | 993 | painter.drawLine( 0, i*3+2, width()-1, i*3+2 ); |
987 | } | 994 | } |
988 | painter.end(); | 995 | painter.end(); |
989 | bgCache->insert( bgName, new BgPixmap(bg) ); | 996 | bgCache->insert( bgName, new BgPixmap(bg) ); |
990 | } | 997 | } |
991 | break; | 998 | break; |
992 | } | 999 | } |
993 | 1000 | ||
994 | case Image: | 1001 | case Image: |
995 | if (!val.isEmpty()) { | 1002 | if (!val.isEmpty()) { |
996 | bgName = val; | 1003 | bgName = val; |
997 | if ( bgCache->contains( bgName ) ) { | 1004 | if ( bgCache->contains( bgName ) ) { |
998 | (*bgCache)[bgName]->ref++; | 1005 | (*bgCache)[bgName]->ref++; |
999 | bg = (*bgCache)[bgName]->pm; | 1006 | bg = (*bgCache)[bgName]->pm; |
1000 | } else { | 1007 | } else { |
1001 | QString imgFile = bgName; | 1008 | QString imgFile = bgName; |
1002 | bool tile = FALSE; | 1009 | bool tile = FALSE; |
1003 | if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { | 1010 | if ( imgFile[0]!='/' || !QFile::exists(imgFile) ) { |
1004 | imgFile = Resource::findPixmap( imgFile ); | 1011 | imgFile = OResource::findPixmap( imgFile ); |
1005 | tile = TRUE; | 1012 | tile = TRUE; |
1006 | } | 1013 | } |
1007 | QImage img = loadBackgroundImage(imgFile); | 1014 | QImage img = loadBackgroundImage(imgFile); |
1008 | 1015 | ||
1009 | 1016 | ||
1010 | if ( img.depth() == 1 ) | 1017 | if ( img.depth() == 1 ) |
1011 | img = img.convertDepth(8); | 1018 | img = img.convertDepth(8); |
1012 | img.setAlphaBuffer(FALSE); | 1019 | img.setAlphaBuffer(FALSE); |
1013 | bg.convertFromImage(img); | 1020 | bg.convertFromImage(img); |
1014 | bgCache->insert( bgName, new BgPixmap(bg) ); | 1021 | bgCache->insert( bgName, new BgPixmap(bg) ); |
1015 | } | 1022 | } |
1016 | } | 1023 | } |
1017 | break; | 1024 | break; |
1018 | 1025 | ||
1019 | case SolidColor: | 1026 | case SolidColor: |
1020 | default: | 1027 | default: |
1021 | break; | 1028 | break; |
1022 | } | 1029 | } |
1023 | 1030 | ||
1024 | const QObjectList *list = queryList( "QWidget", 0, FALSE ); | 1031 | const QObjectList *list = queryList( "QWidget", 0, FALSE ); |
1025 | QObject *obj; | 1032 | QObject *obj; |
1026 | for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { | 1033 | for ( QObjectListIt it( *list ); (obj=it.current()); ++it ) { |
1027 | if ( obj->isWidgetType() ) { | 1034 | if ( obj->isWidgetType() ) { |
1028 | QWidget *w = (QWidget*)obj; | 1035 | QWidget *w = (QWidget*)obj; |
1029 | w->setBackgroundPixmap( bg ); | 1036 | w->setBackgroundPixmap( bg ); |
1030 | if ( bgName.isEmpty() ) { | 1037 | if ( bgName.isEmpty() ) { |
1031 | // Solid Color | 1038 | // Solid Color |
1032 | if ( val.isEmpty() ) | 1039 | if ( val.isEmpty() ) |
1033 | w->setBackgroundColor( colorGroup().base() ); | 1040 | w->setBackgroundColor( colorGroup().base() ); |
1034 | else | 1041 | else |
1035 | w->setBackgroundColor( val ); | 1042 | w->setBackgroundColor( val ); |
1036 | } else { | 1043 | } else { |
1037 | // Ruled or Image pixmap | 1044 | // Ruled or Image pixmap |
1038 | w->setBackgroundOrigin( ParentOrigin ); | 1045 | w->setBackgroundOrigin( ParentOrigin ); |
1039 | } | 1046 | } |
1040 | } | 1047 | } |
1041 | } | 1048 | } |
1042 | delete list; | 1049 | delete list; |
1043 | 1050 | ||
1044 | bgType = t; | 1051 | bgType = t; |
1045 | icons->viewport()->update(); | 1052 | icons->viewport()->update(); |
1046 | 1053 | ||
1047 | QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); | 1054 | QTimer::singleShot( 1000, this, SLOT(flushBgCache()) ); |
1048 | } | 1055 | } |
1049 | 1056 | ||
1050 | void LauncherView::setColNumber( int num ) | 1057 | void LauncherView::setColNumber( int num ) |
1051 | { | 1058 | { |
1052 | icons->setColNumber( num ); | 1059 | icons->setColNumber( num ); |