Source Code (Use browser search to find items of interest.)
Class Index
qt'QFDProgressAnimation (./qt-2.1.0/src/dialogs/qfiledialog.cpp:657)
class QFDProgressAnimation : public QWidget
{
Q_OBJECT
public:
QFDProgressAnimation( QWidget *parent );
void start();
private slots:
void next();
protected:
void paintEvent( QPaintEvent *e );
private:
int step;
QTimer *timer;
};
QFDProgressAnimation::QFDProgressAnimation( QWidget *parent )
: QWidget( parent )
{
setFixedSize( 300, 50 );
step = -1;
next();
timer = new QTimer( this );
connect( timer, SIGNAL( timeout() ),
this, SLOT( next() ) );
}
void QFDProgressAnimation::start()
{
timer->start( 150, FALSE );
}
void QFDProgressAnimation::next()
{
++step;
if ( step > 10 )
step = 0;
repaint();
}
void QFDProgressAnimation::paintEvent( QPaintEvent * )
{
erase();
QPainter p;
p.begin( this );
if ( step == 0 ) {
p.drawPixmap( 5, ( height() - startCopyIcon->height() ) / 2,
*startCopyIcon );
p.drawPixmap( width() - 5 - openFolderIcon->width(),
( height() - openFolderIcon->height() ) / 2 , *openFolderIcon );
} else if ( step == 10 ) {
p.drawPixmap( 5, ( height() - openFolderIcon->height() ) / 2,
*openFolderIcon );
p.drawPixmap( width() - 5 - endCopyIcon->width(),
( height() - endCopyIcon->height() ) / 2 , *endCopyIcon );
} else {
p.drawPixmap( 5, ( height() - openFolderIcon->height() ) / 2,
*openFolderIcon );
p.drawPixmap( width() - 5 - openFolderIcon->width(),
( height() - openFolderIcon->height() ) / 2 , *openFolderIcon );
int x = 10 + openFolderIcon->width();
int w = width() - 2 * x;
int s = w / 9;
p.drawPixmap( x + s * step, ( height() - fileIcon->height() ) / 2 - fileIcon->height(),
*fileIcon );
}
}
qt'QFDProgressAnimation::paintEvent() (./qt-2.1.0/src/dialogs/qfiledialog.cpp:701)
void QFDProgressAnimation::paintEvent( QPaintEvent * )
{
erase();
QPainter p;
p.begin( this );
if ( step == 0 ) {
p.drawPixmap( 5, ( height() - startCopyIcon->height() ) / 2,
*startCopyIcon );
p.drawPixmap( width() - 5 - openFolderIcon->width(),
( height() - openFolderIcon->height() ) / 2 , *openFolderIcon );
} else if ( step == 10 ) {
p.drawPixmap( 5, ( height() - openFolderIcon->height() ) / 2,
*openFolderIcon );
p.drawPixmap( width() - 5 - endCopyIcon->width(),
( height() - endCopyIcon->height() ) / 2 , *endCopyIcon );
} else {
p.drawPixmap( 5, ( height() - openFolderIcon->height() ) / 2,
*openFolderIcon );
p.drawPixmap( width() - 5 - openFolderIcon->width(),
( height() - openFolderIcon->height() ) / 2 , *openFolderIcon );
int x = 10 + openFolderIcon->width();
int w = width() - 2 * x;
int s = w / 9;
p.drawPixmap( x + s * step, ( height() - fileIcon->height() ) / 2 - fileIcon->height(),
*fileIcon );
}
}