author | mickeyl <mickeyl> | 2003-05-07 10:22:55 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-07 10:22:55 (UTC) |
commit | f9cc1ea78086e7df714a34412bbccdbd5c31f62f (patch) (unidiff) | |
tree | 2494e3b8b5363207407552ada2c3b72fd0499a4b /noncore/multimedia/camera/gui/previewwidget.cpp | |
parent | 8e20590a250d4e75153fbca93330b4add0c34161 (diff) | |
download | opie-f9cc1ea78086e7df714a34412bbccdbd5c31f62f.zip opie-f9cc1ea78086e7df714a34412bbccdbd5c31f62f.tar.gz opie-f9cc1ea78086e7df714a34412bbccdbd5c31f62f.tar.bz2 |
add missing
Diffstat (limited to 'noncore/multimedia/camera/gui/previewwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/gui/previewwidget.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/noncore/multimedia/camera/gui/previewwidget.cpp b/noncore/multimedia/camera/gui/previewwidget.cpp new file mode 100644 index 0000000..08330d0 --- a/dev/null +++ b/noncore/multimedia/camera/gui/previewwidget.cpp | |||
@@ -0,0 +1,88 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Opie Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | **********************************************************************/ | ||
15 | |||
16 | #include "previewwidget.h" | ||
17 | #include "zcameraio.h" | ||
18 | |||
19 | #include <opie2/odebug.h> | ||
20 | |||
21 | #include <assert.h> | ||
22 | |||
23 | PreviewWidget::PreviewWidget( QWidget * parent, const char * name, WFlags f ) | ||
24 | :QLabel( parent, name, f ) | ||
25 | { | ||
26 | #ifndef QT_NO_DEBUG | ||
27 | setBackgroundColor( QColor( 255, 0, 0 ) ); | ||
28 | #else | ||
29 | setBackgroundMode( NoBackground ); | ||
30 | #endif | ||
31 | |||
32 | #ifndef QT_NO_DEBUG | ||
33 | if ( ZCameraIO::instance()->isOpen() ) startTimer( 1500 ); | ||
34 | #else | ||
35 | if ( ZCameraIO::instance()->isOpen() ) startTimer( 200 ); | ||
36 | #endif | ||
37 | }; | ||
38 | |||
39 | |||
40 | PreviewWidget::~PreviewWidget() | ||
41 | { | ||
42 | } | ||
43 | |||
44 | |||
45 | void PreviewWidget::resizeEvent( QResizeEvent* e ) | ||
46 | { | ||
47 | QLabel::resizeEvent( e ); | ||
48 | int w = e->size().width(); | ||
49 | int h = e->size().height(); | ||
50 | ZCameraIO::instance()->setCaptureFrame( e->size().width(), | ||
51 | e->size().height(), | ||
52 | 256, | ||
53 | w < h ); | ||
54 | } | ||
55 | |||
56 | |||
57 | void PreviewWidget::timerEvent( QTimerEvent* ) | ||
58 | { | ||
59 | //QDirectPainter fb( this ); | ||
60 | //ZCameraIO::instance()->snapshot( fb.frameBuffer() ); | ||
61 | |||
62 | if ( ZCameraIO::instance()->snapshot( &i ) ) | ||
63 | { | ||
64 | p.convertFromImage( i ); | ||
65 | setPixmap( p ); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | |||
70 | void PreviewWidget::mousePressEvent( QMouseEvent* ) | ||
71 | { | ||
72 | emit contextMenuRequested(); | ||
73 | } | ||
74 | |||
75 | |||
76 | void PreviewWidget::setRefreshingRate( int ms ) | ||
77 | { | ||
78 | killTimers(); | ||
79 | if ( ms ) | ||
80 | startTimer( ms ); | ||
81 | } | ||
82 | |||
83 | |||
84 | void PreviewWidget::refresh() | ||
85 | { | ||
86 | QTimerEvent t( 10 ); // event id is meaningless in this case | ||
87 | timerEvent( &t ); | ||
88 | } | ||