-rw-r--r-- | noncore/multimedia/camera/cmd/capture.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/camera/gui/main.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/camera/gui/mainwindow.cpp | 5 | ||||
-rw-r--r-- | noncore/multimedia/camera/lib/imageio.cpp | 1 | ||||
-rw-r--r-- | noncore/multimedia/camera/lib/zcameraio.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opierec/helpwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/opierec/main.cpp | 2 |
7 files changed, 14 insertions, 2 deletions
diff --git a/noncore/multimedia/camera/cmd/capture.cpp b/noncore/multimedia/camera/cmd/capture.cpp index 64c223c..688622b 100644 --- a/noncore/multimedia/camera/cmd/capture.cpp +++ b/noncore/multimedia/camera/cmd/capture.cpp | |||
@@ -1,190 +1,192 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2003 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 "capture.h" | 16 | #include "capture.h" |
17 | 17 | ||
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 <opie2/oapplication.h> | 22 | #include <opie2/oapplication.h> |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | 24 | ||
25 | #include <qimage.h> | 25 | #include <qimage.h> |
26 | 26 | ||
27 | using namespace Opie::Core; | ||
28 | using namespace Opie::Core; | ||
27 | Capturer::Capturer() | 29 | Capturer::Capturer() |
28 | :QFrame( 0 ), height( 320 ), width( 240 ), zoom( 1 ), quality( 90 ), | 30 | :QFrame( 0 ), height( 320 ), width( 240 ), zoom( 1 ), quality( 90 ), |
29 | flip( "A" ), format( "JPEG" ), name( "Untitled" ) | 31 | flip( "A" ), format( "JPEG" ), name( "Untitled" ) |
30 | { | 32 | { |
31 | } | 33 | } |
32 | 34 | ||
33 | 35 | ||
34 | Capturer::~Capturer() | 36 | Capturer::~Capturer() |
35 | { | 37 | { |
36 | } | 38 | } |
37 | 39 | ||
38 | 40 | ||
39 | void Capturer::checkSettings() | 41 | void Capturer::checkSettings() |
40 | { | 42 | { |
41 | if ( width > height ) | 43 | if ( width > height ) |
42 | { | 44 | { |
43 | if ( 0 != width % 16 || width < 16 || width > 640 ) | 45 | if ( 0 != width % 16 || width < 16 || width > 640 ) |
44 | { | 46 | { |
45 | printf( "Warning: Corrected X resolution to 320 px\n" ); | 47 | printf( "Warning: Corrected X resolution to 320 px\n" ); |
46 | width = 320; | 48 | width = 320; |
47 | } | 49 | } |
48 | if ( 0 != height % 16 || height < 16 || height > 480 ) | 50 | if ( 0 != height % 16 || height < 16 || height > 480 ) |
49 | { | 51 | { |
50 | printf( "Warning: Corrected Y resolution to 240 px\n" ); | 52 | printf( "Warning: Corrected Y resolution to 240 px\n" ); |
51 | height = 240; | 53 | height = 240; |
52 | } | 54 | } |
53 | } | 55 | } |
54 | else | 56 | else |
55 | { | 57 | { |
56 | if ( 0 != width % 16 || width < 16 || width > 480 ) | 58 | if ( 0 != width % 16 || width < 16 || width > 480 ) |
57 | { | 59 | { |
58 | printf( "Warning: Corrected X resolution to 240 px\n" ); | 60 | printf( "Warning: Corrected X resolution to 240 px\n" ); |
59 | width = 240; | 61 | width = 240; |
60 | } | 62 | } |
61 | if ( 0 != height % 16 || height < 16 || height > 640 ) | 63 | if ( 0 != height % 16 || height < 16 || height > 640 ) |
62 | { | 64 | { |
63 | printf( "Warning: Corrected Y resolution to 320 px\n" ); | 65 | printf( "Warning: Corrected Y resolution to 320 px\n" ); |
64 | height = 320; | 66 | height = 320; |
65 | } | 67 | } |
66 | } | 68 | } |
67 | 69 | ||
68 | if ( quality > 100 || quality < 10 ) | 70 | if ( quality > 100 || quality < 10 ) |
69 | { | 71 | { |
70 | printf( "Warning: Corrected quality to 75%%\n" ); | 72 | printf( "Warning: Corrected quality to 75%%\n" ); |
71 | quality = 75; | 73 | quality = 75; |
72 | } | 74 | } |
73 | 75 | ||
74 | if ( zoom > 2 || zoom < 1 ) | 76 | if ( zoom > 2 || zoom < 1 ) |
75 | { | 77 | { |
76 | printf( "Warning: Corrected zoom to x1\n" ); | 78 | printf( "Warning: Corrected zoom to x1\n" ); |
77 | zoom = 1; | 79 | zoom = 1; |
78 | } | 80 | } |
79 | 81 | ||
80 | if ( format != "JPEG" && format != "PNG" && format != "BMP" ) | 82 | if ( format != "JPEG" && format != "PNG" && format != "BMP" ) |
81 | { | 83 | { |
82 | printf( "Warning: Corrected format to 'JPEG'\n" ); | 84 | printf( "Warning: Corrected format to 'JPEG'\n" ); |
83 | format = "JPEG"; | 85 | format = "JPEG"; |
84 | } | 86 | } |
85 | } | 87 | } |
86 | 88 | ||
87 | 89 | ||
88 | void Capturer::capture() | 90 | void Capturer::capture() |
89 | { | 91 | { |
90 | if ( flip == "A" ) | 92 | if ( flip == "A" ) |
91 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); | 93 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); |
92 | else if ( flip == "0" ) | 94 | else if ( flip == "0" ) |
93 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); | 95 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); |
94 | else if ( flip == "X" ) | 96 | else if ( flip == "X" ) |
95 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); | 97 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); |
96 | else if ( flip == "Y" ) | 98 | else if ( flip == "Y" ) |
97 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); | 99 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); |
98 | else if ( flip == "*" ) | 100 | else if ( flip == "*" ) |
99 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); | 101 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); |
100 | 102 | ||
101 | ZCameraIO::instance()->captureFrame( width, height, zoom, &image ); | 103 | ZCameraIO::instance()->captureFrame( width, height, zoom, &image ); |
102 | QImage im = image.convertDepth( 32 ); | 104 | QImage im = image.convertDepth( 32 ); |
103 | bool result = im.save( name, format, quality ); | 105 | bool result = im.save( name, format, quality ); |
104 | if ( !result ) | 106 | if ( !result ) |
105 | { | 107 | { |
106 | printf( "QImageio-Problem while writing.\n" ); | 108 | printf( "QImageio-Problem while writing.\n" ); |
107 | } | 109 | } |
108 | else | 110 | else |
109 | { | 111 | { |
110 | printf( "Ok.\n" ); | 112 | printf( "Ok.\n" ); |
111 | } | 113 | } |
112 | } | 114 | } |
113 | 115 | ||
114 | 116 | ||
115 | void usage() | 117 | void usage() |
116 | { | 118 | { |
117 | printf( "Usage: ./capture [options] filename\n\n" ); | 119 | printf( "Usage: ./capture [options] filename\n\n" ); |
118 | printf( " -x xresolution (dividable by 16) [default=240]\n" ); | 120 | printf( " -x xresolution (dividable by 16) [default=240]\n" ); |
119 | printf( " -y xresolution (dividable by 16) [default=320]\n" ); | 121 | printf( " -y xresolution (dividable by 16) [default=320]\n" ); |
120 | printf( " -q quality (10-100) [default=75]\n" ); | 122 | printf( " -q quality (10-100) [default=75]\n" ); |
121 | printf( " -f flip (A=auto, 0, X, Y, *=both) [default=Auto]\n" ); | 123 | printf( " -f flip (A=auto, 0, X, Y, *=both) [default=Auto]\n" ); |
122 | printf( " -o output format (JPEG,BMP,PNG) [default=JPEG]\n" ); | 124 | printf( " -o output format (JPEG,BMP,PNG) [default=JPEG]\n" ); |
123 | printf( " -z zoom (1-2) [default=1]\n" ); | 125 | printf( " -z zoom (1-2) [default=1]\n" ); |
124 | } | 126 | } |
125 | 127 | ||
126 | int main( int argc, char** argv ) | 128 | int main( int argc, char** argv ) |
127 | { | 129 | { |
128 | OApplication* a = new OApplication( argc, argv, "Capture" ); | 130 | OApplication* a = new OApplication( argc, argv, "Capture" ); |
129 | Capturer* c = new Capturer(); | 131 | Capturer* c = new Capturer(); |
130 | 132 | ||
131 | if ( argc < 2 ) | 133 | if ( argc < 2 ) |
132 | { | 134 | { |
133 | usage(); | 135 | usage(); |
134 | return -1; | 136 | return -1; |
135 | } | 137 | } |
136 | 138 | ||
137 | #define I_HATE_WRITING_HARDCODED_PARSES | 139 | #define I_HATE_WRITING_HARDCODED_PARSES |
138 | 140 | ||
139 | int i = 1; | 141 | int i = 1; |
140 | while ( i < argc ) | 142 | while ( i < argc ) |
141 | { | 143 | { |
142 | // check for filename | 144 | // check for filename |
143 | if ( argv[i][0] != '-' ) | 145 | if ( argv[i][0] != '-' ) |
144 | { | 146 | { |
145 | if ( argc != i+1 ) | 147 | if ( argc != i+1 ) |
146 | { | 148 | { |
147 | usage(); | 149 | usage(); |
148 | return -1; | 150 | return -1; |
149 | } | 151 | } |
150 | else | 152 | else |
151 | { | 153 | { |
152 | c->name = argv[i]; | 154 | c->name = argv[i]; |
153 | break; | 155 | break; |
154 | } | 156 | } |
155 | } | 157 | } |
156 | else | 158 | else |
157 | { | 159 | { |
158 | i++; | 160 | i++; |
159 | if ( argc == i ) | 161 | if ( argc == i ) |
160 | { | 162 | { |
161 | usage(); | 163 | usage(); |
162 | return -1; | 164 | return -1; |
163 | } | 165 | } |
164 | switch ( argv[i-1][1] ) | 166 | switch ( argv[i-1][1] ) |
165 | { | 167 | { |
166 | case 'x': c->width = QString( argv[i] ).toInt(); break; | 168 | case 'x': c->width = QString( argv[i] ).toInt(); break; |
167 | case 'y': c->height = QString( argv[i] ).toInt(); break; | 169 | case 'y': c->height = QString( argv[i] ).toInt(); break; |
168 | case 'z': c->zoom = QString( argv[i] ).toInt(); break; | 170 | case 'z': c->zoom = QString( argv[i] ).toInt(); break; |
169 | case 'o': c->format = QString( argv[i] ); break; | 171 | case 'o': c->format = QString( argv[i] ); break; |
170 | case 'q': c->quality = QString( argv[i] ).toInt(); break; | 172 | case 'q': c->quality = QString( argv[i] ).toInt(); break; |
171 | case 'f': c->flip = QString( argv[i] )[0]; break; | 173 | case 'f': c->flip = QString( argv[i] )[0]; break; |
172 | default: usage(); return -1; | 174 | default: usage(); return -1; |
173 | } | 175 | } |
174 | i++; | 176 | i++; |
175 | } | 177 | } |
176 | 178 | ||
177 | #undef I_HATE_WRITING_HARDCODED_PARSES | 179 | #undef I_HATE_WRITING_HARDCODED_PARSES |
178 | } | 180 | } |
179 | 181 | ||
180 | if ( !ZCameraIO::instance()->isOpen() ) | 182 | if ( !ZCameraIO::instance()->isOpen() ) |
181 | { | 183 | { |
182 | printf( "Error: Can't detect your camera. Exiting.\n" ); | 184 | printf( "Error: Can't detect your camera. Exiting.\n" ); |
183 | return -1; | 185 | return -1; |
184 | } | 186 | } |
185 | 187 | ||
186 | c->checkSettings(); | 188 | c->checkSettings(); |
187 | c->capture(); | 189 | c->capture(); |
188 | return 0; | 190 | return 0; |
189 | } | 191 | } |
190 | 192 | ||
diff --git a/noncore/multimedia/camera/gui/main.cpp b/noncore/multimedia/camera/gui/main.cpp index f25475c..7d6b3bb 100644 --- a/noncore/multimedia/camera/gui/main.cpp +++ b/noncore/multimedia/camera/gui/main.cpp | |||
@@ -1,28 +1,30 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. | 2 | ** Copyright (C) 2003 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 | |||
16 | #include "mainwindow.h" | 17 | #include "mainwindow.h" |
17 | #include <opie2/oapplication.h> | 18 | #include <opie2/oapplication.h> |
18 | 19 | ||
20 | using namespace Opie::Core; | ||
19 | int main( int argc, char **argv ) | 21 | int main( int argc, char **argv ) |
20 | { | 22 | { |
21 | OApplication a( argc, argv, "Opie-Camera" ); | 23 | OApplication a( argc, argv, "Opie-Camera" ); |
22 | CameraMainWindow* w = new CameraMainWindow(); | 24 | CameraMainWindow* w = new CameraMainWindow(); |
23 | a.showMainWidget( w ); | 25 | a.showMainWidget( w ); |
24 | a.exec(); | 26 | a.exec(); |
25 | delete w; | 27 | delete w; |
26 | return 0; | 28 | return 0; |
27 | } | 29 | } |
28 | 30 | ||
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp index e4e1b6c..7f2a9bd 100644 --- a/noncore/multimedia/camera/gui/mainwindow.cpp +++ b/noncore/multimedia/camera/gui/mainwindow.cpp | |||
@@ -1,728 +1,731 @@ | |||
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 */ | 22 | /* OPIE */ |
23 | #include <opie2/ofiledialog.h> | 23 | #include <opie2/ofiledialog.h> |
24 | #include <opie2/odevice.h> | 24 | #include <opie2/odevice.h> |
25 | #include <opie2/oapplication.h> | 25 | #include <opie2/oapplication.h> |
26 | #include <opie2/oconfig.h> | 26 | #include <opie2/oconfig.h> |
27 | #include <opie2/odebug.h> | 27 | #include <opie2/odebug.h> |
28 | #include <qpe/global.h> | 28 | #include <qpe/global.h> |
29 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | #include <qpe/qcopenvelope_qws.h> | 30 | #include <qpe/qcopenvelope_qws.h> |
31 | using namespace Opie; | ||
32 | 31 | ||
33 | /* QT */ | 32 | /* QT */ |
34 | #include <qapplication.h> | 33 | #include <qapplication.h> |
35 | #include <qaction.h> | 34 | #include <qaction.h> |
36 | #include <qvbox.h> | 35 | #include <qvbox.h> |
37 | #include <qcombobox.h> | 36 | #include <qcombobox.h> |
38 | #include <qcursor.h> | 37 | #include <qcursor.h> |
39 | #include <qdatastream.h> | 38 | #include <qdatastream.h> |
40 | #include <qdir.h> | 39 | #include <qdir.h> |
41 | #include <qfile.h> | 40 | #include <qfile.h> |
42 | #include <qimage.h> | 41 | #include <qimage.h> |
43 | #include <qlabel.h> | 42 | #include <qlabel.h> |
44 | #include <qlineedit.h> | 43 | #include <qlineedit.h> |
45 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
46 | #include <qprogressbar.h> | 45 | #include <qprogressbar.h> |
47 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
48 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
49 | #include <qlayout.h> | 48 | #include <qlayout.h> |
50 | #include <qdirectpainter_qws.h> | 49 | #include <qdirectpainter_qws.h> |
51 | 50 | ||
52 | /* STD */ | 51 | /* STD */ |
53 | #include <assert.h> | 52 | #include <assert.h> |
54 | #include <sys/types.h> | 53 | #include <sys/types.h> |
55 | #include <sys/stat.h> | 54 | #include <sys/stat.h> |
56 | #include <fcntl.h> | 55 | #include <fcntl.h> |
57 | #include <string.h> | 56 | #include <string.h> |
58 | #include <errno.h> | 57 | #include <errno.h> |
59 | #include <unistd.h> | 58 | #include <unistd.h> |
60 | 59 | ||
61 | #define CAPTUREFILE "/tmp/capture.dat" | 60 | #define CAPTUREFILE "/tmp/capture.dat" |
62 | #define OUTPUTFILE "/tmp/output.avi" | 61 | #define OUTPUTFILE "/tmp/output.avi" |
63 | 62 | ||
64 | #define OUTPUT_TO_CUSTOM 250 | 63 | #define OUTPUT_TO_CUSTOM 250 |
65 | #define OUTPUT_TO_DOCFOLDER 251 | 64 | #define OUTPUT_TO_DOCFOLDER 251 |
66 | 65 | ||
66 | |||
67 | using namespace Opie::Ui; | ||
68 | using namespace Opie::Core; | ||
69 | |||
67 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) | 70 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) |
68 | :QMainWindow( parent, name, f ), | 71 | :QMainWindow( parent, name, f ), |
69 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) | 72 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) |
70 | _capturing( false ), | 73 | _capturing( false ), |
71 | _pics( 1 ), _videos( 1 ) | 74 | _pics( 1 ), _videos( 1 ) |
72 | { | 75 | { |
73 | #ifdef QT_NO_DEBUG | 76 | #ifdef QT_NO_DEBUG |
74 | if ( !ZCameraIO::instance()->isOpen() ) | 77 | if ( !ZCameraIO::instance()->isOpen() ) |
75 | { | 78 | { |
76 | QVBox* v = new QVBox( this ); | 79 | QVBox* v = new QVBox( this ); |
77 | v->setMargin( 10 ); | 80 | v->setMargin( 10 ); |
78 | QLabel* l1 = new QLabel( v ); | 81 | QLabel* l1 = new QLabel( v ); |
79 | l1->setPixmap( Resource::loadPixmap( "camera/error" ) ); | 82 | l1->setPixmap( Resource::loadPixmap( "camera/error" ) ); |
80 | QLabel* l2 = new QLabel( v ); | 83 | QLabel* l2 = new QLabel( v ); |
81 | l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>" | 84 | l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>" |
82 | "* Is the sharpzdc_cs module loaded ?<br>" | 85 | "* Is the sharpzdc_cs module loaded ?<br>" |
83 | "* Is /dev/sharpzdc read/writable ?<p>" ); | 86 | "* Is /dev/sharpzdc read/writable ?<p>" ); |
84 | connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) ); | 87 | connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) ); |
85 | setCentralWidget( v ); | 88 | setCentralWidget( v ); |
86 | return; | 89 | return; |
87 | } | 90 | } |
88 | #endif | 91 | #endif |
89 | 92 | ||
90 | init(); | 93 | init(); |
91 | 94 | ||
92 | _rotation = 270; //TODO: grab these from the actual settings | 95 | _rotation = 270; //TODO: grab these from the actual settings |
93 | 96 | ||
94 | preview = new PreviewWidget( this, "camera preview widget" ); | 97 | preview = new PreviewWidget( this, "camera preview widget" ); |
95 | //setCentralWidget( preview ); <--- don't do this! | 98 | //setCentralWidget( preview ); <--- don't do this! |
96 | preview->resize( QSize( 240, 288 ) ); | 99 | preview->resize( QSize( 240, 288 ) ); |
97 | preview->show(); | 100 | preview->show(); |
98 | 101 | ||
99 | // construct a System Channel to receive setRotation messages | 102 | // construct a System Channel to receive setRotation messages |
100 | _sysChannel = new QCopChannel( "QPE/System", this ); | 103 | _sysChannel = new QCopChannel( "QPE/System", this ); |
101 | connect( _sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 104 | connect( _sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
102 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 105 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
103 | 106 | ||
104 | connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) ); | 107 | connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) ); |
105 | 108 | ||
106 | connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); | 109 | connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); |
107 | 110 | ||
108 | updateCaption(); | 111 | updateCaption(); |
109 | 112 | ||
110 | }; | 113 | }; |
111 | 114 | ||
112 | 115 | ||
113 | CameraMainWindow::~CameraMainWindow() | 116 | CameraMainWindow::~CameraMainWindow() |
114 | { | 117 | { |
115 | // write back configuration | 118 | // write back configuration |
116 | OConfigGroupSaver cgs( oApp->config(), "General" ); | 119 | OConfigGroupSaver cgs( oApp->config(), "General" ); |
117 | cgs.config()->writeEntry( "flip", flip ); | 120 | cgs.config()->writeEntry( "flip", flip ); |
118 | cgs.config()->writeEntry( "quality", quality ); | 121 | cgs.config()->writeEntry( "quality", quality ); |
119 | cgs.config()->writeEntry( "zoom", zoom ); | 122 | cgs.config()->writeEntry( "zoom", zoom ); |
120 | cgs.config()->writeEntry( "captureX", captureX ); | 123 | cgs.config()->writeEntry( "captureX", captureX ); |
121 | cgs.config()->writeEntry( "captureY", captureY ); | 124 | cgs.config()->writeEntry( "captureY", captureY ); |
122 | cgs.config()->writeEntry( "captureFormat", captureFormat ); | 125 | cgs.config()->writeEntry( "captureFormat", captureFormat ); |
123 | cgs.config()->writeEntry( "outputTo", outputTo ); | 126 | cgs.config()->writeEntry( "outputTo", outputTo ); |
124 | cgs.config()->writeEntry( "prefix", prefix ); | 127 | cgs.config()->writeEntry( "prefix", prefix ); |
125 | cgs.config()->writeEntry( "appendSettings", appendSettings ); | 128 | cgs.config()->writeEntry( "appendSettings", appendSettings ); |
126 | } | 129 | } |
127 | 130 | ||
128 | 131 | ||
129 | void CameraMainWindow::init() | 132 | void CameraMainWindow::init() |
130 | { | 133 | { |
131 | // get values from configuration | 134 | // get values from configuration |
132 | OConfigGroupSaver cgs( oApp->config(), "General" ); | 135 | OConfigGroupSaver cgs( oApp->config(), "General" ); |
133 | flip = cgs.config()->readEntry( "flip", "A" ); | 136 | flip = cgs.config()->readEntry( "flip", "A" ); |
134 | quality = cgs.config()->readNumEntry( "quality", 50 ); | 137 | quality = cgs.config()->readNumEntry( "quality", 50 ); |
135 | zoom = cgs.config()->readNumEntry( "zoom", 1 ); | 138 | zoom = cgs.config()->readNumEntry( "zoom", 1 ); |
136 | captureX = cgs.config()->readNumEntry( "captureX", 480 ); | 139 | captureX = cgs.config()->readNumEntry( "captureX", 480 ); |
137 | captureY = cgs.config()->readNumEntry( "captureY", 640 ); | 140 | captureY = cgs.config()->readNumEntry( "captureY", 640 ); |
138 | captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" ); | 141 | captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" ); |
139 | outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" ); | 142 | outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" ); |
140 | prefix = cgs.config()->readEntry( "prefix", "Untitled" ); | 143 | prefix = cgs.config()->readEntry( "prefix", "Untitled" ); |
141 | appendSettings = cgs.config()->readBoolEntry( "appendSettings", true ); | 144 | appendSettings = cgs.config()->readBoolEntry( "appendSettings", true ); |
142 | 145 | ||
143 | // create action groups | 146 | // create action groups |
144 | QAction* a; | 147 | QAction* a; |
145 | resog = new QActionGroup( 0, "reso", true ); | 148 | resog = new QActionGroup( 0, "reso", true ); |
146 | resog->setToggleAction( true ); | 149 | resog->setToggleAction( true ); |
147 | new QAction( " 64 x 48", 0, 0, resog, "64x48", true ); | 150 | new QAction( " 64 x 48", 0, 0, resog, "64x48", true ); |
148 | new QAction( "128 x 96", 0, 0, resog, "128x96", true ); | 151 | new QAction( "128 x 96", 0, 0, resog, "128x96", true ); |
149 | new QAction( "192 x 144", 0, 0, resog, "192x144", true ); | 152 | new QAction( "192 x 144", 0, 0, resog, "192x144", true ); |
150 | new QAction( "256 x 192", 0, 0, resog, "256x192", true ); | 153 | new QAction( "256 x 192", 0, 0, resog, "256x192", true ); |
151 | new QAction( "320 x 240", 0, 0, resog, "320x240", true ); | 154 | new QAction( "320 x 240", 0, 0, resog, "320x240", true ); |
152 | new QAction( "384 x 288", 0, 0, resog, "384x288", true ); | 155 | new QAction( "384 x 288", 0, 0, resog, "384x288", true ); |
153 | new QAction( "448 x 336", 0, 0, resog, "448x336", true ); | 156 | new QAction( "448 x 336", 0, 0, resog, "448x336", true ); |
154 | new QAction( "512 x 384", 0, 0, resog, "512x384", true ); | 157 | new QAction( "512 x 384", 0, 0, resog, "512x384", true ); |
155 | new QAction( "576 x 432", 0, 0, resog, "576x432", true ); | 158 | new QAction( "576 x 432", 0, 0, resog, "576x432", true ); |
156 | new QAction( "640 x 480", 0, 0, resog, "640x480", true ); | 159 | new QAction( "640 x 480", 0, 0, resog, "640x480", true ); |
157 | a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) ); | 160 | a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) ); |
158 | if ( a ) a->setOn( true ); | 161 | if ( a ) a->setOn( true ); |
159 | else owarn << "can't set resolution" << oendl; | 162 | else owarn << "can't set resolution" << oendl; |
160 | 163 | ||
161 | qualityg = new QActionGroup( 0, "quality", true ); | 164 | qualityg = new QActionGroup( 0, "quality", true ); |
162 | qualityg->setToggleAction( true ); | 165 | qualityg->setToggleAction( true ); |
163 | new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true ); | 166 | new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true ); |
164 | new QAction( " 25 (&low)", 0, 0, qualityg, "25", true ); | 167 | new QAction( " 25 (&low)", 0, 0, qualityg, "25", true ); |
165 | new QAction( " 50 (&good)", 0, 0, qualityg, "50", true ); | 168 | new QAction( " 50 (&good)", 0, 0, qualityg, "50", true ); |
166 | new QAction( " 75 (&better)", 0, 0, qualityg, "75", true ); | 169 | new QAction( " 75 (&better)", 0, 0, qualityg, "75", true ); |
167 | new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true ); | 170 | new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true ); |
168 | a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) ); | 171 | a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) ); |
169 | if ( a ) a->setOn( true ); | 172 | if ( a ) a->setOn( true ); |
170 | else owarn << "can't set quality" << oendl; | 173 | else owarn << "can't set quality" << oendl; |
171 | 174 | ||
172 | zoomg = new QActionGroup( 0, "zoom", true ); | 175 | zoomg = new QActionGroup( 0, "zoom", true ); |
173 | zoomg->setToggleAction( true ); | 176 | zoomg->setToggleAction( true ); |
174 | new QAction( "x 1", 0, 0, zoomg, "1", true ); | 177 | new QAction( "x 1", 0, 0, zoomg, "1", true ); |
175 | new QAction( "x 2", 0, 0, zoomg, "2", true ); | 178 | new QAction( "x 2", 0, 0, zoomg, "2", true ); |
176 | a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) ); | 179 | a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) ); |
177 | if ( a ) a->setOn( true ); | 180 | if ( a ) a->setOn( true ); |
178 | else owarn << "can't set zoom" << oendl; | 181 | else owarn << "can't set zoom" << oendl; |
179 | 182 | ||
180 | flipg = new QActionGroup( 0, "flip", true ); | 183 | flipg = new QActionGroup( 0, "flip", true ); |
181 | flipg->setToggleAction( true ); | 184 | flipg->setToggleAction( true ); |
182 | new QAction( "Auto (recommended)", 0, 0, flipg, "A", true ); | 185 | new QAction( "Auto (recommended)", 0, 0, flipg, "A", true ); |
183 | new QAction( "0 (always off)", 0, 0, flipg, "0", true ); | 186 | new QAction( "0 (always off)", 0, 0, flipg, "0", true ); |
184 | new QAction( "X (always horizontal)", 0, 0, flipg, "X", true ); | 187 | new QAction( "X (always horizontal)", 0, 0, flipg, "X", true ); |
185 | new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true ); | 188 | new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true ); |
186 | new QAction( "* (always both)", 0, 0, flipg, "*", true ); | 189 | new QAction( "* (always both)", 0, 0, flipg, "*", true ); |
187 | a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) ); | 190 | a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) ); |
188 | if ( a ) a->setOn( true ); | 191 | if ( a ) a->setOn( true ); |
189 | else owarn << "can't set flip" << oendl; | 192 | else owarn << "can't set flip" << oendl; |
190 | 193 | ||
191 | outputTog = new QActionGroup( 0, "output", true ); | 194 | outputTog = new QActionGroup( 0, "output", true ); |
192 | outputTog->setToggleAction( true ); | 195 | outputTog->setToggleAction( true ); |
193 | new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true ); | 196 | new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true ); |
194 | new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true ); | 197 | new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true ); |
195 | new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true ); | 198 | new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true ); |
196 | docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true ); | 199 | docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true ); |
197 | custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!? | 200 | custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!? |
198 | a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) ); | 201 | a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) ); |
199 | if ( a ) a->setOn( true ); | 202 | if ( a ) a->setOn( true ); |
200 | else owarn << "can't set outputTo" << oendl; | 203 | else owarn << "can't set outputTo" << oendl; |
201 | 204 | ||
202 | outputg = new QActionGroup( 0, "output", true ); | 205 | outputg = new QActionGroup( 0, "output", true ); |
203 | outputg->setToggleAction( true ); | 206 | outputg->setToggleAction( true ); |
204 | new QAction( "JPEG", 0, 0, outputg, "JPEG", true ); | 207 | new QAction( "JPEG", 0, 0, outputg, "JPEG", true ); |
205 | new QAction( "PNG", 0, 0, outputg, "PNG", true ); | 208 | new QAction( "PNG", 0, 0, outputg, "PNG", true ); |
206 | new QAction( "BMP", 0, 0, outputg, "BMP", true ); | 209 | new QAction( "BMP", 0, 0, outputg, "BMP", true ); |
207 | new QAction( "AVI", 0, 0, outputg, "AVI", true ); | 210 | new QAction( "AVI", 0, 0, outputg, "AVI", true ); |
208 | a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) ); | 211 | a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) ); |
209 | if ( a ) a->setOn( true ); | 212 | if ( a ) a->setOn( true ); |
210 | else owarn << "can't set output format" << oendl; | 213 | else owarn << "can't set output format" << oendl; |
211 | 214 | ||
212 | connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) ); | 215 | connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) ); |
213 | connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) ); | 216 | connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) ); |
214 | connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); | 217 | connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); |
215 | connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) ); | 218 | connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) ); |
216 | connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) ); | 219 | connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) ); |
217 | connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); | 220 | connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); |
218 | } | 221 | } |
219 | 222 | ||
220 | 223 | ||
221 | void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data ) | 224 | void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data ) |
222 | { | 225 | { |
223 | int _newrotation; | 226 | int _newrotation; |
224 | 227 | ||
225 | QDataStream stream( data, IO_ReadOnly ); | 228 | QDataStream stream( data, IO_ReadOnly ); |
226 | odebug << "received system message: " << msg << oendl; | 229 | odebug << "received system message: " << msg << oendl; |
227 | if ( msg == "setCurrentRotation(int)" ) | 230 | if ( msg == "setCurrentRotation(int)" ) |
228 | { | 231 | { |
229 | stream >> _newrotation; | 232 | stream >> _newrotation; |
230 | odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; | 233 | odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl; |
231 | 234 | ||
232 | switch ( _newrotation ) | 235 | switch ( _newrotation ) |
233 | { | 236 | { |
234 | case 270: preview->resize( QSize( 240, 288 ) ); break; | 237 | case 270: preview->resize( QSize( 240, 288 ) ); break; |
235 | case 180: preview->resize( QSize( 320, 208 ) ); break; | 238 | case 180: preview->resize( QSize( 320, 208 ) ); break; |
236 | default: QMessageBox::warning( this, "opie-camera", | 239 | default: QMessageBox::warning( this, "opie-camera", |
237 | "This rotation is not supported.\n" | 240 | "This rotation is not supported.\n" |
238 | "Supported are 180° and 270°" ); | 241 | "Supported are 180° and 270°" ); |
239 | } | 242 | } |
240 | 243 | ||
241 | if ( _newrotation != _rotation ) | 244 | if ( _newrotation != _rotation ) |
242 | { | 245 | { |
243 | int tmp = captureX; | 246 | int tmp = captureX; |
244 | captureX = captureY; | 247 | captureX = captureY; |
245 | captureY = tmp; | 248 | captureY = tmp; |
246 | _rotation = _newrotation; | 249 | _rotation = _newrotation; |
247 | } | 250 | } |
248 | 251 | ||
249 | updateCaption(); | 252 | updateCaption(); |
250 | 253 | ||
251 | } | 254 | } |
252 | } | 255 | } |
253 | 256 | ||
254 | 257 | ||
255 | void CameraMainWindow::changeZoom( int zoom ) | 258 | void CameraMainWindow::changeZoom( int zoom ) |
256 | { | 259 | { |
257 | int z; | 260 | int z; |
258 | switch ( zoom ) | 261 | switch ( zoom ) |
259 | { | 262 | { |
260 | case 0: z = 128; break; | 263 | case 0: z = 128; break; |
261 | case 1: z = 256; break; | 264 | case 1: z = 256; break; |
262 | case 2: z = 512; break; | 265 | case 2: z = 512; break; |
263 | default: assert( 0 ); break; | 266 | default: assert( 0 ); break; |
264 | } | 267 | } |
265 | 268 | ||
266 | ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); | 269 | ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); |
267 | } | 270 | } |
268 | 271 | ||
269 | 272 | ||
270 | void CameraMainWindow::showContextMenu() | 273 | void CameraMainWindow::showContextMenu() |
271 | { | 274 | { |
272 | QPopupMenu reso; | 275 | QPopupMenu reso; |
273 | reso.setCheckable( true ); | 276 | reso.setCheckable( true ); |
274 | resog->addTo( &reso ); | 277 | resog->addTo( &reso ); |
275 | 278 | ||
276 | QPopupMenu quality; | 279 | QPopupMenu quality; |
277 | quality.setCheckable( true ); | 280 | quality.setCheckable( true ); |
278 | qualityg->addTo( &quality ); | 281 | qualityg->addTo( &quality ); |
279 | 282 | ||
280 | QPopupMenu flip; | 283 | QPopupMenu flip; |
281 | flip.setCheckable( true ); | 284 | flip.setCheckable( true ); |
282 | flipg->addTo( &flip ); | 285 | flipg->addTo( &flip ); |
283 | 286 | ||
284 | QPopupMenu zoom; | 287 | QPopupMenu zoom; |
285 | zoom.setCheckable( true ); | 288 | zoom.setCheckable( true ); |
286 | zoomg->addTo( &zoom ); | 289 | zoomg->addTo( &zoom ); |
287 | 290 | ||
288 | QPopupMenu prefix; | 291 | QPopupMenu prefix; |
289 | prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) ); | 292 | prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) ); |
290 | int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) ); | 293 | int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) ); |
291 | prefix.setItemChecked( id, appendSettings ); | 294 | prefix.setItemChecked( id, appendSettings ); |
292 | 295 | ||
293 | QPopupMenu outputTo; | 296 | QPopupMenu outputTo; |
294 | outputTo.setCheckable( true ); | 297 | outputTo.setCheckable( true ); |
295 | outputTog->addTo( &outputTo ); | 298 | outputTog->addTo( &outputTo ); |
296 | 299 | ||
297 | QPopupMenu output; | 300 | QPopupMenu output; |
298 | output.setCheckable( true ); | 301 | output.setCheckable( true ); |
299 | outputg->addTo( &output ); | 302 | outputg->addTo( &output ); |
300 | 303 | ||
301 | QPopupMenu m( this ); | 304 | QPopupMenu m( this ); |
302 | m.insertItem( "&Resolution", &reso ); | 305 | m.insertItem( "&Resolution", &reso ); |
303 | m.insertItem( "&Zoom", &zoom ); | 306 | m.insertItem( "&Zoom", &zoom ); |
304 | m.insertItem( "&Flip", &flip ); | 307 | m.insertItem( "&Flip", &flip ); |
305 | m.insertItem( "&Quality", &quality ); | 308 | m.insertItem( "&Quality", &quality ); |
306 | m.insertSeparator(); | 309 | m.insertSeparator(); |
307 | m.insertItem( "&Prefix", &prefix ); | 310 | m.insertItem( "&Prefix", &prefix ); |
308 | m.insertItem( "Output &To", &outputTo ); | 311 | m.insertItem( "Output &To", &outputTo ); |
309 | m.insertItem( "&Output As", &output ); | 312 | m.insertItem( "&Output As", &output ); |
310 | 313 | ||
311 | #ifndef QT_NO_DEBUG | 314 | #ifndef QT_NO_DEBUG |
312 | m.insertItem( "&Debug!", this, SLOT( doSomething() ) ); | 315 | m.insertItem( "&Debug!", this, SLOT( doSomething() ) ); |
313 | #endif | 316 | #endif |
314 | 317 | ||
315 | m.exec( QCursor::pos() ); | 318 | m.exec( QCursor::pos() ); |
316 | } | 319 | } |
317 | 320 | ||
318 | 321 | ||
319 | void CameraMainWindow::resoMenuItemClicked( QAction* a ) | 322 | void CameraMainWindow::resoMenuItemClicked( QAction* a ) |
320 | { | 323 | { |
321 | switch ( _rotation ) | 324 | switch ( _rotation ) |
322 | { | 325 | { |
323 | case 270: | 326 | case 270: |
324 | captureY = a->text().left(3).toInt(); | 327 | captureY = a->text().left(3).toInt(); |
325 | captureX = a->text().right(3).toInt(); | 328 | captureX = a->text().right(3).toInt(); |
326 | break; | 329 | break; |
327 | case 180: | 330 | case 180: |
328 | captureX = a->text().left(3).toInt(); | 331 | captureX = a->text().left(3).toInt(); |
329 | captureY = a->text().right(3).toInt(); | 332 | captureY = a->text().right(3).toInt(); |
330 | break; | 333 | break; |
331 | default: QMessageBox::warning( this, "opie-camera", | 334 | default: QMessageBox::warning( this, "opie-camera", |
332 | "This rotation is not supported.\n" | 335 | "This rotation is not supported.\n" |
333 | "Supported are 180° and 270°" ); | 336 | "Supported are 180° and 270°" ); |
334 | } | 337 | } |
335 | odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; | 338 | odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl; |
336 | updateCaption(); | 339 | updateCaption(); |
337 | } | 340 | } |
338 | 341 | ||
339 | 342 | ||
340 | void CameraMainWindow::qualityMenuItemClicked( QAction* a ) | 343 | void CameraMainWindow::qualityMenuItemClicked( QAction* a ) |
341 | { | 344 | { |
342 | quality = a->text().left(3).toInt(); | 345 | quality = a->text().left(3).toInt(); |
343 | odebug << "Quality now: " << quality << oendl; | 346 | odebug << "Quality now: " << quality << oendl; |
344 | updateCaption(); | 347 | updateCaption(); |
345 | } | 348 | } |
346 | 349 | ||
347 | 350 | ||
348 | void CameraMainWindow::zoomMenuItemClicked( QAction* a ) | 351 | void CameraMainWindow::zoomMenuItemClicked( QAction* a ) |
349 | { | 352 | { |
350 | zoom = QString( a->text().at(2) ).toInt(); | 353 | zoom = QString( a->text().at(2) ).toInt(); |
351 | odebug << "Zoom now: " << zoom << oendl; | 354 | odebug << "Zoom now: " << zoom << oendl; |
352 | ZCameraIO::instance()->setZoom( zoom ); | 355 | ZCameraIO::instance()->setZoom( zoom ); |
353 | updateCaption(); | 356 | updateCaption(); |
354 | } | 357 | } |
355 | 358 | ||
356 | 359 | ||
357 | void CameraMainWindow::flipMenuItemClicked( QAction* a ) | 360 | void CameraMainWindow::flipMenuItemClicked( QAction* a ) |
358 | { | 361 | { |
359 | flip = QString( a->text().at(0) ); | 362 | flip = QString( a->text().at(0) ); |
360 | odebug << "Flip now: " << flip << oendl; | 363 | odebug << "Flip now: " << flip << oendl; |
361 | if ( flip == "A" ) | 364 | if ( flip == "A" ) |
362 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); | 365 | ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP ); |
363 | else if ( flip == "0" ) | 366 | else if ( flip == "0" ) |
364 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); | 367 | ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP ); |
365 | else if ( flip == "X" ) | 368 | else if ( flip == "X" ) |
366 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); | 369 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP ); |
367 | else if ( flip == "Y" ) | 370 | else if ( flip == "Y" ) |
368 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); | 371 | ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP ); |
369 | else if ( flip == "*" ) | 372 | else if ( flip == "*" ) |
370 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); | 373 | ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP ); |
371 | 374 | ||
372 | updateCaption(); | 375 | updateCaption(); |
373 | } | 376 | } |
374 | 377 | ||
375 | 378 | ||
376 | void CameraMainWindow::outputToMenuItemClicked( QAction* a ) | 379 | void CameraMainWindow::outputToMenuItemClicked( QAction* a ) |
377 | { | 380 | { |
378 | if ( a->text() == "&Custom..." ) | 381 | if ( a->text() == "&Custom..." ) |
379 | { | 382 | { |
380 | QMap<QString, QStringList> map; | 383 | QMap<QString, QStringList> map; |
381 | map.insert( tr("All"), QStringList() ); | 384 | map.insert( tr("All"), QStringList() ); |
382 | QStringList text; | 385 | QStringList text; |
383 | text << "text/*"; | 386 | text << "text/*"; |
384 | map.insert(tr("Text"), text ); | 387 | map.insert(tr("Text"), text ); |
385 | text << "*"; | 388 | text << "*"; |
386 | map.insert(tr("All"), text ); | 389 | map.insert(tr("All"), text ); |
387 | 390 | ||
388 | QString str; | 391 | QString str; |
389 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | 392 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); |
390 | if ( str.isEmpty() || !QFileInfo(str).isDir() ) | 393 | if ( str.isEmpty() || !QFileInfo(str).isDir() ) |
391 | { | 394 | { |
392 | docfolder->setOn( true ); | 395 | docfolder->setOn( true ); |
393 | outputTo = "Documents Folder"; | 396 | outputTo = "Documents Folder"; |
394 | } | 397 | } |
395 | else | 398 | else |
396 | { | 399 | { |
397 | outputTo = str; | 400 | outputTo = str; |
398 | } | 401 | } |
399 | } | 402 | } |
400 | else | 403 | else |
401 | { | 404 | { |
402 | outputTo = a->text(); | 405 | outputTo = a->text(); |
403 | } | 406 | } |
404 | odebug << "Output to now: " << outputTo << oendl; | 407 | odebug << "Output to now: " << outputTo << oendl; |
405 | } | 408 | } |
406 | 409 | ||
407 | 410 | ||
408 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) | 411 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) |
409 | { | 412 | { |
410 | captureFormat = a->text(); | 413 | captureFormat = a->text(); |
411 | odebug << "Output format now: " << captureFormat << oendl; | 414 | odebug << "Output format now: " << captureFormat << oendl; |
412 | updateCaption(); | 415 | updateCaption(); |
413 | } | 416 | } |
414 | 417 | ||
415 | 418 | ||
416 | void CameraMainWindow::prefixItemChoosen() | 419 | void CameraMainWindow::prefixItemChoosen() |
417 | { | 420 | { |
418 | QDialog* d = new QDialog( this, "dialog", true ); | 421 | QDialog* d = new QDialog( this, "dialog", true ); |
419 | d->setCaption( "Enter Prefix..." ); | 422 | d->setCaption( "Enter Prefix..." ); |
420 | QVBoxLayout* v = new QVBoxLayout( d ); | 423 | QVBoxLayout* v = new QVBoxLayout( d ); |
421 | QLineEdit* le = new QLineEdit( prefix, d ); | 424 | QLineEdit* le = new QLineEdit( prefix, d ); |
422 | v->addWidget( le ); | 425 | v->addWidget( le ); |
423 | le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty | 426 | le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty |
424 | if ( d->exec() == QDialog::Accepted ) | 427 | if ( d->exec() == QDialog::Accepted ) |
425 | prefix = le->text(); | 428 | prefix = le->text(); |
426 | odebug << "Prefix now: " << prefix << oendl; | 429 | odebug << "Prefix now: " << prefix << oendl; |
427 | } | 430 | } |
428 | 431 | ||
429 | 432 | ||
430 | void CameraMainWindow::appendSettingsChoosen() | 433 | void CameraMainWindow::appendSettingsChoosen() |
431 | { | 434 | { |
432 | appendSettings = !appendSettings; | 435 | appendSettings = !appendSettings; |
433 | odebug << "appendSettings now: " << appendSettings << oendl; | 436 | odebug << "appendSettings now: " << appendSettings << oendl; |
434 | } | 437 | } |
435 | 438 | ||
436 | 439 | ||
437 | void CameraMainWindow::shutterClicked() | 440 | void CameraMainWindow::shutterClicked() |
438 | { | 441 | { |
439 | if ( captureFormat != "AVI" ) // capture one photo per shutterClick | 442 | if ( captureFormat != "AVI" ) // capture one photo per shutterClick |
440 | { | 443 | { |
441 | Global::statusMessage( "CAPTURING..." ); | 444 | Global::statusMessage( "CAPTURING..." ); |
442 | qApp->processEvents(); | 445 | qApp->processEvents(); |
443 | 446 | ||
444 | odebug << "Shutter has been pressed" << oendl; | 447 | odebug << "Shutter has been pressed" << oendl; |
445 | ODevice::inst()->playTouchSound(); | 448 | ODevice::inst()->playTouchSound(); |
446 | 449 | ||
447 | performCapture( captureFormat ); | 450 | performCapture( captureFormat ); |
448 | } | 451 | } |
449 | else // capture video! start with one shutter click and stop with the next | 452 | else // capture video! start with one shutter click and stop with the next |
450 | { | 453 | { |
451 | !_capturing ? startVideoCapture() : stopVideoCapture(); | 454 | !_capturing ? startVideoCapture() : stopVideoCapture(); |
452 | } | 455 | } |
453 | } | 456 | } |
454 | 457 | ||
455 | 458 | ||
456 | void CameraMainWindow::performCapture( const QString& format ) | 459 | void CameraMainWindow::performCapture( const QString& format ) |
457 | { | 460 | { |
458 | QString name; | 461 | QString name; |
459 | 462 | ||
460 | if ( outputTo == "Documents Folder" ) | 463 | if ( outputTo == "Documents Folder" ) |
461 | { | 464 | { |
462 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | 465 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); |
463 | if ( !QDir( name ).exists() ) | 466 | if ( !QDir( name ).exists() ) |
464 | { | 467 | { |
465 | odebug << "creating directory " << name << oendl; | 468 | odebug << "creating directory " << name << oendl; |
466 | QString msg = "mkdir -p " + name; | 469 | QString msg = "mkdir -p " + name; |
467 | system( msg.latin1() ); | 470 | system( msg.latin1() ); |
468 | } | 471 | } |
469 | } | 472 | } |
470 | else | 473 | else |
471 | name = outputTo; | 474 | name = outputTo; |
472 | 475 | ||
473 | name.append( prefix ); | 476 | name.append( prefix ); |
474 | if ( appendSettings ) | 477 | if ( appendSettings ) |
475 | { | 478 | { |
476 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); | 479 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); |
477 | } | 480 | } |
478 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); | 481 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); |
479 | 482 | ||
480 | QImage i; | 483 | QImage i; |
481 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); | 484 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); |
482 | QImage im = i.convertDepth( 32 ); | 485 | QImage im = i.convertDepth( 32 ); |
483 | bool result = im.save( name, format, quality ); | 486 | bool result = im.save( name, format, quality ); |
484 | if ( !result ) | 487 | if ( !result ) |
485 | { | 488 | { |
486 | oerr << "imageio-Problem while writing." << oendl; | 489 | oerr << "imageio-Problem while writing." << oendl; |
487 | Global::statusMessage( "Error!" ); | 490 | Global::statusMessage( "Error!" ); |
488 | } | 491 | } |
489 | else | 492 | else |
490 | { | 493 | { |
491 | odebug << captureFormat << "-image has been successfully captured" << oendl; | 494 | odebug << captureFormat << "-image has been successfully captured" << oendl; |
492 | Global::statusMessage( "Ok." ); | 495 | Global::statusMessage( "Ok." ); |
493 | } | 496 | } |
494 | } | 497 | } |
495 | 498 | ||
496 | 499 | ||
497 | void CameraMainWindow::startVideoCapture() | 500 | void CameraMainWindow::startVideoCapture() |
498 | { | 501 | { |
499 | ODevice::inst()->playTouchSound(); | 502 | ODevice::inst()->playTouchSound(); |
500 | ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); | 503 | ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); |
501 | 504 | ||
502 | _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); | 505 | _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); |
503 | if ( _capturefd == -1 ) | 506 | if ( _capturefd == -1 ) |
504 | { | 507 | { |
505 | owarn << "can't open capture file: " << strerror(errno) << oendl; | 508 | owarn << "can't open capture file: " << strerror(errno) << oendl; |
506 | return; | 509 | return; |
507 | } | 510 | } |
508 | 511 | ||
509 | _capturebuf = new unsigned char[captureX*captureY*2]; | 512 | _capturebuf = new unsigned char[captureX*captureY*2]; |
510 | _capturing = true; | 513 | _capturing = true; |
511 | _videopics = 0; | 514 | _videopics = 0; |
512 | _framerate = 0; | 515 | _framerate = 0; |
513 | updateCaption(); | 516 | updateCaption(); |
514 | _time.start(); | 517 | _time.start(); |
515 | preview->setRefreshingRate( 1000 ); | 518 | preview->setRefreshingRate( 1000 ); |
516 | startTimer( 100 ); // too fast but that is ok | 519 | startTimer( 100 ); // too fast but that is ok |
517 | } | 520 | } |
518 | 521 | ||
519 | 522 | ||
520 | void CameraMainWindow::timerEvent( QTimerEvent* ) | 523 | void CameraMainWindow::timerEvent( QTimerEvent* ) |
521 | { | 524 | { |
522 | if ( !_capturing ) | 525 | if ( !_capturing ) |
523 | { | 526 | { |
524 | odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; | 527 | odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; |
525 | return; | 528 | return; |
526 | } | 529 | } |
527 | 530 | ||
528 | odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; | 531 | odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; |
529 | 532 | ||
530 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); | 533 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); |
531 | _videopics++; | 534 | _videopics++; |
532 | ::write( _capturefd, _capturebuf, captureX*captureY*2 ); | 535 | ::write( _capturefd, _capturebuf, captureX*captureY*2 ); |
533 | setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", | 536 | setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", |
534 | captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); | 537 | captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); |
535 | } | 538 | } |
536 | 539 | ||
537 | 540 | ||
538 | void CameraMainWindow::stopVideoCapture() | 541 | void CameraMainWindow::stopVideoCapture() |
539 | { | 542 | { |
540 | killTimers(); | 543 | killTimers(); |
541 | ODevice::inst()->playTouchSound(); | 544 | ODevice::inst()->playTouchSound(); |
542 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 545 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
543 | _capturing = false; | 546 | _capturing = false; |
544 | updateCaption(); | 547 | updateCaption(); |
545 | ::close( _capturefd ); | 548 | ::close( _capturefd ); |
546 | _framerate = 1000.0 / (_time.elapsed()/_videopics); | 549 | _framerate = 1000.0 / (_time.elapsed()/_videopics); |
547 | 550 | ||
548 | QString name; | 551 | QString name; |
549 | if ( outputTo == "Documents Folder" ) | 552 | if ( outputTo == "Documents Folder" ) |
550 | { | 553 | { |
551 | name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | 554 | name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); |
552 | if ( !QDir( name ).exists() ) | 555 | if ( !QDir( name ).exists() ) |
553 | { | 556 | { |
554 | odebug << "creating directory " << name << oendl; | 557 | odebug << "creating directory " << name << oendl; |
555 | QString msg = "mkdir -p " + name; | 558 | QString msg = "mkdir -p " + name; |
556 | system( msg.latin1() ); | 559 | system( msg.latin1() ); |
557 | } | 560 | } |
558 | } | 561 | } |
559 | else | 562 | else |
560 | name = outputTo; | 563 | name = outputTo; |
561 | 564 | ||
562 | name.append( "/" ); // sure is sure and safe is safe ;-) | 565 | name.append( "/" ); // sure is sure and safe is safe ;-) |
563 | name.append( prefix ); | 566 | name.append( prefix ); |
564 | if ( appendSettings ) | 567 | if ( appendSettings ) |
565 | name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); | 568 | name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); |
566 | name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); | 569 | name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); |
567 | postProcessVideo( CAPTUREFILE, name ); | 570 | postProcessVideo( CAPTUREFILE, name ); |
568 | 571 | ||
569 | #ifndef QT_NO_DEBUG | 572 | #ifndef QT_NO_DEBUG |
570 | preview->setRefreshingRate( 1500 ); | 573 | preview->setRefreshingRate( 1500 ); |
571 | #else | 574 | #else |
572 | preview->setRefreshingRate( 200 ); | 575 | preview->setRefreshingRate( 200 ); |
573 | #endif | 576 | #endif |
574 | 577 | ||
575 | //delete[] _capturebuf; //FIXME: close memory leak | 578 | //delete[] _capturebuf; //FIXME: close memory leak |
576 | } | 579 | } |
577 | 580 | ||
578 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) | 581 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) |
579 | { | 582 | { |
580 | odebug << "post processing " << infile << " --> " << outfile << oendl; | 583 | odebug << "post processing " << infile << " --> " << outfile << oendl; |
581 | 584 | ||
582 | preview->setRefreshingRate( 0 ); | 585 | preview->setRefreshingRate( 0 ); |
583 | 586 | ||
584 | /* | 587 | /* |
585 | unsigned char buf[153600]; | 588 | unsigned char buf[153600]; |
586 | 589 | ||
587 | int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); | 590 | int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); |
588 | ::read( fd, &buf, 153600 ); | 591 | ::read( fd, &buf, 153600 ); |
589 | QImage i; | 592 | QImage i; |
590 | bufferToImage( 240, 320, (unsigned char*) &buf, &i ); | 593 | bufferToImage( 240, 320, (unsigned char*) &buf, &i ); |
591 | QPixmap p; | 594 | QPixmap p; |
592 | p.convertFromImage( i ); | 595 | p.convertFromImage( i ); |
593 | preview->setPixmap( p ); | 596 | preview->setPixmap( p ); |
594 | imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); | 597 | imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); |
595 | return; | 598 | return; |
596 | */ | 599 | */ |
597 | 600 | ||
598 | QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize ); | 601 | QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize ); |
599 | fr->setCaption( "Please wait..." ); | 602 | fr->setCaption( "Please wait..." ); |
600 | QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 ); | 603 | QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 ); |
601 | QProgressBar* bar = new QProgressBar( fr ); | 604 | QProgressBar* bar = new QProgressBar( fr ); |
602 | bar->setCenterIndicator( true ); | 605 | bar->setCenterIndicator( true ); |
603 | bar->setTotalSteps( _videopics-1 ); | 606 | bar->setTotalSteps( _videopics-1 ); |
604 | QLabel* label = new QLabel( "Post processing frame bla/bla", fr ); | 607 | QLabel* label = new QLabel( "Post processing frame bla/bla", fr ); |
605 | box->addWidget( bar ); | 608 | box->addWidget( bar ); |
606 | box->addWidget( label ); | 609 | box->addWidget( label ); |
607 | fr->show(); | 610 | fr->show(); |
608 | label->show(); | 611 | label->show(); |
609 | bar->show(); | 612 | bar->show(); |
610 | fr->repaint(); | 613 | fr->repaint(); |
611 | qApp->processEvents(); | 614 | qApp->processEvents(); |
612 | 615 | ||
613 | // open files | 616 | // open files |
614 | 617 | ||
615 | int infd = ::open( (const char*) infile, O_RDONLY ); | 618 | int infd = ::open( (const char*) infile, O_RDONLY ); |
616 | if ( infd == -1 ) | 619 | if ( infd == -1 ) |
617 | { | 620 | { |
618 | owarn << "couldn't open capture file: " << strerror(errno) << oendl; | 621 | owarn << "couldn't open capture file: " << strerror(errno) << oendl; |
619 | return; | 622 | return; |
620 | } | 623 | } |
621 | 624 | ||
622 | int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); | 625 | int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); |
623 | if ( outfd == -1 ) | 626 | if ( outfd == -1 ) |
624 | { | 627 | { |
625 | owarn << "couldn't open output file: " << strerror(errno) << oendl; | 628 | owarn << "couldn't open output file: " << strerror(errno) << oendl; |
626 | return; | 629 | return; |
627 | } | 630 | } |
628 | 631 | ||
629 | int framesize = captureX*captureY*2; | 632 | int framesize = captureX*captureY*2; |
630 | 633 | ||
631 | unsigned char* inbuffer = new unsigned char[ framesize ]; | 634 | unsigned char* inbuffer = new unsigned char[ framesize ]; |
632 | QImage image; | 635 | QImage image; |
633 | 636 | ||
634 | avi_start( outfd, _videopics ); // write preambel | 637 | avi_start( outfd, _videopics ); // write preambel |
635 | 638 | ||
636 | // post process | 639 | // post process |
637 | 640 | ||
638 | for ( int i = 0; i < _videopics; ++i ) | 641 | for ( int i = 0; i < _videopics; ++i ) |
639 | { | 642 | { |
640 | odebug << "processing frame " << i << oendl; | 643 | odebug << "processing frame " << i << oendl; |
641 | 644 | ||
642 | // <gui> | 645 | // <gui> |
643 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); | 646 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); |
644 | bar->setProgress( i ); | 647 | bar->setProgress( i ); |
645 | bar->repaint(); | 648 | bar->repaint(); |
646 | qApp->processEvents(); | 649 | qApp->processEvents(); |
647 | // </gui> | 650 | // </gui> |
648 | 651 | ||
649 | int read = ::read( infd, inbuffer, framesize ); | 652 | int read = ::read( infd, inbuffer, framesize ); |
650 | odebug << "read " << read << " bytes" << oendl; | 653 | odebug << "read " << read << " bytes" << oendl; |
651 | bufferToImage( captureX, captureY, inbuffer, &image ); | 654 | bufferToImage( captureX, captureY, inbuffer, &image ); |
652 | 655 | ||
653 | QPixmap p; | 656 | QPixmap p; |
654 | p.convertFromImage( image ); | 657 | p.convertFromImage( image ); |
655 | preview->setPixmap( p ); | 658 | preview->setPixmap( p ); |
656 | preview->repaint(); | 659 | preview->repaint(); |
657 | qApp->processEvents(); | 660 | qApp->processEvents(); |
658 | 661 | ||
659 | #ifdef CAMERA_EXTRA_DEBUG | 662 | #ifdef CAMERA_EXTRA_DEBUG |
660 | QString tmpfilename; | 663 | QString tmpfilename; |
661 | tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); | 664 | tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); |
662 | #else | 665 | #else |
663 | QString tmpfilename( "/tmp/tempfile" ); | 666 | QString tmpfilename( "/tmp/tempfile" ); |
664 | #endif | 667 | #endif |
665 | 668 | ||
666 | imageToFile( &image, tmpfilename, "JPEG", quality ); | 669 | imageToFile( &image, tmpfilename, "JPEG", quality ); |
667 | 670 | ||
668 | QFile framefile( tmpfilename ); | 671 | QFile framefile( tmpfilename ); |
669 | if ( !framefile.open( IO_ReadOnly ) ) | 672 | if ( !framefile.open( IO_ReadOnly ) ) |
670 | { | 673 | { |
671 | oerr << "can't process file: %s" << strerror(errno) << oendl; | 674 | oerr << "can't process file: %s" << strerror(errno) << oendl; |
672 | return; // TODO: clean up temp ressources | 675 | return; // TODO: clean up temp ressources |
673 | } | 676 | } |
674 | 677 | ||
675 | int filesize = framefile.size(); | 678 | int filesize = framefile.size(); |
676 | odebug << "filesize for frame " << i << " = " << filesize << oendl; | 679 | odebug << "filesize for frame " << i << " = " << filesize << oendl; |
677 | 680 | ||
678 | unsigned char* tempbuffer = new unsigned char[ filesize ]; | 681 | unsigned char* tempbuffer = new unsigned char[ filesize ]; |
679 | framefile.readBlock( (char*) tempbuffer, filesize ); | 682 | framefile.readBlock( (char*) tempbuffer, filesize ); |
680 | avi_add( outfd, tempbuffer, filesize ); | 683 | avi_add( outfd, tempbuffer, filesize ); |
681 | delete tempbuffer; | 684 | delete tempbuffer; |
682 | framefile.close(); | 685 | framefile.close(); |
683 | 686 | ||
684 | } | 687 | } |
685 | 688 | ||
686 | avi_end( outfd, captureX, captureY, _framerate ); | 689 | avi_end( outfd, captureX, captureY, _framerate ); |
687 | ::close( outfd ); | 690 | ::close( outfd ); |
688 | ::close( infd ); | 691 | ::close( infd ); |
689 | 692 | ||
690 | label->setText( "deleting temp files..." ); | 693 | label->setText( "deleting temp files..." ); |
691 | qApp->processEvents(); | 694 | qApp->processEvents(); |
692 | odebug << "deleting temporary capturefile " << infile << oendl; | 695 | odebug << "deleting temporary capturefile " << infile << oendl; |
693 | QFile::remove( infile ); | 696 | QFile::remove( infile ); |
694 | 697 | ||
695 | fr->hide(); | 698 | fr->hide(); |
696 | delete fr; | 699 | delete fr; |
697 | 700 | ||
698 | updateCaption(); | 701 | updateCaption(); |
699 | 702 | ||
700 | } | 703 | } |
701 | 704 | ||
702 | 705 | ||
703 | void CameraMainWindow::updateCaption() | 706 | void CameraMainWindow::updateCaption() |
704 | { | 707 | { |
705 | if ( !_capturing ) | 708 | if ( !_capturing ) |
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 ) ); | 709 | setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); |
707 | else | 710 | else |
708 | setCaption( "Opie-Camera: => CAPTURING <=" ); | 711 | setCaption( "Opie-Camera: => CAPTURING <=" ); |
709 | qApp->processEvents(); | 712 | qApp->processEvents(); |
710 | } | 713 | } |
711 | 714 | ||
712 | 715 | ||
713 | #ifndef QT_NO_DEBUG | 716 | #ifndef QT_NO_DEBUG |
714 | void CameraMainWindow::doSomething() | 717 | void CameraMainWindow::doSomething() |
715 | { | 718 | { |
716 | captureX = 240; | 719 | captureX = 240; |
717 | captureY = 320; | 720 | captureY = 320; |
718 | _videopics = 50; | 721 | _videopics = 50; |
719 | _framerate = 5; | 722 | _framerate = 5; |
720 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", | 723 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", |
721 | "/tmp/output.avi" ); | 724 | "/tmp/output.avi" ); |
722 | } | 725 | } |
723 | #else | 726 | #else |
724 | void CameraMainWindow::doSomething() | 727 | void CameraMainWindow::doSomething() |
725 | { | 728 | { |
726 | } | 729 | } |
727 | #endif | 730 | #endif |
728 | 731 | ||
diff --git a/noncore/multimedia/camera/lib/imageio.cpp b/noncore/multimedia/camera/lib/imageio.cpp index ed0d39f..7d20848 100644 --- a/noncore/multimedia/camera/lib/imageio.cpp +++ b/noncore/multimedia/camera/lib/imageio.cpp | |||
@@ -1,55 +1,56 @@ | |||
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 "imageio.h" | 16 | #include "imageio.h" |
17 | 17 | ||
18 | #include <opie2/odebug.h> | 18 | #include <opie2/odebug.h> |
19 | #include <qimage.h> | 19 | #include <qimage.h> |
20 | 20 | ||
21 | using namespace Opie::Core; | ||
21 | 22 | ||
22 | void bufferToImage( int _width, int _height, unsigned char* bp, QImage* image ) | 23 | void bufferToImage( int _width, int _height, unsigned char* bp, QImage* image ) |
23 | { | 24 | { |
24 | unsigned char* p; | 25 | unsigned char* p; |
25 | 26 | ||
26 | image->create( _width, _height, 16 ); | 27 | image->create( _width, _height, 16 ); |
27 | for ( int i = 0; i < _height; ++i ) | 28 | for ( int i = 0; i < _height; ++i ) |
28 | { | 29 | { |
29 | p = image->scanLine( i ); | 30 | p = image->scanLine( i ); |
30 | for ( int j = 0; j < _width; j++ ) | 31 | for ( int j = 0; j < _width; j++ ) |
31 | { | 32 | { |
32 | *p = *bp; | 33 | *p = *bp; |
33 | p++; | 34 | p++; |
34 | bp++; | 35 | bp++; |
35 | *p = *bp; | 36 | *p = *bp; |
36 | p++; | 37 | p++; |
37 | bp++; | 38 | bp++; |
38 | } | 39 | } |
39 | } | 40 | } |
40 | } | 41 | } |
41 | 42 | ||
42 | 43 | ||
43 | void imageToFile( QImage* i, const QString& name, const QString& format, int quality ) | 44 | void imageToFile( QImage* i, const QString& name, const QString& format, int quality ) |
44 | { | 45 | { |
45 | QImage im = i->convertDepth( 32 ); | 46 | QImage im = i->convertDepth( 32 ); |
46 | bool result = im.save( name, format, quality ); | 47 | bool result = im.save( name, format, quality ); |
47 | if ( !result ) | 48 | if ( !result ) |
48 | { | 49 | { |
49 | oerr << "imageio-Problem while writing to " << name << oendl; | 50 | oerr << "imageio-Problem while writing to " << name << oendl; |
50 | } | 51 | } |
51 | else | 52 | else |
52 | { | 53 | { |
53 | odebug << format << "-image has been successfully captured" << oendl; | 54 | odebug << format << "-image has been successfully captured" << oendl; |
54 | } | 55 | } |
55 | } | 56 | } |
diff --git a/noncore/multimedia/camera/lib/zcameraio.cpp b/noncore/multimedia/camera/lib/zcameraio.cpp index d59cbbb..c4be42f 100644 --- a/noncore/multimedia/camera/lib/zcameraio.cpp +++ b/noncore/multimedia/camera/lib/zcameraio.cpp | |||
@@ -1,315 +1,317 @@ | |||
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 "zcameraio.h" | 16 | #include "zcameraio.h" |
17 | 17 | ||
18 | #include <sys/types.h> | 18 | #include <sys/types.h> |
19 | #include <sys/stat.h> | 19 | #include <sys/stat.h> |
20 | #include <errno.h> | 20 | #include <errno.h> |
21 | #include <string.h> | 21 | #include <string.h> |
22 | #include <fcntl.h> | 22 | #include <fcntl.h> |
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | 25 | ||
26 | #include <qimage.h> | 26 | #include <qimage.h> |
27 | #include <qdatetime.h> | 27 | #include <qdatetime.h> |
28 | 28 | ||
29 | #include <opie2/odebug.h> | 29 | #include <opie2/odebug.h> |
30 | 30 | ||
31 | #define SHARPZDC "/dev/sharp_zdc" | 31 | #define SHARPZDC "/dev/sharp_zdc" |
32 | 32 | ||
33 | using namespace Opie::Core; | ||
34 | |||
33 | ZCameraIO* ZCameraIO::_instance = 0; | 35 | ZCameraIO* ZCameraIO::_instance = 0; |
34 | 36 | ||
35 | ZCameraIO* ZCameraIO::instance() | 37 | ZCameraIO* ZCameraIO::instance() |
36 | { | 38 | { |
37 | if ( !ZCameraIO::_instance ) | 39 | if ( !ZCameraIO::_instance ) |
38 | { | 40 | { |
39 | odebug << "Creating ZCameraIO::_instance" << oendl; | 41 | odebug << "Creating ZCameraIO::_instance" << oendl; |
40 | ZCameraIO::_instance = new ZCameraIO(); | 42 | ZCameraIO::_instance = new ZCameraIO(); |
41 | } | 43 | } |
42 | return ZCameraIO::_instance; | 44 | return ZCameraIO::_instance; |
43 | } | 45 | } |
44 | 46 | ||
45 | 47 | ||
46 | ZCameraIO::ZCameraIO() | 48 | ZCameraIO::ZCameraIO() |
47 | : _pressed( false ), _height( 0 ), _width( 0 ), _zoom( 0 ), | 49 | : _pressed( false ), _height( 0 ), _width( 0 ), _zoom( 0 ), |
48 | _flip( -1 ), _rot( 0 ), _readlen( 0 ) | 50 | _flip( -1 ), _rot( 0 ), _readlen( 0 ) |
49 | 51 | ||
50 | { | 52 | { |
51 | _driver = ::open( SHARPZDC, O_RDWR ); | 53 | _driver = ::open( SHARPZDC, O_RDWR ); |
52 | if ( _driver == -1 ) | 54 | if ( _driver == -1 ) |
53 | oerr << "Can't open camera driver: " << strerror(errno) << oendl; | 55 | oerr << "Can't open camera driver: " << strerror(errno) << oendl; |
54 | else | 56 | else |
55 | init(); | 57 | init(); |
56 | } | 58 | } |
57 | 59 | ||
58 | 60 | ||
59 | void ZCameraIO::init() | 61 | void ZCameraIO::init() |
60 | { | 62 | { |
61 | if ( ZCameraIO::_instance ) | 63 | if ( ZCameraIO::_instance ) |
62 | ofatal << "Don't create more than one ZCameraIO instances." << oendl; | 64 | ofatal << "Don't create more than one ZCameraIO instances." << oendl; |
63 | else | 65 | else |
64 | { | 66 | { |
65 | _timer = new QTime(); | 67 | _timer = new QTime(); |
66 | setReadMode( STATUS ); | 68 | setReadMode( STATUS ); |
67 | } | 69 | } |
68 | } | 70 | } |
69 | 71 | ||
70 | 72 | ||
71 | ZCameraIO::~ZCameraIO() | 73 | ZCameraIO::~ZCameraIO() |
72 | { | 74 | { |
73 | if ( _driver != -1 ) | 75 | if ( _driver != -1 ) |
74 | { | 76 | { |
75 | setReadMode( 0 ); | 77 | setReadMode( 0 ); |
76 | ::close( _driver ); | 78 | ::close( _driver ); |
77 | } | 79 | } |
78 | } | 80 | } |
79 | 81 | ||
80 | 82 | ||
81 | bool ZCameraIO::isOpen() const | 83 | bool ZCameraIO::isOpen() const |
82 | { | 84 | { |
83 | return _driver != -1; | 85 | return _driver != -1; |
84 | } | 86 | } |
85 | 87 | ||
86 | 88 | ||
87 | bool ZCameraIO::isShutterPressed() | 89 | bool ZCameraIO::isShutterPressed() |
88 | { | 90 | { |
89 | if ( _status[0] == 'S' ) | 91 | if ( _status[0] == 'S' ) |
90 | { | 92 | { |
91 | if ( !_pressed ) // wasn't pressed before, but is now! | 93 | if ( !_pressed ) // wasn't pressed before, but is now! |
92 | { | 94 | { |
93 | _pressed = true; | 95 | _pressed = true; |
94 | _timer->start(); | 96 | _timer->start(); |
95 | return true; | 97 | return true; |
96 | } | 98 | } |
97 | 99 | ||
98 | if ( _timer->elapsed() > 2000 ) // the press is pretty old now | 100 | if ( _timer->elapsed() > 2000 ) // the press is pretty old now |
99 | { | 101 | { |
100 | clearShutterLatch(); | 102 | clearShutterLatch(); |
101 | _status[0] = 's'; | 103 | _status[0] = 's'; |
102 | _pressed = false; | 104 | _pressed = false; |
103 | } | 105 | } |
104 | } | 106 | } |
105 | 107 | ||
106 | return false; | 108 | return false; |
107 | } | 109 | } |
108 | 110 | ||
109 | 111 | ||
110 | bool ZCameraIO::isFinderReversed() const | 112 | bool ZCameraIO::isFinderReversed() const |
111 | { | 113 | { |
112 | return _status[1] == 'M'; | 114 | return _status[1] == 'M'; |
113 | } | 115 | } |
114 | 116 | ||
115 | 117 | ||
116 | bool ZCameraIO::isCapturing() const | 118 | bool ZCameraIO::isCapturing() const |
117 | { | 119 | { |
118 | return _status[2] == 'C'; | 120 | return _status[2] == 'C'; |
119 | } | 121 | } |
120 | 122 | ||
121 | 123 | ||
122 | bool ZCameraIO::isAvailable() const | 124 | bool ZCameraIO::isAvailable() const |
123 | { | 125 | { |
124 | return _status[3] == 'A'; | 126 | return _status[3] == 'A'; |
125 | } | 127 | } |
126 | 128 | ||
127 | 129 | ||
128 | bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) | 130 | bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) |
129 | { | 131 | { |
130 | odebug << "setCaptureFrame( " << width << ", " << height << ", " << zoom << ", " << rot << " )" << oendl; | 132 | odebug << "setCaptureFrame( " << width << ", " << height << ", " << zoom << ", " << rot << " )" << oendl; |
131 | char b[100]; | 133 | char b[100]; |
132 | sprintf( b, "%c=%d,%d,%d,%d", rot ? 'R':'S', width, height, zoom, width*2 ); | 134 | sprintf( b, "%c=%d,%d,%d,%d", rot ? 'R':'S', width, height, zoom, width*2 ); |
133 | if ( write( b ) ) | 135 | if ( write( b ) ) |
134 | { | 136 | { |
135 | _width = width; | 137 | _width = width; |
136 | _height = height; | 138 | _height = height; |
137 | _zoom = zoom; | 139 | _zoom = zoom; |
138 | _rot = rot; | 140 | _rot = rot; |
139 | _readlen = 2 * _width * _height; // camera is fixed @ 16 bits per pixel | 141 | _readlen = 2 * _width * _height; // camera is fixed @ 16 bits per pixel |
140 | return true; | 142 | return true; |
141 | } | 143 | } |
142 | owarn << "couldn't write to driver" << oendl; | 144 | owarn << "couldn't write to driver" << oendl; |
143 | return false; | 145 | return false; |
144 | } | 146 | } |
145 | 147 | ||
146 | 148 | ||
147 | bool ZCameraIO::setZoom( int zoom ) | 149 | bool ZCameraIO::setZoom( int zoom ) |
148 | { | 150 | { |
149 | return setCaptureFrame( _width, _height, zoom*256, _rot ); | 151 | return setCaptureFrame( _width, _height, zoom*256, _rot ); |
150 | } | 152 | } |
151 | 153 | ||
152 | 154 | ||
153 | void ZCameraIO::setReadMode( int mode ) | 155 | void ZCameraIO::setReadMode( int mode ) |
154 | { | 156 | { |
155 | char b[10]; | 157 | char b[10]; |
156 | sprintf( b, "M=%d", mode ); | 158 | sprintf( b, "M=%d", mode ); |
157 | write( b, mode <= 9 ? 3 : 4 ); | 159 | write( b, mode <= 9 ? 3 : 4 ); |
158 | if ( mode & STATUS ) // STATUS bit is set | 160 | if ( mode & STATUS ) // STATUS bit is set |
159 | { | 161 | { |
160 | read( _status, 4 ); | 162 | read( _status, 4 ); |
161 | if ( isShutterPressed() ) | 163 | if ( isShutterPressed() ) |
162 | { | 164 | { |
163 | emit shutterClicked(); | 165 | emit shutterClicked(); |
164 | } | 166 | } |
165 | } | 167 | } |
166 | } | 168 | } |
167 | 169 | ||
168 | 170 | ||
169 | void ZCameraIO::setFlip( int flip ) | 171 | void ZCameraIO::setFlip( int flip ) |
170 | { | 172 | { |
171 | _flip = flip; | 173 | _flip = flip; |
172 | } | 174 | } |
173 | 175 | ||
174 | 176 | ||
175 | void ZCameraIO::clearShutterLatch() | 177 | void ZCameraIO::clearShutterLatch() |
176 | { | 178 | { |
177 | write( "B", 1 ); | 179 | write( "B", 1 ); |
178 | } | 180 | } |
179 | 181 | ||
180 | 182 | ||
181 | bool ZCameraIO::read( char* b, int len ) | 183 | bool ZCameraIO::read( char* b, int len ) |
182 | { | 184 | { |
183 | #ifndef NO_TIMING | 185 | #ifndef NO_TIMING |
184 | QTime t; | 186 | QTime t; |
185 | t.start(); | 187 | t.start(); |
186 | #endif | 188 | #endif |
187 | int rlen = ::read( _driver, b, len ); | 189 | int rlen = ::read( _driver, b, len ); |
188 | #ifndef NO_TIMING | 190 | #ifndef NO_TIMING |
189 | int time = t.elapsed(); | 191 | int time = t.elapsed(); |
190 | #else | 192 | #else |
191 | int time = -1; | 193 | int time = -1; |
192 | #endif | 194 | #endif |
193 | if ( rlen ) | 195 | if ( rlen ) |
194 | odebug << "read " << rlen << " ('" << b[0] << b[1] << b[2] << b[3] << "') [" << time << " ms] from driver." << oendl; | 196 | odebug << "read " << rlen << " ('" << b[0] << b[1] << b[2] << b[3] << "') [" << time << " ms] from driver." << oendl; |
195 | else | 197 | else |
196 | odebug << "read nothing from driver." << oendl; | 198 | odebug << "read nothing from driver." << oendl; |
197 | return rlen == len; | 199 | return rlen == len; |
198 | } | 200 | } |
199 | 201 | ||
200 | 202 | ||
201 | bool ZCameraIO::write( char* buf, int len ) | 203 | bool ZCameraIO::write( char* buf, int len ) |
202 | { | 204 | { |
203 | if ( !len ) | 205 | if ( !len ) |
204 | len = strlen( buf ); | 206 | len = strlen( buf ); |
205 | 207 | ||
206 | odebug << "writing '" << buf << "' to driver." << oendl; | 208 | odebug << "writing '" << buf << "' to driver." << oendl; |
207 | 209 | ||
208 | return ::write( _driver, buf, len ) == len; | 210 | return ::write( _driver, buf, len ) == len; |
209 | } | 211 | } |
210 | 212 | ||
211 | 213 | ||
212 | bool ZCameraIO::snapshot( QImage* image ) | 214 | bool ZCameraIO::snapshot( QImage* image ) |
213 | { | 215 | { |
214 | setReadMode( STATUS ); | 216 | setReadMode( STATUS ); |
215 | 217 | ||
216 | odebug << "finder reversed = " << isFinderReversed() << oendl; | 218 | odebug << "finder reversed = " << isFinderReversed() << oendl; |
217 | odebug << "rotation = " << _rot << oendl; | 219 | odebug << "rotation = " << _rot << oendl; |
218 | 220 | ||
219 | odebug << "w=" << _width << " h= " << _height << " readlen= " << _readlen << oendl; | 221 | odebug << "w=" << _width << " h= " << _height << " readlen= " << _readlen << oendl; |
220 | 222 | ||
221 | int readmode; | 223 | int readmode; |
222 | if ( _flip == -1 ) // AUTO | 224 | if ( _flip == -1 ) // AUTO |
223 | { | 225 | { |
224 | if ( _rot ) // Portrait | 226 | if ( _rot ) // Portrait |
225 | { | 227 | { |
226 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; | 228 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; |
227 | } | 229 | } |
228 | else // Landscape | 230 | else // Landscape |
229 | { | 231 | { |
230 | readmode = IMAGE | XFLIP | YFLIP; | 232 | readmode = IMAGE | XFLIP | YFLIP; |
231 | } | 233 | } |
232 | } | 234 | } |
233 | else // OVERRIDE | 235 | else // OVERRIDE |
234 | { | 236 | { |
235 | readmode = IMAGE | _flip; | 237 | readmode = IMAGE | _flip; |
236 | } | 238 | } |
237 | 239 | ||
238 | setReadMode( readmode ); | 240 | setReadMode( readmode ); |
239 | 241 | ||
240 | char buf[_readlen]; | 242 | char buf[_readlen]; |
241 | char* bp = buf; | 243 | char* bp = buf; |
242 | unsigned char* p; | 244 | unsigned char* p; |
243 | 245 | ||
244 | read( bp, _readlen ); | 246 | read( bp, _readlen ); |
245 | 247 | ||
246 | image->create( _width, _height, 16 ); | 248 | image->create( _width, _height, 16 ); |
247 | for ( int i = 0; i < _height; ++i ) | 249 | for ( int i = 0; i < _height; ++i ) |
248 | { | 250 | { |
249 | p = image->scanLine( i ); | 251 | p = image->scanLine( i ); |
250 | for ( int j = 0; j < _width; j++ ) | 252 | for ( int j = 0; j < _width; j++ ) |
251 | { | 253 | { |
252 | *p = *bp; | 254 | *p = *bp; |
253 | p++; | 255 | p++; |
254 | bp++; | 256 | bp++; |
255 | *p = *bp; | 257 | *p = *bp; |
256 | p++; | 258 | p++; |
257 | bp++; | 259 | bp++; |
258 | } | 260 | } |
259 | } | 261 | } |
260 | 262 | ||
261 | return true; | 263 | return true; |
262 | } | 264 | } |
263 | 265 | ||
264 | 266 | ||
265 | bool ZCameraIO::snapshot( unsigned char* buf ) | 267 | bool ZCameraIO::snapshot( unsigned char* buf ) |
266 | { | 268 | { |
267 | setReadMode( STATUS ); | 269 | setReadMode( STATUS ); |
268 | 270 | ||
269 | odebug << "finder reversed = " << isFinderReversed() << oendl; | 271 | odebug << "finder reversed = " << isFinderReversed() << oendl; |
270 | odebug << "rotation = " << _rot << oendl; | 272 | odebug << "rotation = " << _rot << oendl; |
271 | 273 | ||
272 | int readmode; | 274 | int readmode; |
273 | if ( _flip == -1 ) // AUTO | 275 | if ( _flip == -1 ) // AUTO |
274 | { | 276 | { |
275 | if ( _rot ) // Portrait | 277 | if ( _rot ) // Portrait |
276 | { | 278 | { |
277 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; | 279 | readmode = IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0; |
278 | } | 280 | } |
279 | else // Landscape | 281 | else // Landscape |
280 | { | 282 | { |
281 | readmode = IMAGE | XFLIP | YFLIP; | 283 | readmode = IMAGE | XFLIP | YFLIP; |
282 | } | 284 | } |
283 | } | 285 | } |
284 | else // OVERRIDE | 286 | else // OVERRIDE |
285 | { | 287 | { |
286 | readmode = IMAGE | _flip; | 288 | readmode = IMAGE | _flip; |
287 | } | 289 | } |
288 | 290 | ||
289 | setReadMode( readmode ); | 291 | setReadMode( readmode ); |
290 | read( (char*) buf, _readlen ); | 292 | read( (char*) buf, _readlen ); |
291 | 293 | ||
292 | } | 294 | } |
293 | 295 | ||
294 | 296 | ||
295 | void ZCameraIO::captureFrame( int w, int h, int zoom, QImage* image ) | 297 | void ZCameraIO::captureFrame( int w, int h, int zoom, QImage* image ) |
296 | { | 298 | { |
297 | int prot = _rot; | 299 | int prot = _rot; |
298 | int pw = _width; | 300 | int pw = _width; |
299 | int ph = _height; | 301 | int ph = _height; |
300 | setCaptureFrame( w, h, zoom*256, w<h ); | 302 | setCaptureFrame( w, h, zoom*256, w<h ); |
301 | snapshot( image ); | 303 | snapshot( image ); |
302 | setCaptureFrame( pw, ph, _zoom, prot ); | 304 | setCaptureFrame( pw, ph, _zoom, prot ); |
303 | } | 305 | } |
304 | 306 | ||
305 | 307 | ||
306 | void ZCameraIO::captureFrame( int w, int h, int zoom, unsigned char* buf ) | 308 | void ZCameraIO::captureFrame( int w, int h, int zoom, unsigned char* buf ) |
307 | { | 309 | { |
308 | //FIXME: this is too slow | 310 | //FIXME: this is too slow |
309 | int pw = _width; | 311 | int pw = _width; |
310 | int ph = _height; | 312 | int ph = _height; |
311 | setCaptureFrame( w, h, zoom*256, _rot ); | 313 | setCaptureFrame( w, h, zoom*256, _rot ); |
312 | snapshot( buf ); | 314 | snapshot( buf ); |
313 | setCaptureFrame( pw, ph, _zoom, _rot ); | 315 | setCaptureFrame( pw, ph, _zoom, _rot ); |
314 | } | 316 | } |
315 | 317 | ||
diff --git a/noncore/multimedia/opierec/helpwindow.cpp b/noncore/multimedia/opierec/helpwindow.cpp index a3b29fa..6aebaa1 100644 --- a/noncore/multimedia/opierec/helpwindow.cpp +++ b/noncore/multimedia/opierec/helpwindow.cpp | |||
@@ -1,196 +1,196 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | *****************************************************************************/ | 9 | *****************************************************************************/ |
10 | 10 | ||
11 | #include "helpwindow.h" | 11 | #include "helpwindow.h" |
12 | #include <qlayout.h> | 12 | #include <qlayout.h> |
13 | 13 | ||
14 | #include <qpe/qpetoolbar.h> | 14 | #include <qtoolbar.h> |
15 | #include <qpe/resource.h> | 15 | #include <qpe/resource.h> |
16 | 16 | ||
17 | #include <qaction.h> | 17 | #include <qaction.h> |
18 | #include <qmenubar.h> | 18 | #include <qmenubar.h> |
19 | 19 | ||
20 | #include <ctype.h> | 20 | #include <ctype.h> |
21 | 21 | ||
22 | HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) | 22 | HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) |
23 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() | 23 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() |
24 | { | 24 | { |
25 | QGridLayout *layout = new QGridLayout( this ); | 25 | QGridLayout *layout = new QGridLayout( this ); |
26 | layout->setSpacing( 2); | 26 | layout->setSpacing( 2); |
27 | layout->setMargin( 2); | 27 | layout->setMargin( 2); |
28 | qDebug(_path); | 28 | qDebug(_path); |
29 | browser = new QTextBrowser( this ); | 29 | browser = new QTextBrowser( this ); |
30 | QStringList Strlist; | 30 | QStringList Strlist; |
31 | Strlist.append( home_); | 31 | Strlist.append( home_); |
32 | browser->mimeSourceFactory()->setFilePath( Strlist ); | 32 | browser->mimeSourceFactory()->setFilePath( Strlist ); |
33 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 33 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
34 | 34 | ||
35 | connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); | 35 | connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); |
36 | 36 | ||
37 | if ( !home_.isEmpty() ) | 37 | if ( !home_.isEmpty() ) |
38 | browser->setSource( home_ ); | 38 | browser->setSource( home_ ); |
39 | QToolBar *toolbar = new QToolBar( this ); | 39 | QToolBar *toolbar = new QToolBar( this ); |
40 | 40 | ||
41 | QAction *a = new QAction( tr( "Backward" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 41 | QAction *a = new QAction( tr( "Backward" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
42 | connect( a, SIGNAL( activated() ), browser, SLOT( backward() ) ); | 42 | connect( a, SIGNAL( activated() ), browser, SLOT( backward() ) ); |
43 | a->addTo( toolbar ); | 43 | a->addTo( toolbar ); |
44 | 44 | ||
45 | a = new QAction( tr( "Forward" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 45 | a = new QAction( tr( "Forward" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
46 | connect( a, SIGNAL( activated() ), browser, SLOT( forward() ) ); | 46 | connect( a, SIGNAL( activated() ), browser, SLOT( forward() ) ); |
47 | a->addTo( toolbar ); | 47 | a->addTo( toolbar ); |
48 | 48 | ||
49 | 49 | ||
50 | layout->addMultiCellWidget( toolbar, 0, 0, 0, 0); | 50 | layout->addMultiCellWidget( toolbar, 0, 0, 0, 0); |
51 | 51 | ||
52 | layout->addMultiCellWidget( browser, 1, 2, 0, 2); | 52 | layout->addMultiCellWidget( browser, 1, 2, 0, 2); |
53 | 53 | ||
54 | browser->setFocus(); | 54 | browser->setFocus(); |
55 | } | 55 | } |
56 | 56 | ||
57 | 57 | ||
58 | void HelpWindow::setBackwardAvailable( bool b) | 58 | void HelpWindow::setBackwardAvailable( bool b) |
59 | { | 59 | { |
60 | menuBar()->setItemEnabled( backwardId, b); | 60 | menuBar()->setItemEnabled( backwardId, b); |
61 | } | 61 | } |
62 | 62 | ||
63 | void HelpWindow::setForwardAvailable( bool b) | 63 | void HelpWindow::setForwardAvailable( bool b) |
64 | { | 64 | { |
65 | menuBar()->setItemEnabled( forwardId, b); | 65 | menuBar()->setItemEnabled( forwardId, b); |
66 | } | 66 | } |
67 | 67 | ||
68 | 68 | ||
69 | void HelpWindow::textChanged() | 69 | void HelpWindow::textChanged() |
70 | { | 70 | { |
71 | if ( browser->documentTitle().isNull() ) { | 71 | if ( browser->documentTitle().isNull() ) { |
72 | setCaption( "QpeRec - Helpviewer - " + browser->context() ); | 72 | setCaption( "QpeRec - Helpviewer - " + browser->context() ); |
73 | selectedURL = browser->context(); | 73 | selectedURL = browser->context(); |
74 | } | 74 | } |
75 | else { | 75 | else { |
76 | setCaption( "QpeRec - Helpviewer - " + browser->documentTitle() ) ; | 76 | setCaption( "QpeRec - Helpviewer - " + browser->documentTitle() ) ; |
77 | selectedURL = browser->documentTitle(); | 77 | selectedURL = browser->documentTitle(); |
78 | } | 78 | } |
79 | 79 | ||
80 | // if ( !selectedURL.isEmpty() && pathCombo ) { | 80 | // if ( !selectedURL.isEmpty() && pathCombo ) { |
81 | // bool exists = FALSE; | 81 | // bool exists = FALSE; |
82 | // int i; | 82 | // int i; |
83 | // for ( i = 0; i < pathCombo->count(); ++i ) { | 83 | // for ( i = 0; i < pathCombo->count(); ++i ) { |
84 | // if ( pathCombo->text( i ) == selectedURL ) { | 84 | // if ( pathCombo->text( i ) == selectedURL ) { |
85 | // exists = TRUE; | 85 | // exists = TRUE; |
86 | // break; | 86 | // break; |
87 | // } | 87 | // } |
88 | // } | 88 | // } |
89 | // if ( !exists ) { | 89 | // if ( !exists ) { |
90 | // pathCombo->insertItem( selectedURL, 0 ); | 90 | // pathCombo->insertItem( selectedURL, 0 ); |
91 | // pathCombo->setCurrentItem( 0 ); | 91 | // pathCombo->setCurrentItem( 0 ); |
92 | // mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; | 92 | // mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; |
93 | // } else | 93 | // } else |
94 | // pathCombo->setCurrentItem( i ); | 94 | // pathCombo->setCurrentItem( i ); |
95 | // selectedURL = QString::null; | 95 | // selectedURL = QString::null; |
96 | // } | 96 | // } |
97 | } | 97 | } |
98 | 98 | ||
99 | HelpWindow::~HelpWindow() | 99 | HelpWindow::~HelpWindow() |
100 | { | 100 | { |
101 | history.clear(); | 101 | history.clear(); |
102 | QMap<int, QString>::Iterator it = mHistory.begin(); | 102 | QMap<int, QString>::Iterator it = mHistory.begin(); |
103 | for ( ; it != mHistory.end(); ++it ) | 103 | for ( ; it != mHistory.end(); ++it ) |
104 | history.append( *it ); | 104 | history.append( *it ); |
105 | 105 | ||
106 | QFile f( QDir::currentDirPath() + "/.history" ); | 106 | QFile f( QDir::currentDirPath() + "/.history" ); |
107 | f.open( IO_WriteOnly ); | 107 | f.open( IO_WriteOnly ); |
108 | QDataStream s( &f ); | 108 | QDataStream s( &f ); |
109 | s << history; | 109 | s << history; |
110 | f.close(); | 110 | f.close(); |
111 | 111 | ||
112 | bookmarks.clear(); | 112 | bookmarks.clear(); |
113 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); | 113 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); |
114 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 114 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
115 | bookmarks.append( *it2 ); | 115 | bookmarks.append( *it2 ); |
116 | 116 | ||
117 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); | 117 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); |
118 | f2.open( IO_WriteOnly ); | 118 | f2.open( IO_WriteOnly ); |
119 | QDataStream s2( &f2 ); | 119 | QDataStream s2( &f2 ); |
120 | s2 << bookmarks; | 120 | s2 << bookmarks; |
121 | f2.close(); | 121 | f2.close(); |
122 | } | 122 | } |
123 | 123 | ||
124 | void HelpWindow::openFile() | 124 | void HelpWindow::openFile() |
125 | { | 125 | { |
126 | #ifndef QT_NO_FILEDIALOG | 126 | #ifndef QT_NO_FILEDIALOG |
127 | #endif | 127 | #endif |
128 | } | 128 | } |
129 | 129 | ||
130 | void HelpWindow::newWindow() | 130 | void HelpWindow::newWindow() |
131 | { | 131 | { |
132 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); | 132 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); |
133 | } | 133 | } |
134 | 134 | ||
135 | void HelpWindow::print() | 135 | void HelpWindow::print() |
136 | { | 136 | { |
137 | #ifndef QT_NO_PRINTER | 137 | #ifndef QT_NO_PRINTER |
138 | #endif | 138 | #endif |
139 | } | 139 | } |
140 | 140 | ||
141 | void HelpWindow::pathSelected( const QString &_path ) | 141 | void HelpWindow::pathSelected( const QString &_path ) |
142 | { | 142 | { |
143 | browser->setSource( _path ); | 143 | browser->setSource( _path ); |
144 | QMap<int, QString>::Iterator it = mHistory.begin(); | 144 | QMap<int, QString>::Iterator it = mHistory.begin(); |
145 | bool exists = FALSE; | 145 | bool exists = FALSE; |
146 | for ( ; it != mHistory.end(); ++it ) { | 146 | for ( ; it != mHistory.end(); ++it ) { |
147 | if ( *it == _path ) { | 147 | if ( *it == _path ) { |
148 | exists = TRUE; | 148 | exists = TRUE; |
149 | break; | 149 | break; |
150 | } | 150 | } |
151 | } | 151 | } |
152 | if ( !exists ) | 152 | if ( !exists ) |
153 | mHistory[ hist->insertItem( _path ) ] = _path; | 153 | mHistory[ hist->insertItem( _path ) ] = _path; |
154 | } | 154 | } |
155 | 155 | ||
156 | void HelpWindow::readHistory() | 156 | void HelpWindow::readHistory() |
157 | { | 157 | { |
158 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { | 158 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { |
159 | QFile f( QDir::currentDirPath() + "/.history" ); | 159 | QFile f( QDir::currentDirPath() + "/.history" ); |
160 | f.open( IO_ReadOnly ); | 160 | f.open( IO_ReadOnly ); |
161 | QDataStream s( &f ); | 161 | QDataStream s( &f ); |
162 | s >> history; | 162 | s >> history; |
163 | f.close(); | 163 | f.close(); |
164 | while ( history.count() > 20 ) | 164 | while ( history.count() > 20 ) |
165 | history.remove( history.begin() ); | 165 | history.remove( history.begin() ); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
169 | void HelpWindow::readBookmarks() | 169 | void HelpWindow::readBookmarks() |
170 | { | 170 | { |
171 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { | 171 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { |
172 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); | 172 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); |
173 | f.open( IO_ReadOnly ); | 173 | f.open( IO_ReadOnly ); |
174 | QDataStream s( &f ); | 174 | QDataStream s( &f ); |
175 | s >> bookmarks; | 175 | s >> bookmarks; |
176 | f.close(); | 176 | f.close(); |
177 | } | 177 | } |
178 | } | 178 | } |
179 | 179 | ||
180 | void HelpWindow::histChosen( int i ) | 180 | void HelpWindow::histChosen( int i ) |
181 | { | 181 | { |
182 | if ( mHistory.contains( i ) ) | 182 | if ( mHistory.contains( i ) ) |
183 | browser->setSource( mHistory[ i ] ); | 183 | browser->setSource( mHistory[ i ] ); |
184 | } | 184 | } |
185 | 185 | ||
186 | void HelpWindow::bookmChosen( int i ) | 186 | void HelpWindow::bookmChosen( int i ) |
187 | { | 187 | { |
188 | if ( mBookmarks.contains( i ) ) | 188 | if ( mBookmarks.contains( i ) ) |
189 | browser->setSource( mBookmarks[ i ] ); | 189 | browser->setSource( mBookmarks[ i ] ); |
190 | } | 190 | } |
191 | 191 | ||
192 | void HelpWindow::addBookmark() | 192 | void HelpWindow::addBookmark() |
193 | { | 193 | { |
194 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); | 194 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); |
195 | } | 195 | } |
196 | 196 | ||
diff --git a/noncore/multimedia/opierec/main.cpp b/noncore/multimedia/opierec/main.cpp index bb51446..a435d8e 100644 --- a/noncore/multimedia/opierec/main.cpp +++ b/noncore/multimedia/opierec/main.cpp | |||
@@ -1,31 +1,33 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | |||
2 | main.cpp - main routine | 3 | main.cpp - main routine |
3 | ***************************************************************************/ | 4 | ***************************************************************************/ |
4 | //// main.cpp | 5 | //// main.cpp |
5 | //// copyright 2001, 2002, by L. J. Potter <ljp@llornkcor.com> | 6 | //// copyright 2001, 2002, by L. J. Potter <ljp@llornkcor.com> |
6 | /*************************************************************************** | 7 | /*************************************************************************** |
7 | * This program is free software; you can redistribute it and/or modify * | 8 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 9 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 10 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 11 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 12 | ***************************************************************************/ |
12 | #include "qtrec.h" | 13 | #include "qtrec.h" |
13 | 14 | ||
14 | #ifdef PDAUDIO | 15 | #ifdef PDAUDIO |
15 | int main(int argc, char* argv[]) { | 16 | int main(int argc, char* argv[]) { |
16 | QPEApplication a(argc, argv); | 17 | QPEApplication a(argc, argv); |
17 | QtRec qtrec; | 18 | QtRec qtrec; |
18 | a.showMainWidget( &qtrec); | 19 | a.showMainWidget( &qtrec); |
19 | return a.exec(); | 20 | return a.exec(); |
20 | } | 21 | } |
21 | 22 | ||
22 | 23 | ||
23 | #else | 24 | #else |
24 | 25 | ||
25 | #include <opie2/oapplicationfactory.h> | 26 | #include <opie2/oapplicationfactory.h> |
26 | 27 | ||
28 | using namespace Opie::Core; | ||
27 | OPIE_EXPORT_APP( OApplicationFactory<QtRec> ) | 29 | OPIE_EXPORT_APP( OApplicationFactory<QtRec> ) |
28 | 30 | ||
29 | #endif | 31 | #endif |
30 | 32 | ||
31 | 33 | ||