+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);
+}
+
+void KdenliveSettingsDialog::slotManageEncodingProfile()
+{
+ int type = 0;
+ if (currentPage() == m_page4) {
+ type = m_configCapture.tabWidget->currentIndex();
+ }
+ QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(type);
+ d->exec();
+ delete d;
+ loadEncodingProfiles();
+}
+
+void KdenliveSettingsDialog::loadEncodingProfiles()
+{
+ KConfig conf("encodingprofiles.rc", KConfig::CascadeConfig, "appdata");
+
+ // Load v4l profiles
+ m_configCapture.kcfg_v4l_profile->blockSignals(true);
+ QString currentItem = m_configCapture.kcfg_v4l_profile->currentText();
+ m_configCapture.kcfg_v4l_profile->clear();
+ KConfigGroup group(&conf, "video4linux");
+ QMap< QString, QString > values = group.entryMap();
+ QMapIterator<QString, QString> i(values);
+ while (i.hasNext()) {
+ i.next();
+ if (!i.key().isEmpty()) m_configCapture.kcfg_v4l_profile->addItem(i.key(), i.value());
+ }
+ m_configCapture.kcfg_v4l_profile->blockSignals(false);
+ if (!currentItem.isEmpty()) m_configCapture.kcfg_v4l_profile->setCurrentIndex(m_configCapture.kcfg_v4l_profile->findText(currentItem));
+
+ // Load Screen Grab profiles
+ m_configCapture.kcfg_grab_profile->blockSignals(true);
+ currentItem = m_configCapture.kcfg_grab_profile->currentText();
+ m_configCapture.kcfg_grab_profile->clear();
+ KConfigGroup group2(&conf, "screengrab");
+ values = group2.entryMap();
+ QMapIterator<QString, QString> j(values);
+ while (j.hasNext()) {
+ j.next();
+ if (!j.key().isEmpty()) m_configCapture.kcfg_grab_profile->addItem(j.key(), j.value());
+ }
+ m_configCapture.kcfg_grab_profile->blockSignals(false);
+ if (!currentItem.isEmpty()) m_configCapture.kcfg_grab_profile->setCurrentIndex(m_configCapture.kcfg_grab_profile->findText(currentItem));
+
+ // Load Decklink profiles
+ m_configCapture.kcfg_decklink_profile->blockSignals(true);
+ currentItem = m_configCapture.kcfg_decklink_profile->currentText();
+ m_configCapture.kcfg_decklink_profile->clear();
+ KConfigGroup group3(&conf, "decklink");
+ values = group3.entryMap();
+ QMapIterator<QString, QString> k(values);
+ while (k.hasNext()) {
+ k.next();
+ if (!k.key().isEmpty()) m_configCapture.kcfg_decklink_profile->addItem(k.key(), k.value());
+ }
+ m_configCapture.kcfg_decklink_profile->blockSignals(false);
+ if (!currentItem.isEmpty()) m_configCapture.kcfg_decklink_profile->setCurrentIndex(m_configCapture.kcfg_decklink_profile->findText(currentItem));
+
+ // Load Proxy profiles
+ m_configProject.kcfg_proxy_profile->blockSignals(true);
+ currentItem = m_configProject.kcfg_proxy_profile->currentText();
+ m_configProject.kcfg_proxy_profile->clear();
+ KConfigGroup group4(&conf, "proxy");
+ values = group4.entryMap();
+ QMapIterator<QString, QString> l(values);
+ while (l.hasNext()) {
+ l.next();
+ if (!l.key().isEmpty()) m_configProject.kcfg_proxy_profile->addItem(l.key(), l.value());
+ }
+ if (!currentItem.isEmpty()) m_configProject.kcfg_proxy_profile->setCurrentIndex(m_configProject.kcfg_proxy_profile->findText(currentItem));
+ m_configProject.kcfg_proxy_profile->blockSignals(false);
+ slotUpdateProxyProfile();
+
+}
+
+void KdenliveSettingsDialog::slotUpdateDecklinkProfile(int ix)
+{
+ if (ix == -1) ix = KdenliveSettings::decklink_profile();
+ else ix = m_configCapture.kcfg_decklink_profile->currentIndex();
+ QString data = m_configCapture.kcfg_decklink_profile->itemData(ix).toString();
+ if (data.isEmpty()) return;
+ m_configCapture.decklink_parameters->setPlainText(data.section(';', 0, 0));
+ //
+}
+
+void KdenliveSettingsDialog::slotUpdateV4lProfile(int ix)
+{
+ if (ix == -1) ix = KdenliveSettings::v4l_profile();
+ else ix = m_configCapture.kcfg_v4l_profile->currentIndex();
+ QString data = m_configCapture.kcfg_v4l_profile->itemData(ix).toString();
+ if (data.isEmpty()) return;
+ m_configCapture.v4l_parameters->setPlainText(data.section(';', 0, 0));
+ //
+}
+
+void KdenliveSettingsDialog::slotUpdateGrabProfile(int ix)
+{
+ if (ix == -1) ix = KdenliveSettings::grab_profile();
+ else ix = m_configCapture.kcfg_grab_profile->currentIndex();
+ QString data = m_configCapture.kcfg_grab_profile->itemData(ix).toString();
+ if (data.isEmpty()) return;
+ m_configCapture.grab_parameters->setPlainText(data.section(';', 0, 0));
+ //
+}
+
+void KdenliveSettingsDialog::slotUpdateProxyProfile(int ix)
+{
+ if (ix == -1) ix = KdenliveSettings::v4l_profile();
+ else ix = m_configProject.kcfg_proxy_profile->currentIndex();
+ QString data = m_configProject.kcfg_proxy_profile->itemData(ix).toString();
+ if (data.isEmpty()) return;
+ m_configProject.proxyparams->setPlainText(data.section(';', 0, 0));
+ //
+}