Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / protocols / testbed / ui / testbedwebcamdialog.cpp
blobd26703b32e749e2921fc8c95b73a172a9bf60d81
1 /*
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 *************************************************************************
8 * *
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. *
13 * *
14 *************************************************************************
17 #include "testbedwebcamdialog.h"
18 #include <webcamwidget.h>
19 #include "avdevice/videodevicepool.h"
21 #include <QObject>
22 #include <QWidget>
23 #include <QPixmap>
24 #include <QVBoxLayout>
26 #include <kdebug.h>
27 #include <klocale.h>
29 TestbedWebcamDialog::TestbedWebcamDialog( const QString &contactId, QWidget * parent )
30 : KDialog( 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);
44 setMainWidget(page);
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 );
53 show();
55 #ifndef Q_OS_WIN
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";
63 #endif
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);
70 qtimer.start(0);
73 TestbedWebcamDialog::~ TestbedWebcamDialog( )
75 #ifndef Q_OS_WIN
76 mVideoDevicePool->stopCapturing();
77 mVideoDevicePool->close();
78 #endif
81 void TestbedWebcamDialog::slotUpdateImage()
83 #ifndef Q_OS_WIN
84 mVideoDevicePool->getFrame();
85 kDebug() << "Getting image";
86 mVideoDevicePool->getImage(&mImage);
87 mImageContainer->updatePixmap( QPixmap::fromImage( mImage.mirrored (mVideoDevicePool->getImageAsMirror(), false) ) );
88 #endif
92 #include "testbedwebcamdialog.moc"