2 Kopete Testbed Protocol
4 Copyright (c) 2006 by Cláudio da Silveira Pinheiro <taupter@gmail.com>
5 Kopete (c) 2002-2006 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
14 *************************************************************************
17 #include "testbedwebcamdialog.h"
18 #include <webcamwidget.h>
19 #include "avdevice/videodevicepool.h"
24 #include <QVBoxLayout>
29 TestbedWebcamDialog::TestbedWebcamDialog( const QString
&contactId
, QWidget
* parent
)
32 setCaption( i18n( "Webcam for %1", contactId
) );
33 setButtons( KDialog::Close
);
34 setDefaultButton( KDialog::Close
);
35 showButtonSeparator( true );
36 setAttribute( Qt::WA_DeleteOnClose
);
38 setInitialSize( QSize(320,290) );
40 setEscapeButton( KDialog::Close
);
41 // QObject::connect( this, SIGNAL( closeClicked() ), this, SIGNAL( closingWebcamDialog() ) );
43 QWidget
*page
= new QWidget(this);
46 QVBoxLayout
*topLayout
= new QVBoxLayout( page
);
47 mImageContainer
= new Kopete::WebcamWidget( page
);
48 mImageContainer
->setMinimumSize(320,240);
49 mImageContainer
->setText( i18n( "No webcam image received" ) );
50 mImageContainer
->setSizePolicy(QSizePolicy::Expanding
, QSizePolicy::Expanding
);
51 topLayout
->addWidget( mImageContainer
);
56 mVideoDevicePool
= Kopete::AV::VideoDevicePool::self();
57 mVideoDevicePool
->open();
58 mVideoDevicePool
->setSize(320, 240);
59 mVideoDevicePool
->startCapturing();
60 mVideoDevicePool
->getFrame();
61 mVideoDevicePool
->getImage(&mImage
);
62 kDebug() << "Just captured 1st frame";
65 mPixmap
=QPixmap::fromImage(mImage
);
66 if (!mPixmap
.isNull())
67 mImageContainer
->updatePixmap(mPixmap
);
68 connect(&qtimer
, SIGNAL(timeout()), this, SLOT(slotUpdateImage()) );
69 qtimer
.setSingleShot(false);
73 TestbedWebcamDialog::~ TestbedWebcamDialog( )
76 mVideoDevicePool
->stopCapturing();
77 mVideoDevicePool
->close();
81 void TestbedWebcamDialog::slotUpdateImage()
84 mVideoDevicePool
->getFrame();
85 kDebug() << "Getting image";
86 mVideoDevicePool
->getImage(&mImage
);
87 mImageContainer
->updatePixmap( QPixmap::fromImage( mImage
.mirrored (mVideoDevicePool
->getImageAsMirror(), false) ) );
92 #include "testbedwebcamdialog.moc"