Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

owait.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022  :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 */
00030 
00031 #include "owait.h"
00032 
00033 /* OPIE */
00034 #include <opie2/oresource.h>
00035 
00036 
00037 #include <qpe/qpeapplication.h>
00038 
00039 /* QT */
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 {}

Generated on Sat Nov 5 16:16:28 2005 for OPIE by  doxygen 1.4.2