summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/launcherview.cpp57
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
@@ -91,91 +91,92 @@ public:
void setBusyIndicatorType ( BusyIndicatorType t ) { busyType = t; }
QPixmap* busyPixmap() const { return (QPixmap*)&bpm[::abs(busystate)]; }
QIconViewItem* busyItem() const { return bsy; }
void setBigIcons( bool bi ) { bigIcns = bi; }
void updateCategoriesAndMimeTypes();
void doAutoScroll()
{
// We don't want rubberbanding (yet)
}
void setBusy(bool on)
{
QIconViewItem *c = on ? currentItem() : 0;
if ( bsy != c ) {
QIconViewItem *oldbsy = bsy;
bsy = c;
if ( oldbsy )
oldbsy-> repaint ( );
+ if ( busytimer ) {
+ killTimer ( busytimer );
+ busytimer = 0;
+ }
+
if ( bsy ) {
QPixmap *src = bsy-> QIconViewItem::pixmap();
for ( int i = 0; i <= 5; i++ ) {
QImage img = src->convertToImage();
QRgb* rgb;
int count;
if ( img.depth() == 32 ) {
rgb = (QRgb*)img.bits();
count = img.bytesPerLine()/sizeof(QRgb)*img.height();
} else {
rgb = img.colorTable();
count = img.numColors();
}
int rc, gc, bc;
int bs = ::abs ( i * 10 ) + 25;
colorGroup().highlight().rgb( &rc, &gc, &bc );
rc = rc * bs / 100;
gc = gc * bs / 100;
bc = bc * bs / 100;
for ( int r = 0; r < count; r++, rgb++ ) {
int ri = rc + qRed ( *rgb ) * ( 100 - bs ) / 100;
int gi = gc + qGreen ( *rgb ) * ( 100 - bs ) / 100;
int bi = bc + qBlue ( *rgb ) * ( 100 - bs ) / 100;
int ai = qAlpha ( *rgb );
*rgb = qRgba ( ri, gi, bi, ai );
}
bpm [i].convertFromImage( img );
}
+
if ( busyType == BIT_Blinking ) {
busystate = 0;
- if ( busytimer )
- killTimer ( busytimer );
busytimer = startTimer ( 200 );
}
- else
+ else {
busystate = 3;
- timerEvent ( 0 );
}
- else {
- killTimer ( busytimer );
- busytimer = 0;
+ timerEvent ( 0 );
}
}
}
virtual void timerEvent ( QTimerEvent *te )
{
if ( !te || ( te-> timerId ( ) == busytimer )) {
if ( bsy ) {
busystate++;
if ( busystate > 5 )
busystate = -4;
QScrollView::updateContents ( bsy-> pixmapRect ( false ));
}
}
}
bool inKeyEvent() const { return ike; }
void keyPressEvent(QKeyEvent* e)
{
ike = TRUE;
if ( e->key() == Key_F33 /* OK button */ || e->key() == Key_Space )
returnPressed(currentItem());
QIconView::keyPressEvent(e);
@@ -311,48 +312,89 @@ protected:
{
int dw = QApplication::desktop()->width();
int viewerWidth = dw-style().scrollBarExtent().width();
if ( pos == Bottom ) {
int cols = 3;
if ( viewerWidth <= 200 )
cols = 2;
else if ( viewerWidth >= 400 )
cols = viewerWidth/96;
setSpacing( 4 );
setGridX( (viewerWidth-(cols+1)*spacing())/cols );
setGridY( fontMetrics().height()*2+24 );
} else {
int cols = 2;
if ( viewerWidth < 150 )
cols = 1;
else if ( viewerWidth >= 400 )
cols = viewerWidth/150;
setSpacing( 2 );
setGridX( (viewerWidth-(cols+1)*spacing())/cols );
setGridY( fontMetrics().height()+2 );
}
}
+
+ // flicker free redrawing of busy indicator
+ // code was taken from QScrollView::viewportPaintEvent
+ void viewportPaintEvent( QPaintEvent* pe )
+ {
+ static QPixmap *pix = new QPixmap ( );
+
+ QWidget* vp = viewport();
+
+ if ( vp-> size ( ) != pix-> size ( ))
+ pix-> resize ( vp-> size ( ));
+
+ QPainter p(pix, vp);
+ QRect r = pe->rect();
+ if ( clipper ( ) != vp ) {
+ QRect rr(
+ -vp->x(), -vp->y(),
+ clipper()->width(), clipper()->height()
+ );
+ r &= rr;
+ if ( r.isValid() ) {
+ int ex = r.x() + vp->x() + contentsX();
+ int ey = r.y() + vp->y() + contentsY();
+ int ew = r.width();
+ int eh = r.height();
+ drawContentsOffset(&p,
+ contentsX()+vp->x(),
+ contentsY()+vp->y(),
+ ex, ey, ew, eh);
+ }
+ } else {
+ r &= clipper()->rect();
+ int ex = r.x() + contentsX();
+ int ey = r.y() + contentsY();
+ int ew = r.width();
+ int eh = r.height();
+ drawContentsOffset(&p, contentsX(), contentsY(), ex, ey, ew, eh);
+ }
+ bitBlt ( vp, r.topLeft(), pix, r );
+ }
+
private:
QList<AppLnk> hidden;
QDict<void> mimes;
QDict<void> cats;
SortMethod sortmeth;
QRegExp tf;
int cf;
QIconViewItem* bsy;
bool ike;
bool bigIcns;
QPixmap bgPixmap;
QPixmap bpm [6];
QColor bgColor;
int busytimer;
int busystate;
BusyIndicatorType busyType;
};
bool LauncherView::bsy=FALSE;
void LauncherView::setBusy(bool on)
{
icons->setBusy(on);
@@ -910,24 +952,25 @@ void LauncherView::addItem(AppLnk* app, bool resort)
void LauncherView::setFileSystems(const QList<FileSystem> &)
{
// ### does nothing now...
}
void LauncherView::paletteChange( const QPalette &p )
{
icons->unsetPalette();
QVBox::paletteChange( p );
if ( bgType == Ruled )
setBackgroundType( Ruled, QString::null );
QColorGroup cg = icons->colorGroup();
cg.setColor( QColorGroup::Text, textCol );
icons->setPalette( QPalette(cg,cg,cg) );
}
void LauncherView::setBusyIndicatorType ( const QString &type )
{
if ( type. lower ( ) == "blink" )
icons-> setBusyIndicatorType ( BIT_Blinking );
else
icons-> setBusyIndicatorType ( BIT_Normal );
}
+