Diffstat (limited to 'noncore/multimedia/camera/gui') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/gui/mainwindow.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp index 2f42049..e4e1b6c 100644 --- a/noncore/multimedia/camera/gui/mainwindow.cpp +++ b/noncore/multimedia/camera/gui/mainwindow.cpp | |||
@@ -5,194 +5,194 @@ | |||
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; | 31 | using namespace Opie; |
32 | 32 | ||
33 | /* QT */ | 33 | /* QT */ |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qaction.h> | 35 | #include <qaction.h> |
36 | #include <qvbox.h> | 36 | #include <qvbox.h> |
37 | #include <qcombobox.h> | 37 | #include <qcombobox.h> |
38 | #include <qcursor.h> | 38 | #include <qcursor.h> |
39 | #include <qdatastream.h> | 39 | #include <qdatastream.h> |
40 | #include <qdir.h> | 40 | #include <qdir.h> |
41 | #include <qfile.h> | 41 | #include <qfile.h> |
42 | #include <qimage.h> | 42 | #include <qimage.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qlineedit.h> | 44 | #include <qlineedit.h> |
45 | #include <qpopupmenu.h> | 45 | #include <qpopupmenu.h> |
46 | #include <qprogressbar.h> | 46 | #include <qprogressbar.h> |
47 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qlayout.h> | 49 | #include <qlayout.h> |
50 | #include <qdirectpainter_qws.h> | 50 | #include <qdirectpainter_qws.h> |
51 | 51 | ||
52 | /* STD */ | 52 | /* STD */ |
53 | #include <assert.h> | 53 | #include <assert.h> |
54 | #include <sys/types.h> | 54 | #include <sys/types.h> |
55 | #include <sys/stat.h> | 55 | #include <sys/stat.h> |
56 | #include <fcntl.h> | 56 | #include <fcntl.h> |
57 | #include <string.h> | 57 | #include <string.h> |
58 | #include <errno.h> | 58 | #include <errno.h> |
59 | #include <unistd.h> | 59 | #include <unistd.h> |
60 | 60 | ||
61 | #define CAPTUREFILE "/tmp/capture.dat" | 61 | #define CAPTUREFILE "/tmp/capture.dat" |
62 | #define OUTPUTFILE "/tmp/output.avi" | 62 | #define OUTPUTFILE "/tmp/output.avi" |
63 | 63 | ||
64 | #define OUTPUT_TO_CUSTOM 250 | 64 | #define OUTPUT_TO_CUSTOM 250 |
65 | #define OUTPUT_TO_DOCFOLDER 251 | 65 | #define OUTPUT_TO_DOCFOLDER 251 |
66 | 66 | ||
67 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) | 67 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) |
68 | :QMainWindow( parent, name, f ), | 68 | :QMainWindow( parent, name, f ), |
69 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) | 69 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) |
70 | _capturing( false ), | 70 | _capturing( false ), |
71 | _pics( 1 ), _videos( 1 ) | 71 | _pics( 1 ), _videos( 1 ) |
72 | { | 72 | { |
73 | #ifdef QT_NO_DEBUG | 73 | #ifdef QT_NO_DEBUG |
74 | if ( !ZCameraIO::instance()->isOpen() ) | 74 | if ( !ZCameraIO::instance()->isOpen() ) |
75 | { | 75 | { |
76 | QVBox* v = new QVBox( this ); | 76 | QVBox* v = new QVBox( this ); |
77 | v->setMargin( 10 ); | 77 | v->setMargin( 10 ); |
78 | QLabel* l1 = new QLabel( v ); | 78 | QLabel* l1 = new QLabel( v ); |
79 | l1->setPixmap( Resource::loadPixmap( "camera/error" ) ); | 79 | l1->setPixmap( Resource::loadPixmap( "camera/error" ) ); |
80 | QLabel* l2 = new QLabel( v ); | 80 | QLabel* l2 = new QLabel( v ); |
81 | l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>" | 81 | l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>" |
82 | "* Is the sharpzdc_cs module loaded ?<br>" | 82 | "* Is the sharpzdc_cs module loaded ?<br>" |
83 | "* Is /dev/sharpzdc read/writable ?<p>" ); | 83 | "* Is /dev/sharpzdc read/writable ?<p>" ); |
84 | connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) ); | 84 | connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) ); |
85 | setCentralWidget( v ); | 85 | setCentralWidget( v ); |
86 | return; | 86 | return; |
87 | } | 87 | } |
88 | #endif | 88 | #endif |
89 | 89 | ||
90 | init(); | 90 | init(); |
91 | 91 | ||
92 | _rotation = 270; //TODO: grab these from the actual settings | 92 | _rotation = 270; //TODO: grab these from the actual settings |
93 | 93 | ||
94 | preview = new PreviewWidget( this, "camera preview widget" ); | 94 | preview = new PreviewWidget( this, "camera preview widget" ); |
95 | //setCentralWidget( preview ); <--- don't do this! | 95 | //setCentralWidget( preview ); <--- don't do this! |
96 | preview->resize( QSize( 240, 288 ) ); | 96 | preview->resize( QSize( 240, 288 ) ); |
97 | preview->show(); | 97 | preview->show(); |
98 | 98 | ||
99 | // construct a System Channel to receive setRotation messages | 99 | // construct a System Channel to receive setRotation messages |
100 | _sysChannel = new QCopChannel( "QPE/System", this ); | 100 | _sysChannel = new QCopChannel( "QPE/System", this ); |
101 | connect( _sysChannel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 101 | connect( _sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
102 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 102 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
103 | 103 | ||
104 | connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) ); | 104 | connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) ); |
105 | 105 | ||
106 | connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); | 106 | connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) ); |
107 | 107 | ||
108 | updateCaption(); | 108 | updateCaption(); |
109 | 109 | ||
110 | }; | 110 | }; |
111 | 111 | ||
112 | 112 | ||
113 | CameraMainWindow::~CameraMainWindow() | 113 | CameraMainWindow::~CameraMainWindow() |
114 | { | 114 | { |
115 | // write back configuration | 115 | // write back configuration |
116 | OConfigGroupSaver cgs( oApp->config(), "General" ); | 116 | OConfigGroupSaver cgs( oApp->config(), "General" ); |
117 | cgs.config()->writeEntry( "flip", flip ); | 117 | cgs.config()->writeEntry( "flip", flip ); |
118 | cgs.config()->writeEntry( "quality", quality ); | 118 | cgs.config()->writeEntry( "quality", quality ); |
119 | cgs.config()->writeEntry( "zoom", zoom ); | 119 | cgs.config()->writeEntry( "zoom", zoom ); |
120 | cgs.config()->writeEntry( "captureX", captureX ); | 120 | cgs.config()->writeEntry( "captureX", captureX ); |
121 | cgs.config()->writeEntry( "captureY", captureY ); | 121 | cgs.config()->writeEntry( "captureY", captureY ); |
122 | cgs.config()->writeEntry( "captureFormat", captureFormat ); | 122 | cgs.config()->writeEntry( "captureFormat", captureFormat ); |
123 | cgs.config()->writeEntry( "outputTo", outputTo ); | 123 | cgs.config()->writeEntry( "outputTo", outputTo ); |
124 | cgs.config()->writeEntry( "prefix", prefix ); | 124 | cgs.config()->writeEntry( "prefix", prefix ); |
125 | cgs.config()->writeEntry( "appendSettings", appendSettings ); | 125 | cgs.config()->writeEntry( "appendSettings", appendSettings ); |
126 | } | 126 | } |
127 | 127 | ||
128 | 128 | ||
129 | void CameraMainWindow::init() | 129 | void CameraMainWindow::init() |
130 | { | 130 | { |
131 | // get values from configuration | 131 | // get values from configuration |
132 | OConfigGroupSaver cgs( oApp->config(), "General" ); | 132 | OConfigGroupSaver cgs( oApp->config(), "General" ); |
133 | flip = cgs.config()->readEntry( "flip", "A" ); | 133 | flip = cgs.config()->readEntry( "flip", "A" ); |
134 | quality = cgs.config()->readNumEntry( "quality", 50 ); | 134 | quality = cgs.config()->readNumEntry( "quality", 50 ); |
135 | zoom = cgs.config()->readNumEntry( "zoom", 1 ); | 135 | zoom = cgs.config()->readNumEntry( "zoom", 1 ); |
136 | captureX = cgs.config()->readNumEntry( "captureX", 480 ); | 136 | captureX = cgs.config()->readNumEntry( "captureX", 480 ); |
137 | captureY = cgs.config()->readNumEntry( "captureY", 640 ); | 137 | captureY = cgs.config()->readNumEntry( "captureY", 640 ); |
138 | captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" ); | 138 | captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" ); |
139 | outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" ); | 139 | outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" ); |
140 | prefix = cgs.config()->readEntry( "prefix", "Untitled" ); | 140 | prefix = cgs.config()->readEntry( "prefix", "Untitled" ); |
141 | appendSettings = cgs.config()->readBoolEntry( "appendSettings", true ); | 141 | appendSettings = cgs.config()->readBoolEntry( "appendSettings", true ); |
142 | 142 | ||
143 | // create action groups | 143 | // create action groups |
144 | QAction* a; | 144 | QAction* a; |
145 | resog = new QActionGroup( 0, "reso", true ); | 145 | resog = new QActionGroup( 0, "reso", true ); |
146 | resog->setToggleAction( true ); | 146 | resog->setToggleAction( true ); |
147 | new QAction( " 64 x 48", 0, 0, resog, "64x48", true ); | 147 | new QAction( " 64 x 48", 0, 0, resog, "64x48", true ); |
148 | new QAction( "128 x 96", 0, 0, resog, "128x96", true ); | 148 | new QAction( "128 x 96", 0, 0, resog, "128x96", true ); |
149 | new QAction( "192 x 144", 0, 0, resog, "192x144", true ); | 149 | new QAction( "192 x 144", 0, 0, resog, "192x144", true ); |
150 | new QAction( "256 x 192", 0, 0, resog, "256x192", true ); | 150 | new QAction( "256 x 192", 0, 0, resog, "256x192", true ); |
151 | new QAction( "320 x 240", 0, 0, resog, "320x240", true ); | 151 | new QAction( "320 x 240", 0, 0, resog, "320x240", true ); |
152 | new QAction( "384 x 288", 0, 0, resog, "384x288", true ); | 152 | new QAction( "384 x 288", 0, 0, resog, "384x288", true ); |
153 | new QAction( "448 x 336", 0, 0, resog, "448x336", true ); | 153 | new QAction( "448 x 336", 0, 0, resog, "448x336", true ); |
154 | new QAction( "512 x 384", 0, 0, resog, "512x384", true ); | 154 | new QAction( "512 x 384", 0, 0, resog, "512x384", true ); |
155 | new QAction( "576 x 432", 0, 0, resog, "576x432", true ); | 155 | new QAction( "576 x 432", 0, 0, resog, "576x432", true ); |
156 | new QAction( "640 x 480", 0, 0, resog, "640x480", true ); | 156 | 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 ) ); | 157 | a = (QAction*) resog->child( QString().sprintf( "%dx%d", captureX>captureY ? captureX:captureY, captureX>captureY ? captureY:captureX ) ); |
158 | if ( a ) a->setOn( true ); | 158 | if ( a ) a->setOn( true ); |
159 | else owarn << "can't set resolution" << oendl; | 159 | else owarn << "can't set resolution" << oendl; |
160 | 160 | ||
161 | qualityg = new QActionGroup( 0, "quality", true ); | 161 | qualityg = new QActionGroup( 0, "quality", true ); |
162 | qualityg->setToggleAction( true ); | 162 | qualityg->setToggleAction( true ); |
163 | new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true ); | 163 | new QAction( " 0 (&minimal)", 0, 0, qualityg, "0", true ); |
164 | new QAction( " 25 (&low)", 0, 0, qualityg, "25", true ); | 164 | new QAction( " 25 (&low)", 0, 0, qualityg, "25", true ); |
165 | new QAction( " 50 (&good)", 0, 0, qualityg, "50", true ); | 165 | new QAction( " 50 (&good)", 0, 0, qualityg, "50", true ); |
166 | new QAction( " 75 (&better)", 0, 0, qualityg, "75", true ); | 166 | new QAction( " 75 (&better)", 0, 0, qualityg, "75", true ); |
167 | new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true ); | 167 | new QAction( "100 (bes&t)", 0, 0, qualityg, "100", true ); |
168 | a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) ); | 168 | a = (QAction*) qualityg->child( QString().sprintf( "%d", quality ) ); |
169 | if ( a ) a->setOn( true ); | 169 | if ( a ) a->setOn( true ); |
170 | else owarn << "can't set quality" << oendl; | 170 | else owarn << "can't set quality" << oendl; |
171 | 171 | ||
172 | zoomg = new QActionGroup( 0, "zoom", true ); | 172 | zoomg = new QActionGroup( 0, "zoom", true ); |
173 | zoomg->setToggleAction( true ); | 173 | zoomg->setToggleAction( true ); |
174 | new QAction( "x 1", 0, 0, zoomg, "1", true ); | 174 | new QAction( "x 1", 0, 0, zoomg, "1", true ); |
175 | new QAction( "x 2", 0, 0, zoomg, "2", true ); | 175 | new QAction( "x 2", 0, 0, zoomg, "2", true ); |
176 | a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) ); | 176 | a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) ); |
177 | if ( a ) a->setOn( true ); | 177 | if ( a ) a->setOn( true ); |
178 | else owarn << "can't set zoom" << oendl; | 178 | else owarn << "can't set zoom" << oendl; |
179 | 179 | ||
180 | flipg = new QActionGroup( 0, "flip", true ); | 180 | flipg = new QActionGroup( 0, "flip", true ); |
181 | flipg->setToggleAction( true ); | 181 | flipg->setToggleAction( true ); |
182 | new QAction( "Auto (recommended)", 0, 0, flipg, "A", true ); | 182 | new QAction( "Auto (recommended)", 0, 0, flipg, "A", true ); |
183 | new QAction( "0 (always off)", 0, 0, flipg, "0", true ); | 183 | new QAction( "0 (always off)", 0, 0, flipg, "0", true ); |
184 | new QAction( "X (always horizontal)", 0, 0, flipg, "X", true ); | 184 | new QAction( "X (always horizontal)", 0, 0, flipg, "X", true ); |
185 | new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true ); | 185 | new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true ); |
186 | new QAction( "* (always both)", 0, 0, flipg, "*", true ); | 186 | new QAction( "* (always both)", 0, 0, flipg, "*", true ); |
187 | a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) ); | 187 | a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) ); |
188 | if ( a ) a->setOn( true ); | 188 | if ( a ) a->setOn( true ); |
189 | else owarn << "can't set flip" << oendl; | 189 | else owarn << "can't set flip" << oendl; |
190 | 190 | ||
191 | outputTog = new QActionGroup( 0, "output", true ); | 191 | outputTog = new QActionGroup( 0, "output", true ); |
192 | outputTog->setToggleAction( true ); | 192 | outputTog->setToggleAction( true ); |
193 | new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true ); | 193 | new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true ); |
194 | new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true ); | 194 | new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true ); |
195 | new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true ); | 195 | new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true ); |
196 | docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true ); | 196 | 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!? | 197 | 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 ) ); | 198 | a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) ); |