00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <qlayout.h>
00021 #include <qpe/qpeapplication.h>
00022 #include <qpainter.h>
00023
00024 #include "owait.h"
00025
00026 #include <qpe/resource.h>
00027
00028 static int frame = 0;
00029
00039 OWait::OWait(QWidget *parent, const char* msg, bool dispIcon )
00040 :QDialog(parent, msg, TRUE,WStyle_Customize) {
00041
00042
00043 QHBoxLayout *hbox = new QHBoxLayout( this );
00044
00045 m_lb = new QLabel( this );
00046 m_lb->setBackgroundMode ( NoBackground );
00047
00048 hbox->addWidget( m_lb );
00049 hbox->activate();
00050
00051 m_pix = Resource::loadPixmap( "BigBusy" );
00052 m_aniSize = m_pix.height();
00053 resize( m_aniSize, m_aniSize );
00054
00055 m_timerLength = 10;
00056
00057 m_waitTimer = new QTimer( this );
00058 connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) );
00059 }
00060
00061 void OWait::timerEvent( QTimerEvent * ) {
00062 frame = (++frame) % 4;
00063 repaint();
00064 }
00065
00066 void OWait::paintEvent( QPaintEvent * ) {
00067 QPainter p( m_lb );
00068 p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize );
00069 }
00070
00071 void OWait::show() {
00072
00073 move( ( ( qApp->desktop()->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop()->height() ) / 2 ) - ( m_aniSize / 2 ) );
00074 startTimer( 300 );
00075 m_waitTimer->start( m_timerLength * 1000, true );
00076 QDialog::show();
00077 }
00078
00079 void OWait::hide() {
00080 killTimers();
00081 m_waitTimer->stop();
00082 frame = 0;
00083 QDialog::hide();
00084 }
00085
00086 void OWait::setTimerLength( int length ) {
00087 m_timerLength = length;
00088 }
00089
00090 OWait::~OWait() {
00091 }