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 /*  This file is part of the OPIE libraries
00002     Copyright (C) 2003 Maximilian Reiss  (harlekin@handhelds.org)
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017     Boston, MA 02111-1307, USA.
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 }

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