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

66 lines
1.7 KiB
C++
Raw Normal View History

2014-07-07 00:19:45 +08:00
/*
Copyright (C) 2014 by Project Tox <https://tox.im>
This file is part of qTox, a Qt-based graphical interface for Tox.
This program is libre software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the COPYING file for more details.
*/
2014-06-29 04:24:26 +08:00
#include "selfcamview.h"
#include <QCloseEvent>
#include <QShowEvent>
#include "widget.h"
2014-08-29 19:40:37 +08:00
using namespace cv;
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()
{
2014-08-29 20:20:32 +08:00
displayLabel->setPixmap(QPixmap::fromImage(cam->getLastImage()));
}