26
#include "../lib/videodevice.h"
27
#include "../lib/videocodecmodel.h"
28
#include "../lib/videomodel.h"
26
#include "../lib/video/videodevice.h"
27
#include "../lib/video/videocodecmodel.h"
28
#include "../lib/video/videomodel.h"
29
#include "../lib/video/videoresolution.h"
30
#include "../lib/video/videochannel.h"
31
#include "../lib/video/videorate.h"
32
#include "../lib/video/videodevicemodel.h"
31
35
DlgVideo::DlgVideo(KConfigDialog* parent)
32
: QWidget(parent),m_pDevice(nullptr),m_IsChanged(false),m_IsLoading(true)
36
: QWidget(parent),m_pDevice(nullptr),m_IsChanged(false),m_IsLoading(true),m_pChannel(nullptr),m_pResolution(nullptr)
36
const QList<VideoDevice*> devices = VideoDevice::deviceList();
37
foreach(VideoDevice* dev,devices) {
38
m_pDeviceCB->addItem(dev->deviceId());
41
connect(m_pDeviceCB ,SIGNAL(currentIndexChanged(QString)), this , SLOT(loadDevice(QString)) );
42
connect(m_pChannelCB ,SIGNAL(currentIndexChanged(QString)), this , SLOT(loadResolution(QString)));
43
connect(m_pResolutionCB,SIGNAL(currentIndexChanged(QString)), this , SLOT(loadRate(QString)) );
44
connect(m_pRateCB ,SIGNAL(currentIndexChanged(QString)), this , SLOT(changeRate(QString)) );
45
42
connect(m_pPreviewPB ,SIGNAL(clicked()) , this , SLOT(startStopPreview()) );
46
43
connect( this ,SIGNAL(updateButtons()) , parent , SLOT(updateButtons()) );
49
m_pConfGB->setEnabled(devices.size());
52
loadDevice(devices[0]->deviceId());
44
connect(VideoModel::instance(),SIGNAL(previewStateChanged(bool)),this,SLOT(startStopPreview(bool)) );
46
connect(VideoModel::instance(),SIGNAL(previewStarted(VideoRenderer*)),m_pPreviewGV,SLOT(addRenderer(VideoRenderer*)) );
47
connect(VideoModel::instance(),SIGNAL(previewStopped(VideoRenderer*)),m_pPreviewGV,SLOT(removeRenderer(VideoRenderer*)));
54
50
if (VideoModel::instance()->isPreviewing()) {
55
51
m_pPreviewPB->setText(i18n("Stop preview"));
53
// m_pVideoSettings->slotReloadDevices();
57
54
m_IsChanged = false;
58
55
m_IsLoading = false;
70
67
return m_IsChanged;
73
///Load the device list
74
void DlgVideo::loadDevice(QString device)
80
m_pDevice = VideoDevice::getDevice(device);
81
const QString curChan = m_pDevice->channel();
83
m_pChannelCB->clear();
84
foreach(const VideoChannel& channel,m_pDevice->channelList()) {
85
m_pChannelCB->addItem(channel);
86
if (channel == curChan)
87
m_pChannelCB->setCurrentIndex(m_pChannelCB->count()-1);
93
void DlgVideo::loadResolution(QString channel)
99
Resolution current = m_pDevice->resolution();
100
m_pResolutionCB->clear();
101
foreach(const Resolution& res,m_pDevice->resolutionList(channel)) {
102
m_pResolutionCB->addItem(res.toString());
103
if (current == res) {
104
m_pResolutionCB->setCurrentIndex(m_pResolutionCB->count()-1);
107
m_pDevice->setChannel(channel);
111
void DlgVideo::loadRate(QString resolution)
115
emit updateButtons();
118
const QString rate = m_pDevice->rate();
119
foreach(const QString& r,m_pDevice->rateList(m_pChannelCB->currentText(),resolution)) {
120
m_pRateCB->addItem(r);
122
m_pRateCB->setCurrentIndex(m_pRateCB->count()-1);
124
m_pDevice->setResolution(resolution);
128
void DlgVideo::changeRate(QString rate)
132
emit updateButtons();
134
m_pDevice->setRate(rate);
137
70
///Start or stop preview
138
71
void DlgVideo::startStopPreview()
140
73
//TODO check if the preview is already running
141
74
if (VideoModel::instance()->isPreviewing()) {
75
VideoModel::instance()->stopPreview();
78
VideoModel::instance()->startPreview();
82
void DlgVideo::startStopPreview(bool state)
85
m_pPreviewPB->setText(i18n("Stop preview"));
142
88
m_pPreviewPB->setText(i18n("Start preview"));
92
void DlgVideo::updateWidgets ()
94
//The models should take care of that
97
void DlgVideo::updateSettings()
99
VideoDeviceModel::instance()->setActive(m_pVideoSettings->device());
103
void DlgVideo::slotReloadPreview()
105
if (VideoModel::instance()->isPreviewing()) {
143
106
VideoModel::instance()->stopPreview();
146
m_pPreviewPB->setText(i18n("Stop preview"));
147
107
VideoModel::instance()->startPreview();
112
void DlgVideo::slotSettingsChanged()
115
emit updateButtons();