summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/camera/mainwindow.cpp36
-rw-r--r--noncore/multimedia/camera/mainwindow.h2
-rw-r--r--noncore/multimedia/camera/zcameraio.cpp10
-rw-r--r--noncore/multimedia/camera/zcameraio.h2
4 files changed, 42 insertions, 8 deletions
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp
index 7080e63..34ebe9e 100644
--- a/noncore/multimedia/camera/mainwindow.cpp
+++ b/noncore/multimedia/camera/mainwindow.cpp
@@ -16,39 +16,58 @@
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 19
20#include <qvbox.h> 20#include <qvbox.h>
21#include <qcombobox.h> 21#include <qcombobox.h>
22#include <qcursor.h>
22#include <qdatastream.h> 23#include <qdatastream.h>
23#include <qpushbutton.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qpopupmenu.h>
26#include <qpushbutton.h>
27#include <qmessagebox.h>
25#include <qdirectpainter_qws.h> 28#include <qdirectpainter_qws.h>
26#include <qpe/resource.h> 29#include <qpe/resource.h>
27#include <qpe/qcopenvelope_qws.h> 30#include <qpe/qcopenvelope_qws.h>
28#include <opie/ofiledialog.h> 31#include <opie/ofiledialog.h>
29 32
30#include <opie2/odebug.h> 33#include <opie2/odebug.h>
31 34
32#include <assert.h> 35#include <assert.h>
33 36
34CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) 37CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f )
35 :QMainWindow( parent, name, f ) 38 :QMainWindow( parent, name, f )
36{ 39{
40 if ( !ZCameraIO::instance()->isOpen() )
41 {
42 QVBox* v = new QVBox( this );
43 v->setMargin( 10 );
44 QLabel* l1 = new QLabel( v );
45 l1->setPixmap( Resource::loadPixmap( "camera/error" ) );
46 QLabel* l2 = new QLabel( v );
47 l2->setText( "<b>Sorry. could not detect your camera :-(</b><p>"
48 "* Is the sharpzdc_cs module loaded ?<br>"
49 "* Is /dev/sharpzdc read/writable ?<p>" );
50 connect( new QPushButton( "Exit", v ), SIGNAL( clicked() ), this, SLOT( close() ) );
51 setCentralWidget( v );
52 return;
53 }
54
37 _rotation = 270; //TODO: grab these from the actual settings 55 _rotation = 270; //TODO: grab these from the actual settings
38 56
39 preview = new PreviewWidget( this, "camera preview widget" ); 57 preview = new PreviewWidget( this, "camera preview widget" );
40 //setCentralWidget( preview ); <--- don't do this! 58 //setCentralWidget( preview ); <--- don't do this!
41 preview->resize( QSize( 240, 288 ) ); 59 preview->resize( QSize( 240, 288 ) );
42 preview->show(); 60 preview->show();
43 61
44 // construct a System Channel to receive setRotation messages 62 // construct a System Channel to receive setRotation messages
45 _sysChannel = new QCopChannel( "QPE/System", this ); 63 _sysChannel = new QCopChannel( "QPE/System", this );
46 connect( _sysChannel, SIGNAL( received( const QCString&, const QByteArray& ) ), 64 connect( _sysChannel, SIGNAL( received( const QCString&, const QByteArray& ) ),
47 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 65 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
48 66
67 connect( preview, SIGNAL( contextMenuRequested() ), this, SLOT( showContextMenu() ) );
49}; 68};
50 69
51 70
52CameraMainWindow::~CameraMainWindow() 71CameraMainWindow::~CameraMainWindow()
53{ 72{
54} 73}
@@ -64,13 +83,15 @@ void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& dat
64 odebug << "received setCurrentRotation(" << _rotation << ")" << oendl; 83 odebug << "received setCurrentRotation(" << _rotation << ")" << oendl;
65 84
66 switch ( _rotation ) 85 switch ( _rotation )
67 { 86 {
68 case 270: preview->resize( QSize( 240, 288 ) ); break; 87 case 270: preview->resize( QSize( 240, 288 ) ); break;
69 case 180: preview->resize( QSize( 320, 208 ) ); break; 88 case 180: preview->resize( QSize( 320, 208 ) ); break;
70 default: assert( 0 ); // not yet handled 89 default: QMessageBox::warning( this, "opie-camera",
90 "This rotation is not supported.\n"
91 "Supported are 180° and 270°" );
71 } 92 }
72 } 93 }
73} 94}
74 95
75 96
76void CameraMainWindow::changeZoom( int zoom ) 97void CameraMainWindow::changeZoom( int zoom )
@@ -84,6 +105,17 @@ void CameraMainWindow::changeZoom( int zoom )
84 default: assert( 0 ); break; 105 default: assert( 0 ); break;
85 } 106 }
86 107
87 ZCameraIO::instance()->setCaptureFrame( 240, 160, z ); 108 ZCameraIO::instance()->setCaptureFrame( 240, 160, z );
88} 109}
89 110
111
112void CameraMainWindow::showContextMenu()
113{
114 QPopupMenu m( this );
115 m.insertItem( "Item 1" );
116 m.insertItem( "Item 1" );
117 m.insertItem( "Item 1" );
118 m.insertItem( "Item 1" );
119 m.exec( QCursor::pos() );
120}
121
diff --git a/noncore/multimedia/camera/mainwindow.h b/noncore/multimedia/camera/mainwindow.h
index cc12840..df66204 100644
--- a/noncore/multimedia/camera/mainwindow.h
+++ b/noncore/multimedia/camera/mainwindow.h
@@ -37,12 +37,14 @@ class CameraMainWindow: public QMainWindow
37 virtual ~CameraMainWindow(); 37 virtual ~CameraMainWindow();
38 38
39 public slots: 39 public slots:
40 void changeZoom( int ); 40 void changeZoom( int );
41 void systemMessage( const QCString&, const QByteArray& ); 41 void systemMessage( const QCString&, const QByteArray& );
42 42
43 void showContextMenu();
44
43 protected: 45 protected:
44 46
45 private: 47 private:
46 PreviewWidget* preview; 48 PreviewWidget* preview;
47 int _rotation; 49 int _rotation;
48 QCopChannel* _sysChannel; 50 QCopChannel* _sysChannel;
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp
index 51771a5..b37ae8c 100644
--- a/noncore/multimedia/camera/zcameraio.cpp
+++ b/noncore/multimedia/camera/zcameraio.cpp
@@ -72,38 +72,38 @@ ZCameraIO::~ZCameraIO()
72 setReadMode( 0 ); 72 setReadMode( 0 );
73 ::close( _driver ); 73 ::close( _driver );
74 } 74 }
75} 75}
76 76
77 77
78inline bool ZCameraIO::isOpen() const 78bool ZCameraIO::isOpen() const
79{ 79{
80 return _driver != -1; 80 return _driver != -1;
81} 81}
82 82
83 83
84inline bool ZCameraIO::isShutterPressed() 84bool ZCameraIO::isShutterPressed()
85{ 85{
86 return _status[0] == 'S'; 86 return _status[0] == 'S';
87 clearShutterLatch(); 87 clearShutterLatch();
88} 88}
89 89
90 90
91inline bool ZCameraIO::isFinderReversed() const 91bool ZCameraIO::isFinderReversed() const
92{ 92{
93 return _status[1] == 'M'; 93 return _status[1] == 'M';
94} 94}
95 95
96 96
97inline bool ZCameraIO::isCapturing() const 97bool ZCameraIO::isCapturing() const
98{ 98{
99 return _status[2] == 'C'; 99 return _status[2] == 'C';
100} 100}
101 101
102 102
103inline bool ZCameraIO::isAvailable() const 103bool ZCameraIO::isAvailable() const
104{ 104{
105 return _status[3] == 'A'; 105 return _status[3] == 'A';
106} 106}
107 107
108 108
109bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) 109bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot )
diff --git a/noncore/multimedia/camera/zcameraio.h b/noncore/multimedia/camera/zcameraio.h
index bc4926b..9d4b1d7 100644
--- a/noncore/multimedia/camera/zcameraio.h
+++ b/noncore/multimedia/camera/zcameraio.h
@@ -35,14 +35,14 @@ class ZCameraIO
35 void setReadMode( int = IMAGE | XFLIP | YFLIP ); 35 void setReadMode( int = IMAGE | XFLIP | YFLIP );
36 36
37 bool isShutterPressed(); // not const, because it calls clearShutterLatch 37 bool isShutterPressed(); // not const, because it calls clearShutterLatch
38 bool isAvailable() const; 38 bool isAvailable() const;
39 bool isCapturing() const; 39 bool isCapturing() const;
40 bool isFinderReversed() const; 40 bool isFinderReversed() const;
41
42 bool isOpen() const; 41 bool isOpen() const;
42
43 bool snapshot( QImage* ); 43 bool snapshot( QImage* );
44 bool snapshot( unsigned char* ); 44 bool snapshot( unsigned char* );
45 static ZCameraIO* instance(); 45 static ZCameraIO* instance();
46 46
47 protected: 47 protected:
48 ZCameraIO(); 48 ZCameraIO();