summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/camera/cmd/.cvsignore4
-rw-r--r--noncore/multimedia/camera/gui/.cvsignore4
-rw-r--r--noncore/multimedia/camera/gui/mainwindow.cpp8
-rw-r--r--noncore/multimedia/camera/lib/.cvsignore4
4 files changed, 10 insertions, 10 deletions
diff --git a/noncore/multimedia/camera/cmd/.cvsignore b/noncore/multimedia/camera/cmd/.cvsignore
index 737c5b2..e5aacf6 100644
--- a/noncore/multimedia/camera/cmd/.cvsignore
+++ b/noncore/multimedia/camera/cmd/.cvsignore
@@ -1,5 +1,5 @@
-moc
-obj
+*moc
+*obj
config.in
Makefile
diff --git a/noncore/multimedia/camera/gui/.cvsignore b/noncore/multimedia/camera/gui/.cvsignore
index 2a3a7a8..8e95df7 100644
--- a/noncore/multimedia/camera/gui/.cvsignore
+++ b/noncore/multimedia/camera/gui/.cvsignore
@@ -1,6 +1,6 @@
*.pro
-moc
-obj
+*moc
+*obj
config.in
Makefile
diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp
index bde448d..b2fcc6c 100644
--- a/noncore/multimedia/camera/gui/mainwindow.cpp
+++ b/noncore/multimedia/camera/gui/mainwindow.cpp
@@ -1,146 +1,146 @@
/**********************************************************************
** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
**********************************************************************/
#include "mainwindow.h"
#include "previewwidget.h"
#include "zcameraio.h"
#include "imageio.h"
#include "avi.h"
/* OPIE */
#include <opie2/ofiledialog.h>
#include <opie2/odevice.h>
#include <opie2/oapplication.h>
#include <opie2/oconfig.h>
#include <opie2/odebug.h>
+#include <opie2/oresource.h>
#include <qpe/global.h>
-#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
/* QT */
#include <qapplication.h>
#include <qaction.h>
#include <qvbox.h>
#include <qcombobox.h>
#include <qcursor.h>
#include <qdatastream.h>
#include <qdir.h>
#include <qfile.h>
#include <qimage.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpopupmenu.h>
#include <qprogressbar.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qlayout.h>
#include <qdirectpainter_qws.h>
/* STD */
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#define CAPTUREFILE "/tmp/capture.dat"
#define OUTPUTFILE "/tmp/output.avi"
#define OUTPUT_TO_CUSTOM 250
#define OUTPUT_TO_DOCFOLDER 251
using namespace Opie::Ui;
using namespace Opie::Core;
CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f )
:QMainWindow( parent, name, f ),
_rotation( 270 ), // FIXME: get this from current settings (ODevice?)
_capturing( false ),
_pics( 1 ), _videos( 1 )
{
#ifdef QT_NO_DEBUG
if ( !ZCameraIO::instance()->isOpen() )
{
QVBox* v = new QVBox( this );
v->setMargin( 10 );
QLabel* l1 = new QLabel( v );
- l1->setPixmap( Resource::loadPixmap( "camera/error" ) );
+ l1->setPixmap( Opie::Core::OResource::loadPixmap( "camera/error", Opie::Core::OResource::SmallIcon ) );
QLabel* l2 = new QLabel( v );
l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>"
"* Is the sharpzdc_cs module loaded ?<br>"
"* Is /dev/sharpzdc read/writable ?<p>" );
connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) );
setCentralWidget( v );
return;
}
#endif
init();
_rotation = 270; //TODO: grab these from the actual settings
preview = new PreviewWidget( this, "camera preview widget" );
//setCentralWidget( preview ); <--- don't do this!
preview->resize( QSize( 240, 288 ) );
preview->show();
// construct a System Channel to receive setRotation messages
_sysChannel = new QCopChannel( "QPE/System", this );
connect( _sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) );
connect( ZCameraIO::instance(), SIGNAL( shutterClicked() ), this, SLOT( shutterClicked() ) );
updateCaption();
};
CameraMainWindow::~CameraMainWindow()
{
// write back configuration
OConfigGroupSaver cgs( oApp->config(), "General" );
cgs.config()->writeEntry( "flip", flip );
cgs.config()->writeEntry( "quality", quality );
cgs.config()->writeEntry( "zoom", zoom );
cgs.config()->writeEntry( "captureX", captureX );
cgs.config()->writeEntry( "captureY", captureY );
cgs.config()->writeEntry( "captureFormat", captureFormat );
cgs.config()->writeEntry( "outputTo", outputTo );
cgs.config()->writeEntry( "prefix", prefix );
cgs.config()->writeEntry( "appendSettings", appendSettings );
}
void CameraMainWindow::init()
{
// get values from configuration
OConfigGroupSaver cgs( oApp->config(), "General" );
flip = cgs.config()->readEntry( "flip", "A" );
quality = cgs.config()->readNumEntry( "quality", 50 );
zoom = cgs.config()->readNumEntry( "zoom", 1 );
captureX = cgs.config()->readNumEntry( "captureX", 480 );
captureY = cgs.config()->readNumEntry( "captureY", 640 );
captureFormat = cgs.config()->readEntry( "captureFormat", "JPEG" );
outputTo = cgs.config()->readEntry( "outputTo", "Documents Folder" );
prefix = cgs.config()->readEntry( "prefix", "Untitled" );
appendSettings = cgs.config()->readBoolEntry( "appendSettings", true );
// create action groups
@@ -177,224 +177,224 @@ void CameraMainWindow::init()
new QAction( "x 1", 0, 0, zoomg, "1", true );
new QAction( "x 2", 0, 0, zoomg, "2", true );
a = (QAction*) zoomg->child( QString().sprintf( "%d", zoom ) );
if ( a ) a->setOn( true );
else owarn << "can't set zoom" << oendl;
flipg = new QActionGroup( 0, "flip", true );
flipg->setToggleAction( true );
new QAction( "Auto (recommended)", 0, 0, flipg, "A", true );
new QAction( "0 (always off)", 0, 0, flipg, "0", true );
new QAction( "X (always horizontal)", 0, 0, flipg, "X", true );
new QAction( "Y (always vertical)", 0, 0, flipg, "Y", true );
new QAction( "* (always both)", 0, 0, flipg, "*", true );
a = (QAction*) flipg->child( QString().sprintf( "%s", (const char*) flip ) );
if ( a ) a->setOn( true );
else owarn << "can't set flip" << oendl;
outputTog = new QActionGroup( 0, "output", true );
outputTog->setToggleAction( true );
new QAction( "/tmp/", 0, 0, outputTog, "/tmp/", true );
new QAction( "/mnt/card/", 0, 0, outputTog, "/mnt/card/", true );
new QAction( "/mnt/cf/", 0, 0, outputTog, "/mnt/cf/", true );
docfolder = new QAction( "Documents Folder", 0, 0, outputTog, "Documents Folder", true );
custom = new QAction( "&Custom...", 0, 0, outputTog, "custom", true ); //TODO: How to save custom!?
a = (QAction*) outputTog->child( QString().sprintf( "%s", (const char*) outputTo ) );
if ( a ) a->setOn( true );
else owarn << "can't set outputTo" << oendl;
outputg = new QActionGroup( 0, "output", true );
outputg->setToggleAction( true );
new QAction( "JPEG", 0, 0, outputg, "JPEG", true );
new QAction( "PNG", 0, 0, outputg, "PNG", true );
new QAction( "BMP", 0, 0, outputg, "BMP", true );
new QAction( "AVI", 0, 0, outputg, "AVI", true );
a = (QAction*) outputg->child( QString().sprintf( "%s", (const char*) captureFormat ) );
if ( a ) a->setOn( true );
else owarn << "can't set output format" << oendl;
connect( resog, SIGNAL( selected(QAction*) ), this, SLOT( resoMenuItemClicked(QAction*) ) );
connect( qualityg, SIGNAL( selected(QAction*) ), this, SLOT( qualityMenuItemClicked(QAction*) ) );
connect( zoomg, SIGNAL( selected(QAction*) ), this, SLOT( zoomMenuItemClicked(QAction*) ) );
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*) ) );
}
void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data )
{
int _newrotation;
QDataStream stream( data, IO_ReadOnly );
odebug << "received system message: " << msg << oendl;
if ( msg == "setCurrentRotation(int)" )
{
stream >> _newrotation;
odebug << "received setCurrentRotation(" << _newrotation << ")" << oendl;
switch ( _newrotation )
{
case 270: preview->resize( QSize( 240, 288 ) ); break;
case 180: preview->resize( QSize( 320, 208 ) ); break;
default: QMessageBox::warning( this, "opie-camera",
"This rotation is not supported.\n"
- "Supported are 180° and 270°" );
+ "Supported are 180 and 270" );
}
if ( _newrotation != _rotation )
{
int tmp = captureX;
captureX = captureY;
captureY = tmp;
_rotation = _newrotation;
}
updateCaption();
}
}
void CameraMainWindow::changeZoom( int zoom )
{
int z;
switch ( zoom )
{
case 0: z = 128; break;
case 1: z = 256; break;
case 2: z = 512; break;
default: assert( 0 ); break;
}
ZCameraIO::instance()->setCaptureFrame( 240, 160, z );
}
void CameraMainWindow::showContextMenu()
{
QPopupMenu reso;
reso.setCheckable( true );
resog->addTo( &reso );
QPopupMenu quality;
quality.setCheckable( true );
qualityg->addTo( &quality );
QPopupMenu flip;
flip.setCheckable( true );
flipg->addTo( &flip );
QPopupMenu zoom;
zoom.setCheckable( true );
zoomg->addTo( &zoom );
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;
output.setCheckable( true );
outputg->addTo( &output );
QPopupMenu m( this );
m.insertItem( "&Resolution", &reso );
m.insertItem( "&Zoom", &zoom );
m.insertItem( "&Flip", &flip );
m.insertItem( "&Quality", &quality );
m.insertSeparator();
m.insertItem( "&Prefix", &prefix );
m.insertItem( "Output &To", &outputTo );
m.insertItem( "&Output As", &output );
#ifndef QT_NO_DEBUG
m.insertItem( "&Debug!", this, SLOT( doSomething() ) );
#endif
m.exec( QCursor::pos() );
}
void CameraMainWindow::resoMenuItemClicked( QAction* a )
{
switch ( _rotation )
{
case 270:
captureY = a->text().left(3).toInt();
captureX = a->text().right(3).toInt();
break;
case 180:
captureX = a->text().left(3).toInt();
captureY = a->text().right(3).toInt();
break;
default: QMessageBox::warning( this, "opie-camera",
"This rotation is not supported.\n"
- "Supported are 180° and 270°" );
+ "Supported are 180 and 270" );
}
odebug << "Capture Resolution now: " << captureX << ", " << captureY << oendl;
updateCaption();
}
void CameraMainWindow::qualityMenuItemClicked( QAction* a )
{
quality = a->text().left(3).toInt();
odebug << "Quality now: " << quality << oendl;
updateCaption();
}
void CameraMainWindow::zoomMenuItemClicked( QAction* a )
{
zoom = QString( a->text().at(2) ).toInt();
odebug << "Zoom now: " << zoom << oendl;
ZCameraIO::instance()->setZoom( zoom );
updateCaption();
}
void CameraMainWindow::flipMenuItemClicked( QAction* a )
{
flip = QString( a->text().at(0) );
odebug << "Flip now: " << flip << oendl;
if ( flip == "A" )
ZCameraIO::instance()->setFlip( ZCameraIO::AUTOMATICFLIP );
else if ( flip == "0" )
ZCameraIO::instance()->setFlip( ZCameraIO::XNOFLIP | ZCameraIO::YNOFLIP );
else if ( flip == "X" )
ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP );
else if ( flip == "Y" )
ZCameraIO::instance()->setFlip( ZCameraIO::YFLIP );
else if ( flip == "*" )
ZCameraIO::instance()->setFlip( ZCameraIO::XFLIP | ZCameraIO::YFLIP );
updateCaption();
}
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;
diff --git a/noncore/multimedia/camera/lib/.cvsignore b/noncore/multimedia/camera/lib/.cvsignore
index 2a3a7a8..8e95df7 100644
--- a/noncore/multimedia/camera/lib/.cvsignore
+++ b/noncore/multimedia/camera/lib/.cvsignore
@@ -1,6 +1,6 @@
*.pro
-moc
-obj
+*moc
+*obj
config.in
Makefile