libopie API Documentation

owait.cpp

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 <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 }
KDE Logo
This file is part of the documentation for OPIE Version 1.1.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:45 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001