1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00
qTox/widget/selfcamview.cpp

52 lines
1.2 KiB
C++
Raw Normal View History

2014-06-29 04:24:26 +08:00
#include "selfcamview.h"
#include <QActionGroup>
#include <QMessageBox>
#include <QCloseEvent>
#include <QShowEvent>
#include <QVideoFrame>
2014-06-29 04:24:26 +08:00
#include "videosurface.h"
#include "widget.h"
SelfCamView::SelfCamView(Camera* Cam, QWidget* parent)
: QWidget(parent), displayLabel{new QLabel},
mainLayout{new QHBoxLayout()}, cam(Cam)
2014-06-29 04:24:26 +08:00
{
setLayout(mainLayout);
setWindowTitle(SelfCamView::tr("Tox video test","Title of the window to test the video/webcam"));
2014-06-29 04:24:26 +08:00
setMinimumSize(320,240);
2014-06-30 20:49:42 +08:00
updateDisplayTimer.setInterval(5);
updateDisplayTimer.setSingleShot(false);
2014-06-29 04:24:26 +08:00
displayLabel->setScaledContents(true);
2014-06-29 04:24:26 +08:00
mainLayout->addWidget(displayLabel);
2014-06-29 04:24:26 +08:00
connect(&updateDisplayTimer, SIGNAL(timeout()), this, SLOT(updateDisplay()));
2014-06-29 04:24:26 +08:00
}
SelfCamView::~SelfCamView()
{
}
void SelfCamView::closeEvent(QCloseEvent* event)
{
cam->unsuscribe();
updateDisplayTimer.stop();
2014-06-29 04:24:26 +08:00
event->accept();
}
void SelfCamView::showEvent(QShowEvent* event)
{
cam->suscribe();
updateDisplayTimer.start();
2014-06-29 04:24:26 +08:00
event->accept();
}
void SelfCamView::updateDisplay()
{
displayLabel->setPixmap(QPixmap::fromImage(cam->getLastImage()));
}