summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-02-13 13:38:06 (UTC)
committer mickeyl <mickeyl>2004-02-13 13:38:06 (UTC)
commit97bdea970b2fb017eef7d3b03d7a316eb216266b (patch) (unidiff)
tree21e9eb8986829cde04447a2018ba745a64640386
parentdba46ffd80c121aee412ec45f9bd6d0b9be5058e (diff)
downloadopie-97bdea970b2fb017eef7d3b03d7a316eb216266b.zip
opie-97bdea970b2fb017eef7d3b03d7a316eb216266b.tar.gz
opie-97bdea970b2fb017eef7d3b03d7a316eb216266b.tar.bz2
opie-camera no longer needs libopie1
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/cmd/cmd.pro2
-rw-r--r--noncore/multimedia/camera/config.in6
-rw-r--r--noncore/multimedia/camera/gui/gui.pro4
-rw-r--r--noncore/multimedia/camera/gui/mainwindow.cpp28
-rw-r--r--noncore/multimedia/camera/lib/lib.pro4
5 files changed, 21 insertions, 23 deletions
diff --git a/noncore/multimedia/camera/cmd/cmd.pro b/noncore/multimedia/camera/cmd/cmd.pro
index 7981e82..b90289b 100644
--- a/noncore/multimedia/camera/cmd/cmd.pro
+++ b/noncore/multimedia/camera/cmd/cmd.pro
@@ -1,18 +1,16 @@
1MOC_DIR = ./moc
2OBJECTS_DIR = ./obj
3DESTDIR = $(OPIEDIR)/bin 1DESTDIR = $(OPIEDIR)/bin
4TEMPLATE = app 2TEMPLATE = app
5CONFIG += qt warn_on debug 3CONFIG += qt warn_on debug
6 4
7HEADERS = capture.h 5HEADERS = capture.h
8 6
9SOURCES = capture.cpp 7SOURCES = capture.cpp
10 8
11INCLUDEPATH += $(OPIEDIR)/include ../lib 9INCLUDEPATH += $(OPIEDIR)/include ../lib
12DEPENDPATH += $(OPIEDIR)/include ../lib 10DEPENDPATH += $(OPIEDIR)/include ../lib
13LIBS += -lqpe -lopiecore2 -lopiecam 11LIBS += -lqpe -lopiecore2 -lopiecam
14INTERFACES = 12INTERFACES =
15TARGET = capture 13TARGET = capture
16 14
17include ( $(OPIEDIR)/include.pro ) 15include ( $(OPIEDIR)/include.pro )
18 16
diff --git a/noncore/multimedia/camera/config.in b/noncore/multimedia/camera/config.in
index 861abcb..cfd71ad 100644
--- a/noncore/multimedia/camera/config.in
+++ b/noncore/multimedia/camera/config.in
@@ -1,7 +1,7 @@
1 config CAMERA 1 config CAMERA
2 boolean "opie-camera (camera app to use with the Sharp CE-AG06)" 2 boolean "opie-camera (camera app to use with the Sharp CE-AG06)"
3 default "n" 3 default "n"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2CORE 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE
5 comment "opie-camera needs a libqpe, libopie and libopie2core" 5 comment "opie-camera needs a libqpe, libopie2core"
6 depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE && LIBOPIE2CORE) 6 depends !(( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE)
7 7
diff --git a/noncore/multimedia/camera/gui/gui.pro b/noncore/multimedia/camera/gui/gui.pro
index f587b57..d74f4b6 100644
--- a/noncore/multimedia/camera/gui/gui.pro
+++ b/noncore/multimedia/camera/gui/gui.pro
@@ -1,21 +1,19 @@
1MOC_DIR = ./moc
2OBJECTS_DIR = ./obj
3DESTDIR = $(OPIEDIR)/bin 1DESTDIR = $(OPIEDIR)/bin
4TEMPLATE = app 2TEMPLATE = app
5CONFIG += qt warn_on debug 3CONFIG += qt warn_on debug
6 4
7HEADERS = previewwidget.h \ 5HEADERS = previewwidget.h \
8 mainwindow.h 6 mainwindow.h
9 7
10SOURCES = previewwidget.cpp \ 8SOURCES = previewwidget.cpp \
11 mainwindow.cpp \ 9 mainwindow.cpp \
12 main.cpp 10 main.cpp
13 11
14INCLUDEPATH += $(OPIEDIR)/include ../lib 12INCLUDEPATH += $(OPIEDIR)/include ../lib
15DEPENDPATH += $(OPIEDIR)/include ../lib 13DEPENDPATH += $(OPIEDIR)/include ../lib
16LIBS += -lqpe -lopie -lopiecore2 -lopiecam 14LIBS += -lopiecore2 -lopieui2 -lopiecam
17INTERFACES = 15INTERFACES =
18TARGET = opiecam 16TARGET = opiecam
19 17
20include ( $(OPIEDIR)/include.pro ) 18include ( $(OPIEDIR)/include.pro )
21 19
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp
index 5da3757..2f42049 100644
--- a/noncore/multimedia/camera/gui/mainwindow.cpp
+++ b/noncore/multimedia/camera/gui/mainwindow.cpp
@@ -1,240 +1,244 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#include "mainwindow.h" 16#include "mainwindow.h"
17#include "previewwidget.h" 17#include "previewwidget.h"
18#include "zcameraio.h" 18#include "zcameraio.h"
19#include "imageio.h" 19#include "imageio.h"
20#include "avi.h" 20#include "avi.h"
21 21
22/* OPIE */
23#include <opie2/ofiledialog.h>
24#include <opie2/odevice.h>
25#include <opie2/oapplication.h>
26#include <opie2/oconfig.h>
27#include <opie2/odebug.h>
28#include <qpe/global.h>
29#include <qpe/resource.h>
30#include <qpe/qcopenvelope_qws.h>
31using namespace Opie;
32
33/* QT */
22#include <qapplication.h> 34#include <qapplication.h>
23#include <qaction.h> 35#include <qaction.h>
24#include <qvbox.h> 36#include <qvbox.h>
25#include <qcombobox.h> 37#include <qcombobox.h>
26#include <qcursor.h> 38#include <qcursor.h>
27#include <qdatastream.h> 39#include <qdatastream.h>
28#include <qdir.h> 40#include <qdir.h>
29#include <qfile.h> 41#include <qfile.h>
30#include <qimage.h> 42#include <qimage.h>
31#include <qlabel.h> 43#include <qlabel.h>
32#include <qlineedit.h> 44#include <qlineedit.h>
33#include <qpopupmenu.h> 45#include <qpopupmenu.h>
34#include <qprogressbar.h> 46#include <qprogressbar.h>
35#include <qpushbutton.h> 47#include <qpushbutton.h>
36#include <qmessagebox.h> 48#include <qmessagebox.h>
37#include <qlayout.h> 49#include <qlayout.h>
38#include <qdirectpainter_qws.h> 50#include <qdirectpainter_qws.h>
39#include <qpe/global.h>
40#include <qpe/resource.h>
41#include <qpe/qcopenvelope_qws.h>
42#include <opie/ofiledialog.h>
43#include <opie/odevice.h>
44using namespace Opie;
45#include <opie2/oapplication.h>
46#include <opie2/oconfig.h>
47#include <opie2/odebug.h>
48 51
52/* STD */
49#include <assert.h> 53#include <assert.h>
50#include <sys/types.h> 54#include <sys/types.h>
51#include <sys/stat.h> 55#include <sys/stat.h>
52#include <fcntl.h> 56#include <fcntl.h>
53#include <string.h> 57#include <string.h>
54#include <errno.h> 58#include <errno.h>
55#include <unistd.h> 59#include <unistd.h>
56 60
57#define CAPTUREFILE "/tmp/capture.dat" 61#define CAPTUREFILE "/tmp/capture.dat"
58#define OUTPUTFILE "/tmp/output.avi" 62#define OUTPUTFILE "/tmp/output.avi"
59 63
60#define OUTPUT_TO_CUSTOM 250 64#define OUTPUT_TO_CUSTOM 250
61#define OUTPUT_TO_DOCFOLDER 251 65#define OUTPUT_TO_DOCFOLDER 251
62 66
63CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) 67CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f )
64 :QMainWindow( parent, name, f ), 68 :QMainWindow( parent, name, f ),
65 _rotation( 270 ), // FIXME: get this from current settings (ODevice?) 69 _rotation( 270 ), // FIXME: get this from current settings (ODevice?)
66 _capturing( false ), 70 _capturing( false ),
67 _pics( 1 ), _videos( 1 ) 71 _pics( 1 ), _videos( 1 )
68{ 72{
69 #ifdef QT_NO_DEBUG 73 #ifdef QT_NO_DEBUG
70 if ( !ZCameraIO::instance()->isOpen() ) 74 if ( !ZCameraIO::instance()->isOpen() )
71 { 75 {
72 QVBox* v = new QVBox( this ); 76 QVBox* v = new QVBox( this );
73 v->setMargin( 10 ); 77 v->setMargin( 10 );
74 QLabel* l1 = new QLabel( v ); 78 QLabel* l1 = new QLabel( v );
75 l1->setPixmap( Resource::loadPixmap( "camera/error" ) ); 79 l1->setPixmap( Resource::loadPixmap( "camera/error" ) );
76 QLabel* l2 = new QLabel( v ); 80 QLabel* l2 = new QLabel( v );
77 l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>" 81 l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>"
78 "* Is the sharpzdc_cs module loaded ?<br>" 82 "* Is the sharpzdc_cs module loaded ?<br>"
79 "* Is /dev/sharpzdc read/writable ?<p>" ); 83 "* Is /dev/sharpzdc read/writable ?<p>" );
80 connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) ); 84 connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) );
81 setCentralWidget( v ); 85 setCentralWidget( v );
82 return; 86 return;
83 } 87 }
84 #endif 88 #endif
85 89
86 init(); 90 init();
87 91
88 _rotation = 270; //TODO: grab these from the actual settings 92 _rotation = 270; //TODO: grab these from the actual settings
89 93
90 preview = new PreviewWidget( this, "camera preview widget" ); 94 preview = new PreviewWidget( this, "camera preview widget" );
91 //setCentralWidget( preview ); <--- don't do this! 95 //setCentralWidget( preview ); <--- don't do this!
92 preview->resize( QSize( 240, 288 ) ); 96 preview->resize( QSize( 240, 288 ) );
93 preview->show(); 97 preview->show();
94 98
95 // construct a System Channel to receive setRotation messages 99 // construct a System Channel to receive setRotation messages
96 _sysChannel = new QCopChannel( "QPE/System", this ); 100 _sysChannel = new QCopChannel( "QPE/System", this );
97 connect( _sysChannel, SIGNAL( received( const QCString&, const QByteArray& ) ), 101 connect( _sysChannel, SIGNAL( received( const QCString&, const QByteArray& ) ),
98 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 102 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
99 103
100 connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) ); 104 connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) );
101 105
102 connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); 106 connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) );
103 107
104 updateCaption(); 108 updateCaption();
105 109
106}; 110};
107 111
108 112
109CameraMainWindow::~CameraMainWindow() 113CameraMainWindow::~CameraMainWindow()
110{ 114{
111 // write back configuration 115 // write back configuration
112 OConfigGroupSaver cgs( oApp->config(), "General" ); 116 OConfigGroupSaver cgs( oApp->config(), "General" );
113 cgs.config()->writeEntry( "flip", flip ); 117 cgs.config()->writeEntry( "flip", flip );
114 cgs.config()->writeEntry( "quality", quality ); 118 cgs.config()->writeEntry( "quality", quality );
115 cgs.config()->writeEntry( "zoom", zoom ); 119 cgs.config()->writeEntry( "zoom", zoom );
116 cgs.config()->writeEntry( "captureX", captureX ); 120 cgs.config()->writeEntry( "captureX", captureX );
117 cgs.config()->writeEntry( "captureY", captureY ); 121 cgs.config()->writeEntry( "captureY", captureY );
118 cgs.config()->writeEntry( "captureFormat", captureFormat ); 122 cgs.config()->writeEntry( "captureFormat", captureFormat );
119 cgs.config()->writeEntry( "outputTo", outputTo ); 123 cgs.config()->writeEntry( "outputTo", outputTo );
120 cgs.config()->writeEntry( "prefix", prefix ); 124 cgs.config()->writeEntry( "prefix", prefix );
121 cgs.config()->writeEntry( "appendSettings", appendSettings ); 125 cgs.config()->writeEntry( "appendSettings", appendSettings );
122} 126}
123 127
124 128
125void CameraMainWindow::init() 129void CameraMainWindow::init()
126{ 130{
127 // get values from configuration 131 // get values from configuration
128 OConfigGroupSaver cgs( oApp->config(), "General" ); 132 OConfigGroupSaver cgs( oApp->config(), "General" );
129 flip = cgs.config()->readEntry( "flip", "A" ); 133 flip = cgs.config()->readEntry( "flip", "A" );
130 quality = cgs.config()->readNumEntry( "quality", 50 ); 134 quality = cgs.config()->readNumEntry( "quality", 50 );
131 zoom = cgs.config()->readNumEntry( "zoom", 1 ); 135 zoom = cgs.config()->readNumEntry( "zoom", 1 );
132 captureX = cgs.config()->readNumEntry( "captureX", 480 ); 136 captureX = cgs.config()->readNumEntry( "captureX", 480 );
133 captureY = cgs.config()->readNumEntry( "captureY", 640 ); 137 captureY = cgs.config()->readNumEntry( "captureY", 640 );
134 captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" ); 138 captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" );
135 outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" ); 139 outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" );
136 prefix = cgs.config()->readEntry( "prefix", "Untitled" ); 140 prefix = cgs.config()->readEntry( "prefix", "Untitled" );
137 appendSettings = cgs.config()->readBoolEntry( "appendSettings", true ); 141 appendSettings = cgs.config()->readBoolEntry( "appendSettings", true );
138 142
139 // create action groups 143 // create action groups
140 QAction* a; 144 QAction* a;
141 resog = new QActionGroup( 0, "reso", true ); 145 resog = new QActionGroup( 0, "reso", true );
142 resog->setToggleAction( true ); 146 resog->setToggleAction( true );
143 new QAction( " 64 x 48", 0, 0, resog, "64x48", true ); 147 new QAction( " 64 x 48", 0, 0, resog, "64x48", true );
144 new QAction( "128 x 96", 0, 0, resog, "128x96", true ); 148 new QAction( "128 x 96", 0, 0, resog, "128x96", true );
145 new QAction( "192 x 144", 0, 0, resog, "192x144", true ); 149 new QAction( "192 x 144", 0, 0, resog, "192x144", true );
146 new QAction( "256 x 192", 0, 0, resog, "256x192", true ); 150 new QAction( "256 x 192", 0, 0, resog, "256x192", true );
147 new QAction( "320 x 240", 0, 0, resog, "320x240", true ); 151 new QAction( "320 x 240", 0, 0, resog, "320x240", true );
148 new QAction( "384 x 288", 0, 0, resog, "384x288", true ); 152 new QAction( "384 x 288", 0, 0, resog, "384x288", true );
149 new QAction( "448 x 336", 0, 0, resog, "448x336", true ); 153 new QAction( "448 x 336", 0, 0, resog, "448x336", true );
150 new QAction( "512 x 384", 0, 0, resog, "512x384", true ); 154 new QAction( "512 x 384", 0, 0, resog, "512x384", true );
151 new QAction( "576 x 432", 0, 0, resog, "576x432", true ); 155 new QAction( "576 x 432", 0, 0, resog, "576x432", true );
152 new QAction( "640 x 480", 0, 0, resog, "640x480", true ); 156 new QAction( "640 x 480", 0, 0, resog, "640x480", true );
153 a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) ); 157 a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) );
154 if ( a ) a->setOn( true ); 158 if ( a ) a->setOn( true );
155 else owarn << "can't set resolution" << oendl; 159 else owarn << "can't set resolution" << oendl;
156 160
157 qualityg = new QActionGroup( 0, "quality", true ); 161 qualityg = new QActionGroup( 0, "quality", true );
158 qualityg->setToggleAction( true ); 162 qualityg->setToggleAction( true );
159 new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true ); 163 new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true );
160 new QAction( " 25 (&low)", 0, 0, qualityg, "25", true ); 164 new QAction( " 25 (&low)", 0, 0, qualityg, "25", true );
161 new QAction( " 50 (&good)", 0, 0, qualityg, "50", true ); 165 new QAction( " 50 (&good)", 0, 0, qualityg, "50", true );
162 new QAction( " 75 (&better)", 0, 0, qualityg, "75", true ); 166 new QAction( " 75 (&better)", 0, 0, qualityg, "75", true );
163 new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true ); 167 new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true );
164 a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) ); 168 a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) );
165 if ( a ) a->setOn( true ); 169 if ( a ) a->setOn( true );
166 else owarn << "can't set quality" << oendl; 170 else owarn << "can't set quality" << oendl;
167 171
168 zoomg = new QActionGroup( 0, "zoom", true ); 172 zoomg = new QActionGroup( 0, "zoom", true );
169 zoomg->setToggleAction( true ); 173 zoomg->setToggleAction( true );
170 new QAction( "x 1", 0, 0, zoomg, "1", true ); 174 new QAction( "x 1", 0, 0, zoomg, "1", true );
171 new QAction( "x 2", 0, 0, zoomg, "2", true ); 175 new QAction( "x 2", 0, 0, zoomg, "2", true );
172 a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) ); 176 a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) );
173 if ( a ) a->setOn( true ); 177 if ( a ) a->setOn( true );
174 else owarn << "can't set zoom" << oendl; 178 else owarn << "can't set zoom" << oendl;
175 179
176 flipg = new QActionGroup( 0, "flip", true ); 180 flipg = new QActionGroup( 0, "flip", true );
177 flipg->setToggleAction( true ); 181 flipg->setToggleAction( true );
178 new QAction( "Auto (recommended)", 0, 0, flipg, "A", true ); 182 new QAction( "Auto (recommended)", 0, 0, flipg, "A", true );
179 new QAction( "0 (always off)", 0, 0, flipg, "0", true ); 183 new QAction( "0 (always off)", 0, 0, flipg, "0", true );
180 new QAction( "X (always horizontal)", 0, 0, flipg, "X", true ); 184 new QAction( "X (always horizontal)", 0, 0, flipg, "X", true );
181 new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true ); 185 new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true );
182 new QAction( "* (always both)", 0, 0, flipg, "*", true ); 186 new QAction( "* (always both)", 0, 0, flipg, "*", true );
183 a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) ); 187 a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) );
184 if ( a ) a->setOn( true ); 188 if ( a ) a->setOn( true );
185 else owarn << "can't set flip" << oendl; 189 else owarn << "can't set flip" << oendl;
186 190
187 outputTog = new QActionGroup( 0, "output", true ); 191 outputTog = new QActionGroup( 0, "output", true );
188 outputTog->setToggleAction( true ); 192 outputTog->setToggleAction( true );
189 new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true ); 193 new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true );
190 new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true ); 194 new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true );
191 new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true ); 195 new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true );
192 docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true ); 196 docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true );
193 custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!? 197 custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!?
194 a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) ); 198 a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) );
195 if ( a ) a->setOn( true ); 199 if ( a ) a->setOn( true );
196 else owarn << "can't set outputTo" << oendl; 200 else owarn << "can't set outputTo" << oendl;
197 201
198 outputg = new QActionGroup( 0, "output", true ); 202 outputg = new QActionGroup( 0, "output", true );
199 outputg->setToggleAction( true ); 203 outputg->setToggleAction( true );
200 new QAction( "JPEG", 0, 0, outputg, "JPEG", true ); 204 new QAction( "JPEG", 0, 0, outputg, "JPEG", true );
201 new QAction( "PNG", 0, 0, outputg, "PNG", true ); 205 new QAction( "PNG", 0, 0, outputg, "PNG", true );
202 new QAction( "BMP", 0, 0, outputg, "BMP", true ); 206 new QAction( "BMP", 0, 0, outputg, "BMP", true );
203 new QAction( "AVI", 0, 0, outputg, "AVI", true ); 207 new QAction( "AVI", 0, 0, outputg, "AVI", true );
204 a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) ); 208 a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) );
205 if ( a ) a->setOn( true ); 209 if ( a ) a->setOn( true );
206 else owarn << "can't set output format" << oendl; 210 else owarn << "can't set output format" << oendl;
207 211
208 connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) ); 212 connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) );
209 connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) ); 213 connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) );
210 connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); 214 connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) );
211 connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) ); 215 connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) );
212 connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) ); 216 connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) );
213 connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); 217 connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) );
214} 218}
215 219
216 220
217void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data ) 221void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data )
218{ 222{
219 int _newrotation; 223 int _newrotation;
220 224
221 QDataStream stream( data, IO_ReadOnly ); 225 QDataStream stream( data, IO_ReadOnly );
222 odebug << "received system message: " << msg << oendl; 226 odebug << "received system message: " << msg << oendl;
223 if ( msg == "setCurrentRotation(int)" ) 227 if ( msg == "setCurrentRotation(int)" )
224 { 228 {
225 stream >> _newrotation; 229 stream >> _newrotation;
226 odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; 230 odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl;
227 231
228 switch ( _newrotation ) 232 switch ( _newrotation )
229 { 233 {
230 case 270: preview->resize( QSize( 240, 288 ) ); break; 234 case 270: preview->resize( QSize( 240, 288 ) ); break;
231 case 180: preview->resize( QSize( 320, 208 ) ); break; 235 case 180: preview->resize( QSize( 320, 208 ) ); break;
232 default: QMessageBox::warning( this, "opie-camera", 236 default: QMessageBox::warning( this, "opie-camera",
233 "This rotation is not supported.\n" 237 "This rotation is not supported.\n"
234 "Supported are 180° and 270°" ); 238 "Supported are 180° and 270°" );
235 } 239 }
236 240
237 if ( _newrotation != _rotation ) 241 if ( _newrotation != _rotation )
238 { 242 {
239 int tmp = captureX; 243 int tmp = captureX;
240 captureX = captureY; 244 captureX = captureY;
@@ -249,476 +253,476 @@ void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& dat
249 253
250 254
251void CameraMainWindow::changeZoom( int zoom ) 255void CameraMainWindow::changeZoom( int zoom )
252{ 256{
253 int z; 257 int z;
254 switch ( zoom ) 258 switch ( zoom )
255 { 259 {
256 case 0: z = 128; break; 260 case 0: z = 128; break;
257 case 1: z = 256; break; 261 case 1: z = 256; break;
258 case 2: z = 512; break; 262 case 2: z = 512; break;
259 default: assert( 0 ); break; 263 default: assert( 0 ); break;
260 } 264 }
261 265
262 ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); 266 ZCameraIO::instance()->setCaptureFrame( 240, 160, z );
263} 267}
264 268
265 269
266void CameraMainWindow::showContextMenu() 270void CameraMainWindow::showContextMenu()
267{ 271{
268 QPopupMenu reso; 272 QPopupMenu reso;
269 reso.setCheckable( true ); 273 reso.setCheckable( true );
270 resog->addTo( &reso ); 274 resog->addTo( &reso );
271 275
272 QPopupMenu quality; 276 QPopupMenu quality;
273 quality.setCheckable( true ); 277 quality.setCheckable( true );
274 qualityg->addTo( &quality ); 278 qualityg->addTo( &quality );
275 279
276 QPopupMenu flip; 280 QPopupMenu flip;
277 flip.setCheckable( true ); 281 flip.setCheckable( true );
278 flipg->addTo( &flip ); 282 flipg->addTo( &flip );
279 283
280 QPopupMenu zoom; 284 QPopupMenu zoom;
281 zoom.setCheckable( true ); 285 zoom.setCheckable( true );
282 zoomg->addTo( &zoom ); 286 zoomg->addTo( &zoom );
283 287
284 QPopupMenu prefix; 288 QPopupMenu prefix;
285 prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) ); 289 prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) );
286 int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) ); 290 int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) );
287 prefix.setItemChecked( id, appendSettings ); 291 prefix.setItemChecked( id, appendSettings );
288 292
289 QPopupMenu outputTo; 293 QPopupMenu outputTo;
290 outputTo.setCheckable( true ); 294 outputTo.setCheckable( true );
291 outputTog->addTo( &outputTo ); 295 outputTog->addTo( &outputTo );
292 296
293 QPopupMenu output; 297 QPopupMenu output;
294 output.setCheckable( true ); 298 output.setCheckable( true );
295 outputg->addTo( &output ); 299 outputg->addTo( &output );
296 300
297 QPopupMenu m( this ); 301 QPopupMenu m( this );
298 m.insertItem( "&Resolution", &reso ); 302 m.insertItem( "&Resolution", &reso );
299 m.insertItem( "&Zoom", &zoom ); 303 m.insertItem( "&Zoom", &zoom );
300 m.insertItem( "&Flip", &flip ); 304 m.insertItem( "&Flip", &flip );
301 m.insertItem( "&Quality", &quality ); 305 m.insertItem( "&Quality", &quality );
302 m.insertSeparator(); 306 m.insertSeparator();
303 m.insertItem( "&Prefix", &prefix ); 307 m.insertItem( "&Prefix", &prefix );
304 m.insertItem( "Output &To", &outputTo ); 308 m.insertItem( "Output &To", &outputTo );
305 m.insertItem( "&Output As", &output ); 309 m.insertItem( "&Output As", &output );
306 310
307 #ifndef QT_NO_DEBUG 311 #ifndef QT_NO_DEBUG
308 m.insertItem( "&Debug!", this, SLOT( doSomething() ) ); 312 m.insertItem( "&Debug!", this, SLOT( doSomething() ) );
309 #endif 313 #endif
310 314
311 m.exec( QCursor::pos() ); 315 m.exec( QCursor::pos() );
312} 316}
313 317
314 318
315void CameraMainWindow::resoMenuItemClicked( QAction* a ) 319void CameraMainWindow::resoMenuItemClicked( QAction* a )
316{ 320{
317 switch ( _rotation ) 321 switch ( _rotation )
318 { 322 {
319 case 270: 323 case 270:
320 captureY = a->text().left(3).toInt(); 324 captureY = a->text().left(3).toInt();
321 captureX = a->text().right(3).toInt(); 325 captureX = a->text().right(3).toInt();
322 break; 326 break;
323 case 180: 327 case 180:
324 captureX = a->text().left(3).toInt(); 328 captureX = a->text().left(3).toInt();
325 captureY = a->text().right(3).toInt(); 329 captureY = a->text().right(3).toInt();
326 break; 330 break;
327 default: QMessageBox::warning( this, "opie-camera", 331 default: QMessageBox::warning( this, "opie-camera",
328 "This rotation is not supported.\n" 332 "This rotation is not supported.\n"
329 "Supported are 180° and 270°" ); 333 "Supported are 180° and 270°" );
330 } 334 }
331 odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; 335 odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl;
332 updateCaption(); 336 updateCaption();
333} 337}
334 338
335 339
336void CameraMainWindow::qualityMenuItemClicked( QAction* a ) 340void CameraMainWindow::qualityMenuItemClicked( QAction* a )
337{ 341{
338 quality = a->text().left(3).toInt(); 342 quality = a->text().left(3).toInt();
339 odebug << "Quality now: " << quality << oendl; 343 odebug << "Quality now: " << quality << oendl;
340 updateCaption(); 344 updateCaption();
341} 345}
342 346
343 347
344void CameraMainWindow::zoomMenuItemClicked( QAction* a ) 348void CameraMainWindow::zoomMenuItemClicked( QAction* a )
345{ 349{
346 zoom = QString( a->text().at(2) ).toInt(); 350 zoom = QString( a->text().at(2) ).toInt();
347 odebug << "Zoom now: " << zoom << oendl; 351 odebug << "Zoom now: " << zoom << oendl;
348 ZCameraIO::instance()->setZoom( zoom ); 352 ZCameraIO::instance()->setZoom( zoom );
349 updateCaption(); 353 updateCaption();
350} 354}
351 355
352 356
353void CameraMainWindow::flipMenuItemClicked( QAction* a ) 357void CameraMainWindow::flipMenuItemClicked( QAction* a )
354{ 358{
355 flip = QString( a->text().at(0) ); 359 flip = QString( a->text().at(0) );
356 odebug << "Flip now: " << flip << oendl; 360 odebug << "Flip now: " << flip << oendl;
357 if ( flip == "A" ) 361 if ( flip == "A" )
358 ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); 362 ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP );
359 else if ( flip == "0" ) 363 else if ( flip == "0" )
360 ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); 364 ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP );
361 else if ( flip == "X" ) 365 else if ( flip == "X" )
362 ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); 366 ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP );
363 else if ( flip == "Y" ) 367 else if ( flip == "Y" )
364 ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); 368 ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP );
365 else if ( flip == "*" ) 369 else if ( flip == "*" )
366 ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); 370 ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP );
367 371
368 updateCaption(); 372 updateCaption();
369} 373}
370 374
371 375
372void CameraMainWindow::outputToMenuItemClicked( QAction* a ) 376void CameraMainWindow::outputToMenuItemClicked( QAction* a )
373{ 377{
374 if ( a->text() == "&Custom..." ) 378 if ( a->text() == "&Custom..." )
375 { 379 {
376 QMap<QString, QStringList> map; 380 QMap<QString, QStringList> map;
377 map.insert( tr("All"), QStringList() ); 381 map.insert( tr("All"), QStringList() );
378 QStringList text; 382 QStringList text;
379 text << "text/*"; 383 text << "text/*";
380 map.insert(tr("Text"), text ); 384 map.insert(tr("Text"), text );
381 text << "*"; 385 text << "*";
382 map.insert(tr("All"), text ); 386 map.insert(tr("All"), text );
383 387
384 QString str; 388 QString str;
385 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); 389 str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
386 if ( str.isEmpty() || !QFileInfo(str).isDir() ) 390 if ( str.isEmpty() || !QFileInfo(str).isDir() )
387 { 391 {
388 docfolder->setOn( true ); 392 docfolder->setOn( true );
389 outputTo = "Documents Folder"; 393 outputTo = "Documents Folder";
390 } 394 }
391 else 395 else
392 { 396 {
393 outputTo = str; 397 outputTo = str;
394 } 398 }
395 } 399 }
396 else 400 else
397 { 401 {
398 outputTo = a->text(); 402 outputTo = a->text();
399 } 403 }
400 odebug << "Output to now: " << outputTo << oendl; 404 odebug << "Output to now: " << outputTo << oendl;
401} 405}
402 406
403 407
404void CameraMainWindow::outputMenuItemClicked( QAction* a ) 408void CameraMainWindow::outputMenuItemClicked( QAction* a )
405{ 409{
406 captureFormat = a->text(); 410 captureFormat = a->text();
407 odebug << "Output format now: " << captureFormat << oendl; 411 odebug << "Output format now: " << captureFormat << oendl;
408 updateCaption(); 412 updateCaption();
409} 413}
410 414
411 415
412void CameraMainWindow::prefixItemChoosen() 416void CameraMainWindow::prefixItemChoosen()
413{ 417{
414 QDialog* d = new QDialog( this, "dialog", true ); 418 QDialog* d = new QDialog( this, "dialog", true );
415 d->setCaption( "Enter Prefix..." ); 419 d->setCaption( "Enter Prefix..." );
416 QVBoxLayout* v = new QVBoxLayout( d ); 420 QVBoxLayout* v = new QVBoxLayout( d );
417 QLineEdit* le = new QLineEdit( prefix, d ); 421 QLineEdit* le = new QLineEdit( prefix, d );
418 v->addWidget( le ); 422 v->addWidget( le );
419 le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty 423 le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty
420 if ( d->exec() == QDialog::Accepted ) 424 if ( d->exec() == QDialog::Accepted )
421 prefix = le->text(); 425 prefix = le->text();
422 odebug << "Prefix now: " << prefix << oendl; 426 odebug << "Prefix now: " << prefix << oendl;
423} 427}
424 428
425 429
426void CameraMainWindow::appendSettingsChoosen() 430void CameraMainWindow::appendSettingsChoosen()
427{ 431{
428 appendSettings = !appendSettings; 432 appendSettings = !appendSettings;
429 odebug << "appendSettings now: " << appendSettings << oendl; 433 odebug << "appendSettings now: " << appendSettings << oendl;
430} 434}
431 435
432 436
433void CameraMainWindow::shutterClicked() 437void CameraMainWindow::shutterClicked()
434{ 438{
435 if ( captureFormat != "AVI" ) // capture one photo per shutterClick 439 if ( captureFormat != "AVI" ) // capture one photo per shutterClick
436 { 440 {
437 Global::statusMessage( "CAPTURING..." ); 441 Global::statusMessage( "CAPTURING..." );
438 qApp->processEvents(); 442 qApp->processEvents();
439 443
440 odebug << "Shutter has been pressed" << oendl; 444 odebug << "Shutter has been pressed" << oendl;
441 ODevice::inst()->touchSound(); 445 ODevice::inst()->playTouchSound();
442 446
443 performCapture( captureFormat ); 447 performCapture( captureFormat );
444 } 448 }
445 else // capture video! start with one shutter click and stop with the next 449 else // capture video! start with one shutter click and stop with the next
446 { 450 {
447 !_capturing ? startVideoCapture() : stopVideoCapture(); 451 !_capturing ? startVideoCapture() : stopVideoCapture();
448 } 452 }
449} 453}
450 454
451 455
452void CameraMainWindow::performCapture( const QString& format ) 456void CameraMainWindow::performCapture( const QString& format )
453{ 457{
454 QString name; 458 QString name;
455 459
456 if ( outputTo == "Documents Folder" ) 460 if ( outputTo == "Documents Folder" )
457 { 461 {
458 name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); 462 name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() );
459 if ( !QDir( name ).exists() ) 463 if ( !QDir( name ).exists() )
460 { 464 {
461 odebug << "creating directory " << name << oendl; 465 odebug << "creating directory " << name << oendl;
462 QString msg = "mkdir -p " + name; 466 QString msg = "mkdir -p " + name;
463 system( msg.latin1() ); 467 system( msg.latin1() );
464 } 468 }
465 } 469 }
466 else 470 else
467 name = outputTo; 471 name = outputTo;
468 472
469 name.append( prefix ); 473 name.append( prefix );
470 if ( appendSettings ) 474 if ( appendSettings )
471 { 475 {
472 name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); 476 name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) );
473 } 477 }
474 name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); 478 name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) );
475 479
476 QImage i; 480 QImage i;
477 ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); 481 ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i );
478 QImage im = i.convertDepth( 32 ); 482 QImage im = i.convertDepth( 32 );
479 bool result = im.save( name, format, quality ); 483 bool result = im.save( name, format, quality );
480 if ( !result ) 484 if ( !result )
481 { 485 {
482 oerr << "imageio-Problem while writing." << oendl; 486 oerr << "imageio-Problem while writing." << oendl;
483 Global::statusMessage( "Error!" ); 487 Global::statusMessage( "Error!" );
484 } 488 }
485 else 489 else
486 { 490 {
487 odebug << captureFormat << "-image has been successfully captured" << oendl; 491 odebug << captureFormat << "-image has been successfully captured" << oendl;
488 Global::statusMessage( "Ok." ); 492 Global::statusMessage( "Ok." );
489 } 493 }
490} 494}
491 495
492 496
493void CameraMainWindow::startVideoCapture() 497void CameraMainWindow::startVideoCapture()
494{ 498{
495 ODevice::inst()->touchSound(); 499 ODevice::inst()->playTouchSound();
496 ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); 500 ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow );
497 501
498 _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); 502 _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC );
499 if ( _capturefd == -1 ) 503 if ( _capturefd == -1 )
500 { 504 {
501 owarn << "can't open capture file: " << strerror(errno) << oendl; 505 owarn << "can't open capture file: " << strerror(errno) << oendl;
502 return; 506 return;
503 } 507 }
504 508
505 _capturebuf = new unsigned char[captureX*captureY*2]; 509 _capturebuf = new unsigned char[captureX*captureY*2];
506 _capturing = true; 510 _capturing = true;
507 _videopics = 0; 511 _videopics = 0;
508 _framerate = 0; 512 _framerate = 0;
509 updateCaption(); 513 updateCaption();
510 _time.start(); 514 _time.start();
511 preview->setRefreshingRate( 1000 ); 515 preview->setRefreshingRate( 1000 );
512 startTimer( 100 ); // too fast but that is ok 516 startTimer( 100 ); // too fast but that is ok
513} 517}
514 518
515 519
516void CameraMainWindow::timerEvent( QTimerEvent* ) 520void CameraMainWindow::timerEvent( QTimerEvent* )
517{ 521{
518 if ( !_capturing ) 522 if ( !_capturing )
519 { 523 {
520 odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; 524 odebug << "timer event in CameraMainWindow without capturing video ?" << oendl;
521 return; 525 return;
522 } 526 }
523 527
524 odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; 528 odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl;
525 529
526 ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); 530 ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf );
527 _videopics++; 531 _videopics++;
528 ::write( _capturefd, _capturebuf, captureX*captureY*2 ); 532 ::write( _capturefd, _capturebuf, captureX*captureY*2 );
529 setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", 533 setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d",
530 captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); 534 captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) );
531} 535}
532 536
533 537
534void CameraMainWindow::stopVideoCapture() 538void CameraMainWindow::stopVideoCapture()
535{ 539{
536 killTimers(); 540 killTimers();
537 ODevice::inst()->touchSound(); 541 ODevice::inst()->playTouchSound();
538 ODevice::inst()->setLedState( Led_Mail, Led_Off ); 542 ODevice::inst()->setLedState( Led_Mail, Led_Off );
539 _capturing = false; 543 _capturing = false;
540 updateCaption(); 544 updateCaption();
541 ::close( _capturefd ); 545 ::close( _capturefd );
542 _framerate = 1000.0 / (_time.elapsed()/_videopics); 546 _framerate = 1000.0 / (_time.elapsed()/_videopics);
543 547
544 QString name; 548 QString name;
545 if ( outputTo == "Documents Folder" ) 549 if ( outputTo == "Documents Folder" )
546 { 550 {
547 name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); 551 name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() );
548 if ( !QDir( name ).exists() ) 552 if ( !QDir( name ).exists() )
549 { 553 {
550 odebug << "creating directory " << name << oendl; 554 odebug << "creating directory " << name << oendl;
551 QString msg = "mkdir -p " + name; 555 QString msg = "mkdir -p " + name;
552 system( msg.latin1() ); 556 system( msg.latin1() );
553 } 557 }
554 } 558 }
555 else 559 else
556 name = outputTo; 560 name = outputTo;
557 561
558 name.append( "/" ); // sure is sure and safe is safe ;-) 562 name.append( "/" ); // sure is sure and safe is safe ;-)
559 name.append( prefix ); 563 name.append( prefix );
560 if ( appendSettings ) 564 if ( appendSettings )
561 name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); 565 name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) );
562 name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); 566 name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) );
563 postProcessVideo( CAPTUREFILE, name ); 567 postProcessVideo( CAPTUREFILE, name );
564 568
565 #ifndef QT_NO_DEBUG 569 #ifndef QT_NO_DEBUG
566 preview->setRefreshingRate( 1500 ); 570 preview->setRefreshingRate( 1500 );
567 #else 571 #else
568 preview->setRefreshingRate( 200 ); 572 preview->setRefreshingRate( 200 );
569 #endif 573 #endif
570 574
571 //delete[] _capturebuf; //FIXME: close memory leak 575 //delete[] _capturebuf; //FIXME: close memory leak
572} 576}
573 577
574void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) 578void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile )
575{ 579{
576 odebug << "post processing " << infile << " --> " << outfile << oendl; 580 odebug << "post processing " << infile << " --> " << outfile << oendl;
577 581
578 preview->setRefreshingRate( 0 ); 582 preview->setRefreshingRate( 0 );
579 583
580 /* 584 /*
581 unsigned char buf[153600]; 585 unsigned char buf[153600];
582 586
583 int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); 587 int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY );
584 ::read( fd, &buf, 153600 ); 588 ::read( fd, &buf, 153600 );
585 QImage i; 589 QImage i;
586 bufferToImage( 240, 320, (unsigned char*) &buf, &i ); 590 bufferToImage( 240, 320, (unsigned char*) &buf, &i );
587 QPixmap p; 591 QPixmap p;
588 p.convertFromImage( i ); 592 p.convertFromImage( i );
589 preview->setPixmap( p ); 593 preview->setPixmap( p );
590 imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); 594 imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 );
591 return; 595 return;
592 */ 596 */
593 597
594 QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize ); 598 QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize );
595 fr->setCaption( "Please wait..." ); 599 fr->setCaption( "Please wait..." );
596 QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 ); 600 QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 );
597 QProgressBar* bar = new QProgressBar( fr ); 601 QProgressBar* bar = new QProgressBar( fr );
598 bar->setCenterIndicator( true ); 602 bar->setCenterIndicator( true );
599 bar->setTotalSteps( _videopics-1 ); 603 bar->setTotalSteps( _videopics-1 );
600 QLabel* label = new QLabel( "Post processing frame bla/bla", fr ); 604 QLabel* label = new QLabel( "Post processing frame bla/bla", fr );
601 box->addWidget( bar ); 605 box->addWidget( bar );
602 box->addWidget( label ); 606 box->addWidget( label );
603 fr->show(); 607 fr->show();
604 label->show(); 608 label->show();
605 bar->show(); 609 bar->show();
606 fr->repaint(); 610 fr->repaint();
607 qApp->processEvents(); 611 qApp->processEvents();
608 612
609 // open files 613 // open files
610 614
611 int infd = ::open( (const char*) infile, O_RDONLY ); 615 int infd = ::open( (const char*) infile, O_RDONLY );
612 if ( infd == -1 ) 616 if ( infd == -1 )
613 { 617 {
614 owarn << "couldn't open capture file: " << strerror(errno) << oendl; 618 owarn << "couldn't open capture file: " << strerror(errno) << oendl;
615 return; 619 return;
616 } 620 }
617 621
618 int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); 622 int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 );
619 if ( outfd == -1 ) 623 if ( outfd == -1 )
620 { 624 {
621 owarn << "couldn't open output file: " << strerror(errno) << oendl; 625 owarn << "couldn't open output file: " << strerror(errno) << oendl;
622 return; 626 return;
623 } 627 }
624 628
625 int framesize = captureX*captureY*2; 629 int framesize = captureX*captureY*2;
626 630
627 unsigned char* inbuffer = new unsigned char[ framesize ]; 631 unsigned char* inbuffer = new unsigned char[ framesize ];
628 QImage image; 632 QImage image;
629 633
630 avi_start( outfd, _videopics ); // write preambel 634 avi_start( outfd, _videopics ); // write preambel
631 635
632 // post process 636 // post process
633 637
634 for ( int i = 0; i < _videopics; ++i ) 638 for ( int i = 0; i < _videopics; ++i )
635 { 639 {
636 odebug << "processing frame " << i << oendl; 640 odebug << "processing frame " << i << oendl;
637 641
638 // <gui> 642 // <gui>
639 label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); 643 label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) );
640 bar->setProgress( i ); 644 bar->setProgress( i );
641 bar->repaint(); 645 bar->repaint();
642 qApp->processEvents(); 646 qApp->processEvents();
643 // </gui> 647 // </gui>
644 648
645 int read = ::read( infd, inbuffer, framesize ); 649 int read = ::read( infd, inbuffer, framesize );
646 odebug << "read " << read << " bytes" << oendl; 650 odebug << "read " << read << " bytes" << oendl;
647 bufferToImage( captureX, captureY, inbuffer, &image ); 651 bufferToImage( captureX, captureY, inbuffer, &image );
648 652
649 QPixmap p; 653 QPixmap p;
650 p.convertFromImage( image ); 654 p.convertFromImage( image );
651 preview->setPixmap( p ); 655 preview->setPixmap( p );
652 preview->repaint(); 656 preview->repaint();
653 qApp->processEvents(); 657 qApp->processEvents();
654 658
655 #ifdef CAMERA_EXTRA_DEBUG 659 #ifdef CAMERA_EXTRA_DEBUG
656 QString tmpfilename; 660 QString tmpfilename;
657 tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); 661 tmpfilename.sprintf( "/tmp/test/%04d.jpg", i );
658 #else 662 #else
659 QString tmpfilename( "/tmp/tempfile" ); 663 QString tmpfilename( "/tmp/tempfile" );
660 #endif 664 #endif
661 665
662 imageToFile( &image, tmpfilename, "JPEG", quality ); 666 imageToFile( &image, tmpfilename, "JPEG", quality );
663 667
664 QFile framefile( tmpfilename ); 668 QFile framefile( tmpfilename );
665 if ( !framefile.open( IO_ReadOnly ) ) 669 if ( !framefile.open( IO_ReadOnly ) )
666 { 670 {
667 oerr << "can't process file: %s" << strerror(errno) << oendl; 671 oerr << "can't process file: %s" << strerror(errno) << oendl;
668 return; // TODO: clean up temp ressources 672 return; // TODO: clean up temp ressources
669 } 673 }
670 674
671 int filesize = framefile.size(); 675 int filesize = framefile.size();
672 odebug << "filesize for frame " << i << " = " << filesize << oendl; 676 odebug << "filesize for frame " << i << " = " << filesize << oendl;
673 677
674 unsigned char* tempbuffer = new unsigned char[ filesize ]; 678 unsigned char* tempbuffer = new unsigned char[ filesize ];
675 framefile.readBlock( (char*) tempbuffer, filesize ); 679 framefile.readBlock( (char*) tempbuffer, filesize );
676 avi_add( outfd, tempbuffer, filesize ); 680 avi_add( outfd, tempbuffer, filesize );
677 delete tempbuffer; 681 delete tempbuffer;
678 framefile.close(); 682 framefile.close();
679 683
680 } 684 }
681 685
682 avi_end( outfd, captureX, captureY, _framerate ); 686 avi_end( outfd, captureX, captureY, _framerate );
683 ::close( outfd ); 687 ::close( outfd );
684 ::close( infd ); 688 ::close( infd );
685 689
686 label->setText( "deleting temp files..." ); 690 label->setText( "deleting temp files..." );
687 qApp->processEvents(); 691 qApp->processEvents();
688 odebug << "deleting temporary capturefile " << infile << oendl; 692 odebug << "deleting temporary capturefile " << infile << oendl;
689 QFile::remove( infile ); 693 QFile::remove( infile );
690 694
691 fr->hide(); 695 fr->hide();
692 delete fr; 696 delete fr;
693 697
694 updateCaption(); 698 updateCaption();
695 699
696} 700}
697 701
698 702
699void CameraMainWindow::updateCaption() 703void CameraMainWindow::updateCaption()
700{ 704{
701 if ( !_capturing ) 705 if ( !_capturing )
702 setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); 706 setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) );
703 else 707 else
704 setCaption( "Opie-Camera: => CAPTURING <=" ); 708 setCaption( "Opie-Camera: => CAPTURING <=" );
705 qApp->processEvents(); 709 qApp->processEvents();
706} 710}
707 711
708 712
709#ifndef QT_NO_DEBUG 713#ifndef QT_NO_DEBUG
710void CameraMainWindow::doSomething() 714void CameraMainWindow::doSomething()
711{ 715{
712 captureX = 240; 716 captureX = 240;
713 captureY = 320; 717 captureY = 320;
714 _videopics = 50; 718 _videopics = 50;
715 _framerate = 5; 719 _framerate = 5;
716 postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", 720 postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat",
717 "/tmp/output.avi" ); 721 "/tmp/output.avi" );
718} 722}
719#else 723#else
720void CameraMainWindow::doSomething() 724void CameraMainWindow::doSomething()
721{ 725{
722} 726}
723#endif 727#endif
724 728
diff --git a/noncore/multimedia/camera/lib/lib.pro b/noncore/multimedia/camera/lib/lib.pro
index 3d2c59b..1e7346f 100644
--- a/noncore/multimedia/camera/lib/lib.pro
+++ b/noncore/multimedia/camera/lib/lib.pro
@@ -1,24 +1,22 @@
1MOC_DIR = ./moc
2OBJECTS_DIR = ./obj
3DESTDIR = $(OPIEDIR)/lib 1DESTDIR = $(OPIEDIR)/lib
4TEMPLATE = lib 2TEMPLATE = lib
5CONFIG += qt warn_on debug 3CONFIG += qt warn_on debug
6 4
7HEADERS = avi.h \ 5HEADERS = avi.h \
8 imageio.h \ 6 imageio.h \
9 zcameraio.h \ 7 zcameraio.h \
10 8
11SOURCES = avi.c \ 9SOURCES = avi.c \
12 imageio.cpp \ 10 imageio.cpp \
13 zcameraio.cpp \ 11 zcameraio.cpp \
14 12
15INCLUDEPATH += $(OPIEDIR)/include 13INCLUDEPATH += $(OPIEDIR)/include
16DEPENDPATH += $(OPIEDIR)/include 14DEPENDPATH += $(OPIEDIR)/include
17LIBS += -lqpe -lopie -lopiecore2 15LIBS += -lopiecore2
18INTERFACES = 16INTERFACES =
19VERSION = 1.0.0 17VERSION = 1.0.0
20TARGET = opiecam 18TARGET = opiecam
21 19
22 20
23include ( $(OPIEDIR)/include.pro ) 21include ( $(OPIEDIR)/include.pro )
24 22