author | mickeyl <mickeyl> | 2003-04-12 15:02:32 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-12 15:02:32 (UTC) |
commit | 2cc909c36a779d1041a3382939f8ad41d84b0fc5 (patch) (side-by-side diff) | |
tree | 42c95673d72f7ecb7a8f4acbb0f517dd75ecc167 /noncore | |
parent | 11861d35730cee70920aa6797ba12263bbcce081 (diff) | |
download | opie-2cc909c36a779d1041a3382939f8ad41d84b0fc5.zip opie-2cc909c36a779d1041a3382939f8ad41d84b0fc5.tar.gz opie-2cc909c36a779d1041a3382939f8ad41d84b0fc5.tar.bz2 |
- 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
-rw-r--r-- | noncore/multimedia/camera/.cvsignore | 4 | ||||
-rw-r--r-- | noncore/multimedia/camera/camera.pro | 2 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.cpp | 41 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.h | 7 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindowbase.ui | 246 | ||||
-rw-r--r-- | noncore/multimedia/camera/previewwidget.cpp | 21 | ||||
-rw-r--r-- | noncore/multimedia/camera/previewwidget.h | 4 | ||||
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 24 |
8 files changed, 87 insertions, 262 deletions
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 @@ -17,5 +17,5 @@ INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -INTERFACES = mainwindowbase.ui +INTERFACES = TARGET = opiecam 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 @@ -15,15 +15,19 @@ #include "mainwindow.h" -#include "mainwindowbase.h" +#include "previewwidget.h" #include "zcameraio.h" #include <qvbox.h> #include <qcombobox.h> +#include <qdatastream.h> #include <qpushbutton.h> #include <qlabel.h> #include <qdirectpainter_qws.h> #include <qpe/resource.h> +#include <qpe/qcopenvelope_qws.h> #include <opie/ofiledialog.h> +#include <opie2/odebug.h> + #include <assert.h> @@ -31,10 +35,16 @@ CameraMainWindow::CameraMainWindow( QWidget * parent, const char * name, WFlags :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) ) ); }; @@ -45,4 +55,23 @@ 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 ) { 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 @@ -26,4 +26,6 @@ class QToolButton; class QLabel; class MainWindowBase; +class QCopChannel; +class PreviewWidget; class CameraMainWindow: public QMainWindow @@ -37,9 +39,12 @@ 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; }; 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 @@ -<!DOCTYPE UI><UI> -<class>MainWindowBase</class> -<widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>MainWindowBase</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>242</width> - <height>329</height> - </rect> - </property> - <property stdset="1"> - <name>caption</name> - <string>Form1</string> - </property> - <property> - <name>layoutMargin</name> - </property> - <property> - <name>layoutSpacing</name> - </property> - <grid> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>2</number> - </property> - <widget row="1" column="0" > - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout1</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Reso:</string> - </property> - </widget> - <widget> - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>240x160</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>480x320</string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>resolution</cstring> - </property> - </widget> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>TextLabel2</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Zoom:</string> - </property> - </widget> - <widget> - <class>QComboBox</class> - <item> - <property> - <name>text</name> - <string>Half</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Full</string> - </property> - </item> - <item> - <property> - <name>text</name> - <string>Double</string> - </property> - </item> - <property stdset="1"> - <name>name</name> - <cstring>zoom</cstring> - </property> - </widget> - </hbox> - </widget> - <widget row="2" column="0" > - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout2</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <spacer> - <property> - <name>name</name> - <cstring>Spacer1</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <widget> - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>PushButton1</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Take Photo</string> - </property> - <property stdset="1"> - <name>default</name> - <bool>true</bool> - </property> - </widget> - <spacer> - <property> - <name>name</name> - <cstring>Spacer2</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Horizontal</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </hbox> - </widget> - <spacer row="3" column="0" > - <property> - <name>name</name> - <cstring>Spacer3</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <widget row="0" column="0" > - <class>PreviewWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>preview</cstring> - </property> - </widget> - </grid> -</widget> -<customwidgets> - <customwidget> - <class>PreviewWidget</class> - <header location="local">previewwidget.h</header> - <sizehint> - <width>240</width> - <height>160</height> - </sizehint> - <container>0</container> - <sizepolicy> - <hordata>0</hordata> - <verdata>0</verdata> - </sizepolicy> - <pixmap>image0</pixmap> - </customwidget> -</customwidgets> -<images> - <image> - <name>image0</name> - <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1ddec44f503c0ae2a154410f53d0ed20e2bf6bdb656dd6861dd23d9a66591b0587fd1654235ebded6f0edcd53e419d87ae7b1f4f9b8f906d0bfe012317426a70b07bdc2f3ec77f8ed6b89559061a0343d06a124cc105596482585094bc0ae599b04646c9018926491b2205e140c485cace25755c175d0a967b622ff900b8cc9c7d29af594ea722d589167f813aa852ba07d94b9dce296e883fe7bb163f23896753</data> - </image> -</images> -</UI> 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 @@ -17,11 +17,18 @@ #include "zcameraio.h" +#include <opie2/odebug.h> + 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 ); }; @@ -32,4 +39,16 @@ 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* ) { 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 @@ -21,4 +21,7 @@ #include <qpixmap.h> +class QTimerEvent; +class QResizeEvent; + class PreviewWidget: public QLabel { @@ -31,4 +34,5 @@ class PreviewWidget: public QLabel protected: virtual void timerEvent( QTimerEvent* ); + virtual void resizeEvent( QResizeEvent* ); private: 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 @@ -109,4 +109,5 @@ 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 ); @@ -174,6 +175,19 @@ 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; @@ -181,9 +195,9 @@ bool ZCameraIO::snapshot( QImage* image ) 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; |