summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/mainwindow.cpp125
-rw-r--r--noncore/multimedia/camera/mainwindow.h14
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 @@
#include <qdatastream.h>
+#include <qdir.h>
#include <qfile.h>
@@ -30,2 +31,3 @@
#include <qlabel.h>
+#include <qlineedit.h>
#include <qpopupmenu.h>
@@ -55,2 +57,5 @@ using namespace Opie;
+#define OUTPUT_TO_CUSTOM 250
+#define OUTPUT_TO_DOCFOLDER 251
+
CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f )
@@ -59,3 +64,3 @@ CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags
_capturing( false ),
- _pics( 0 ), _videos( 0 )
+ _pics( 1 ), _videos( 1 )
{
@@ -115,2 +120,5 @@ void CameraMainWindow::init()
captureFormat = "JPEG";
+ outputTo = "Documents Folder";
+ prefix = "Untitled";
+ appendSettings = true;
@@ -131,7 +139,7 @@ void CameraMainWindow::init()
qualityg->setToggleAction( true );
- new QAction( " 0 (minimal)", 0, 0, qualityg, 0, true );
- new QAction( " 25 (low)", 0, 0, qualityg, 0, true );
- ( new QAction( " 50 (good)", 0, 0, qualityg, 0, true ) )->setOn( true );
- new QAction( " 75 (better)", 0, 0, qualityg, 0, true );
- new QAction( "100 (best)", 0, 0, qualityg, 0, true );
+ new QAction( " 0 (&minimal)", 0, 0, qualityg, 0, true );
+ new QAction( " 25 (&low)", 0, 0, qualityg, 0, true );
+ ( new QAction( " 50 (&good)", 0, 0, qualityg, 0, true ) )->setOn( true );
+ new QAction( " 75 (&better)", 0, 0, qualityg, 0, true );
+ new QAction( "100 (bes&t)", 0, 0, qualityg, 0, true );
@@ -150,2 +158,11 @@ void CameraMainWindow::init()
+ outputTog = new QActionGroup( 0, "output", true );
+ outputTog->setToggleAction( true );
+ new QAction( "/tmp", 0, 0, outputTog, 0, true );
+ new QAction( "/mnt/card/", 0, 0, outputTog, 0, true );
+ new QAction( "/mnt/sd/", 0, 0, outputTog, 0, true );
+ docfolder = new QAction( "Documents Folder", 0, 0, outputTog, 0, true );
+ docfolder->setOn( true );
+ custom = new QAction( "&Custom...", 0, 0, outputTog, 0, true );
+
outputg = new QActionGroup( 0, "output", true );
@@ -161,2 +178,3 @@ void CameraMainWindow::init()
connect( flipg, SIGNAL( selected(QAction*) ), this, SLOT( flipMenuItemClicked(QAction*) ) );
+ connect( outputTog, SIGNAL( selected(QAction*) ), this, SLOT( outputToMenuItemClicked(QAction*) ) );
connect( outputg, SIGNAL( selected(QAction*) ), this, SLOT( outputMenuItemClicked(QAction*) ) );
@@ -233,2 +251,11 @@ void CameraMainWindow::showContextMenu()
+ QPopupMenu prefix;
+ prefix.insertItem( "&Choose...", this, SLOT( prefixItemChoosen() ) );
+ int id = prefix.insertItem( "&Append Settings", this, SLOT( appendSettingsChoosen() ) );
+ prefix.setItemChecked( id, appendSettings );
+
+ QPopupMenu outputTo;
+ outputTo.setCheckable( true );
+ outputTog->addTo( &outputTo );
+
QPopupMenu output;
@@ -242,2 +269,5 @@ void CameraMainWindow::showContextMenu()
m.insertItem( "&Quality", &quality );
+ m.insertSeparator();
+ m.insertItem( "&Prefix", &prefix );
+ m.insertItem( "Output &To", &outputTo );
m.insertItem( "&Output As", &output );
@@ -309,2 +339,34 @@ void CameraMainWindow::flipMenuItemClicked( QAction* a )
+void CameraMainWindow::outputToMenuItemClicked( QAction* a )
+{
+ if ( a->text() == "&Custom..." )
+ {
+ QMap<QString, QStringList> map;
+ map.insert( tr("All"), QStringList() );
+ QStringList text;
+ text << "text/*";
+ map.insert(tr("Text"), text );
+ text << "*";
+ map.insert(tr("All"), text );
+
+ QString str;
+ str = OFileDialog::getSaveFileName( 2, "/", QString::null, map );
+ if ( str.isEmpty() || !QFileInfo(str).isDir() )
+ {
+ docfolder->setOn( true );
+ outputTo = "Documents Folder";
+ }
+ else
+ {
+ outputTo = str;
+ }
+ }
+ else
+ {
+ outputTo = a->text();
+ }
+ odebug << "Output to now: " << outputTo << oendl;
+}
+
+
void CameraMainWindow::outputMenuItemClicked( QAction* a )
@@ -317,2 +379,23 @@ void CameraMainWindow::outputMenuItemClicked( QAction* a )
+void CameraMainWindow::prefixItemChoosen()
+{
+ QDialog* d = new QDialog( this, "dialog", true );
+ d->setCaption( "Enter Prefix..." );
+ QVBoxLayout* v = new QVBoxLayout( d );
+ QLineEdit* le = new QLineEdit( prefix, d );
+ v->addWidget( le );
+ le->setFixedWidth( 150 ); //FIXME: 'tis a bit dirty
+ if ( d->exec() == QDialog::Accepted )
+ prefix = le->text();
+ odebug << "Prefix now: " << prefix << oendl;
+}
+
+
+void CameraMainWindow::appendSettingsChoosen()
+{
+ appendSettings = !appendSettings;
+ odebug << "appendSettings now: " << appendSettings << oendl;
+}
+
+
void CameraMainWindow::shutterClicked()
@@ -339,3 +422,15 @@ void CameraMainWindow::performCapture( const QString& format )
QString name;
- name.sprintf( "/tmp/image-%d_%d_%d_q%d.%s", _pics++, captureX, captureY, quality, (const char*) captureFormat.lower() );
+
+ if ( outputTo == "Documents Folder" )
+ name.sprintf( "%s/Documents/image/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() );
+ else
+ name = outputTo;
+
+ name.append( prefix );
+ if ( appendSettings )
+ {
+ name.append( QString().sprintf( "_%d_%d_q%d", captureX, captureY, quality ) );
+ }
+ name.append( QString().sprintf( "-%d.%s", _pics++, (const char*) captureFormat.lower() ) );
+
QImage i;
@@ -408,3 +503,8 @@ void CameraMainWindow::stopVideoCapture()
- postProcessVideo( CAPTUREFILE, QString().sprintf( "/tmp/video-%d_%d_%d_q%d-%dfps.avi", _videos++, captureX, captureY, quality, _framerate ) );
+ QString name( outputTo );
+ name.append( "/prefix" );
+ if ( appendSettings )
+ name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) );
+ name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) );
+ postProcessVideo( CAPTUREFILE, name );
@@ -522,2 +622,6 @@ void CameraMainWindow::postProcessVideo( const QString& infile, const QString& o
framefile.close();
+
+ odebug << "deleting temporary capturefile " << infile << oendl;
+ ::close( infd );
+ QFile::remove( infile );
}
@@ -525,2 +629,3 @@ void CameraMainWindow::postProcessVideo( const QString& infile, const QString& o
avi_end( outfd, captureX, captureY, _framerate );
+ ::close( outfd );
@@ -553,2 +658,6 @@ void CameraMainWindow::doSomething()
}
+#else
+void CameraMainWindow::doSomething()
+{
+}
#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
void flipMenuItemClicked( QAction* );
+ void outputToMenuItemClicked( QAction* );
void outputMenuItemClicked( QAction* );
+ void prefixItemChoosen();
+ void appendSettingsChoosen();
void shutterClicked();
@@ -65,5 +68,3 @@ class CameraMainWindow: public QMainWindow
protected slots:
- #ifndef QT_NO_DEBUG
- //void doSomething(); // solely for debugging purposes
- #endif
+ void doSomething(); // solely for debugging purposes
@@ -78,2 +79,5 @@ class CameraMainWindow: public QMainWindow
QActionGroup* flipg;
+ QActionGroup* outputTog;
+ QAction* custom;
+ QAction* docfolder;
QActionGroup* outputg;
@@ -87,2 +91,6 @@ class CameraMainWindow: public QMainWindow
+ QString outputTo;
+ QString prefix;
+ bool appendSettings;
+
bool _capturing;