author | mickeyl <mickeyl> | 2003-04-23 22:33:01 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-23 22:33:01 (UTC) |
commit | 545bc71ee282f93b993ae680fbe9ec135162dd21 (patch) (unidiff) | |
tree | ba23be7854b2bc017130b7e9814d2e0815292553 | |
parent | 79b22a18f68b5f39bc14eb28a175d22208d6853a (diff) | |
download | opie-545bc71ee282f93b993ae680fbe9ec135162dd21.zip opie-545bc71ee282f93b993ae680fbe9ec135162dd21.tar.gz opie-545bc71ee282f93b993ae680fbe9ec135162dd21.tar.bz2 |
add customization of output folder and filename
-rw-r--r-- | noncore/multimedia/camera/mainwindow.cpp | 125 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.h | 14 |
2 files changed, 128 insertions, 11 deletions
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp index 7e60e16..16ee8bc 100644 --- a/noncore/multimedia/camera/mainwindow.cpp +++ b/noncore/multimedia/camera/mainwindow.cpp | |||
@@ -26,7 +26,9 @@ | |||
26 | #include <qcursor.h> | 26 | #include <qcursor.h> |
27 | #include <qdatastream.h> | 27 | #include <qdatastream.h> |
28 | #include <qdir.h> | ||
28 | #include <qfile.h> | 29 | #include <qfile.h> |
29 | #include <qimage.h> | 30 | #include <qimage.h> |
30 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlineedit.h> | ||
31 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
32 | #include <qprogressbar.h> | 34 | #include <qprogressbar.h> |
@@ -54,9 +56,12 @@ using namespace Opie; | |||
54 | #define OUTPUTFILE "/tmp/output.avi" | 56 | #define OUTPUTFILE "/tmp/output.avi" |
55 | 57 | ||
58 | #define OUTPUT_TO_CUSTOM 250 | ||
59 | #define OUTPUT_TO_DOCFOLDER 251 | ||
60 | |||
56 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) | 61 | CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) |
57 | :QMainWindow( parent, name, f ), | 62 | :QMainWindow( parent, name, f ), |
58 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) | 63 | _rotation( 270 ), // FIXME: get this from current settings (ODevice?) |
59 | _capturing( false ), | 64 | _capturing( false ), |
60 | _pics( 0 ), _videos( 0 ) | 65 | _pics( 1 ), _videos( 1 ) |
61 | { | 66 | { |
62 | #ifdef QT_NO_DEBUG | 67 | #ifdef QT_NO_DEBUG |
@@ -114,4 +119,7 @@ void CameraMainWindow::init() | |||
114 | captureY = 640; | 119 | captureY = 640; |
115 | captureFormat = "JPEG"; | 120 | captureFormat = "JPEG"; |
121 | outputTo = "Documents Folder"; | ||
122 | prefix = "Untitled"; | ||
123 | appendSettings = true; | ||
116 | 124 | ||
117 | resog = new QActionGroup( 0, "reso", true ); | 125 | resog = new QActionGroup( 0, "reso", true ); |
@@ -130,9 +138,9 @@ void CameraMainWindow::init() | |||
130 | qualityg = new QActionGroup( 0, "quality", true ); | 138 | qualityg = new QActionGroup( 0, "quality", true ); |
131 | qualityg->setToggleAction( true ); | 139 | qualityg->setToggleAction( true ); |
132 | new QAction( " 0 (minimal)", 0, 0, qualityg, 0, true ); | 140 | new QAction( " 0 (&minimal)", 0, 0, qualityg, 0, true ); |
133 | new QAction( " 25 (low)", 0, 0, qualityg, 0, true ); | 141 | new QAction( " 25 (&low)", 0, 0, qualityg, 0, true ); |
134 | ( new QAction( " 50 (good)", 0, 0, qualityg, 0, true ) )->setOn( true ); | 142 | ( new QAction( " 50 (&good)", 0, 0, qualityg, 0, true ) )->setOn( true ); |
135 | new QAction( " 75 (better)", 0, 0, qualityg, 0, true ); | 143 | new QAction( " 75 (&better)", 0, 0, qualityg, 0, true ); |
136 | new QAction( "100 (best)", 0, 0, qualityg, 0, true ); | 144 | new QAction( "100 (bes&t)", 0, 0, qualityg, 0, true ); |
137 | 145 | ||
138 | zoomg = new QActionGroup( 0, "zoom", true ); | 146 | zoomg = new QActionGroup( 0, "zoom", true ); |
@@ -149,4 +157,13 @@ void CameraMainWindow::init() | |||
149 | new QAction( "* (always both)", 0, 0, flipg, 0, true ); | 157 | new QAction( "* (always both)", 0, 0, flipg, 0, true ); |
150 | 158 | ||
159 | outputTog = new QActionGroup( 0, "output", true ); | ||
160 | outputTog->setToggleAction( true ); | ||
161 | new QAction( "/tmp", 0, 0, outputTog, 0, true ); | ||
162 | new QAction( "/mnt/card/", 0, 0, outputTog, 0, true ); | ||
163 | new QAction( "/mnt/sd/", 0, 0, outputTog, 0, true ); | ||
164 | docfolder = new QAction( "Documents Folder", 0, 0, outputTog, 0, true ); | ||
165 | docfolder->setOn( true ); | ||
166 | custom = new QAction( "&Custom...", 0, 0, outputTog, 0, true ); | ||
167 | |||
151 | outputg = new QActionGroup( 0, "output", true ); | 168 | outputg = new QActionGroup( 0, "output", true ); |
152 | outputg->setToggleAction( true ); | 169 | outputg->setToggleAction( true ); |
@@ -160,4 +177,5 @@ void CameraMainWindow::init() | |||
160 | connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); | 177 | connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) ); |
161 | connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) ); | 178 | connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) ); |
179 | connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) ); | ||
162 | connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); | 180 | connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) ); |
163 | 181 | ||
@@ -232,4 +250,13 @@ void CameraMainWindow::showContextMenu() | |||
232 | zoomg->addTo( &zoom ); | 250 | zoomg->addTo( &zoom ); |
233 | 251 | ||
252 | QPopupMenu prefix; | ||
253 | prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) ); | ||
254 | int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) ); | ||
255 | prefix.setItemChecked( id, appendSettings ); | ||
256 | |||
257 | QPopupMenu outputTo; | ||
258 | outputTo.setCheckable( true ); | ||
259 | outputTog->addTo( &outputTo ); | ||
260 | |||
234 | QPopupMenu output; | 261 | QPopupMenu output; |
235 | output.setCheckable( true ); | 262 | output.setCheckable( true ); |
@@ -241,4 +268,7 @@ void CameraMainWindow::showContextMenu() | |||
241 | m.insertItem( "&Flip", &flip ); | 268 | m.insertItem( "&Flip", &flip ); |
242 | m.insertItem( "&Quality", &quality ); | 269 | m.insertItem( "&Quality", &quality ); |
270 | m.insertSeparator(); | ||
271 | m.insertItem( "&Prefix", &prefix ); | ||
272 | m.insertItem( "Output &To", &outputTo ); | ||
243 | m.insertItem( "&Output As", &output ); | 273 | m.insertItem( "&Output As", &output ); |
244 | 274 | ||
@@ -308,4 +338,36 @@ void CameraMainWindow::flipMenuItemClicked( QAction* a ) | |||
308 | 338 | ||
309 | 339 | ||
340 | void CameraMainWindow::outputToMenuItemClicked( QAction* a ) | ||
341 | { | ||
342 | if ( a->text() == "&Custom..." ) | ||
343 | { | ||
344 | QMap<QString, QStringList> map; | ||
345 | map.insert( tr("All"), QStringList() ); | ||
346 | QStringList text; | ||
347 | text << "text/*"; | ||
348 | map.insert(tr("Text"), text ); | ||
349 | text << "*"; | ||
350 | map.insert(tr("All"), text ); | ||
351 | |||
352 | QString str; | ||
353 | str = OFileDialog::getSaveFileName( 2, "/", QString::null, map ); | ||
354 | if ( str.isEmpty() || !QFileInfo(str).isDir() ) | ||
355 | { | ||
356 | docfolder->setOn( true ); | ||
357 | outputTo = "Documents Folder"; | ||
358 | } | ||
359 | else | ||
360 | { | ||
361 | outputTo = str; | ||
362 | } | ||
363 | } | ||
364 | else | ||
365 | { | ||
366 | outputTo = a->text(); | ||
367 | } | ||
368 | odebug << "Output to now: " << outputTo << oendl; | ||
369 | } | ||
370 | |||
371 | |||
310 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) | 372 | void CameraMainWindow::outputMenuItemClicked( QAction* a ) |
311 | { | 373 | { |
@@ -316,4 +378,25 @@ void CameraMainWindow::outputMenuItemClicked( QAction* a ) | |||
316 | 378 | ||
317 | 379 | ||
380 | void CameraMainWindow::prefixItemChoosen() | ||
381 | { | ||
382 | QDialog* d = new QDialog( this, "dialog", true ); | ||
383 | d->setCaption( "Enter Prefix..." ); | ||
384 | QVBoxLayout* v = new QVBoxLayout( d ); | ||
385 | QLineEdit* le = new QLineEdit( prefix, d ); | ||
386 | v->addWidget( le ); | ||
387 | le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty | ||
388 | if ( d->exec() == QDialog::Accepted ) | ||
389 | prefix = le->text(); | ||
390 | odebug << "Prefix now: " << prefix << oendl; | ||
391 | } | ||
392 | |||
393 | |||
394 | void CameraMainWindow::appendSettingsChoosen() | ||
395 | { | ||
396 | appendSettings = !appendSettings; | ||
397 | odebug << "appendSettings now: " << appendSettings << oendl; | ||
398 | } | ||
399 | |||
400 | |||
318 | void CameraMainWindow::shutterClicked() | 401 | void CameraMainWindow::shutterClicked() |
319 | { | 402 | { |
@@ -338,5 +421,17 @@ void CameraMainWindow::performCapture( const QString& format ) | |||
338 | { | 421 | { |
339 | QString name; | 422 | QString name; |
340 | name.sprintf( "/tmp/image-%d_%d_%d_q%d.%s", _pics++, captureX, captureY, quality, (const char*) captureFormat.lower() ); | 423 | |
424 | if ( outputTo == "Documents Folder" ) | ||
425 | name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); | ||
426 | else | ||
427 | name = outputTo; | ||
428 | |||
429 | name.append( prefix ); | ||
430 | if ( appendSettings ) | ||
431 | { | ||
432 | name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) ); | ||
433 | } | ||
434 | name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) ); | ||
435 | |||
341 | QImage i; | 436 | QImage i; |
342 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); | 437 | ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, &i ); |
@@ -407,5 +502,10 @@ void CameraMainWindow::stopVideoCapture() | |||
407 | _framerate = 1000.0 / (_time.elapsed()/_videopics); | 502 | _framerate = 1000.0 / (_time.elapsed()/_videopics); |
408 | 503 | ||
409 | postProcessVideo( CAPTUREFILE, QString().sprintf( "/tmp/video-%d_%d_%d_q%d-%dfps.avi", _videos++, captureX, captureY, quality, _framerate ) ); | 504 | QString name( outputTo ); |
505 | name.append( "/prefix" ); | ||
506 | if ( appendSettings ) | ||
507 | name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); | ||
508 | name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); | ||
509 | postProcessVideo( CAPTUREFILE, name ); | ||
410 | 510 | ||
411 | #ifndef QT_NO_DEBUG | 511 | #ifndef QT_NO_DEBUG |
@@ -521,7 +621,12 @@ void CameraMainWindow::postProcessVideo( const QString& infile, const QString& o | |||
521 | delete tempbuffer; | 621 | delete tempbuffer; |
522 | framefile.close(); | 622 | framefile.close(); |
623 | |||
624 | odebug << "deleting temporary capturefile " << infile << oendl; | ||
625 | ::close( infd ); | ||
626 | QFile::remove( infile ); | ||
523 | } | 627 | } |
524 | 628 | ||
525 | avi_end( outfd, captureX, captureY, _framerate ); | 629 | avi_end( outfd, captureX, captureY, _framerate ); |
630 | ::close( outfd ); | ||
526 | 631 | ||
527 | fr->hide(); | 632 | fr->hide(); |
@@ -552,4 +657,8 @@ void CameraMainWindow::doSomething() | |||
552 | "/tmp/output.avi" ); | 657 | "/tmp/output.avi" ); |
553 | } | 658 | } |
659 | #else | ||
660 | void CameraMainWindow::doSomething() | ||
661 | { | ||
662 | } | ||
554 | #endif | 663 | #endif |
555 | 664 | ||
diff --git a/noncore/multimedia/camera/mainwindow.h b/noncore/multimedia/camera/mainwindow.h index 1d844da..451ad5f 100644 --- a/noncore/multimedia/camera/mainwindow.h +++ b/noncore/multimedia/camera/mainwindow.h | |||
@@ -49,5 +49,8 @@ class CameraMainWindow: public QMainWindow | |||
49 | void zoomMenuItemClicked( QAction* ); | 49 | void zoomMenuItemClicked( QAction* ); |
50 | void flipMenuItemClicked( QAction* ); | 50 | void flipMenuItemClicked( QAction* ); |
51 | void outputToMenuItemClicked( QAction* ); | ||
51 | void outputMenuItemClicked( QAction* ); | 52 | void outputMenuItemClicked( QAction* ); |
53 | void prefixItemChoosen(); | ||
54 | void appendSettingsChoosen(); | ||
52 | void shutterClicked(); | 55 | void shutterClicked(); |
53 | 56 | ||
@@ -64,7 +67,5 @@ class CameraMainWindow: public QMainWindow | |||
64 | 67 | ||
65 | protected slots: | 68 | protected slots: |
66 | #ifndef QT_NO_DEBUG | 69 | void doSomething(); // solely for debugging purposes |
67 | //void doSomething(); // solely for debugging purposes | ||
68 | #endif | ||
69 | 70 | ||
70 | private: | 71 | private: |
@@ -77,4 +78,7 @@ class CameraMainWindow: public QMainWindow | |||
77 | QActionGroup* zoomg; | 78 | QActionGroup* zoomg; |
78 | QActionGroup* flipg; | 79 | QActionGroup* flipg; |
80 | QActionGroup* outputTog; | ||
81 | QAction* custom; | ||
82 | QAction* docfolder; | ||
79 | QActionGroup* outputg; | 83 | QActionGroup* outputg; |
80 | 84 | ||
@@ -86,4 +90,8 @@ class CameraMainWindow: public QMainWindow | |||
86 | QString captureFormat; | 90 | QString captureFormat; |
87 | 91 | ||
92 | QString outputTo; | ||
93 | QString prefix; | ||
94 | bool appendSettings; | ||
95 | |||
88 | bool _capturing; | 96 | bool _capturing; |
89 | int _pics; | 97 | int _pics; |