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

previewwidget.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2002 Michael 'Mickey' Lauer.  All rights reserved.
00003 **
00004 ** This file is part of Opie Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 **********************************************************************/
00015 
00016 #include "previewwidget.h"
00017 #include "zcameraio.h"
00018 
00019 #include <opie2/odebug.h>
00020 
00021 #include <assert.h>
00022 
00023 PreviewWidget::PreviewWidget( QWidget * parent, const char * name, WFlags f )
00024            :QLabel( parent, name, f )
00025 {
00026     #ifndef QT_NO_DEBUG
00027     setBackgroundColor( QColor( 255, 0, 0 ) );
00028     #else
00029     setBackgroundMode( NoBackground );
00030     #endif
00031 
00032     #ifndef QT_NO_DEBUG
00033     if ( ZCameraIO::instance()->isOpen() ) startTimer( 1500 );
00034     #else
00035     if ( ZCameraIO::instance()->isOpen() ) startTimer( 200 );
00036     #endif
00037 };
00038 
00039 
00040 PreviewWidget::~PreviewWidget()
00041 {
00042 }
00043 
00044 
00045 void PreviewWidget::resizeEvent( QResizeEvent* e )
00046 {
00047     QLabel::resizeEvent( e );
00048     int w = e->size().width();
00049     int h = e->size().height();
00050     ZCameraIO::instance()->setCaptureFrame( e->size().width(),
00051                                           e->size().height(),
00052                                           256,
00053                                           w < h );
00054 }
00055 
00056 
00057 void PreviewWidget::timerEvent( QTimerEvent*  )
00058 {
00059     //QDirectPainter fb( this );
00060     //ZCameraIO::instance()->snapshot( fb.frameBuffer() );
00061 
00062     if ( ZCameraIO::instance()->snapshot( &i ) )
00063     {
00064         p.convertFromImage( i );
00065         setPixmap( p );
00066     }
00067 }
00068 
00069 
00070 void PreviewWidget::mousePressEvent( QMouseEvent* )
00071 {
00072     emit contextMenuRequested();
00073 }
00074 
00075 
00076 void PreviewWidget::setRefreshingRate( int ms )
00077 {
00078     killTimers();
00079     if ( ms )
00080         startTimer( ms );
00081 }
00082 
00083 
00084 void PreviewWidget::refresh()
00085 {
00086     QTimerEvent t( 10 ); // event id is meaningless in this case
00087     timerEvent( &t );
00088 }

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