-rw-r--r-- | core/launcher/launcherview.cpp | 57 |
1 files changed, 50 insertions, 7 deletions
diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index 6e63fca..9fc4565 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp | |||
@@ -83,108 +83,109 @@ public: | |||
83 | AppLnk* l; | 83 | AppLnk* l; |
84 | while ((l=it.current())) { | 84 | while ((l=it.current())) { |
85 | ++it; | 85 | ++it; |
86 | //qDebug("%p: hidden (should remove)",l); | 86 | //qDebug("%p: hidden (should remove)",l); |
87 | } | 87 | } |
88 | #endif | 88 | #endif |
89 | } | 89 | } |
90 | 90 | ||
91 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } | 91 | void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; } |
92 | 92 | ||
93 | QPixmap* busyPixmap() const { return (QPixmap*)&bpm[::abs(busystate)]; } | 93 | QPixmap* busyPixmap() const { return (QPixmap*)&bpm[::abs(busystate)]; } |
94 | QIconViewItem* busyItem() const { return bsy; } | 94 | QIconViewItem* busyItem() const { return bsy; } |
95 | void setBigIcons( bool bi ) { bigIcns = bi; } | 95 | void setBigIcons( bool bi ) { bigIcns = bi; } |
96 | 96 | ||
97 | void updateCategoriesAndMimeTypes(); | 97 | void updateCategoriesAndMimeTypes(); |
98 | 98 | ||
99 | void doAutoScroll() | 99 | void doAutoScroll() |
100 | { | 100 | { |
101 | // We don't want rubberbanding (yet) | 101 | // We don't want rubberbanding (yet) |
102 | } | 102 | } |
103 | 103 | ||
104 | void setBusy(bool on) | 104 | void setBusy(bool on) |
105 | { | 105 | { |
106 | QIconViewItem *c = on ? currentItem() : 0; | 106 | QIconViewItem *c = on ? currentItem() : 0; |
107 | 107 | ||
108 | if ( bsy != c ) { | 108 | if ( bsy != c ) { |
109 | QIconViewItem *oldbsy = bsy; | 109 | QIconViewItem *oldbsy = bsy; |
110 | bsy = c; | 110 | bsy = c; |
111 | 111 | ||
112 | if ( oldbsy ) | 112 | if ( oldbsy ) |
113 | oldbsy-> repaint ( ); | 113 | oldbsy-> repaint ( ); |
114 | 114 | ||
115 | if ( busytimer ) { | ||
116 | killTimer ( busytimer ); | ||
117 | busytimer = 0; | ||
118 | } | ||
119 | |||
115 | if ( bsy ) { | 120 | if ( bsy ) { |
116 | QPixmap *src = bsy-> QIconViewItem::pixmap(); | 121 | QPixmap *src = bsy-> QIconViewItem::pixmap(); |
117 | for ( int i = 0; i <= 5; i++ ) { | 122 | for ( int i = 0; i <= 5; i++ ) { |
118 | QImage img = src->convertToImage(); | 123 | QImage img = src->convertToImage(); |
119 | QRgb* rgb; | 124 | QRgb* rgb; |
120 | int count; | 125 | int count; |
121 | if ( img.depth() == 32 ) { | 126 | if ( img.depth() == 32 ) { |
122 | rgb = (QRgb*)img.bits(); | 127 | rgb = (QRgb*)img.bits(); |
123 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); | 128 | count = img.bytesPerLine()/sizeof(QRgb)*img.height(); |
124 | } else { | 129 | } else { |
125 | rgb = img.colorTable(); | 130 | rgb = img.colorTable(); |
126 | count = img.numColors(); | 131 | count = img.numColors(); |
127 | } | 132 | } |
128 | int rc, gc, bc; | 133 | int rc, gc, bc; |
129 | int bs = ::abs ( i * 10 ) + 25; | 134 | int bs = ::abs ( i * 10 ) + 25; |
130 | colorGroup().highlight().rgb( &rc, &gc, &bc ); | 135 | colorGroup().highlight().rgb( &rc, &gc, &bc ); |
131 | rc = rc * bs / 100; | 136 | rc = rc * bs / 100; |
132 | gc = gc * bs / 100; | 137 | gc = gc * bs / 100; |
133 | bc = bc * bs / 100; | 138 | bc = bc * bs / 100; |
134 | 139 | ||
135 | for ( int r = 0; r < count; r++, rgb++ ) { | 140 | for ( int r = 0; r < count; r++, rgb++ ) { |
136 | int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100; | 141 | int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100; |
137 | int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100; | 142 | int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100; |
138 | int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100; | 143 | int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100; |
139 | int ai = qAlpha ( *rgb ); | 144 | int ai = qAlpha ( *rgb ); |
140 | *rgb = qRgba ( ri, gi, bi, ai ); | 145 | *rgb = qRgba ( ri, gi, bi, ai ); |
141 | } | 146 | } |
142 | 147 | ||
143 | bpm [i].convertFromImage( img ); | 148 | bpm [i].convertFromImage( img ); |
144 | } | 149 | } |
150 | |||
145 | if ( busyType == BIT_Blinking ) { | 151 | if ( busyType == BIT_Blinking ) { |
146 | busystate = 0; | 152 | busystate = 0; |
147 | if ( busytimer ) | ||
148 | killTimer ( busytimer ); | ||
149 | busytimer = startTimer ( 200 ); | 153 | busytimer = startTimer ( 200 ); |
150 | } | 154 | } |
151 | else | 155 | else { |
152 | busystate = 3; | 156 | busystate = 3; |
157 | } | ||
153 | timerEvent ( 0 ); | 158 | timerEvent ( 0 ); |
154 | } | 159 | } |
155 | else { | ||
156 | killTimer ( busytimer ); | ||
157 | busytimer = 0; | ||
158 | } | ||
159 | } | 160 | } |
160 | } | 161 | } |
161 | 162 | ||
162 | virtual void timerEvent ( QTimerEvent *te ) | 163 | virtual void timerEvent ( QTimerEvent *te ) |
163 | { | 164 | { |
164 | if ( !te || ( te-> timerId ( ) == busytimer )) { | 165 | if ( !te || ( te-> timerId ( ) == busytimer )) { |
165 | if ( bsy ) { | 166 | if ( bsy ) { |
166 | busystate++; | 167 | busystate++; |
167 | if ( busystate > 5 ) | 168 | if ( busystate > 5 ) |
168 | busystate = -4; | 169 | busystate = -4; |
169 | 170 | ||
170 | QScrollView::updateContents ( bsy-> pixmapRect ( false )); | 171 | QScrollView::updateContents ( bsy-> pixmapRect ( false )); |
171 | } | 172 | } |
172 | } | 173 | } |
173 | } | 174 | } |
174 | 175 | ||
175 | bool inKeyEvent() const { return ike; } | 176 | bool inKeyEvent() const { return ike; } |
176 | void keyPressEvent(QKeyEvent* e) | 177 | void keyPressEvent(QKeyEvent* e) |
177 | { | 178 | { |
178 | ike = TRUE; | 179 | ike = TRUE; |
179 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) | 180 | if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space ) |
180 | returnPressed(currentItem()); | 181 | returnPressed(currentItem()); |
181 | QIconView::keyPressEvent(e); | 182 | QIconView::keyPressEvent(e); |
182 | ike = FALSE; | 183 | ike = FALSE; |
183 | } | 184 | } |
184 | 185 | ||
185 | void addItem(AppLnk* app, bool resort=TRUE); | 186 | void addItem(AppLnk* app, bool resort=TRUE); |
186 | bool removeLink(const QString& linkfile); | 187 | bool removeLink(const QString& linkfile); |
187 | 188 | ||
188 | QStringList mimeTypes() const; | 189 | QStringList mimeTypes() const; |
189 | QStringList categories() const; | 190 | QStringList categories() const; |
190 | 191 | ||
@@ -303,64 +304,105 @@ protected: | |||
303 | 304 | ||
304 | void styleChange( QStyle &old ) | 305 | void styleChange( QStyle &old ) |
305 | { | 306 | { |
306 | QIconView::styleChange( old ); | 307 | QIconView::styleChange( old ); |
307 | calculateGrid( itemTextPos() ); | 308 | calculateGrid( itemTextPos() ); |
308 | } | 309 | } |
309 | 310 | ||
310 | void calculateGrid( ItemTextPos pos ) | 311 | void calculateGrid( ItemTextPos pos ) |
311 | { | 312 | { |
312 | int dw = QApplication::desktop()->width(); | 313 | int dw = QApplication::desktop()->width(); |
313 | int viewerWidth = dw-style().scrollBarExtent().width(); | 314 | int viewerWidth = dw-style().scrollBarExtent().width(); |
314 | if ( pos == Bottom ) { | 315 | if ( pos == Bottom ) { |
315 | int cols = 3; | 316 | int cols = 3; |
316 | if ( viewerWidth <= 200 ) | 317 | if ( viewerWidth <= 200 ) |
317 | cols = 2; | 318 | cols = 2; |
318 | else if ( viewerWidth >= 400 ) | 319 | else if ( viewerWidth >= 400 ) |
319 | cols = viewerWidth/96; | 320 | cols = viewerWidth/96; |
320 | setSpacing( 4 ); | 321 | setSpacing( 4 ); |
321 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 322 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
322 | setGridY( fontMetrics().height()*2+24 ); | 323 | setGridY( fontMetrics().height()*2+24 ); |
323 | } else { | 324 | } else { |
324 | int cols = 2; | 325 | int cols = 2; |
325 | if ( viewerWidth < 150 ) | 326 | if ( viewerWidth < 150 ) |
326 | cols = 1; | 327 | cols = 1; |
327 | else if ( viewerWidth >= 400 ) | 328 | else if ( viewerWidth >= 400 ) |
328 | cols = viewerWidth/150; | 329 | cols = viewerWidth/150; |
329 | setSpacing( 2 ); | 330 | setSpacing( 2 ); |
330 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); | 331 | setGridX( (viewerWidth-(cols+1)*spacing())/cols ); |
331 | setGridY( fontMetrics().height()+2 ); | 332 | setGridY( fontMetrics().height()+2 ); |
332 | } | 333 | } |
333 | } | 334 | } |
334 | 335 | ||
336 | |||
337 | // flicker free redrawing of busy indicator | ||
338 | // code was taken from QScrollView::viewportPaintEvent | ||
339 | void viewportPaintEvent( QPaintEvent* pe ) | ||
340 | { | ||
341 | static QPixmap *pix = new QPixmap ( ); | ||
342 | |||
343 | QWidget* vp = viewport(); | ||
344 | |||
345 | if ( vp-> size ( ) != pix-> size ( )) | ||
346 | pix-> resize ( vp-> size ( )); | ||
347 | |||
348 | QPainter p(pix, vp); | ||
349 | QRect r = pe->rect(); | ||
350 | if ( clipper ( ) != vp ) { | ||
351 | QRect rr( | ||
352 | -vp->x(), -vp->y(), | ||
353 | clipper()->width(), clipper()->height() | ||
354 | ); | ||
355 | r &= rr; | ||
356 | if ( r.isValid() ) { | ||
357 | int ex = r.x() + vp->x() + contentsX(); | ||
358 | int ey = r.y() + vp->y() + contentsY(); | ||
359 | int ew = r.width(); | ||
360 | int eh = r.height(); | ||
361 | drawContentsOffset(&p, | ||
362 | contentsX()+vp->x(), | ||
363 | contentsY()+vp->y(), | ||
364 | ex, ey, ew, eh); | ||
365 | } | ||
366 | } else { | ||
367 | r &= clipper()->rect(); | ||
368 | int ex = r.x() + contentsX(); | ||
369 | int ey = r.y() + contentsY(); | ||
370 | int ew = r.width(); | ||
371 | int eh = r.height(); | ||
372 | drawContentsOffset(&p, contentsX(), contentsY(), ex, ey, ew, eh); | ||
373 | } | ||
374 | bitBlt ( vp, r.topLeft(), pix, r ); | ||
375 | } | ||
376 | |||
335 | private: | 377 | private: |
336 | QList<AppLnk> hidden; | 378 | QList<AppLnk> hidden; |
337 | QDict<void> mimes; | 379 | QDict<void> mimes; |
338 | QDict<void> cats; | 380 | QDict<void> cats; |
339 | SortMethod sortmeth; | 381 | SortMethod sortmeth; |
340 | QRegExp tf; | 382 | QRegExp tf; |
341 | int cf; | 383 | int cf; |
342 | QIconViewItem* bsy; | 384 | QIconViewItem* bsy; |
343 | bool ike; | 385 | bool ike; |
344 | bool bigIcns; | 386 | bool bigIcns; |
345 | QPixmap bgPixmap; | 387 | QPixmap bgPixmap; |
346 | QPixmap bpm [6]; | 388 | QPixmap bpm [6]; |
347 | QColor bgColor; | 389 | QColor bgColor; |
348 | int busytimer; | 390 | int busytimer; |
349 | int busystate; | 391 | int busystate; |
350 | BusyIndicatorType busyType; | 392 | BusyIndicatorType busyType; |
351 | }; | 393 | }; |
352 | 394 | ||
353 | 395 | ||
354 | bool LauncherView::bsy=FALSE; | 396 | bool LauncherView::bsy=FALSE; |
355 | 397 | ||
356 | void LauncherView::setBusy(bool on) | 398 | void LauncherView::setBusy(bool on) |
357 | { | 399 | { |
358 | icons->setBusy(on); | 400 | icons->setBusy(on); |
359 | } | 401 | } |
360 | 402 | ||
361 | class LauncherItem : public QIconViewItem | 403 | class LauncherItem : public QIconViewItem |
362 | { | 404 | { |
363 | public: | 405 | public: |
364 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); | 406 | LauncherItem( QIconView *parent, AppLnk* applnk, bool bigIcon=TRUE ); |
365 | ~LauncherItem() | 407 | ~LauncherItem() |
366 | { | 408 | { |
@@ -902,32 +944,33 @@ void LauncherView::sort() | |||
902 | icons->sort(); | 944 | icons->sort(); |
903 | } | 945 | } |
904 | 946 | ||
905 | void LauncherView::addItem(AppLnk* app, bool resort) | 947 | void LauncherView::addItem(AppLnk* app, bool resort) |
906 | { | 948 | { |
907 | icons->addItem(app,resort); | 949 | icons->addItem(app,resort); |
908 | } | 950 | } |
909 | 951 | ||
910 | void LauncherView::setFileSystems(const QList<FileSystem> &) | 952 | void LauncherView::setFileSystems(const QList<FileSystem> &) |
911 | { | 953 | { |
912 | // ### does nothing now... | 954 | // ### does nothing now... |
913 | } | 955 | } |
914 | 956 | ||
915 | void LauncherView::paletteChange( const QPalette &p ) | 957 | void LauncherView::paletteChange( const QPalette &p ) |
916 | { | 958 | { |
917 | icons->unsetPalette(); | 959 | icons->unsetPalette(); |
918 | QVBox::paletteChange( p ); | 960 | QVBox::paletteChange( p ); |
919 | if ( bgType == Ruled ) | 961 | if ( bgType == Ruled ) |
920 | setBackgroundType( Ruled, QString::null ); | 962 | setBackgroundType( Ruled, QString::null ); |
921 | QColorGroup cg = icons->colorGroup(); | 963 | QColorGroup cg = icons->colorGroup(); |
922 | cg.setColor( QColorGroup::Text, textCol ); | 964 | cg.setColor( QColorGroup::Text, textCol ); |
923 | icons->setPalette( QPalette(cg,cg,cg) ); | 965 | icons->setPalette( QPalette(cg,cg,cg) ); |
924 | } | 966 | } |
925 | 967 | ||
926 | 968 | ||
927 | void LauncherView::setBusyIndicatorType ( const QString &type ) | 969 | void LauncherView::setBusyIndicatorType ( const QString &type ) |
928 | { | 970 | { |
929 | if ( type. lower ( ) == "blink" ) | 971 | if ( type. lower ( ) == "blink" ) |
930 | icons-> setBusyIndicatorType ( BIT_Blinking ); | 972 | icons-> setBusyIndicatorType ( BIT_Blinking ); |
931 | else | 973 | else |
932 | icons-> setBusyIndicatorType ( BIT_Normal ); | 974 | icons-> setBusyIndicatorType ( BIT_Normal ); |
933 | } | 975 | } |
976 | |||