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"
22 #include "v4l/v4lcapture.h"
23 #include "blackmagic/devices.h"
24 #include "kdenlivesettings.h"
26 #include <KStandardDirs>
28 #include <kopenwithdialog.h>
29 #include <KConfigDialogManager>
31 #include <KIO/NetAccess>
32 #include <kdeversion.h>
36 #include <QTreeWidgetItem>
43 #include <linux/input.h>
44 #endif /* NO_JOGSHUTTLE */
47 KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent) :
48 KConfigDialog(parent, "settings", KdenliveSettings::self()),
52 QWidget *p1 = new QWidget;
53 m_configMisc.setupUi(p1);
54 m_page1 = addPage(p1, i18n("Misc"), "configure");
56 // Hide multi tab option until Kdenlive really supports it
57 m_configMisc.kcfg_activatetabs->setVisible(false);
59 QWidget *p8 = new QWidget;
60 m_configProject.setupUi(p8);
61 m_page8 = addPage(p8, i18n("Project Defaults"), "document-new");
63 QWidget *p3 = new QWidget;
64 m_configTimeline.setupUi(p3);
65 m_page3 = addPage(p3, i18n("Timeline"), "video-display");
67 QWidget *p2 = new QWidget;
68 m_configEnv.setupUi(p2);
69 m_configEnv.mltpathurl->setMode(KFile::Directory);
70 m_configEnv.mltpathurl->lineEdit()->setObjectName("kcfg_mltpath");
71 m_configEnv.rendererpathurl->lineEdit()->setObjectName("kcfg_rendererpath");
72 m_configEnv.tmppathurl->setMode(KFile::Directory);
73 m_configEnv.tmppathurl->lineEdit()->setObjectName("kcfg_currenttmpfolder");
74 m_configEnv.projecturl->setMode(KFile::Directory);
75 m_configEnv.projecturl->lineEdit()->setObjectName("kcfg_defaultprojectfolder");
76 m_configEnv.capturefolderurl->setMode(KFile::Directory);
77 m_configEnv.capturefolderurl->lineEdit()->setObjectName("kcfg_capturefolder");
78 m_configEnv.capturefolderurl->setEnabled(!KdenliveSettings::capturetoprojectfolder());
79 connect(m_configEnv.kcfg_capturetoprojectfolder, SIGNAL(clicked()), this, SLOT(slotEnableCaptureFolder()));
80 m_page2 = addPage(p2, i18n("Environment"), "application-x-executable-script");
82 QWidget *p4 = new QWidget;
83 m_configCapture.setupUi(p4);
85 #if !defined(Q_WS_MAC) && !defined(Q_OS_FREEBSD)
86 V4lCaptureHandler v4l(NULL);
87 // Video 4 Linux device detection
88 for (int i = 0; i < 10; i++) {
89 QString path = "/dev/video" + QString::number(i);
90 if (QFile::exists(path)) {
91 QStringList deviceInfo = v4l.getDeviceName(path);
92 if (!deviceInfo.isEmpty()) {
93 m_configCapture.kcfg_detectedv4ldevices->addItem(deviceInfo.at(0), path);
94 m_configCapture.kcfg_detectedv4ldevices->setItemData(m_configCapture.kcfg_detectedv4ldevices->count() - 1, deviceInfo.at(1), Qt::UserRole + 1);
98 connect(m_configCapture.kcfg_detectedv4ldevices, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdatev4lDevice()));
101 m_page4 = addPage(p4, i18n("Capture"), "media-record");
102 m_configCapture.tabWidget->setCurrentIndex(KdenliveSettings::defaultcapture());
104 m_configCapture.tabWidget->setEnabled(false);
105 m_configCapture.kcfg_defaultcapture->setEnabled(false);
106 m_configCapture.label->setText(i18n("Capture is not yet available on OS X."));
109 QWidget *p5 = new QWidget;
110 m_configShuttle.setupUi(p5);
111 #ifndef NO_JOGSHUTTLE
112 connect(m_configShuttle.kcfg_enableshuttle, SIGNAL(stateChanged(int)), this, SLOT(slotCheckShuttle(int)));
113 connect(m_configShuttle.shuttledevicelist, SIGNAL(activated(int)), this, SLOT(slotUpdateShuttleDevice(int)));
114 slotCheckShuttle(KdenliveSettings::enableshuttle());
115 m_configShuttle.shuttledisabled->hide();
117 m_configShuttle.kcfg_enableshuttle->hide();
118 m_configShuttle.kcfg_enableshuttle->setDisabled(true);
119 #endif /* NO_JOGSHUTTLE */
120 m_page5 = addPage(p5, i18n("JogShuttle"), "input-mouse");
122 QWidget *p6 = new QWidget;
123 m_configSdl.setupUi(p6);
125 #if not defined(Q_WS_MAC) && not defined(USE_OPEN_GL)
126 m_configSdl.kcfg_openglmonitors->setHidden(true);
129 m_page6 = addPage(p6, i18n("Playback"), "media-playback-start");
131 QWidget *p7 = new QWidget;
132 m_configTranscode.setupUi(p7);
133 m_page7 = addPage(p7, i18n("Transcode"), "edit-copy");
134 connect(m_configTranscode.button_add, SIGNAL(clicked()), this, SLOT(slotAddTranscode()));
135 connect(m_configTranscode.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteTranscode()));
136 connect(m_configTranscode.profiles_list, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDialogModified()));
139 actions << i18n("Do nothing");
140 actions << i18n("Play / Pause");
141 actions << i18n("Cut");
142 m_configShuttle.kcfg_shuttle1->addItems(actions);
143 m_configShuttle.kcfg_shuttle2->addItems(actions);
144 m_configShuttle.kcfg_shuttle3->addItems(actions);
145 m_configShuttle.kcfg_shuttle4->addItems(actions);
146 m_configShuttle.kcfg_shuttle5->addItems(actions);
148 connect(m_configCapture.kcfg_video4vdevice, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
149 connect(m_configCapture.kcfg_video4adevice, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
150 connect(m_configCapture.kcfg_video4vcodec, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
151 connect(m_configCapture.kcfg_video4acodec, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
152 connect(m_configCapture.kcfg_video4vformat, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
153 connect(m_configCapture.kcfg_video4aformat, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
154 connect(m_configCapture.kcfg_video4size, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
155 connect(m_configCapture.kcfg_video4rate, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
157 connect(m_configCapture.kcfg_rmd_capture_audio, SIGNAL(clicked(bool)), m_configCapture.audio_group, SLOT(setVisible(bool)));
159 m_configCapture.audio_group->setVisible(KdenliveSettings::rmd_capture_audio());
161 connect(m_configEnv.kp_image, SIGNAL(clicked()), this, SLOT(slotEditImageApplication()));
162 connect(m_configEnv.kp_audio, SIGNAL(clicked()), this, SLOT(slotEditAudioApplication()));
163 connect(m_configEnv.kp_player, SIGNAL(clicked()), this, SLOT(slotEditVideoApplication()));
169 connect(m_configSdl.kcfg_audio_driver, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCheckAlsaDriver()));
171 connect(m_configProject.kcfg_profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
172 connect(m_configCapture.kcfg_rmd_capture_type, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateRmdRegionStatus()));
174 slotUpdateRmdRegionStatus();
175 loadTranscodeProfiles();
178 //HACK: check dvgrab version, because only dvgrab >= 3.3 supports
179 // --timestamp option without bug
181 if (KdenliveSettings::dvgrab_path().isEmpty() || !QFile::exists(KdenliveSettings::dvgrab_path())) {
182 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
183 KdenliveSettings::setDvgrab_path(dvgrabpath);
187 BMInterface::getBlackMagicDeviceList(m_configCapture.kcfg_hdmi_capturedevice, m_configCapture.kcfg_hdmi_capturemode);
188 connect(m_configCapture.kcfg_hdmi_capturedevice, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateHDMIModes()));
190 if (BMInterface::getBlackMagicOutputDeviceList(m_configSdl.kcfg_blackmagic_output_device)) {
191 // Found blackmagic card
192 } else m_configSdl.kcfg_external_display->setEnabled(false);
194 double dvgrabVersion = 0;
195 if (!KdenliveSettings::dvgrab_path().isEmpty()) {
196 QProcess *versionCheck = new QProcess;
197 versionCheck->setProcessChannelMode(QProcess::MergedChannels);
198 versionCheck->start("dvgrab", QStringList() << "--version");
199 if (versionCheck->waitForFinished()) {
200 QString version = QString(versionCheck->readAll()).simplified();
201 if (version.contains(' ')) version = version.section(' ', -1);
202 dvgrabVersion = version.toDouble();
204 kDebug() << "// FOUND DVGRAB VERSION: " << dvgrabVersion;
207 if (dvgrabVersion < 3.3) {
208 KdenliveSettings::setFirewiretimestamp(false);
209 m_configCapture.kcfg_firewiretimestamp->setEnabled(false);
211 m_configCapture.dvgrab_info->setText(i18n("dvgrab version %1 at %2", dvgrabVersion, KdenliveSettings::dvgrab_path()));
212 } else m_configCapture.dvgrab_info->setText(i18n("<strong><em>dvgrab</em> utility not found, please install it for firewire capture</strong>"));
214 if (KdenliveSettings::rmd_path().isEmpty() || !QFile::exists(KdenliveSettings::rmd_path())) {
215 QString rmdpath = KStandardDirs::findExe("recordmydesktop");
216 KdenliveSettings::setRmd_path(rmdpath);
218 if (KdenliveSettings::rmd_path().isEmpty())
219 m_configCapture.rmd_info->setText(i18n("<strong><em>Recordmydesktop</em> utility not found, please install it for screen grabs</strong>"));
221 m_configCapture.rmd_info->setText(i18n("Recordmydesktop found at: %1", KdenliveSettings::rmd_path()));
224 KdenliveSettingsDialog::~KdenliveSettingsDialog() {}
226 void KdenliveSettingsDialog::slotUpdateHDMIModes()
228 QStringList modes = m_configCapture.kcfg_hdmi_capturedevice->itemData(m_configCapture.kcfg_hdmi_capturedevice->currentIndex()).toStringList();
229 m_configCapture.kcfg_hdmi_capturemode->clear();
230 m_configCapture.kcfg_hdmi_capturemode->insertItems(0, modes);
233 void KdenliveSettingsDialog::slotUpdateRmdRegionStatus()
235 m_configCapture.region_group->setHidden(m_configCapture.kcfg_rmd_capture_type->currentIndex() != 1);
238 void KdenliveSettingsDialog::slotEnableCaptureFolder()
240 m_configEnv.capturefolderurl->setEnabled(!m_configEnv.kcfg_capturetoprojectfolder->isChecked());
243 void KdenliveSettingsDialog::checkProfile()
245 m_configProject.kcfg_profiles_list->clear();
246 QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
247 QMapIterator<QString, QString> i(profilesInfo);
248 while (i.hasNext()) {
250 m_configProject.kcfg_profiles_list->addItem(i.key(), i.value());
253 if (!KdenliveSettings::default_profile().isEmpty()) {
254 for (int i = 0; i < m_configProject.kcfg_profiles_list->count(); i++) {
255 if (m_configProject.kcfg_profiles_list->itemData(i).toString() == KdenliveSettings::default_profile()) {
256 m_configProject.kcfg_profiles_list->setCurrentIndex(i);
257 KdenliveSettings::setProfiles_list(i);
264 void KdenliveSettingsDialog::initDevices()
266 // Fill audio drivers
267 m_configSdl.kcfg_audio_driver->addItem(i18n("Automatic"), QString());
269 m_configSdl.kcfg_audio_driver->addItem(i18n("OSS"), "dsp");
270 m_configSdl.kcfg_audio_driver->addItem(i18n("ALSA"), "alsa");
271 m_configSdl.kcfg_audio_driver->addItem(i18n("PulseAudio"), "pulse");
272 m_configSdl.kcfg_audio_driver->addItem(i18n("OSS with DMA access"), "dma");
273 m_configSdl.kcfg_audio_driver->addItem(i18n("Esound daemon"), "esd");
274 m_configSdl.kcfg_audio_driver->addItem(i18n("ARTS daemon"), "artsc");
277 if (!KdenliveSettings::audiodrivername().isEmpty())
278 for (int i = 1; i < m_configSdl.kcfg_audio_driver->count(); i++) {
279 if (m_configSdl.kcfg_audio_driver->itemData(i).toString() == KdenliveSettings::audiodrivername()) {
280 m_configSdl.kcfg_audio_driver->setCurrentIndex(i);
281 KdenliveSettings::setAudio_driver((uint) i);
285 // Fill video drivers
286 m_configSdl.kcfg_video_driver->addItem(i18n("Automatic"), QString());
288 m_configSdl.kcfg_video_driver->addItem(i18n("XVideo"), "x11");
289 m_configSdl.kcfg_video_driver->addItem(i18n("X11"), "x11_noaccel");
290 m_configSdl.kcfg_video_driver->addItem(i18n("XFree86 DGA 2.0"), "dga");
291 m_configSdl.kcfg_video_driver->addItem(i18n("Nano X"), "nanox");
292 m_configSdl.kcfg_video_driver->addItem(i18n("Framebuffer console"), "fbcon");
293 m_configSdl.kcfg_video_driver->addItem(i18n("Direct FB"), "directfb");
294 m_configSdl.kcfg_video_driver->addItem(i18n("SVGAlib"), "svgalib");
295 m_configSdl.kcfg_video_driver->addItem(i18n("General graphics interface"), "ggi");
296 m_configSdl.kcfg_video_driver->addItem(i18n("Ascii art library"), "aalib");
299 // Fill the list of audio playback devices
300 m_configSdl.kcfg_audio_device->addItem(i18n("Default"), QString());
301 m_configCapture.kcfg_rmd_alsa_device->addItem(i18n("Default"), QString());
302 if (!KStandardDirs::findExe("aplay").isEmpty()) {
303 m_readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
304 m_readProcess.setProgram("aplay", QStringList() << "-l");
305 connect(&m_readProcess, SIGNAL(readyReadStandardOutput()) , this, SLOT(slotReadAudioDevices()));
306 m_readProcess.execute(5000);
308 // If aplay is not installed on the system, parse the /proc/asound/pcm file
309 QFile file("/proc/asound/pcm");
310 if (file.open(QIODevice::ReadOnly)) {
311 QTextStream stream(&file);
314 while (!stream.atEnd()) {
315 line = stream.readLine();
316 if (line.contains("playback")) {
317 deviceId = line.section(':', 0, 0);
318 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()));
320 if (line.contains("capture")) {
321 deviceId = line.section(':', 0, 0);
322 m_configCapture.kcfg_rmd_alsa_device->addItem(line.section(':', 1, 1), "plughw:" + QString::number(deviceId.section('-', 0, 0).toInt()) + ',' + QString::number(deviceId.section('-', 1, 1).toInt()));
328 if (!KdenliveSettings::audiodevicename().isEmpty()) {
329 // Select correct alsa device
330 int ix = m_configSdl.kcfg_audio_device->findData(KdenliveSettings::audiodevicename());
331 m_configSdl.kcfg_audio_device->setCurrentIndex(ix);
332 KdenliveSettings::setAudio_device(ix);
334 if (!KdenliveSettings::rmd_alsadevicename().isEmpty()) {
335 // Select correct alsa device
336 int ix = m_configCapture.kcfg_rmd_alsa_device->findData(KdenliveSettings::rmd_alsadevicename());
337 m_configCapture.kcfg_rmd_alsa_device->setCurrentIndex(ix);
338 KdenliveSettings::setRmd_alsa_device(ix);
343 void KdenliveSettingsDialog::slotReadAudioDevices()
345 QString result = QString(m_readProcess.readAllStandardOutput());
346 kDebug() << "// / / / / / READING APLAY: ";
348 QStringList lines = result.split('\n');
349 foreach(const QString & data, lines) {
350 kDebug() << "// READING LINE: " << data;
351 if (data.simplified().startsWith("card")) {
352 QString card = data.section(':', 0, 0).section(' ', -1);
353 QString device = data.section(':', 1, 1).section(' ', -1);
354 m_configSdl.kcfg_audio_device->addItem(data.section(':', -1), "plughw:" + card + ',' + device);
355 m_configCapture.kcfg_rmd_alsa_device->addItem(data.section(':', -1), "plughw:" + card + ',' + device);
360 void KdenliveSettingsDialog::showPage(int page, int option)
364 setCurrentPage(m_page1);
367 setCurrentPage(m_page2);
370 setCurrentPage(m_page3);
373 setCurrentPage(m_page4);
374 m_configCapture.tabWidget->setCurrentIndex(option);
377 setCurrentPage(m_page5);
380 setCurrentPage(m_page6);
383 setCurrentPage(m_page7);
386 setCurrentPage(m_page1);
390 void KdenliveSettingsDialog::slotEditVideoApplication()
392 KService::Ptr service;
393 KOpenWithDialog dlg(KUrl::List(), i18n("Select default video player"), m_configEnv.kcfg_defaultplayerapp->text(), this);
394 if (dlg.exec() != QDialog::Accepted)
397 service = dlg.service();
398 m_configEnv.kcfg_defaultplayerapp->setText(service->exec());
401 void KdenliveSettingsDialog::slotEditAudioApplication()
403 KService::Ptr service;
404 KOpenWithDialog dlg(KUrl::List(), i18n("Select default audio editor"), m_configEnv.kcfg_defaultaudioapp->text(), this);
405 if (dlg.exec() != QDialog::Accepted)
408 service = dlg.service();
409 m_configEnv.kcfg_defaultaudioapp->setText(service->exec());
412 void KdenliveSettingsDialog::slotEditImageApplication()
414 KService::Ptr service;
415 KOpenWithDialog dlg(KUrl::List(), i18n("Select default image editor"), m_configEnv.kcfg_defaultimageapp->text(), this);
416 if (dlg.exec() != QDialog::Accepted)
419 service = dlg.service();
420 m_configEnv.kcfg_defaultimageapp->setText(service->exec());
423 #ifndef NO_JOGSHUTTLE
424 void KdenliveSettingsDialog::slotCheckShuttle(int state)
426 m_configShuttle.config_group->setEnabled(state);
427 if (m_configShuttle.shuttledevicelist->count() == 0) {
429 QString baseName = "/dev/input/event";
431 for (int i = 0; i < 30; i++) {
432 QString filename = baseName + QString::number(i);
433 kDebug() << "/// CHECKING OFR: " << filename;
435 char name[256] = "unknown";
436 fd = KDE_open((char *) filename.toUtf8().data(), O_RDONLY);
437 if (fd >= 0 && ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0) {
438 m_configShuttle.shuttledevicelist->addItem(name, filename);
442 if (KdenliveSettings::shuttledevice().isEmpty()) QTimer::singleShot(1500, this, SLOT(slotUpdateShuttleDevice()));
446 void KdenliveSettingsDialog::slotUpdateShuttleDevice(int ix)
448 QString device = m_configShuttle.shuttledevicelist->itemData(ix).toString();
449 //KdenliveSettings::setShuttledevice(device);
450 m_configShuttle.kcfg_shuttledevice->setText(device);
452 #endif /* NO_JOGSHUTTLE */
454 void KdenliveSettingsDialog::rebuildVideo4Commands()
456 QString captureCommand;
457 if (!m_configCapture.kcfg_video4adevice->text().isEmpty()) captureCommand = "-f " + m_configCapture.kcfg_video4aformat->text() + " -i " + m_configCapture.kcfg_video4adevice->text() + " -acodec " + m_configCapture.kcfg_video4acodec->text();
459 captureCommand += " -f " + m_configCapture.kcfg_video4vformat->text() + " -s " + m_configCapture.kcfg_video4size->text() + " -r " + QString::number(m_configCapture.kcfg_video4rate->value()) + " -i " + m_configCapture.kcfg_video4vdevice->text() + " -vcodec " + m_configCapture.kcfg_video4vcodec->text();
460 m_configCapture.kcfg_video4capture->setText(captureCommand);
464 void KdenliveSettingsDialog::updateSettings()
466 //kDebug() << "// // // KCONFIG UPDATE called";
468 m_defaultProfile = m_configProject.kcfg_profiles_list->currentText();
469 KdenliveSettings::setDefault_profile(m_defaultPath);
471 bool resetProfile = false;
472 bool updateCapturePath = false;
474 if (m_configEnv.kcfg_capturetoprojectfolder->isChecked() != KdenliveSettings::capturetoprojectfolder()) {
475 KdenliveSettings::setCapturetoprojectfolder(m_configEnv.kcfg_capturetoprojectfolder->isChecked());
476 updateCapturePath = true;
479 if (m_configEnv.capturefolderurl->url().path() != KdenliveSettings::capturefolder()) {
480 KdenliveSettings::setCapturefolder(m_configEnv.capturefolderurl->url().path());
481 updateCapturePath = true;
484 if (m_configCapture.kcfg_dvgrabfilename->text() != KdenliveSettings::dvgrabfilename()) {
485 KdenliveSettings::setDvgrabfilename(m_configCapture.kcfg_dvgrabfilename->text());
486 updateCapturePath = true;
489 if ((uint) m_configCapture.kcfg_firewireformat->currentIndex() != KdenliveSettings::firewireformat()) {
490 KdenliveSettings::setFirewireformat(m_configCapture.kcfg_firewireformat->currentIndex());
491 updateCapturePath = true;
494 if (updateCapturePath) emit updateCaptureFolder();
496 QString value = m_configCapture.kcfg_rmd_alsa_device->itemData(m_configCapture.kcfg_rmd_alsa_device->currentIndex()).toString();
497 if (value != KdenliveSettings::rmd_alsadevicename()) {
498 KdenliveSettings::setRmd_alsadevicename(value);
501 value = m_configCapture.kcfg_rmd_audio_freq->itemText(m_configCapture.kcfg_rmd_audio_freq->currentIndex());
502 kDebug() << "// AUDIO FREQ VALUE: " << value << ", CURRENT: " << KdenliveSettings::rmd_freq() << ", IX: " << m_configCapture.kcfg_rmd_audio_freq->currentIndex();
503 if (value != KdenliveSettings::rmd_freq()) {
504 kDebug() << "// SETTING AUDIO FREQ TO: " << value;
505 KdenliveSettings::setRmd_freq(value);
508 value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
509 if (value != KdenliveSettings::audiodrivername()) {
510 KdenliveSettings::setAudiodrivername(value);
514 if (value == "alsa") {
515 // Audio device setting is only valid for alsa driver
516 value = m_configSdl.kcfg_audio_device->itemData(m_configSdl.kcfg_audio_device->currentIndex()).toString();
517 if (value != KdenliveSettings::audiodevicename()) {
518 KdenliveSettings::setAudiodevicename(value);
521 } else if (KdenliveSettings::audiodevicename().isEmpty() == false) {
522 KdenliveSettings::setAudiodevicename(QString::null);
526 value = m_configSdl.kcfg_video_driver->itemData(m_configSdl.kcfg_video_driver->currentIndex()).toString();
527 if (value != KdenliveSettings::videodrivername()) {
528 KdenliveSettings::setVideodrivername(value);
532 if (m_configSdl.kcfg_window_background->color() != KdenliveSettings::window_background()) {
533 KdenliveSettings::setWindow_background(m_configSdl.kcfg_window_background->color());
537 if (m_configSdl.kcfg_volume->value() != KdenliveSettings::volume()) {
538 KdenliveSettings::setVolume(m_configSdl.kcfg_volume->value());
543 // The transcoding profiles were modified, save.
545 saveTranscodeProfiles();
548 #if KDE_IS_VERSION(4,3,0)
549 KConfigDialog::settingsChangedSlot();
552 //KConfigDialog::updateSettings();
553 if (resetProfile) emit doResetProfile();
556 void KdenliveSettingsDialog::slotUpdateDisplay()
558 QString currentProfile = m_configProject.kcfg_profiles_list->itemData(m_configProject.kcfg_profiles_list->currentIndex()).toString();
559 QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
560 m_configProject.p_size->setText(values.value("width") + 'x' + values.value("height"));
561 m_configProject.p_fps->setText(values.value("frame_rate_num") + '/' + values.value("frame_rate_den"));
562 m_configProject.p_aspect->setText(values.value("sample_aspect_num") + '/' + values.value("sample_aspect_den"));
563 m_configProject.p_display->setText(values.value("display_aspect_num") + '/' + values.value("display_aspect_den"));
564 if (values.value("progressive").toInt() == 0)
565 m_configProject.p_progressive->setText(i18n("Interlaced"));
567 m_configProject.p_progressive->setText(i18n("Progressive"));
568 m_defaultProfile = m_configProject.kcfg_profiles_list->itemText(m_configProject.kcfg_profiles_list->currentIndex());
569 m_defaultPath = currentProfile;
572 void KdenliveSettingsDialog::slotCheckAlsaDriver()
574 QString value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
575 m_configSdl.kcfg_audio_device->setEnabled(value == "alsa");
578 void KdenliveSettingsDialog::loadTranscodeProfiles()
580 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
581 KConfigGroup transConfig(config, "Transcoding");
583 m_configTranscode.profiles_list->blockSignals(true);
584 QMap< QString, QString > profiles = transConfig.entryMap();
585 QMapIterator<QString, QString> i(profiles);
586 while (i.hasNext()) {
588 QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i.key() << i.value());
589 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
591 m_configTranscode.profiles_list->blockSignals(false);
594 void KdenliveSettingsDialog::saveTranscodeProfiles()
596 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
597 //KSharedConfigPtr config = KGlobal::config();
598 KConfigGroup transConfig(config, "Transcoding");
600 transConfig.deleteGroup();
601 int max = m_configTranscode.profiles_list->topLevelItemCount();
602 for (int i = 0; i < max; i++) {
603 QTreeWidgetItem *item = m_configTranscode.profiles_list->topLevelItem(i);
604 transConfig.writeEntry(item->text(0), item->text(1));
609 void KdenliveSettingsDialog::slotAddTranscode()
611 QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i18n("Name") << i18n("Parameters"));
612 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
613 m_configTranscode.profiles_list->setCurrentItem(item);
614 m_configTranscode.profiles_list->editItem(item);
615 slotDialogModified();
618 void KdenliveSettingsDialog::slotDeleteTranscode()
620 QTreeWidgetItem *item = m_configTranscode.profiles_list->currentItem();
621 if (item == NULL) return;
623 slotDialogModified();
626 void KdenliveSettingsDialog::slotDialogModified()
629 #if KDE_IS_VERSION(4,3,0)
630 KConfigDialog::updateButtons();
635 bool KdenliveSettingsDialog::hasChanged()
637 if (m_modified) return true;
638 return KConfigDialog::hasChanged();
641 void KdenliveSettingsDialog::slotUpdatev4lDevice()
643 QString device = m_configCapture.kcfg_detectedv4ldevices->itemData(m_configCapture.kcfg_detectedv4ldevices->currentIndex()).toString();
644 if (!device.isEmpty()) m_configCapture.kcfg_video4vdevice->setText(device);
645 QString size = m_configCapture.kcfg_detectedv4ldevices->itemData(m_configCapture.kcfg_detectedv4ldevices->currentIndex(), Qt::UserRole + 1).toString();
646 if (!size.isEmpty()) m_configCapture.kcfg_video4size->setText(size);
647 rebuildVideo4Commands();
651 #include "kdenlivesettingsdialog.moc"