1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "kdenlivesettingsdialog.h"
21 #include "profilesdialog.h"
23 #include "v4l/v4lcapture.h"
25 #include "encodingprofilesdialog.h"
26 #include "kdenlivesettings.h"
29 #include <KStandardDirs>
31 #include <kopenwithdialog.h>
32 #include <KConfigDialogManager>
34 #include <KIO/NetAccess>
35 #include <kdeversion.h>
36 #include <KMessageBox>
40 #include <QTreeWidgetItem>
48 #include "jogaction.h"
49 #include "jogshuttleconfig.h"
50 #include <linux/input.h>
54 KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& mappable_actions, QWidget * parent) :
55 KConfigDialog(parent, "settings", KdenliveSettings::self()),
57 m_shuttleModified(false),
58 m_mappable_actions(mappable_actions)
60 KdenliveSettings::setV4l_format(0);
61 QWidget *p1 = new QWidget;
62 m_configMisc.setupUi(p1);
63 m_page1 = addPage(p1, i18n("Misc"), "configure");
65 // Hide multi tab option until Kdenlive really supports it
66 m_configMisc.kcfg_activatetabs->setVisible(false);
67 // Hide avformat-novalidate trick, causes crash (bug #2205 and #2206)
68 m_configMisc.kcfg_projectloading_avformatnovalidate->setVisible(false);
70 QWidget *p8 = new QWidget;
71 m_configProject.setupUi(p8);
72 m_page8 = addPage(p8, i18n("Project Defaults"), "document-new");
73 connect(m_configProject.kcfg_generateproxy, SIGNAL(toggled(bool)), m_configProject.kcfg_proxyminsize, SLOT(setEnabled(bool)));
74 m_configProject.kcfg_proxyminsize->setEnabled(KdenliveSettings::generateproxy());
75 connect(m_configProject.kcfg_generateimageproxy, SIGNAL(toggled(bool)), m_configProject.kcfg_proxyimageminsize, SLOT(setEnabled(bool)));
76 m_configProject.kcfg_proxyimageminsize->setEnabled(KdenliveSettings::generateimageproxy());
78 QWidget *p3 = new QWidget;
79 m_configTimeline.setupUi(p3);
80 m_page3 = addPage(p3, i18n("Timeline"), "video-display");
82 QWidget *p2 = new QWidget;
83 m_configEnv.setupUi(p2);
84 m_configEnv.mltpathurl->setMode(KFile::Directory);
85 m_configEnv.mltpathurl->lineEdit()->setObjectName("kcfg_mltpath");
86 m_configEnv.rendererpathurl->lineEdit()->setObjectName("kcfg_rendererpath");
87 m_configEnv.ffmpegurl->lineEdit()->setObjectName("kcfg_ffmpegpath");
88 m_configEnv.ffplayurl->lineEdit()->setObjectName("kcfg_ffplaypath");
89 m_configEnv.kcfg_mltthreads->setMaximum( QThread::idealThreadCount() < 4 ? QThread::idealThreadCount() : 3 );
90 m_configEnv.tmppathurl->setMode(KFile::Directory);
91 m_configEnv.tmppathurl->lineEdit()->setObjectName("kcfg_currenttmpfolder");
92 m_configEnv.projecturl->setMode(KFile::Directory);
93 m_configEnv.projecturl->lineEdit()->setObjectName("kcfg_defaultprojectfolder");
94 m_configEnv.capturefolderurl->setMode(KFile::Directory);
95 m_configEnv.capturefolderurl->lineEdit()->setObjectName("kcfg_capturefolder");
96 m_configEnv.capturefolderurl->setEnabled(!KdenliveSettings::capturetoprojectfolder());
97 connect(m_configEnv.kcfg_capturetoprojectfolder, SIGNAL(clicked()), this, SLOT(slotEnableCaptureFolder()));
98 m_page2 = addPage(p2, i18n("Environment"), "application-x-executable-script");
100 QWidget *p4 = new QWidget;
101 m_configCapture.setupUi(p4);
105 // Video 4 Linux device detection
106 for (int i = 0; i < 10; i++) {
107 QString path = "/dev/video" + QString::number(i);
108 if (QFile::exists(path)) {
109 QStringList deviceInfo = V4lCaptureHandler::getDeviceName(path);
110 if (!deviceInfo.isEmpty()) {
111 m_configCapture.kcfg_detectedv4ldevices->addItem(deviceInfo.at(0), path);
112 m_configCapture.kcfg_detectedv4ldevices->setItemData(m_configCapture.kcfg_detectedv4ldevices->count() - 1, deviceInfo.at(1), Qt::UserRole + 1);
116 connect(m_configCapture.kcfg_detectedv4ldevices, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdatev4lDevice()));
117 connect(m_configCapture.kcfg_v4l_format, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdatev4lCaptureProfile()));
118 connect(m_configCapture.config_v4l, SIGNAL(clicked()), this, SLOT(slotEditVideo4LinuxProfile()));
120 slotUpdatev4lDevice();
123 m_page4 = addPage(p4, i18n("Capture"), "media-record");
124 m_configCapture.tabWidget->setCurrentIndex(KdenliveSettings::defaultcapture());
126 m_configCapture.tabWidget->setEnabled(false);
127 m_configCapture.kcfg_defaultcapture->setEnabled(false);
128 m_configCapture.label->setText(i18n("Capture is not yet available on Mac OS X."));
131 QWidget *p5 = new QWidget;
132 m_configShuttle.setupUi(p5);
133 #ifdef USE_JOGSHUTTLE
134 connect(m_configShuttle.kcfg_enableshuttle, SIGNAL(stateChanged(int)), this, SLOT(slotCheckShuttle(int)));
135 connect(m_configShuttle.shuttledevicelist, SIGNAL(activated(int)), this, SLOT(slotUpdateShuttleDevice(int)));
136 slotCheckShuttle(KdenliveSettings::enableshuttle());
137 m_configShuttle.shuttledisabled->hide();
139 // Store the button pointers into an array for easier handling them in the other functions.
140 // TODO: impl enumerator or live with cut and paste :-)))
141 m_shuttle_buttons.push_back(m_configShuttle.shuttle1);
142 m_shuttle_buttons.push_back(m_configShuttle.shuttle2);
143 m_shuttle_buttons.push_back(m_configShuttle.shuttle3);
144 m_shuttle_buttons.push_back(m_configShuttle.shuttle4);
145 m_shuttle_buttons.push_back(m_configShuttle.shuttle5);
146 m_shuttle_buttons.push_back(m_configShuttle.shuttle6);
147 m_shuttle_buttons.push_back(m_configShuttle.shuttle7);
148 m_shuttle_buttons.push_back(m_configShuttle.shuttle8);
149 m_shuttle_buttons.push_back(m_configShuttle.shuttle9);
150 m_shuttle_buttons.push_back(m_configShuttle.shuttle10);
151 m_shuttle_buttons.push_back(m_configShuttle.shuttle11);
152 m_shuttle_buttons.push_back(m_configShuttle.shuttle12);
153 m_shuttle_buttons.push_back(m_configShuttle.shuttle13);
154 m_shuttle_buttons.push_back(m_configShuttle.shuttle14);
155 m_shuttle_buttons.push_back(m_configShuttle.shuttle15);
157 // populate the buttons with the current configuration. The items are sorted
158 // according to the user-selected language, so they do not appear in random order.
159 QList<QString> action_names = mappable_actions.keys();
162 // Here we need to compute the action_id -> index-in-action_names. We iterate over the
163 // action_names, as the sorting may depend on the user-language.
164 QStringList actions_map = JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons());
165 QMap<QString, int> action_pos;
166 foreach (const QString& action_id, actions_map) {
167 // This loop find out at what index is the string that would map to the action_id.
168 for (int i = 0; i < action_names.size(); i++) {
169 if (mappable_actions[action_names[i]] == action_id) {
170 action_pos[action_id] = i;
177 foreach (KComboBox* button, m_shuttle_buttons) {
178 button->addItems(action_names);
179 connect(button, SIGNAL(activated(int)), this, SLOT(slotShuttleModified()));
181 if (i < actions_map.size())
182 button->setCurrentIndex(action_pos[actions_map[i]]);
184 #else /* ! USE_JOGSHUTTLE */
185 m_configShuttle.kcfg_enableshuttle->hide();
186 m_configShuttle.kcfg_enableshuttle->setDisabled(true);
187 #endif /* USE_JOGSHUTTLE */
188 m_page5 = addPage(p5, i18n("JogShuttle"), "input-mouse");
190 QWidget *p6 = new QWidget;
191 m_configSdl.setupUi(p6);
192 m_configSdl.reload_blackmagic->setIcon(KIcon("view-refresh"));
193 connect(m_configSdl.reload_blackmagic, SIGNAL(clicked(bool)), this, SLOT(slotReloadBlackMagic()));
196 m_configSdl.kcfg_openglmonitors->setHidden(true);
199 m_page6 = addPage(p6, i18n("Playback"), "media-playback-start");
201 QWidget *p7 = new QWidget;
202 m_configTranscode.setupUi(p7);
203 m_page7 = addPage(p7, i18n("Transcode"), "edit-copy");
204 connect(m_configTranscode.button_add, SIGNAL(clicked()), this, SLOT(slotAddTranscode()));
205 connect(m_configTranscode.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteTranscode()));
206 connect(m_configTranscode.profiles_list, SIGNAL(itemChanged(QListWidgetItem *)), this, SLOT(slotDialogModified()));
207 connect(m_configTranscode.profiles_list, SIGNAL(currentRowChanged(int)), this, SLOT(slotSetTranscodeProfile()));
209 connect(m_configTranscode.profile_name, SIGNAL(textChanged(const QString &)), this, SLOT(slotEnableTranscodeUpdate()));
210 connect(m_configTranscode.profile_description, SIGNAL(textChanged(const QString &)), this, SLOT(slotEnableTranscodeUpdate()));
211 connect(m_configTranscode.profile_extension, SIGNAL(textChanged(const QString &)), this, SLOT(slotEnableTranscodeUpdate()));
212 connect(m_configTranscode.profile_parameters, SIGNAL(textChanged()), this, SLOT(slotEnableTranscodeUpdate()));
213 connect(m_configTranscode.profile_audioonly, SIGNAL(stateChanged(int)), this, SLOT(slotEnableTranscodeUpdate()));
215 connect(m_configTranscode.button_update, SIGNAL(pressed()), this, SLOT(slotUpdateTranscodingProfile()));
217 m_configTranscode.profile_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
219 connect(m_configEnv.kp_image, SIGNAL(clicked()), this, SLOT(slotEditImageApplication()));
220 connect(m_configEnv.kp_audio, SIGNAL(clicked()), this, SLOT(slotEditAudioApplication()));
221 connect(m_configEnv.kp_player, SIGNAL(clicked()), this, SLOT(slotEditVideoApplication()));
223 loadEncodingProfiles();
228 connect(m_configSdl.kcfg_audio_driver, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCheckAlsaDriver()));
230 connect(m_configProject.kcfg_profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
231 connect(m_configCapture.kcfg_grab_capture_type, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateGrabRegionStatus()));
233 slotUpdateGrabRegionStatus();
234 loadTranscodeProfiles();
237 //HACK: check dvgrab version, because only dvgrab >= 3.3 supports
238 // --timestamp option without bug
240 if (KdenliveSettings::dvgrab_path().isEmpty() || !QFile::exists(KdenliveSettings::dvgrab_path())) {
241 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
242 KdenliveSettings::setDvgrab_path(dvgrabpath);
246 m_configCapture.decklink_showprofileinfo->setIcon(KIcon("help-about"));
247 m_configCapture.decklink_manageprofile->setIcon(KIcon("configure"));
248 m_configCapture.decklink_parameters->setVisible(false);
249 m_configCapture.decklink_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
250 m_configCapture.decklink_parameters->setPlainText(KdenliveSettings::decklink_parameters());
251 connect(m_configCapture.decklink_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
252 connect(m_configCapture.kcfg_decklink_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDecklinkProfile()));
253 connect(m_configCapture.decklink_showprofileinfo, SIGNAL(clicked(bool)), m_configCapture.decklink_parameters, SLOT(setVisible(bool)));
256 m_configCapture.v4l_showprofileinfo->setIcon(KIcon("help-about"));
257 m_configCapture.v4l_manageprofile->setIcon(KIcon("configure"));
258 m_configCapture.v4l_parameters->setVisible(false);
259 m_configCapture.v4l_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
260 m_configCapture.v4l_parameters->setPlainText(KdenliveSettings::v4l_parameters());
261 connect(m_configCapture.v4l_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
262 connect(m_configCapture.kcfg_v4l_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateV4lProfile()));
263 connect(m_configCapture.v4l_showprofileinfo, SIGNAL(clicked(bool)), m_configCapture.v4l_parameters, SLOT(setVisible(bool)));
265 // screen grab profile
266 m_configCapture.grab_showprofileinfo->setIcon(KIcon("help-about"));
267 m_configCapture.grab_manageprofile->setIcon(KIcon("configure"));
268 m_configCapture.grab_parameters->setVisible(false);
269 m_configCapture.grab_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
270 m_configCapture.grab_parameters->setPlainText(KdenliveSettings::grab_parameters());
271 connect(m_configCapture.grab_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
272 connect(m_configCapture.kcfg_grab_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateGrabProfile()));
273 connect(m_configCapture.grab_showprofileinfo, SIGNAL(clicked(bool)), m_configCapture.grab_parameters, SLOT(setVisible(bool)));
275 // proxy profile stuff
276 m_configProject.proxy_showprofileinfo->setIcon(KIcon("help-about"));
277 m_configProject.proxy_manageprofile->setIcon(KIcon("configure"));
278 m_configProject.proxyparams->setVisible(false);
279 m_configProject.proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
280 m_configProject.proxyparams->setPlainText(KdenliveSettings::proxyparams());
281 connect(m_configProject.proxy_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
282 connect(m_configProject.proxy_showprofileinfo, SIGNAL(clicked(bool)), m_configProject.proxyparams, SLOT(setVisible(bool)));
283 connect(m_configProject.kcfg_proxy_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateProxyProfile()));
286 slotUpdateProxyProfile(-1);
287 slotUpdateV4lProfile(-1);
288 slotUpdateGrabProfile(-1);
289 slotUpdateDecklinkProfile(-1);
291 Render::getBlackMagicDeviceList(m_configCapture.kcfg_decklink_capturedevice);
292 if (!Render::getBlackMagicOutputDeviceList(m_configSdl.kcfg_blackmagic_output_device)) {
293 // No blackmagic card found
294 m_configSdl.kcfg_external_display->setEnabled(false);
297 double dvgrabVersion = 0;
298 if (!KdenliveSettings::dvgrab_path().isEmpty()) {
299 QProcess *versionCheck = new QProcess;
300 versionCheck->setProcessChannelMode(QProcess::MergedChannels);
301 versionCheck->start("dvgrab", QStringList() << "--version");
302 if (versionCheck->waitForFinished()) {
303 QString version = QString(versionCheck->readAll()).simplified();
304 if (version.contains(' ')) version = version.section(' ', -1);
305 dvgrabVersion = version.toDouble();
307 kDebug() << "// FOUND DVGRAB VERSION: " << dvgrabVersion;
310 if (dvgrabVersion < 3.3) {
311 KdenliveSettings::setFirewiretimestamp(false);
312 m_configCapture.kcfg_firewiretimestamp->setEnabled(false);
314 m_configCapture.dvgrab_info->setText(i18n("dvgrab version %1 at %2", dvgrabVersion, KdenliveSettings::dvgrab_path()));
315 } else m_configCapture.dvgrab_info->setText(i18n("<strong><em>dvgrab</em> utility not found, please install it for firewire capture</strong>"));
318 KdenliveSettingsDialog::~KdenliveSettingsDialog() {}
320 void KdenliveSettingsDialog::slotUpdateGrabRegionStatus()
322 m_configCapture.region_group->setHidden(m_configCapture.kcfg_grab_capture_type->currentIndex() != 1);
325 void KdenliveSettingsDialog::slotEnableCaptureFolder()
327 m_configEnv.capturefolderurl->setEnabled(!m_configEnv.kcfg_capturetoprojectfolder->isChecked());
330 void KdenliveSettingsDialog::checkProfile()
332 m_configProject.kcfg_profiles_list->clear();
333 QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
334 QMapIterator<QString, QString> i(profilesInfo);
335 while (i.hasNext()) {
337 m_configProject.kcfg_profiles_list->addItem(i.key(), i.value());
340 if (!KdenliveSettings::default_profile().isEmpty()) {
341 for (int i = 0; i < m_configProject.kcfg_profiles_list->count(); i++) {
342 if (m_configProject.kcfg_profiles_list->itemData(i).toString() == KdenliveSettings::default_profile()) {
343 m_configProject.kcfg_profiles_list->setCurrentIndex(i);
344 KdenliveSettings::setProfiles_list(i);
351 void KdenliveSettingsDialog::initDevices()
353 // Fill audio drivers
354 m_configSdl.kcfg_audio_driver->addItem(i18n("Automatic"), QString());
356 m_configSdl.kcfg_audio_driver->addItem(i18n("OSS"), "dsp");
357 m_configSdl.kcfg_audio_driver->addItem(i18n("ALSA"), "alsa");
358 m_configSdl.kcfg_audio_driver->addItem(i18n("PulseAudio"), "pulse");
359 m_configSdl.kcfg_audio_driver->addItem(i18n("OSS with DMA access"), "dma");
360 m_configSdl.kcfg_audio_driver->addItem(i18n("Esound daemon"), "esd");
361 m_configSdl.kcfg_audio_driver->addItem(i18n("ARTS daemon"), "artsc");
364 if (!KdenliveSettings::audiodrivername().isEmpty())
365 for (int i = 1; i < m_configSdl.kcfg_audio_driver->count(); i++) {
366 if (m_configSdl.kcfg_audio_driver->itemData(i).toString() == KdenliveSettings::audiodrivername()) {
367 m_configSdl.kcfg_audio_driver->setCurrentIndex(i);
368 KdenliveSettings::setAudio_driver((uint) i);
372 // Fill video drivers
373 m_configSdl.kcfg_video_driver->addItem(i18n("Automatic"), QString());
375 m_configSdl.kcfg_video_driver->addItem(i18n("XVideo"), "x11");
376 m_configSdl.kcfg_video_driver->addItem(i18n("X11"), "x11_noaccel");
377 m_configSdl.kcfg_video_driver->addItem(i18n("XFree86 DGA 2.0"), "dga");
378 m_configSdl.kcfg_video_driver->addItem(i18n("Nano X"), "nanox");
379 m_configSdl.kcfg_video_driver->addItem(i18n("Framebuffer console"), "fbcon");
380 m_configSdl.kcfg_video_driver->addItem(i18n("Direct FB"), "directfb");
381 m_configSdl.kcfg_video_driver->addItem(i18n("SVGAlib"), "svgalib");
382 m_configSdl.kcfg_video_driver->addItem(i18n("General graphics interface"), "ggi");
383 m_configSdl.kcfg_video_driver->addItem(i18n("Ascii art library"), "aalib");
386 // Fill the list of audio playback / recording devices
387 m_configSdl.kcfg_audio_device->addItem(i18n("Default"), QString());
388 m_configCapture.kcfg_v4l_alsadevice->addItem(i18n("Default"), "default");
389 if (!KStandardDirs::findExe("aplay").isEmpty()) {
390 m_readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
391 m_readProcess.setProgram("aplay", QStringList() << "-l");
392 connect(&m_readProcess, SIGNAL(readyReadStandardOutput()) , this, SLOT(slotReadAudioDevices()));
393 m_readProcess.execute(5000);
395 // If aplay is not installed on the system, parse the /proc/asound/pcm file
396 QFile file("/proc/asound/pcm");
397 if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
398 QTextStream stream(&file);
399 QString line = stream.readLine();
401 while (!line.isNull()) {
402 if (line.contains("playback")) {
403 deviceId = line.section(':', 0, 0);
404 m_configSdl.kcfg_audio_device->addItem(line.section(':', 1, 1), "plughw:" + QString::number(deviceId.section('-', 0, 0).toInt()) + ',' + QString::number(deviceId.section('-', 1, 1).toInt()));
406 if (line.contains("capture")) {
407 deviceId = line.section(':', 0, 0);
408 m_configCapture.kcfg_v4l_alsadevice->addItem(line.section(':', 1, 1).simplified(), "hw:" + QString::number(deviceId.section('-', 0, 0).toInt()) + ',' + QString::number(deviceId.section('-', 1, 1).toInt()));
410 line = stream.readLine();
413 } else kDebug()<<" / / / /CANNOT READ PCM";
416 // Add pulseaudio capture option
417 m_configCapture.kcfg_v4l_alsadevice->addItem(i18n("PulseAudio"), "pulse");
419 if (!KdenliveSettings::audiodevicename().isEmpty()) {
420 // Select correct alsa device
421 int ix = m_configSdl.kcfg_audio_device->findData(KdenliveSettings::audiodevicename());
422 m_configSdl.kcfg_audio_device->setCurrentIndex(ix);
423 KdenliveSettings::setAudio_device(ix);
426 if (!KdenliveSettings::v4l_alsadevicename().isEmpty()) {
427 // Select correct alsa device
428 int ix = m_configCapture.kcfg_v4l_alsadevice->findData(KdenliveSettings::v4l_alsadevicename());
429 m_configCapture.kcfg_v4l_alsadevice->setCurrentIndex(ix);
430 KdenliveSettings::setV4l_alsadevice(ix);
433 loadCurrentV4lProfileInfo();
437 void KdenliveSettingsDialog::slotReadAudioDevices()
439 QString result = QString(m_readProcess.readAllStandardOutput());
440 kDebug() << "// / / / / / READING APLAY: ";
442 QStringList lines = result.split('\n');
443 foreach(const QString & data, lines) {
444 //kDebug() << "// READING LINE: " << data;
445 if (!data.startsWith(' ') && data.count(':') > 1) {
446 QString card = data.section(':', 0, 0).section(' ', -1);
447 QString device = data.section(':', 1, 1).section(' ', -1);
448 m_configSdl.kcfg_audio_device->addItem(data.section(':', -1).simplified(), "plughw:" + card + ',' + device);
449 m_configCapture.kcfg_v4l_alsadevice->addItem(data.section(':', -1).simplified(), "hw:" + card + ',' + device);
454 void KdenliveSettingsDialog::showPage(int page, int option)
458 setCurrentPage(m_page1);
461 setCurrentPage(m_page2);
464 setCurrentPage(m_page3);
467 setCurrentPage(m_page4);
468 m_configCapture.tabWidget->setCurrentIndex(option);
471 setCurrentPage(m_page5);
474 setCurrentPage(m_page6);
477 setCurrentPage(m_page7);
480 setCurrentPage(m_page1);
484 void KdenliveSettingsDialog::slotEditVideoApplication()
486 KService::Ptr service;
487 QPointer<KOpenWithDialog> dlg = new KOpenWithDialog(KUrl::List(), i18n("Select default video player"), m_configEnv.kcfg_defaultplayerapp->text(), this);
488 if (dlg->exec() != QDialog::Accepted)
494 service = dlg->service();
495 m_configEnv.kcfg_defaultplayerapp->setText(service->exec());
499 void KdenliveSettingsDialog::slotEditAudioApplication()
501 KService::Ptr service;
502 QPointer<KOpenWithDialog> dlg = new KOpenWithDialog(KUrl::List(), i18n("Select default audio editor"), m_configEnv.kcfg_defaultaudioapp->text(), this);
503 if (dlg->exec() != QDialog::Accepted)
509 service = dlg->service();
510 m_configEnv.kcfg_defaultaudioapp->setText(service->exec());
514 void KdenliveSettingsDialog::slotEditImageApplication()
516 KService::Ptr service;
517 QPointer<KOpenWithDialog> dlg = new KOpenWithDialog(KUrl::List(), i18n("Select default image editor"), m_configEnv.kcfg_defaultimageapp->text(), this);
518 if (dlg->exec() != QDialog::Accepted)
523 service = dlg->service();
524 m_configEnv.kcfg_defaultimageapp->setText(service->exec());
528 void KdenliveSettingsDialog::slotCheckShuttle(int state)
530 #ifdef USE_JOGSHUTTLE
531 m_configShuttle.config_group->setEnabled(state);
532 if (m_configShuttle.shuttledevicelist->count() == 0) {
534 QString baseName = "/dev/input/event";
536 for (int i = 0; i < 30; i++) {
537 QString filename = baseName + QString::number(i);
538 kDebug() << "/// CHECKING device: " << filename;
540 char name[256] = "unknown";
541 fd = KDE_open((char *) filename.toUtf8().data(), O_RDONLY);
542 if (fd >= 0 && ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0) {
543 m_configShuttle.shuttledevicelist->addItem(name, filename);
547 if (KdenliveSettings::shuttledevice().isEmpty()) QTimer::singleShot(1500, this, SLOT(slotUpdateShuttleDevice()));
549 #endif /* USE_JOGSHUTTLE */
552 void KdenliveSettingsDialog::slotUpdateShuttleDevice(int ix)
554 #ifdef USE_JOGSHUTTLE
555 QString device = m_configShuttle.shuttledevicelist->itemData(ix).toString();
556 //KdenliveSettings::setShuttledevice(device);
557 m_configShuttle.kcfg_shuttledevice->setText(device);
558 #endif /* USE_JOGSHUTTLE */
561 void KdenliveSettingsDialog::updateWidgets()
563 // Revert widgets to last saved state (for example when user pressed "Cancel")
564 // kDebug() << "// // // KCONFIG Revert called";
565 #ifdef USE_JOGSHUTTLE
566 // revert jog shuttle device
567 if (m_configShuttle.shuttledevicelist->count() > 0) {
568 for (int i = 0; i < m_configShuttle.shuttledevicelist->count(); i++) {
569 if (m_configShuttle.shuttledevicelist->itemData(i) == KdenliveSettings::shuttledevice()) {
570 m_configShuttle.shuttledevicelist->setCurrentIndex(i);
576 // Revert jog shuttle buttons
577 QList<QString> action_names = m_mappable_actions.keys();
579 QStringList actions_map = JogShuttleConfig::actionMap(KdenliveSettings::shuttlebuttons());
580 QMap<QString, int> action_pos;
581 foreach (const QString& action_id, actions_map) {
582 // This loop find out at what index is the string that would map to the action_id.
583 for (int i = 0; i < action_names.size(); i++) {
584 if (m_mappable_actions[action_names[i]] == action_id) {
585 action_pos[action_id] = i;
591 foreach (KComboBox* button, m_shuttle_buttons) {
593 if (i < actions_map.size())
594 button->setCurrentIndex(action_pos[actions_map[i]]);
596 #endif /* USE_JOGSHUTTLE */
599 void KdenliveSettingsDialog::updateSettings()
601 // Save changes to settings (for example when user pressed "Apply" or "Ok")
602 // kDebug() << "// // // KCONFIG UPDATE called";
603 m_defaultProfile = m_configProject.kcfg_profiles_list->currentText();
604 KdenliveSettings::setDefault_profile(m_defaultPath);
606 bool resetProfile = false;
607 bool updateCapturePath = false;
609 /*if (m_configShuttle.shuttledevicelist->count() > 0) {
610 QString device = m_configShuttle.shuttledevicelist->itemData(m_configShuttle.shuttledevicelist->currentIndex()).toString();
611 if (device != KdenliveSettings::shuttledevice()) KdenliveSettings::setShuttledevice(device);
614 if (m_configEnv.kcfg_capturetoprojectfolder->isChecked() != KdenliveSettings::capturetoprojectfolder()) {
615 KdenliveSettings::setCapturetoprojectfolder(m_configEnv.kcfg_capturetoprojectfolder->isChecked());
616 updateCapturePath = true;
619 if (m_configEnv.capturefolderurl->url().path() != KdenliveSettings::capturefolder()) {
620 KdenliveSettings::setCapturefolder(m_configEnv.capturefolderurl->url().path());
621 updateCapturePath = true;
624 if (m_configCapture.kcfg_dvgrabfilename->text() != KdenliveSettings::dvgrabfilename()) {
625 KdenliveSettings::setDvgrabfilename(m_configCapture.kcfg_dvgrabfilename->text());
626 updateCapturePath = true;
629 if ((uint) m_configCapture.kcfg_firewireformat->currentIndex() != KdenliveSettings::firewireformat()) {
630 KdenliveSettings::setFirewireformat(m_configCapture.kcfg_firewireformat->currentIndex());
631 updateCapturePath = true;
634 if ((uint) m_configCapture.kcfg_v4l_format->currentIndex() != KdenliveSettings::v4l_format()) {
635 saveCurrentV4lProfile();
636 KdenliveSettings::setV4l_format(0);
639 // Check encoding profiles
641 QString data = m_configCapture.kcfg_v4l_profile->itemData(m_configCapture.kcfg_v4l_profile->currentIndex()).toString();
642 if (!data.isEmpty() && (data.section(';', 0, 0) != KdenliveSettings::v4l_parameters() || data.section(';', 1, 1) != KdenliveSettings::v4l_extension())) {
643 KdenliveSettings::setV4l_parameters(data.section(';', 0, 0));
644 KdenliveSettings::setV4l_extension(data.section(';', 1, 1));
647 data = m_configCapture.kcfg_grab_profile->itemData(m_configCapture.kcfg_grab_profile->currentIndex()).toString();
648 if (!data.isEmpty() && (data.section(';', 0, 0) != KdenliveSettings::grab_parameters() || data.section(';', 1, 1) != KdenliveSettings::grab_extension())) {
649 KdenliveSettings::setGrab_parameters(data.section(';', 0, 0));
650 KdenliveSettings::setGrab_extension(data.section(';', 1, 1));
654 data = m_configCapture.kcfg_decklink_profile->itemData(m_configCapture.kcfg_decklink_profile->currentIndex()).toString();
655 if (!data.isEmpty() && (data.section(';', 0, 0) != KdenliveSettings::decklink_parameters() || data.section(';', 1, 1) != KdenliveSettings::decklink_extension())) {
656 KdenliveSettings::setDecklink_parameters(data.section(';', 0, 0));
657 KdenliveSettings::setDecklink_extension(data.section(';', 1, 1));
660 data = m_configProject.kcfg_proxy_profile->itemData(m_configProject.kcfg_proxy_profile->currentIndex()).toString();
661 if (!data.isEmpty() && (data.section(';', 0, 0) != KdenliveSettings::proxyparams() || data.section(';', 1, 1) != KdenliveSettings::proxyextension())) {
662 KdenliveSettings::setProxyparams(data.section(';', 0, 0));
663 KdenliveSettings::setProxyextension(data.section(';', 1, 1));
667 if (updateCapturePath) emit updateCaptureFolder();
669 QString value = m_configCapture.kcfg_v4l_alsadevice->itemData(m_configCapture.kcfg_v4l_alsadevice->currentIndex()).toString();
670 if (value != KdenliveSettings::v4l_alsadevicename()) {
671 KdenliveSettings::setV4l_alsadevicename(value);
674 if (m_configSdl.kcfg_external_display->isChecked() != KdenliveSettings::external_display()) {
675 KdenliveSettings::setExternal_display(m_configSdl.kcfg_external_display->isChecked());
679 value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
680 if (value != KdenliveSettings::audiodrivername()) {
681 KdenliveSettings::setAudiodrivername(value);
685 if (value == "alsa") {
686 // Audio device setting is only valid for alsa driver
687 value = m_configSdl.kcfg_audio_device->itemData(m_configSdl.kcfg_audio_device->currentIndex()).toString();
688 if (value != KdenliveSettings::audiodevicename()) {
689 KdenliveSettings::setAudiodevicename(value);
692 } else if (KdenliveSettings::audiodevicename().isEmpty() == false) {
693 KdenliveSettings::setAudiodevicename(QString::null);
697 value = m_configSdl.kcfg_video_driver->itemData(m_configSdl.kcfg_video_driver->currentIndex()).toString();
698 if (value != KdenliveSettings::videodrivername()) {
699 KdenliveSettings::setVideodrivername(value);
703 if (m_configSdl.kcfg_window_background->color() != KdenliveSettings::window_background()) {
704 KdenliveSettings::setWindow_background(m_configSdl.kcfg_window_background->color());
708 if (m_configSdl.kcfg_volume->value() != KdenliveSettings::volume()) {
709 KdenliveSettings::setVolume(m_configSdl.kcfg_volume->value());
714 // The transcoding profiles were modified, save.
716 saveTranscodeProfiles();
719 #ifdef USE_JOGSHUTTLE
720 m_shuttleModified = false;
723 actions << "monitor_pause"; // the Job rest position action.
724 foreach (KComboBox* button, m_shuttle_buttons) {
725 actions << m_mappable_actions[button->currentText()];
727 QString maps = JogShuttleConfig::actionMap(actions);
728 //fprintf(stderr, "Shuttle config: %s\n", JogShuttleConfig::actionMap(actions).toAscii().constData());
729 if (KdenliveSettings::shuttlebuttons() != maps)
730 KdenliveSettings::setShuttlebuttons(maps);
733 KConfigDialog::settingsChangedSlot();
734 //KConfigDialog::updateSettings();
735 if (resetProfile) emit doResetProfile();
738 void KdenliveSettingsDialog::slotUpdateDisplay()
740 QString currentProfile = m_configProject.kcfg_profiles_list->itemData(m_configProject.kcfg_profiles_list->currentIndex()).toString();
741 QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
742 m_configProject.p_size->setText(values.value("width") + 'x' + values.value("height"));
743 m_configProject.p_fps->setText(values.value("frame_rate_num") + '/' + values.value("frame_rate_den"));
744 m_configProject.p_aspect->setText(values.value("sample_aspect_num") + '/' + values.value("sample_aspect_den"));
745 m_configProject.p_display->setText(values.value("display_aspect_num") + '/' + values.value("display_aspect_den"));
746 if (values.value("progressive").toInt() == 0)
747 m_configProject.p_progressive->setText(i18n("Interlaced"));
749 m_configProject.p_progressive->setText(i18n("Progressive"));
750 m_defaultProfile = m_configProject.kcfg_profiles_list->itemText(m_configProject.kcfg_profiles_list->currentIndex());
751 m_defaultPath = currentProfile;
754 void KdenliveSettingsDialog::slotCheckAlsaDriver()
756 QString value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
757 m_configSdl.kcfg_audio_device->setEnabled(value == "alsa");
760 void KdenliveSettingsDialog::loadTranscodeProfiles()
762 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc", KConfig::CascadeConfig);
763 KConfigGroup transConfig(config, "Transcoding");
765 m_configTranscode.profiles_list->blockSignals(true);
766 m_configTranscode.profiles_list->clear();
767 QMap< QString, QString > profiles = transConfig.entryMap();
768 QMapIterator<QString, QString> i(profiles);
769 while (i.hasNext()) {
771 QListWidgetItem *item = new QListWidgetItem(i.key());
772 QString data = i.value();
773 if (data.contains(';')) item->setToolTip(data.section(';', 1, 1));
774 item->setData(Qt::UserRole, data);
775 m_configTranscode.profiles_list->addItem(item);
776 //item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
778 m_configTranscode.profiles_list->blockSignals(false);
779 m_configTranscode.profiles_list->setCurrentRow(0);
782 void KdenliveSettingsDialog::saveTranscodeProfiles()
784 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc", KConfig::CascadeConfig);
785 //KSharedConfigPtr config = KGlobal::config();
786 KConfigGroup transConfig(config, "Transcoding");
788 transConfig.deleteGroup();
789 int max = m_configTranscode.profiles_list->count();
790 for (int i = 0; i < max; i++) {
791 QListWidgetItem *item = m_configTranscode.profiles_list->item(i);
792 transConfig.writeEntry(item->text(), item->data(Qt::UserRole).toString());
797 void KdenliveSettingsDialog::slotAddTranscode()
799 if (!m_configTranscode.profiles_list->findItems(m_configTranscode.profile_name->text(), Qt::MatchExactly).isEmpty()) {
800 KMessageBox::sorry(this, i18n("A profile with that name already exists"));
803 QListWidgetItem *item = new QListWidgetItem(m_configTranscode.profile_name->text());
804 QString data = m_configTranscode.profile_parameters->toPlainText();
805 data.append(" %1." + m_configTranscode.profile_extension->text());
807 if (!m_configTranscode.profile_description->text().isEmpty())
808 data.append(m_configTranscode.profile_description->text());
809 if (m_configTranscode.profile_audioonly->isChecked()) data.append(";audio");
810 item->setData(Qt::UserRole, data);
811 m_configTranscode.profiles_list->addItem(item);
812 m_configTranscode.profiles_list->setCurrentItem(item);
813 slotDialogModified();
816 void KdenliveSettingsDialog::slotUpdateTranscodingProfile()
818 QListWidgetItem *item = m_configTranscode.profiles_list->currentItem();
820 m_configTranscode.button_update->setEnabled(false);
821 item->setText(m_configTranscode.profile_name->text());
822 QString data = m_configTranscode.profile_parameters->toPlainText();
823 data.append(" %1." + m_configTranscode.profile_extension->text());
825 if (!m_configTranscode.profile_description->text().isEmpty())
826 data.append(m_configTranscode.profile_description->text());
827 if (m_configTranscode.profile_audioonly->isChecked()) data.append(";audio");
828 item->setData(Qt::UserRole, data);
829 slotDialogModified();
832 void KdenliveSettingsDialog::slotDeleteTranscode()
834 QListWidgetItem *item = m_configTranscode.profiles_list->currentItem();
835 if (item == NULL) return;
837 slotDialogModified();
840 void KdenliveSettingsDialog::slotEnableTranscodeUpdate()
842 if (!m_configTranscode.profile_box->isEnabled()) return;
844 if (m_configTranscode.profile_name->text().isEmpty() || m_configTranscode.profile_extension->text().isEmpty()) allow = false;
845 m_configTranscode.button_update->setEnabled(allow);
848 void KdenliveSettingsDialog::slotSetTranscodeProfile()
850 m_configTranscode.profile_box->setEnabled(false);
851 m_configTranscode.button_update->setEnabled(false);
852 m_configTranscode.profile_name->clear();
853 m_configTranscode.profile_description->clear();
854 m_configTranscode.profile_extension->clear();
855 m_configTranscode.profile_parameters->clear();
856 m_configTranscode.profile_audioonly->setChecked(false);
857 QListWidgetItem *item = m_configTranscode.profiles_list->currentItem();
861 m_configTranscode.profile_name->setText(item->text());
862 QString data = item->data(Qt::UserRole).toString();
863 if (data.contains(';')) {
864 m_configTranscode.profile_description->setText(data.section(';', 1, 1));
865 if (data.section(';', 2, 2) == "audio") m_configTranscode.profile_audioonly->setChecked(true);
866 data = data.section(';', 0, 0).simplified();
868 m_configTranscode.profile_extension->setText(data.section('.', -1));
869 m_configTranscode.profile_parameters->setPlainText(data.section(' ', 0, -2));
870 m_configTranscode.profile_box->setEnabled(true);
873 void KdenliveSettingsDialog::slotShuttleModified()
875 #ifdef USE_JOGSHUTTLE
877 actions << "monitor_pause"; // the Job rest position action.
878 foreach (KComboBox* button, m_shuttle_buttons) {
879 actions << m_mappable_actions[button->currentText()];
881 QString maps = JogShuttleConfig::actionMap(actions);
882 m_shuttleModified = KdenliveSettings::shuttlebuttons() != maps;
884 KConfigDialog::updateButtons();
887 void KdenliveSettingsDialog::slotDialogModified()
890 KConfigDialog::updateButtons();
894 bool KdenliveSettingsDialog::hasChanged()
896 if (m_modified || m_shuttleModified) return true;
897 return KConfigDialog::hasChanged();
900 void KdenliveSettingsDialog::slotUpdatev4lDevice()
902 QString device = m_configCapture.kcfg_detectedv4ldevices->itemData(m_configCapture.kcfg_detectedv4ldevices->currentIndex()).toString();
903 if (!device.isEmpty()) m_configCapture.kcfg_video4vdevice->setText(device);
904 QString info = m_configCapture.kcfg_detectedv4ldevices->itemData(m_configCapture.kcfg_detectedv4ldevices->currentIndex(), Qt::UserRole + 1).toString();
906 m_configCapture.kcfg_v4l_format->blockSignals(true);
907 m_configCapture.kcfg_v4l_format->clear();
909 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
910 if (QFile::exists(vl4ProfilePath)) {
911 m_configCapture.kcfg_v4l_format->addItem(i18n("Current settings"));
914 QStringList pixelformats = info.split('>', QString::SkipEmptyParts);
917 QStringList itemRates;
918 for (int i = 0; i < pixelformats.count(); i++) {
919 QString format = pixelformats.at(i).section(':', 0, 0);
920 QStringList sizes = pixelformats.at(i).split(':', QString::SkipEmptyParts);
921 pixelFormat = sizes.takeFirst();
922 for (int j = 0; j < sizes.count(); j++) {
923 itemSize = sizes.at(j).section('=', 0, 0);
924 itemRates = sizes.at(j).section('=', 1, 1).split(',', QString::SkipEmptyParts);
925 for (int k = 0; k < itemRates.count(); k++) {
926 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));
930 m_configCapture.kcfg_v4l_format->blockSignals(false);
931 slotUpdatev4lCaptureProfile();
934 void KdenliveSettingsDialog::slotUpdatev4lCaptureProfile()
936 QStringList info = m_configCapture.kcfg_v4l_format->itemData(m_configCapture.kcfg_v4l_format->currentIndex(), Qt::UserRole).toStringList();
937 if (info.isEmpty()) {
938 // No auto info, display the current ones
939 loadCurrentV4lProfileInfo();
942 m_configCapture.p_size->setText(info.at(1) + 'x' + info.at(2));
943 m_configCapture.p_fps->setText(info.at(3) + '/' + info.at(4));
944 m_configCapture.p_aspect->setText("1/1");
945 m_configCapture.p_display->setText(info.at(1) + '/' + info.at(2));
946 m_configCapture.p_colorspace->setText(ProfilesDialog::getColorspaceDescription(601));
947 m_configCapture.p_progressive->setText(i18n("Progressive"));
949 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
950 if (!QFile::exists(vl4ProfilePath)) saveCurrentV4lProfile();
953 void KdenliveSettingsDialog::loadCurrentV4lProfileInfo()
955 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
956 MltVideoProfile prof;
957 if (!QFile::exists(vl4ProfilePath)) {
958 // No default formats found, build one
961 prof.frame_rate_num = 15;
962 prof.frame_rate_den = 1;
963 prof.display_aspect_num = 4;
964 prof.display_aspect_den = 3;
965 prof.sample_aspect_num = 1;
966 prof.sample_aspect_den = 1;
967 prof.progressive = 1;
968 prof.colorspace = 601;
969 ProfilesDialog::saveProfile(prof, vl4ProfilePath);
971 else prof = ProfilesDialog::getVideoProfile(vl4ProfilePath);
972 m_configCapture.p_size->setText(QString::number(prof.width) + 'x' + QString::number(prof.height));
973 m_configCapture.p_fps->setText(QString::number(prof.frame_rate_num) + '/' + QString::number(prof.frame_rate_den));
974 m_configCapture.p_aspect->setText(QString::number(prof.sample_aspect_num) + '/' + QString::number(prof.sample_aspect_den));
975 m_configCapture.p_display->setText(QString::number(prof.display_aspect_num) + '/' + QString::number(prof.display_aspect_den));
976 m_configCapture.p_colorspace->setText(ProfilesDialog::getColorspaceDescription(prof.colorspace));
977 if (prof.progressive) m_configCapture.p_progressive->setText(i18n("Progressive"));
980 void KdenliveSettingsDialog::saveCurrentV4lProfile()
982 MltVideoProfile profile;
983 profile.description = "Video4Linux capture";
984 profile.colorspace = ProfilesDialog::getColorspaceFromDescription(m_configCapture.p_colorspace->text());
985 profile.width = m_configCapture.p_size->text().section('x', 0, 0).toInt();
986 profile.height = m_configCapture.p_size->text().section('x', 1, 1).toInt();
987 profile.sample_aspect_num = m_configCapture.p_aspect->text().section('/', 0, 0).toInt();
988 profile.sample_aspect_den = m_configCapture.p_aspect->text().section('/', 1, 1).toInt();
989 profile.display_aspect_num = m_configCapture.p_display->text().section('/', 0, 0).toInt();
990 profile.display_aspect_den = m_configCapture.p_display->text().section('/', 1, 1).toInt();
991 profile.frame_rate_num = m_configCapture.p_fps->text().section('/', 0, 0).toInt();
992 profile.frame_rate_den = m_configCapture.p_fps->text().section('/', 1, 1).toInt();
993 profile.progressive = m_configCapture.p_progressive->text() == i18n("Progressive");
994 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
995 ProfilesDialog::saveProfile(profile, vl4ProfilePath);
998 void KdenliveSettingsDialog::slotManageEncodingProfile()
1001 if (currentPage() == m_page4) {
1002 type = m_configCapture.tabWidget->currentIndex();
1004 QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(type);
1007 loadEncodingProfiles();
1010 void KdenliveSettingsDialog::loadEncodingProfiles()
1012 KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
1014 // Load v4l profiles
1015 m_configCapture.kcfg_v4l_profile->blockSignals(true);
1016 QString currentItem = m_configCapture.kcfg_v4l_profile->currentText();
1017 m_configCapture.kcfg_v4l_profile->clear();
1018 KConfigGroup group(&conf, "video4linux");
1019 QMap< QString, QString > values = group.entryMap();
1020 QMapIterator<QString, QString> i(values);
1021 while (i.hasNext()) {
1023 if (!i.key().isEmpty()) m_configCapture.kcfg_v4l_profile->addItem(i.key(), i.value());
1025 m_configCapture.kcfg_v4l_profile->blockSignals(false);
1026 if (!currentItem.isEmpty()) m_configCapture.kcfg_v4l_profile->setCurrentIndex(m_configCapture.kcfg_v4l_profile->findText(currentItem));
1028 // Load Screen Grab profiles
1029 m_configCapture.kcfg_grab_profile->blockSignals(true);
1030 currentItem = m_configCapture.kcfg_grab_profile->currentText();
1031 m_configCapture.kcfg_grab_profile->clear();
1032 KConfigGroup group2(&conf, "screengrab");
1033 values = group2.entryMap();
1034 QMapIterator<QString, QString> j(values);
1035 while (j.hasNext()) {
1037 if (!j.key().isEmpty()) m_configCapture.kcfg_grab_profile->addItem(j.key(), j.value());
1039 m_configCapture.kcfg_grab_profile->blockSignals(false);
1040 if (!currentItem.isEmpty()) m_configCapture.kcfg_grab_profile->setCurrentIndex(m_configCapture.kcfg_grab_profile->findText(currentItem));
1042 // Load Decklink profiles
1043 m_configCapture.kcfg_decklink_profile->blockSignals(true);
1044 currentItem = m_configCapture.kcfg_decklink_profile->currentText();
1045 m_configCapture.kcfg_decklink_profile->clear();
1046 KConfigGroup group3(&conf, "decklink");
1047 values = group3.entryMap();
1048 QMapIterator<QString, QString> k(values);
1049 while (k.hasNext()) {
1051 if (!k.key().isEmpty()) m_configCapture.kcfg_decklink_profile->addItem(k.key(), k.value());
1053 m_configCapture.kcfg_decklink_profile->blockSignals(false);
1054 if (!currentItem.isEmpty()) m_configCapture.kcfg_decklink_profile->setCurrentIndex(m_configCapture.kcfg_decklink_profile->findText(currentItem));
1056 // Load Proxy profiles
1057 m_configProject.kcfg_proxy_profile->blockSignals(true);
1058 currentItem = m_configProject.kcfg_proxy_profile->currentText();
1059 m_configProject.kcfg_proxy_profile->clear();
1060 KConfigGroup group4(&conf, "proxy");
1061 values = group4.entryMap();
1062 QMapIterator<QString, QString> l(values);
1063 while (l.hasNext()) {
1065 if (!l.key().isEmpty()) m_configProject.kcfg_proxy_profile->addItem(l.key(), l.value());
1067 if (!currentItem.isEmpty()) m_configProject.kcfg_proxy_profile->setCurrentIndex(m_configProject.kcfg_proxy_profile->findText(currentItem));
1068 m_configProject.kcfg_proxy_profile->blockSignals(false);
1069 slotUpdateProxyProfile();
1073 void KdenliveSettingsDialog::slotUpdateDecklinkProfile(int ix)
1075 if (ix == -1) ix = KdenliveSettings::decklink_profile();
1076 else ix = m_configCapture.kcfg_decklink_profile->currentIndex();
1077 QString data = m_configCapture.kcfg_decklink_profile->itemData(ix).toString();
1078 if (data.isEmpty()) return;
1079 m_configCapture.decklink_parameters->setPlainText(data.section(';', 0, 0));
1083 void KdenliveSettingsDialog::slotUpdateV4lProfile(int ix)
1085 if (ix == -1) ix = KdenliveSettings::v4l_profile();
1086 else ix = m_configCapture.kcfg_v4l_profile->currentIndex();
1087 QString data = m_configCapture.kcfg_v4l_profile->itemData(ix).toString();
1088 if (data.isEmpty()) return;
1089 m_configCapture.v4l_parameters->setPlainText(data.section(';', 0, 0));
1093 void KdenliveSettingsDialog::slotUpdateGrabProfile(int ix)
1095 if (ix == -1) ix = KdenliveSettings::grab_profile();
1096 else ix = m_configCapture.kcfg_grab_profile->currentIndex();
1097 QString data = m_configCapture.kcfg_grab_profile->itemData(ix).toString();
1098 if (data.isEmpty()) return;
1099 m_configCapture.grab_parameters->setPlainText(data.section(';', 0, 0));
1103 void KdenliveSettingsDialog::slotUpdateProxyProfile(int ix)
1105 if (ix == -1) ix = KdenliveSettings::v4l_profile();
1106 else ix = m_configProject.kcfg_proxy_profile->currentIndex();
1107 QString data = m_configProject.kcfg_proxy_profile->itemData(ix).toString();
1108 if (data.isEmpty()) return;
1109 m_configProject.proxyparams->setPlainText(data.section(';', 0, 0));
1113 void KdenliveSettingsDialog::slotEditVideo4LinuxProfile()
1115 QString vl4ProfilePath = KStandardDirs::locateLocal("appdata", "profiles/video4linux");
1116 QPointer<ProfilesDialog> w = new ProfilesDialog(vl4ProfilePath);
1117 if (w->exec() == QDialog::Accepted) {
1118 // save and update profile
1119 loadCurrentV4lProfileInfo();
1124 void KdenliveSettingsDialog::slotReloadBlackMagic()
1126 Render::getBlackMagicDeviceList(m_configCapture.kcfg_decklink_capturedevice, true);
1127 if (!Render::getBlackMagicOutputDeviceList(m_configSdl.kcfg_blackmagic_output_device), true) {
1128 // No blackmagic card found
1129 m_configSdl.kcfg_external_display->setEnabled(false);
1131 m_configSdl.kcfg_external_display->setEnabled(KdenliveSettings::decklink_device_found());
1133 #include "kdenlivesettingsdialog.moc"