00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include "owait.h"
00032
00033
00034 #include <opie2/oresource.h>
00035
00036
00037 #include <qpe/qpeapplication.h>
00038
00039
00040 #include <qlayout.h>
00041 #include <qpainter.h>
00042
00043 using namespace Opie::Ui;
00044
00045 static int frame = 0;
00046
00056 OWait::OWait( QWidget *parent, const char* msg, bool dispIcon )
00057 :QDialog( parent, msg, TRUE, WStyle_Customize )
00058 {
00059
00060 Q_UNUSED( dispIcon )
00061
00062 QHBoxLayout * hbox = new QHBoxLayout( this );
00063
00064 m_lb = new QLabel( this );
00065 m_lb->setBackgroundMode ( NoBackground );
00066
00067 hbox->addWidget( m_lb );
00068 hbox->activate();
00069
00070 m_pix = Opie::Core::OResource::loadPixmap( "BigBusy" );
00071 m_aniSize = m_pix.height();
00072 resize( m_aniSize, m_aniSize );
00073
00074 m_timerLength = 10;
00075
00076 m_waitTimer = new QTimer( this );
00077 connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) );
00078 }
00079
00080 void OWait::timerEvent( QTimerEvent * )
00081 {
00082 frame = ( ++frame ) % 4;
00083 repaint();
00084 }
00085
00086 void OWait::paintEvent( QPaintEvent * )
00087 {
00088 QPainter p( m_lb );
00089 p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize );
00090 }
00091
00092 void OWait::show()
00093 {
00094
00095 move( ( ( qApp->desktop() ->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop() ->height() ) / 2 ) - ( m_aniSize / 2 ) );
00096 startTimer( 300 );
00097 m_waitTimer->start( m_timerLength * 1000, true );
00098 QDialog::show();
00099 }
00100
00101 void OWait::hide()
00102 {
00103 killTimers();
00104 m_waitTimer->stop();
00105 frame = 0;
00106 QDialog::hide();
00107 }
00108
00109 void OWait::setTimerLength( int length )
00110 {
00111 m_timerLength = length;
00112 }
00113
00114 OWait::~OWait()
00115 {}