~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/conf/dlgvideo.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <KLocale>
24
24
 
25
25
//SFLPhone
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"
29
33
 
30
34
///Constructor
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)
33
37
{
34
38
   setupUi(this);
35
 
   
36
 
   const QList<VideoDevice*> devices =  VideoDevice::deviceList();
37
 
   foreach(VideoDevice* dev,devices) {
38
 
      m_pDeviceCB->addItem(dev->deviceId());
39
 
   }
40
 
 
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))    );
 
39
 
 
40
   //updateWidgets();
 
41
 
45
42
   connect(m_pPreviewPB   ,SIGNAL(clicked())                   , this   , SLOT(startStopPreview())     );
46
43
   connect( this          ,SIGNAL(updateButtons())             , parent , SLOT(updateButtons())        );
47
 
 
48
 
 
49
 
   m_pConfGB->setEnabled(devices.size());
50
 
 
51
 
   if (devices.size())
52
 
      loadDevice(devices[0]->deviceId());
 
44
   connect(VideoModel::instance(),SIGNAL(previewStateChanged(bool)),this,SLOT(startStopPreview(bool))  );
 
45
 
 
46
   connect(VideoModel::instance(),SIGNAL(previewStarted(VideoRenderer*)),m_pPreviewGV,SLOT(addRenderer(VideoRenderer*))   );
 
47
   connect(VideoModel::instance(),SIGNAL(previewStopped(VideoRenderer*)),m_pPreviewGV,SLOT(removeRenderer(VideoRenderer*)));
 
48
 
53
49
 
54
50
   if (VideoModel::instance()->isPreviewing()) {
55
51
      m_pPreviewPB->setText(i18n("Stop preview"));
56
52
   }
 
53
//    m_pVideoSettings->slotReloadDevices();
57
54
   m_IsChanged = false;
58
55
   m_IsLoading = false;
59
56
}
70
67
   return m_IsChanged;
71
68
}
72
69
 
73
 
///Load the device list
74
 
void DlgVideo::loadDevice(QString device)
75
 
{
76
 
   if (!m_IsLoading) {
77
 
      m_IsChanged = true;
78
 
      emit updateButtons();
79
 
   }
80
 
   m_pDevice = VideoDevice::getDevice(device);
81
 
   const QString curChan = m_pDevice->channel();
82
 
   if (m_pDevice) {
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);
88
 
      }
89
 
   }
90
 
}
91
 
 
92
 
///Load resolution
93
 
void DlgVideo::loadResolution(QString channel)
94
 
{
95
 
   if (!m_IsLoading) {
96
 
      m_IsChanged = true;
97
 
      emit updateButtons();
98
 
   }
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);
105
 
      }
106
 
   }
107
 
   m_pDevice->setChannel(channel);
108
 
}
109
 
 
110
 
///Load the rate
111
 
void DlgVideo::loadRate(QString resolution)
112
 
{
113
 
   if (!m_IsLoading) {
114
 
      m_IsChanged = true;
115
 
      emit updateButtons();
116
 
   }
117
 
   m_pRateCB->clear();
118
 
   const QString rate = m_pDevice->rate();
119
 
   foreach(const QString& r,m_pDevice->rateList(m_pChannelCB->currentText(),resolution)) {
120
 
      m_pRateCB->addItem(r);
121
 
      if (r == rate)
122
 
         m_pRateCB->setCurrentIndex(m_pRateCB->count()-1);
123
 
   }
124
 
   m_pDevice->setResolution(resolution);
125
 
}
126
 
 
127
 
///Changes the rate
128
 
void DlgVideo::changeRate(QString rate)
129
 
{
130
 
   if (!m_IsLoading) {
131
 
      m_IsChanged = true;
132
 
      emit updateButtons();
133
 
   }
134
 
   m_pDevice->setRate(rate);
135
 
}
136
 
 
137
70
///Start or stop preview
138
71
void DlgVideo::startStopPreview()
139
72
{
140
73
   //TODO check if the preview is already running
141
74
   if (VideoModel::instance()->isPreviewing()) {
 
75
      VideoModel::instance()->stopPreview();
 
76
   }
 
77
   else {
 
78
      VideoModel::instance()->startPreview();
 
79
   }
 
80
}
 
81
 
 
82
void DlgVideo::startStopPreview(bool state)
 
83
{
 
84
   if (state) {
 
85
      m_pPreviewPB->setText(i18n("Stop preview"));
 
86
   }
 
87
   else {
142
88
      m_pPreviewPB->setText(i18n("Start preview"));
 
89
   }
 
90
}
 
91
 
 
92
void DlgVideo::updateWidgets ()
 
93
{
 
94
   //The models should take care of that
 
95
}
 
96
 
 
97
void DlgVideo::updateSettings()
 
98
{
 
99
   VideoDeviceModel::instance()->setActive(m_pVideoSettings->device());
 
100
   m_IsChanged = false;
 
101
}
 
102
 
 
103
void DlgVideo::slotReloadPreview()
 
104
{
 
105
   if (VideoModel::instance()->isPreviewing()) {
143
106
      VideoModel::instance()->stopPreview();
144
 
   }
145
 
   else {
146
 
      m_pPreviewPB->setText(i18n("Stop preview"));
147
107
      VideoModel::instance()->startPreview();
148
108
   }
149
109
}
 
110
 
 
111
 
 
112
void DlgVideo::slotSettingsChanged()
 
113
{
 
114
   m_IsChanged = true;
 
115
   emit updateButtons();
 
116
   slotReloadPreview();
 
117
}