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