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 /noncore/multimedia | |
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 | |||
@@ -27,2 +27,3 @@ | |||
27 | #include <qdatastream.h> | 27 | #include <qdatastream.h> |
28 | #include <qdir.h> | ||
28 | #include <qfile.h> | 29 | #include <qfile.h> |
@@ -30,2 +31,3 @@ | |||
30 | #include <qlabel.h> | 31 | #include <qlabel.h> |
32 | #include <qlineedit.h> | ||
31 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
@@ -55,2 +57,5 @@ using namespace Opie; | |||
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 ) |
@@ -59,3 +64,3 @@ CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags | |||
59 | _capturing( false ), | 64 | _capturing( false ), |
60 | _pics( 0 ), _videos( 0 ) | 65 | _pics( 1 ), _videos( 1 ) |
61 | { | 66 | { |
@@ -115,2 +120,5 @@ void CameraMainWindow::init() | |||
115 | captureFormat = "JPEG"; | 120 | captureFormat = "JPEG"; |
121 | outputTo = "Documents Folder"; | ||
122 | prefix = "Untitled"; | ||
123 | appendSettings = true; | ||
116 | 124 | ||
@@ -131,7 +139,7 @@ void CameraMainWindow::init() | |||
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 | ||
@@ -150,2 +158,11 @@ void CameraMainWindow::init() | |||
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 ); |
@@ -161,2 +178,3 @@ void CameraMainWindow::init() | |||
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*) ) ); |
@@ -233,2 +251,11 @@ void CameraMainWindow::showContextMenu() | |||
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; |
@@ -242,2 +269,5 @@ void CameraMainWindow::showContextMenu() | |||
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 ); |
@@ -309,2 +339,34 @@ void CameraMainWindow::flipMenuItemClicked( QAction* a ) | |||
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 ) |
@@ -317,2 +379,23 @@ void CameraMainWindow::outputMenuItemClicked( QAction* a ) | |||
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() |
@@ -339,3 +422,15 @@ void CameraMainWindow::performCapture( const QString& format ) | |||
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; |
@@ -408,3 +503,8 @@ void CameraMainWindow::stopVideoCapture() | |||
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 | ||
@@ -522,2 +622,6 @@ void CameraMainWindow::postProcessVideo( const QString& infile, const QString& o | |||
522 | framefile.close(); | 622 | framefile.close(); |
623 | |||
624 | odebug << "deleting temporary capturefile " << infile << oendl; | ||
625 | ::close( infd ); | ||
626 | QFile::remove( infile ); | ||
523 | } | 627 | } |
@@ -525,2 +629,3 @@ void CameraMainWindow::postProcessVideo( const QString& infile, const QString& o | |||
525 | avi_end( outfd, captureX, captureY, _framerate ); | 629 | avi_end( outfd, captureX, captureY, _framerate ); |
630 | ::close( outfd ); | ||
526 | 631 | ||
@@ -553,2 +658,6 @@ void CameraMainWindow::doSomething() | |||
553 | } | 658 | } |
659 | #else | ||
660 | void CameraMainWindow::doSomething() | ||
661 | { | ||
662 | } | ||
554 | #endif | 663 | #endif |
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 | |||
@@ -50,3 +50,6 @@ class CameraMainWindow: public QMainWindow | |||
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(); |
@@ -65,5 +68,3 @@ class CameraMainWindow: public QMainWindow | |||
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 | ||
@@ -78,2 +79,5 @@ class CameraMainWindow: public QMainWindow | |||
78 | QActionGroup* flipg; | 79 | QActionGroup* flipg; |
80 | QActionGroup* outputTog; | ||
81 | QAction* custom; | ||
82 | QAction* docfolder; | ||
79 | QActionGroup* outputg; | 83 | QActionGroup* outputg; |
@@ -87,2 +91,6 @@ class CameraMainWindow: public QMainWindow | |||
87 | 91 | ||
92 | QString outputTo; | ||
93 | QString prefix; | ||
94 | bool appendSettings; | ||
95 | |||
88 | bool _capturing; | 96 | bool _capturing; |