summaryrefslogtreecommitdiff
path: root/core/launcher/launcherview.cpp
authorsandman <sandman>2002-10-01 22:44:28 (UTC)
committer sandman <sandman>2002-10-01 22:44:28 (UTC)
commit8f904d99e7b6e04b6043226a63f6c417171a7cad (patch) (unidiff)
tree07d5f2b7e1338cf1035fe92436328a9c74208b03 /core/launcher/launcherview.cpp
parent895280b5ff189fff2e77d6f5f27668e7dad0d88d (diff)
downloadopie-8f904d99e7b6e04b6043226a63f6c417171a7cad.zip
opie-8f904d99e7b6e04b6043226a63f6c417171a7cad.tar.gz
opie-8f904d99e7b6e04b6043226a63f6c417171a7cad.tar.bz2
busyindicator type can now be changed at run-time
Diffstat (limited to 'core/launcher/launcherview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp
index e15b150..fa46543 100644
--- a/core/launcher/launcherview.cpp
+++ b/core/launcher/launcherview.cpp
@@ -31,138 +31,148 @@
31#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
32//#include <qtopia/private/palmtoprecord.h> 32//#include <qtopia/private/palmtoprecord.h>
33 33
34#include <qtimer.h> 34#include <qtimer.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qdict.h> 36#include <qdict.h>
37#include <qfile.h> 37#include <qfile.h>
38#include <qfileinfo.h> 38#include <qfileinfo.h>
39#include <qhbox.h> 39#include <qhbox.h>
40#include <qiconview.h> 40#include <qiconview.h>
41#include <qpainter.h> 41#include <qpainter.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qtoolbutton.h> 43#include <qtoolbutton.h>
44#include <qimage.h> 44#include <qimage.h>
45 45
46 46
47class BgPixmap 47class BgPixmap
48{ 48{
49public: 49public:
50 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {} 50 BgPixmap( const QPixmap &p ) : pm(p), ref(1) {}
51 QPixmap pm; 51 QPixmap pm;
52 int ref; 52 int ref;
53}; 53};
54 54
55enum BusyIndicatorType {
56 BIT_Normal = 0,
57 BIT_Blinking
58};
59
55static QMap<QString,BgPixmap*> *bgCache = 0; 60static QMap<QString,BgPixmap*> *bgCache = 0;
56 61
57class LauncherIconView : public QIconView { 62class LauncherIconView : public QIconView {
58public: 63public:
59 LauncherIconView( QWidget* parent, const char* name=0 ) : 64 LauncherIconView( QWidget* parent, const char* name=0 ) :
60 QIconView(parent,name), 65 QIconView(parent,name),
61 tf(""), 66 tf(""),
62 cf(0), 67 cf(0),
63 bsy(0), 68 bsy(0),
64 bigIcns(TRUE), 69 bigIcns(TRUE),
65 bgColor(white) 70 bgColor(white)
66 { 71 {
67 sortmeth = Name; 72 sortmeth = Name;
68 hidden.setAutoDelete(TRUE); 73 hidden.setAutoDelete(TRUE);
69 ike = FALSE; 74 ike = FALSE;
70 busytimer = 0; 75 busytimer = 0;
71 calculateGrid( Bottom ); 76 calculateGrid( Bottom );
72 } 77 }
73 78
74 ~LauncherIconView() 79 ~LauncherIconView()
75 { 80 {
76#if 0 // debuggery 81#if 0 // debuggery
77 QListIterator<AppLnk> it(hidden); 82 QListIterator<AppLnk> it(hidden);
78 AppLnk* l; 83 AppLnk* l;
79 while ((l=it.current())) { 84 while ((l=it.current())) {
80 ++it; 85 ++it;
81 //qDebug("%p: hidden (should remove)",l); 86 //qDebug("%p: hidden (should remove)",l);
82 } 87 }
83#endif 88#endif
84 } 89 }
85 90
91 void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
92
86 QPixmap* busyPixmap() const { return (QPixmap*)&bpm[::abs(busystate)]; } 93 QPixmap* busyPixmap() const { return (QPixmap*)&bpm[::abs(busystate)]; }
87 QIconViewItem* busyItem() const { return bsy; } 94 QIconViewItem* busyItem() const { return bsy; }
88 void setBigIcons( bool bi ) { bigIcns = bi; } 95 void setBigIcons( bool bi ) { bigIcns = bi; }
89 96
90 void updateCategoriesAndMimeTypes(); 97 void updateCategoriesAndMimeTypes();
91 98
92 void doAutoScroll() 99 void doAutoScroll()
93 { 100 {
94 // We don't want rubberbanding (yet) 101 // We don't want rubberbanding (yet)
95 } 102 }
96 103
97 void setBusy(bool on) 104 void setBusy(bool on)
98 { 105 {
99 QIconViewItem *c = on ? currentItem() : 0; 106 QIconViewItem *c = on ? currentItem() : 0;
100 qDebug ( "set busy %d -> %s", on, c ? c-> text ().latin1() : "(null)" );
101 107
102 if ( bsy != c ) { 108 if ( bsy != c ) {
103 QIconViewItem *oldbsy = bsy; 109 QIconViewItem *oldbsy = bsy;
104 bsy = c; 110 bsy = c;
105 111
106 if ( oldbsy ) 112 if ( oldbsy )
107 oldbsy-> repaint ( ); 113 oldbsy-> repaint ( );
108 114
109 if ( bsy ) { 115 if ( bsy ) {
110 QPixmap *src = bsy-> QIconViewItem::pixmap(); 116 QPixmap *src = bsy-> QIconViewItem::pixmap();
111 for ( int i = 0; i <= 5; i++ ) { 117 for ( int i = 0; i <= 5; i++ ) {
112 QImage img = src->convertToImage(); 118 QImage img = src->convertToImage();
113 QRgb* rgb; 119 QRgb* rgb;
114 int count; 120 int count;
115 if ( img.depth() == 32 ) { 121 if ( img.depth() == 32 ) {
116 rgb = (QRgb*)img.bits(); 122 rgb = (QRgb*)img.bits();
117 count = img.bytesPerLine()/sizeof(QRgb)*img.height(); 123 count = img.bytesPerLine()/sizeof(QRgb)*img.height();
118 } else { 124 } else {
119 rgb = img.colorTable(); 125 rgb = img.colorTable();
120 count = img.numColors(); 126 count = img.numColors();
121 } 127 }
122 int rc, gc, bc; 128 int rc, gc, bc;
123 int bs = ::abs ( i * 10 ) + 25; 129 int bs = ::abs ( i * 10 ) + 25;
124 colorGroup().highlight().rgb( &rc, &gc, &bc ); 130 colorGroup().highlight().rgb( &rc, &gc, &bc );
125 rc = rc * bs / 100; 131 rc = rc * bs / 100;
126 gc = gc * bs / 100; 132 gc = gc * bs / 100;
127 bc = bc * bs / 100; 133 bc = bc * bs / 100;
128 134
129 for ( int r = 0; r < count; r++, rgb++ ) { 135 for ( int r = 0; r < count; r++, rgb++ ) {
130 int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100; 136 int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100;
131 int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100; 137 int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100;
132 int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100; 138 int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100;
133 int ai = qAlpha ( *rgb ); 139 int ai = qAlpha ( *rgb );
134 *rgb = qRgba ( ri, gi, bi, ai ); 140 *rgb = qRgba ( ri, gi, bi, ai );
135 } 141 }
136 142
137 bpm [i].convertFromImage( img ); 143 bpm [i].convertFromImage( img );
138 } 144 }
145 if ( busyType == BIT_Blinking ) {
139 busystate = 0; 146 busystate = 0;
140 if ( busytimer ) 147 if ( busytimer )
141 killTimer ( busytimer ); 148 killTimer ( busytimer );
142 timerEvent ( 0 );
143 busytimer = startTimer ( 200 ); 149 busytimer = startTimer ( 200 );
144 } 150 }
151 else
152 busystate = 3;
153 timerEvent ( 0 );
154 }
145 else { 155 else {
146 killTimer ( busytimer ); 156 killTimer ( busytimer );
147 busytimer = 0; 157 busytimer = 0;
148 } 158 }
149 } 159 }
150 } 160 }
151 161
152 virtual void timerEvent ( QTimerEvent *te ) 162 virtual void timerEvent ( QTimerEvent *te )
153 { 163 {
154 if ( !te || ( te-> timerId ( ) == busytimer )) { 164 if ( !te || ( te-> timerId ( ) == busytimer )) {
155 if ( bsy ) { 165 if ( bsy ) {
156 busystate++; 166 busystate++;
157 if ( busystate > 5 ) 167 if ( busystate > 5 )
158 busystate = -4; 168 busystate = -4;
159 169
160 QScrollView::updateContents ( bsy-> pixmapRect ( false )); 170 QScrollView::updateContents ( bsy-> pixmapRect ( false ));
161 } 171 }
162 } 172 }
163 } 173 }
164 174
165 bool inKeyEvent() const { return ike; } 175 bool inKeyEvent() const { return ike; }
166 void keyPressEvent(QKeyEvent* e) 176 void keyPressEvent(QKeyEvent* e)
167 { 177 {
168 ike = TRUE; 178 ike = TRUE;
@@ -316,48 +326,49 @@ protected:
316 cols = 1; 326 cols = 1;
317 else if ( viewerWidth >= 400 ) 327 else if ( viewerWidth >= 400 )
318 cols = viewerWidth/150; 328 cols = viewerWidth/150;
319 setSpacing( 2 ); 329 setSpacing( 2 );
320 setGridX( (viewerWidth-(cols+1)*spacing())/cols ); 330 setGridX( (viewerWidth-(cols+1)*spacing())/cols );
321 setGridY( fontMetrics().height()+2 ); 331 setGridY( fontMetrics().height()+2 );
322 } 332 }
323 } 333 }
324 334
325private: 335private:
326 QList<AppLnk> hidden; 336 QList<AppLnk> hidden;
327 QDict<void> mimes; 337 QDict<void> mimes;
328 QDict<void> cats; 338 QDict<void> cats;
329 SortMethod sortmeth; 339 SortMethod sortmeth;
330 QRegExp tf; 340 QRegExp tf;
331 int cf; 341 int cf;
332 QIconViewItem* bsy; 342 QIconViewItem* bsy;
333 bool ike; 343 bool ike;
334 bool bigIcns; 344 bool bigIcns;
335 QPixmap bgPixmap; 345 QPixmap bgPixmap;
336 QPixmap bpm [6]; 346 QPixmap bpm [6];
337 QColor bgColor; 347 QColor bgColor;
338 int busytimer; 348 int busytimer;
339 int busystate; 349 int busystate;
350 BusyIndicatorType busyType;
340}; 351};
341 352
342 353
343bool LauncherView::bsy=FALSE; 354bool LauncherView::bsy=FALSE;
344 355
345void LauncherView::setBusy(bool on) 356void LauncherView::setBusy(bool on)
346{ 357{
347 icons->setBusy(on); 358 icons->setBusy(on);
348} 359}
349 360
350class LauncherItem : public QIconViewItem 361class LauncherItem : public QIconViewItem
351{ 362{
352public: 363public:
353 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); 364 LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE );
354 ~LauncherItem() 365 ~LauncherItem()
355 { 366 {
356 LauncherIconView* liv = (LauncherIconView*)iconView(); 367 LauncherIconView* liv = (LauncherIconView*)iconView();
357 if ( liv->busyItem() == this ) 368 if ( liv->busyItem() == this )
358 liv->setBusy(FALSE); 369 liv->setBusy(FALSE);
359 delete app; 370 delete app;
360 } 371 }
361 372
362 AppLnk* appLnk() const { return app; } 373 AppLnk* appLnk() const { return app; }
363 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; } 374 AppLnk* takeAppLnk() { AppLnk* r=app; app=0; return r; }
@@ -892,24 +903,32 @@ void LauncherView::sort()
892 icons->sort(); 903 icons->sort();
893} 904}
894 905
895void LauncherView::addItem(AppLnk* app, bool resort) 906void LauncherView::addItem(AppLnk* app, bool resort)
896{ 907{
897 icons->addItem(app,resort); 908 icons->addItem(app,resort);
898} 909}
899 910
900void LauncherView::setFileSystems(const QList<FileSystem> &) 911void LauncherView::setFileSystems(const QList<FileSystem> &)
901{ 912{
902 // ### does nothing now... 913 // ### does nothing now...
903} 914}
904 915
905void LauncherView::paletteChange( const QPalette &p ) 916void LauncherView::paletteChange( const QPalette &p )
906{ 917{
907 icons->unsetPalette(); 918 icons->unsetPalette();
908 QVBox::paletteChange( p ); 919 QVBox::paletteChange( p );
909 if ( bgType == Ruled ) 920 if ( bgType == Ruled )
910 setBackgroundType( Ruled, QString::null ); 921 setBackgroundType( Ruled, QString::null );
911 QColorGroup cg = icons->colorGroup(); 922 QColorGroup cg = icons->colorGroup();
912 cg.setColor( QColorGroup::Text, textCol ); 923 cg.setColor( QColorGroup::Text, textCol );
913 icons->setPalette( QPalette(cg,cg,cg) ); 924 icons->setPalette( QPalette(cg,cg,cg) );
914} 925}
915 926
927
928void LauncherView::setBusyIndicatorType ( const QString &type )
929{
930 if ( type. lower ( ) == "blink" )
931 icons-> setBusyIndicatorType ( BIT_Blinking );
932 else
933 icons-> setBusyIndicatorType ( BIT_Normal );
934}