+void KdenliveSettingsDialog::slotUpdatev4lDevice()
+{
+ QString device = m_configCapture.kcfg_detectedv4ldevices->itemData(m_configCapture.kcfg_detectedv4ldevices->currentIndex()).toString();
+ if (!device.isEmpty()) m_configCapture.kcfg_video4vdevice->setText(device);
+ QString info = m_configCapture.kcfg_detectedv4ldevices->itemData(m_configCapture.kcfg_detectedv4ldevices->currentIndex(), Qt::UserRole + 1).toString();
+
+ m_configCapture.kcfg_v4l_format->blockSignals(true);
+ m_configCapture.kcfg_v4l_format->clear();
+
+ QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
+ if (QFile::exists(vl4ProfilePath)) {
+ m_configCapture.kcfg_v4l_format->addItem(i18n("Current settings"));
+ }
+
+ QStringList pixelformats = info.split('>', QString::SkipEmptyParts);
+ QString itemSize;
+ QString pixelFormat;
+ QStringList itemRates;
+ for (int i = 0; i < pixelformats.count(); ++i) {
+ QString format = pixelformats.at(i).section(':', 0, 0);
+ QStringList sizes = pixelformats.at(i).split(':', QString::SkipEmptyParts);
+ pixelFormat = sizes.takeFirst();
+ for (int j = 0; j < sizes.count(); j++) {
+ itemSize = sizes.at(j).section('=', 0, 0);
+ itemRates = sizes.at(j).section('=', 1, 1).split(',', QString::SkipEmptyParts);
+ for (int k = 0; k < itemRates.count(); k++) {
+ m_configCapture.kcfg_v4l_format->addItem('[' + format + "] " + itemSize + " (" + itemRates.at(k) + ')', QStringList() << format << itemSize.section('x', 0, 0) << itemSize.section('x', 1, 1) << itemRates.at(k).section('/', 0, 0) << itemRates.at(k).section('/', 1, 1));
+ }
+ }
+ }
+ m_configCapture.kcfg_v4l_format->blockSignals(false);
+ slotUpdatev4lCaptureProfile();
+}
+
+void KdenliveSettingsDialog::slotUpdatev4lCaptureProfile()
+{
+ QStringList info = m_configCapture.kcfg_v4l_format->itemData(m_configCapture.kcfg_v4l_format->currentIndex(), Qt::UserRole).toStringList();
+ if (info.isEmpty()) {
+ // No auto info, display the current ones
+ loadCurrentV4lProfileInfo();
+ return;
+ }
+ m_configCapture.p_size->setText(info.at(1) + 'x' + info.at(2));
+ m_configCapture.p_fps->setText(info.at(3) + '/' + info.at(4));
+ m_configCapture.p_aspect->setText("1/1");
+ m_configCapture.p_display->setText(info.at(1) + '/' + info.at(2));
+ m_configCapture.p_colorspace->setText(ProfilesDialog::getColorspaceDescription(601));
+ m_configCapture.p_progressive->setText(i18n("Progressive"));
+
+ QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
+ if (!QFile::exists(vl4ProfilePath)) saveCurrentV4lProfile();
+}
+
+void KdenliveSettingsDialog::loadCurrentV4lProfileInfo()
+{
+ QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
+ MltVideoProfile prof;
+ if (!QFile::exists(vl4ProfilePath)) {
+ // No default formats found, build one
+ prof.width = 320;
+ prof.height = 200;
+ prof.frame_rate_num = 15;
+ prof.frame_rate_den = 1;
+ prof.display_aspect_num = 4;
+ prof.display_aspect_den = 3;
+ prof.sample_aspect_num = 1;
+ prof.sample_aspect_den = 1;
+ prof.progressive = 1;
+ prof.colorspace = 601;
+ ProfilesDialog::saveProfile(prof, vl4ProfilePath);
+ }
+ else prof = ProfilesDialog::getVideoProfile(vl4ProfilePath);
+ m_configCapture.p_size->setText(QString::number(prof.width) + 'x' + QString::number(prof.height));
+ m_configCapture.p_fps->setText(QString::number(prof.frame_rate_num) + '/' + QString::number(prof.frame_rate_den));
+ m_configCapture.p_aspect->setText(QString::number(prof.sample_aspect_num) + '/' + QString::number(prof.sample_aspect_den));
+ m_configCapture.p_display->setText(QString::number(prof.display_aspect_num) + '/' + QString::number(prof.display_aspect_den));
+ m_configCapture.p_colorspace->setText(ProfilesDialog::getColorspaceDescription(prof.colorspace));
+ if (prof.progressive) m_configCapture.p_progressive->setText(i18n("Progressive"));
+}
+
+void KdenliveSettingsDialog::saveCurrentV4lProfile()
+{
+ MltVideoProfile profile;
+ profile.description = "Video4Linux capture";
+ profile.colorspace = ProfilesDialog::getColorspaceFromDescription(m_configCapture.p_colorspace->text());
+ profile.width = m_configCapture.p_size->text().section('x', 0, 0).toInt();
+ profile.height = m_configCapture.p_size->text().section('x', 1, 1).toInt();
+ profile.sample_aspect_num = m_configCapture.p_aspect->text().section('/', 0, 0).toInt();
+ profile.sample_aspect_den = m_configCapture.p_aspect->text().section('/', 1, 1).toInt();
+ profile.display_aspect_num = m_configCapture.p_display->text().section('/', 0, 0).toInt();
+ profile.display_aspect_den = m_configCapture.p_display->text().section('/', 1, 1).toInt();
+ profile.frame_rate_num = m_configCapture.p_fps->text().section('/', 0, 0).toInt();
+ profile.frame_rate_den = m_configCapture.p_fps->text().section('/', 1, 1).toInt();
+ profile.progressive = m_configCapture.p_progressive->text() == i18n("Progressive");
+ QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
+ ProfilesDialog::saveProfile(profile, vl4ProfilePath);
+}