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