From 2cc909c36a779d1041a3382939f8ad41d84b0fc5 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Sat, 12 Apr 2003 15:02:32 +0000 Subject: - make main layout a full preview window and think about configuring capturing parameters later...adding an on-demand-applet to the taskbar would be spiffy - portrait or landscape mode is now self-configuring thanks to life-rotation :-D --- (limited to 'noncore/multimedia') diff --git a/noncore/multimedia/camera/.cvsignore b/noncore/multimedia/camera/.cvsignore index d89e3af..737c5b2 100644 --- a/noncore/multimedia/camera/.cvsignore +++ b/noncore/multimedia/camera/.cvsignore @@ -1,5 +1,5 @@ +moc +obj config.in -mainwindowbase.h -mainwindowbase.cpp Makefile diff --git a/noncore/multimedia/camera/camera.pro b/noncore/multimedia/camera/camera.pro index 2d1faa3..16da0c9 100644 --- a/noncore/multimedia/camera/camera.pro +++ b/noncore/multimedia/camera/camera.pro @@ -16,7 +16,7 @@ SOURCES = zcameraio.cpp \ INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -INTERFACES = mainwindowbase.ui +INTERFACES = TARGET = opiecam include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp index 8578bce..7080e63 100644 --- a/noncore/multimedia/camera/mainwindow.cpp +++ b/noncore/multimedia/camera/mainwindow.cpp @@ -14,28 +14,38 @@ **********************************************************************/ #include "mainwindow.h" -#include "mainwindowbase.h" +#include "previewwidget.h" #include "zcameraio.h" #include #include +#include #include #include #include #include +#include #include +#include + #include CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags f ) :QMainWindow( parent, name, f ) { - mw = new MainWindowBase( this, "main widget" ); - ZCameraIO::instance()->setCaptureFrame( 240, 160, 256 ); - setCentralWidget( mw ); - mw->show(); + _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( mw->zoom, SIGNAL( activated( int ) ), this, SLOT( changeZoom(int) ) ); }; @@ -44,6 +54,25 @@ CameraMainWindow::~CameraMainWindow() } +void CameraMainWindow::systemMessage( const QCString& msg, const QByteArray& data ) +{ + QDataStream stream( data, IO_ReadOnly ); + odebug << "received system message: " << msg << oendl; + if ( msg == "setCurrentRotation(int)" ) + { + stream >> _rotation; + odebug << "received setCurrentRotation(" << _rotation << ")" << oendl; + + switch ( _rotation ) + { + case 270: preview->resize( QSize( 240, 288 ) ); break; + case 180: preview->resize( QSize( 320, 208 ) ); break; + default: assert( 0 ); // not yet handled + } + } +} + + void CameraMainWindow::changeZoom( int zoom ) { int z; diff --git a/noncore/multimedia/camera/mainwindow.h b/noncore/multimedia/camera/mainwindow.h index 7ccdcf8..cc12840 100644 --- a/noncore/multimedia/camera/mainwindow.h +++ b/noncore/multimedia/camera/mainwindow.h @@ -25,6 +25,8 @@ class QIconSet; class QToolButton; class QLabel; class MainWindowBase; +class QCopChannel; +class PreviewWidget; class CameraMainWindow: public QMainWindow { @@ -36,11 +38,14 @@ class CameraMainWindow: public QMainWindow public slots: void changeZoom( int ); + void systemMessage( const QCString&, const QByteArray& ); protected: private: - MainWindowBase* mw; + PreviewWidget* preview; + int _rotation; + QCopChannel* _sysChannel; }; #endif diff --git a/noncore/multimedia/camera/mainwindowbase.ui b/noncore/multimedia/camera/mainwindowbase.ui deleted file mode 100644 index 8da884a..0000000 --- a/noncore/multimedia/camera/mainwindowbase.ui +++ b/dev/null @@ -1,246 +0,0 @@ - -MainWindowBase - - QWidget - - name - MainWindowBase - - - geometry - - 0 - 0 - 242 - 329 - - - - caption - Form1 - - - layoutMargin - - - layoutSpacing - - - - margin - 0 - - - spacing - 2 - - - QLayoutWidget - - name - Layout1 - - - - margin - 0 - - - spacing - 6 - - - QLabel - - name - TextLabel1 - - - text - Reso: - - - - QComboBox - - - text - 240x160 - - - - - text - 480x320 - - - - name - resolution - - - - QLabel - - name - TextLabel2 - - - text - Zoom: - - - - QComboBox - - - text - Half - - - - - text - Full - - - - - text - Double - - - - name - zoom - - - - - - QLayoutWidget - - name - Layout2 - - - - margin - 0 - - - spacing - 6 - - - - name - Spacer1 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QPushButton - - name - PushButton1 - - - text - Take Photo - - - default - true - - - - - name - Spacer2 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - - - - name - Spacer3 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - PreviewWidget - - name - preview - - - - - - - PreviewWidget -
previewwidget.h
- - 240 - 160 - - 0 - - 0 - 0 - - image0 -
-
- - - image0 - 789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753 - - -
diff --git a/noncore/multimedia/camera/previewwidget.cpp b/noncore/multimedia/camera/previewwidget.cpp index bb84c00..cdeacf6 100644 --- a/noncore/multimedia/camera/previewwidget.cpp +++ b/noncore/multimedia/camera/previewwidget.cpp @@ -16,13 +16,20 @@ #include "previewwidget.h" #include "zcameraio.h" +#include + PreviewWidget::PreviewWidget( QWidget * parent, const char * name, WFlags f ) :QLabel( parent, name, f ) { - setFixedSize( QSize( 240, 160 ) ); + #ifndef QT_NO_DEBUG + setBackgroundColor( QColor( 255, 0, 0 ) ); + #else setBackgroundMode( NoBackground ); + #endif + startTimer( 150 ); + //startTimer( 2000 ); }; @@ -31,6 +38,18 @@ PreviewWidget::~PreviewWidget() } +void PreviewWidget::resizeEvent( QResizeEvent* e ) +{ + QLabel::resizeEvent( e ); + int w = e->size().width(); + int h = e->size().height(); + ZCameraIO::instance()->setCaptureFrame( e->size().width(), + e->size().height(), + 256, + w < h ); +} + + void PreviewWidget::timerEvent( QTimerEvent* ) { //QDirectPainter fb( this ); diff --git a/noncore/multimedia/camera/previewwidget.h b/noncore/multimedia/camera/previewwidget.h index c031d95..6b64768 100644 --- a/noncore/multimedia/camera/previewwidget.h +++ b/noncore/multimedia/camera/previewwidget.h @@ -20,6 +20,9 @@ #include #include +class QTimerEvent; +class QResizeEvent; + class PreviewWidget: public QLabel { Q_OBJECT @@ -30,6 +33,7 @@ class PreviewWidget: public QLabel protected: virtual void timerEvent( QTimerEvent* ); + virtual void resizeEvent( QResizeEvent* ); private: QPixmap p; diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp index 56b2e13..51771a5 100644 --- a/noncore/multimedia/camera/zcameraio.cpp +++ b/noncore/multimedia/camera/zcameraio.cpp @@ -108,6 +108,7 @@ inline bool ZCameraIO::isAvailable() const bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) { + odebug << "setCaptureFrame( " << width << ", " << height << ", " << zoom << ", " << rot << " )" << oendl; char b[100]; sprintf( b, "%c=%d,%d,%d,%d", rot ? 'R':'S', width, height, zoom, width*2 ); if ( write( b ) ) @@ -173,18 +174,31 @@ bool ZCameraIO::write( char* buf, int len ) bool ZCameraIO::snapshot( QImage* image ) { - setReadMode( IMAGE | XFLIP | YFLIP ); - char buf[76800]; + setReadMode( STATUS ); + + odebug << "finder reversed = " << isFinderReversed() << oendl; + odebug << "rotation = " << _rot << oendl; + + if ( _rot ) // Portrait + { + setReadMode( IMAGE | isFinderReversed() ? XFLIP | YFLIP : 0 ); + } + else // Landscape + { + setReadMode( IMAGE | XFLIP | YFLIP ); //isFinderReversed() ? 0 : XFLIP ); + } + + char buf[_readlen]; char* bp = buf; unsigned char* p; read( bp, _readlen ); - image->create( 240, 160, 16 ); - for ( int i = 0; i < 160; ++i ) + image->create( _width, _height, 16 ); + for ( int i = 0; i < _height; ++i ) { p = image->scanLine( i ); - for ( int j = 0; j < 240; j++ ) + for ( int j = 0; j < _width; j++ ) { *p = *bp; p++; -- cgit v0.9.0.2