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 V4lCaptureHandler v4l(NULL);
88 // Video 4 Linux device detection
89 for (int i = 0; i < 10; i++) {
90 QString path = "/dev/video" + QString::number(i);
91 if (QFile::exists(path)) {
92 QString deviceName = v4l.getDeviceName(path.toUtf8().constData(), &width, &height);
93 m_configCapture.kcfg_detectedv4ldevices->addItem(deviceName, path);
94 if (width > 0) m_configCapture.kcfg_detectedv4ldevices->setItemData(m_configCapture.kcfg_detectedv4ldevices->count() - 1, QString("%1x%2").arg(width).arg(height), Qt::UserRole + 1);
97 connect(m_configCapture.kcfg_detectedv4ldevices, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdatev4lDevice()));
100 m_page4 = addPage(p4, i18n("Capture"), "media-record");
101 m_configCapture.tabWidget->setCurrentIndex(KdenliveSettings::defaultcapture());
103 m_configCapture.tabWidget->setEnabled(false);
104 m_configCapture.kcfg_defaultcapture->setEnabled(false);
105 m_configCapture.label->setText(i18n("Capture is not yet available on OS X."));
108 QWidget *p5 = new QWidget;
109 m_configShuttle.setupUi(p5);
110 #ifndef NO_JOGSHUTTLE
111 connect(m_configShuttle.kcfg_enableshuttle, SIGNAL(stateChanged(int)), this, SLOT(slotCheckShuttle(int)));
112 connect(m_configShuttle.shuttledevicelist, SIGNAL(activated(int)), this, SLOT(slotUpdateShuttleDevice(int)));
113 slotCheckShuttle(KdenliveSettings::enableshuttle());
114 m_configShuttle.shuttledisabled->hide();
116 m_configShuttle.kcfg_enableshuttle->hide();
117 m_configShuttle.kcfg_enableshuttle->setDisabled(true);
118 #endif /* NO_JOGSHUTTLE */
119 m_page5 = addPage(p5, i18n("JogShuttle"), "input-mouse");
121 QWidget *p6 = new QWidget;
122 m_configSdl.setupUi(p6);
124 // Disable drop B frames, see Kdenlive issue #1330
125 m_configSdl.groupBox->setHidden(true);
126 #if not defined(Q_WS_MAC) && not defined(USE_OPEN_GL)
127 m_configSdl.kcfg_openglmonitors->setHidden(true);
130 m_page6 = addPage(p6, i18n("Playback"), "media-playback-start");
132 QWidget *p7 = new QWidget;
133 m_configTranscode.setupUi(p7);
134 m_page7 = addPage(p7, i18n("Transcode"), "edit-copy");
135 connect(m_configTranscode.button_add, SIGNAL(clicked()), this, SLOT(slotAddTranscode()));
136 connect(m_configTranscode.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteTranscode()));
137 connect(m_configTranscode.profiles_list, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDialogModified()));
140 actions << i18n("Do nothing");
141 actions << i18n("Play / Pause");
142 actions << i18n("Cut");
143 m_configShuttle.kcfg_shuttle1->addItems(actions);
144 m_configShuttle.kcfg_shuttle2->addItems(actions);
145 m_configShuttle.kcfg_shuttle3->addItems(actions);
146 m_configShuttle.kcfg_shuttle4->addItems(actions);
147 m_configShuttle.kcfg_shuttle5->addItems(actions);
149 connect(m_configCapture.kcfg_video4vdevice, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
150 connect(m_configCapture.kcfg_video4adevice, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
151 connect(m_configCapture.kcfg_video4vcodec, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
152 connect(m_configCapture.kcfg_video4acodec, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
153 connect(m_configCapture.kcfg_video4vformat, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
154 connect(m_configCapture.kcfg_video4aformat, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
155 connect(m_configCapture.kcfg_video4size, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
156 connect(m_configCapture.kcfg_video4rate, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
158 connect(m_configCapture.kcfg_rmd_capture_audio, SIGNAL(clicked(bool)), m_configCapture.audio_group, SLOT(setVisible(bool)));
160 m_configCapture.audio_group->setVisible(KdenliveSettings::rmd_capture_audio());
162 connect(m_configEnv.kp_image, SIGNAL(clicked()), this, SLOT(slotEditImageApplication()));
163 connect(m_configEnv.kp_audio, SIGNAL(clicked()), this, SLOT(slotEditAudioApplication()));
164 connect(m_configEnv.kp_player, SIGNAL(clicked()), this, SLOT(slotEditVideoApplication()));
170 connect(m_configSdl.kcfg_audio_driver, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCheckAlsaDriver()));
172 connect(m_configProject.kcfg_profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
173 connect(m_configCapture.kcfg_rmd_capture_type, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateRmdRegionStatus()));
175 slotUpdateRmdRegionStatus();
176 loadTranscodeProfiles();
179 //HACK: check dvgrab version, because only dvgrab >= 3.3 supports
180 // --timestamp option without bug
182 if (KdenliveSettings::dvgrab_path().isEmpty() || !QFile::exists(KdenliveSettings::dvgrab_path())) {
183 QString dvgrabpath = KStandardDirs::findExe("dvgrab");
184 KdenliveSettings::setDvgrab_path(dvgrabpath);
188 BMInterface::getBlackMagicDeviceList(m_configCapture.kcfg_hdmi_capturedevice, m_configCapture.kcfg_hdmi_capturemode);
189 connect(m_configCapture.kcfg_hdmi_capturedevice, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateHDMIModes()));
191 double dvgrabVersion = 0;
192 if (!KdenliveSettings::dvgrab_path().isEmpty()) {
193 QProcess *versionCheck = new QProcess;
194 versionCheck->setProcessChannelMode(QProcess::MergedChannels);
195 versionCheck->start("dvgrab", QStringList() << "--version");
196 if (versionCheck->waitForFinished()) {
197 QString version = QString(versionCheck->readAll()).simplified();
198 if (version.contains(' ')) version = version.section(' ', -1);
199 dvgrabVersion = version.toDouble();
201 kDebug() << "// FOUND DVGRAB VERSION: " << dvgrabVersion;
204 if (dvgrabVersion < 3.3) {
205 KdenliveSettings::setFirewiretimestamp(false);
206 m_configCapture.kcfg_firewiretimestamp->setEnabled(false);
208 m_configCapture.dvgrab_info->setText(i18n("dvgrab version %1 at %2", dvgrabVersion, KdenliveSettings::dvgrab_path()));
209 } else m_configCapture.dvgrab_info->setText(i18n("<strong><em>dvgrab</em> utility not found, please install it for firewire capture</strong>"));
211 if (KdenliveSettings::rmd_path().isEmpty() || !QFile::exists(KdenliveSettings::rmd_path())) {
212 QString rmdpath = KStandardDirs::findExe("recordmydesktop");
213 KdenliveSettings::setRmd_path(rmdpath);
215 if (KdenliveSettings::rmd_path().isEmpty())
216 m_configCapture.rmd_info->setText(i18n("<strong><em>Recordmydesktop</em> utility not found, please install it for screen grabs</strong>"));
218 m_configCapture.rmd_info->setText(i18n("Recordmydesktop found at: %1", KdenliveSettings::rmd_path()));
221 KdenliveSettingsDialog::~KdenliveSettingsDialog() {}
223 void KdenliveSettingsDialog::slotUpdateHDMIModes()
225 QStringList modes = m_configCapture.kcfg_hdmi_capturedevice->itemData(m_configCapture.kcfg_hdmi_capturedevice->currentIndex()).toStringList();
226 m_configCapture.kcfg_hdmi_capturemode->clear();
227 m_configCapture.kcfg_hdmi_capturemode->insertItems(0, modes);
230 void KdenliveSettingsDialog::slotUpdateRmdRegionStatus()
232 m_configCapture.region_group->setHidden(m_configCapture.kcfg_rmd_capture_type->currentIndex() != 1);
235 void KdenliveSettingsDialog::slotEnableCaptureFolder()
237 m_configEnv.capturefolderurl->setEnabled(!m_configEnv.kcfg_capturetoprojectfolder->isChecked());
240 void KdenliveSettingsDialog::checkProfile()
242 m_configProject.kcfg_profiles_list->clear();
243 QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
244 QMapIterator<QString, QString> i(profilesInfo);
245 while (i.hasNext()) {
247 m_configProject.kcfg_profiles_list->addItem(i.key(), i.value());
250 if (!KdenliveSettings::default_profile().isEmpty()) {
251 for (int i = 0; i < m_configProject.kcfg_profiles_list->count(); i++) {
252 if (m_configProject.kcfg_profiles_list->itemData(i).toString() == KdenliveSettings::default_profile()) {
253 m_configProject.kcfg_profiles_list->setCurrentIndex(i);
254 KdenliveSettings::setProfiles_list(i);
261 void KdenliveSettingsDialog::initDevices()
263 // Fill audio drivers
264 m_configSdl.kcfg_audio_driver->addItem(i18n("Automatic"), QString());
266 m_configSdl.kcfg_audio_driver->addItem(i18n("OSS"), "dsp");
267 m_configSdl.kcfg_audio_driver->addItem(i18n("ALSA"), "alsa");
268 m_configSdl.kcfg_audio_driver->addItem(i18n("PulseAudio"), "pulse");
269 m_configSdl.kcfg_audio_driver->addItem(i18n("OSS with DMA access"), "dma");
270 m_configSdl.kcfg_audio_driver->addItem(i18n("Esound daemon"), "esd");
271 m_configSdl.kcfg_audio_driver->addItem(i18n("ARTS daemon"), "artsc");
274 if (!KdenliveSettings::audiodrivername().isEmpty())
275 for (int i = 1; i < m_configSdl.kcfg_audio_driver->count(); i++) {
276 if (m_configSdl.kcfg_audio_driver->itemData(i).toString() == KdenliveSettings::audiodrivername()) {
277 m_configSdl.kcfg_audio_driver->setCurrentIndex(i);
278 KdenliveSettings::setAudio_driver((uint) i);
282 // Fill video drivers
283 m_configSdl.kcfg_video_driver->addItem(i18n("Automatic"), QString());
285 m_configSdl.kcfg_video_driver->addItem(i18n("XVideo"), "x11");
286 m_configSdl.kcfg_video_driver->addItem(i18n("X11"), "x11_noaccel");
287 m_configSdl.kcfg_video_driver->addItem(i18n("XFree86 DGA 2.0"), "dga");
288 m_configSdl.kcfg_video_driver->addItem(i18n("Nano X"), "nanox");
289 m_configSdl.kcfg_video_driver->addItem(i18n("Framebuffer console"), "fbcon");
290 m_configSdl.kcfg_video_driver->addItem(i18n("Direct FB"), "directfb");
291 m_configSdl.kcfg_video_driver->addItem(i18n("SVGAlib"), "svgalib");
292 m_configSdl.kcfg_video_driver->addItem(i18n("General graphics interface"), "ggi");
293 m_configSdl.kcfg_video_driver->addItem(i18n("Ascii art library"), "aalib");
296 // Fill the list of audio playback devices
297 m_configSdl.kcfg_audio_device->addItem(i18n("Default"), QString());
298 m_configCapture.kcfg_rmd_alsa_device->addItem(i18n("Default"), QString());
299 if (!KStandardDirs::findExe("aplay").isEmpty()) {
300 m_readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
301 m_readProcess.setProgram("aplay", QStringList() << "-l");
302 connect(&m_readProcess, SIGNAL(readyReadStandardOutput()) , this, SLOT(slotReadAudioDevices()));
303 m_readProcess.execute(5000);
305 // If aplay is not installed on the system, parse the /proc/asound/pcm file
306 QFile file("/proc/asound/pcm");
307 if (file.open(QIODevice::ReadOnly)) {
308 QTextStream stream(&file);
311 while (!stream.atEnd()) {
312 line = stream.readLine();
313 if (line.contains("playback")) {
314 deviceId = line.section(':', 0, 0);
315 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()));
317 if (line.contains("capture")) {
318 deviceId = line.section(':', 0, 0);
319 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()));
325 if (!KdenliveSettings::audiodevicename().isEmpty()) {
326 // Select correct alsa device
327 int ix = m_configSdl.kcfg_audio_device->findData(KdenliveSettings::audiodevicename());
328 m_configSdl.kcfg_audio_device->setCurrentIndex(ix);
329 KdenliveSettings::setAudio_device(ix);
331 if (!KdenliveSettings::rmd_alsadevicename().isEmpty()) {
332 // Select correct alsa device
333 int ix = m_configCapture.kcfg_rmd_alsa_device->findData(KdenliveSettings::rmd_alsadevicename());
334 m_configCapture.kcfg_rmd_alsa_device->setCurrentIndex(ix);
335 KdenliveSettings::setRmd_alsa_device(ix);
340 void KdenliveSettingsDialog::slotReadAudioDevices()
342 QString result = QString(m_readProcess.readAllStandardOutput());
343 kDebug() << "// / / / / / READING APLAY: ";
345 QStringList lines = result.split('\n');
346 foreach(const QString & data, lines) {
347 kDebug() << "// READING LINE: " << data;
348 if (data.simplified().startsWith("card")) {
349 QString card = data.section(':', 0, 0).section(' ', -1);
350 QString device = data.section(':', 1, 1).section(' ', -1);
351 m_configSdl.kcfg_audio_device->addItem(data.section(':', -1), "plughw:" + card + ',' + device);
352 m_configCapture.kcfg_rmd_alsa_device->addItem(data.section(':', -1), "plughw:" + card + ',' + device);
357 void KdenliveSettingsDialog::showPage(int page, int option)
361 setCurrentPage(m_page1);
364 setCurrentPage(m_page2);
367 setCurrentPage(m_page3);
370 setCurrentPage(m_page4);
371 m_configCapture.tabWidget->setCurrentIndex(option);
374 setCurrentPage(m_page5);
377 setCurrentPage(m_page6);
380 setCurrentPage(m_page7);
383 setCurrentPage(m_page1);
387 void KdenliveSettingsDialog::slotEditVideoApplication()
389 KService::Ptr service;
390 KOpenWithDialog dlg(KUrl::List(), i18n("Select default video player"), m_configEnv.kcfg_defaultplayerapp->text(), this);
391 if (dlg.exec() != QDialog::Accepted)
394 service = dlg.service();
395 m_configEnv.kcfg_defaultplayerapp->setText(service->exec());
398 void KdenliveSettingsDialog::slotEditAudioApplication()
400 KService::Ptr service;
401 KOpenWithDialog dlg(KUrl::List(), i18n("Select default audio editor"), m_configEnv.kcfg_defaultaudioapp->text(), this);
402 if (dlg.exec() != QDialog::Accepted)
405 service = dlg.service();
406 m_configEnv.kcfg_defaultaudioapp->setText(service->exec());
409 void KdenliveSettingsDialog::slotEditImageApplication()
411 KService::Ptr service;
412 KOpenWithDialog dlg(KUrl::List(), i18n("Select default image editor"), m_configEnv.kcfg_defaultimageapp->text(), this);
413 if (dlg.exec() != QDialog::Accepted)
416 service = dlg.service();
417 m_configEnv.kcfg_defaultimageapp->setText(service->exec());
420 #ifndef NO_JOGSHUTTLE
421 void KdenliveSettingsDialog::slotCheckShuttle(int state)
423 m_configShuttle.config_group->setEnabled(state);
424 if (m_configShuttle.shuttledevicelist->count() == 0) {
426 QString baseName = "/dev/input/event";
428 for (int i = 0; i < 30; i++) {
429 QString filename = baseName + QString::number(i);
430 kDebug() << "/// CHECKING OFR: " << filename;
432 char name[256] = "unknown";
433 fd = KDE_open((char *) filename.toUtf8().data(), O_RDONLY);
434 if (fd >= 0 && ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0) {
435 m_configShuttle.shuttledevicelist->addItem(name, filename);
439 if (KdenliveSettings::shuttledevice().isEmpty()) QTimer::singleShot(1500, this, SLOT(slotUpdateShuttleDevice()));
443 void KdenliveSettingsDialog::slotUpdateShuttleDevice(int ix)
445 QString device = m_configShuttle.shuttledevicelist->itemData(ix).toString();
446 //KdenliveSettings::setShuttledevice(device);
447 m_configShuttle.kcfg_shuttledevice->setText(device);
449 #endif /* NO_JOGSHUTTLE */
451 void KdenliveSettingsDialog::rebuildVideo4Commands()
453 QString captureCommand;
454 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();
456 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();
457 m_configCapture.kcfg_video4capture->setText(captureCommand);
461 void KdenliveSettingsDialog::updateSettings()
463 //kDebug() << "// // // KCONFIG UPDATE called";
465 m_defaultProfile = m_configProject.kcfg_profiles_list->currentText();
466 KdenliveSettings::setDefault_profile(m_defaultPath);
468 bool resetProfile = false;
469 bool updateCapturePath = false;
471 if (m_configEnv.kcfg_capturetoprojectfolder->isChecked() != KdenliveSettings::capturetoprojectfolder()) {
472 KdenliveSettings::setCapturetoprojectfolder(m_configEnv.kcfg_capturetoprojectfolder->isChecked());
473 updateCapturePath = true;
476 if (m_configEnv.capturefolderurl->url().path() != KdenliveSettings::capturefolder()) {
477 KdenliveSettings::setCapturefolder(m_configEnv.capturefolderurl->url().path());
478 updateCapturePath = true;
481 if (m_configCapture.kcfg_dvgrabfilename->text() != KdenliveSettings::dvgrabfilename()) {
482 KdenliveSettings::setDvgrabfilename(m_configCapture.kcfg_dvgrabfilename->text());
483 updateCapturePath = true;
486 if ((uint) m_configCapture.kcfg_firewireformat->currentIndex() != KdenliveSettings::firewireformat()) {
487 KdenliveSettings::setFirewireformat(m_configCapture.kcfg_firewireformat->currentIndex());
488 updateCapturePath = true;
491 if (updateCapturePath) emit updateCaptureFolder();
493 QString value = m_configCapture.kcfg_rmd_alsa_device->itemData(m_configCapture.kcfg_rmd_alsa_device->currentIndex()).toString();
494 if (value != KdenliveSettings::rmd_alsadevicename()) {
495 KdenliveSettings::setRmd_alsadevicename(value);
498 value = m_configCapture.kcfg_rmd_audio_freq->itemText(m_configCapture.kcfg_rmd_audio_freq->currentIndex());
499 kDebug() << "// AUDIO FREQ VALUE: " << value << ", CURRENT: " << KdenliveSettings::rmd_freq() << ", IX: " << m_configCapture.kcfg_rmd_audio_freq->currentIndex();
500 if (value != KdenliveSettings::rmd_freq()) {
501 kDebug() << "// SETTING AUDIO FREQ TO: " << value;
502 KdenliveSettings::setRmd_freq(value);
505 value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
506 if (value != KdenliveSettings::audiodrivername()) {
507 KdenliveSettings::setAudiodrivername(value);
511 if (value == "alsa") {
512 // Audio device setting is only valid for alsa driver
513 value = m_configSdl.kcfg_audio_device->itemData(m_configSdl.kcfg_audio_device->currentIndex()).toString();
514 if (value != KdenliveSettings::audiodevicename()) {
515 KdenliveSettings::setAudiodevicename(value);
518 } else if (KdenliveSettings::audiodevicename().isEmpty() == false) {
519 KdenliveSettings::setAudiodevicename(QString::null);
523 value = m_configSdl.kcfg_video_driver->itemData(m_configSdl.kcfg_video_driver->currentIndex()).toString();
524 if (value != KdenliveSettings::videodrivername()) {
525 KdenliveSettings::setVideodrivername(value);
529 if (m_configSdl.kcfg_window_background->color() != KdenliveSettings::window_background()) {
530 KdenliveSettings::setWindow_background(m_configSdl.kcfg_window_background->color());
534 if (m_configSdl.kcfg_volume->value() != KdenliveSettings::volume()) {
535 KdenliveSettings::setVolume(m_configSdl.kcfg_volume->value());
539 bool updatePreview = false;
540 if (m_configSdl.kcfg_dropbframes->isChecked() != KdenliveSettings::dropbframes()) {
541 KdenliveSettings::setDropbframes(m_configSdl.kcfg_dropbframes->isChecked());
542 updatePreview = true;
546 // The transcoding profiles were modified, save.
548 saveTranscodeProfiles();
551 #if KDE_IS_VERSION(4,3,0)
552 KConfigDialog::settingsChangedSlot();
555 //KConfigDialog::updateSettings();
556 if (resetProfile) emit doResetProfile();
557 if (updatePreview) emit updatePreviewSettings();
560 void KdenliveSettingsDialog::slotUpdateDisplay()
562 QString currentProfile = m_configProject.kcfg_profiles_list->itemData(m_configProject.kcfg_profiles_list->currentIndex()).toString();
563 QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
564 m_configProject.p_size->setText(values.value("width") + 'x' + values.value("height"));
565 m_configProject.p_fps->setText(values.value("frame_rate_num") + '/' + values.value("frame_rate_den"));
566 m_configProject.p_aspect->setText(values.value("sample_aspect_num") + '/' + values.value("sample_aspect_den"));
567 m_configProject.p_display->setText(values.value("display_aspect_num") + '/' + values.value("display_aspect_den"));
568 if (values.value("progressive").toInt() == 0)
569 m_configProject.p_progressive->setText(i18n("Interlaced"));
571 m_configProject.p_progressive->setText(i18n("Progressive"));
572 m_defaultProfile = m_configProject.kcfg_profiles_list->itemText(m_configProject.kcfg_profiles_list->currentIndex());
573 m_defaultPath = currentProfile;
576 void KdenliveSettingsDialog::slotCheckAlsaDriver()
578 QString value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
579 m_configSdl.kcfg_audio_device->setEnabled(value == "alsa");
582 void KdenliveSettingsDialog::loadTranscodeProfiles()
584 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
585 KConfigGroup transConfig(config, "Transcoding");
587 m_configTranscode.profiles_list->blockSignals(true);
588 QMap< QString, QString > profiles = transConfig.entryMap();
589 QMapIterator<QString, QString> i(profiles);
590 while (i.hasNext()) {
592 QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i.key() << i.value());
593 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
595 m_configTranscode.profiles_list->blockSignals(false);
598 void KdenliveSettingsDialog::saveTranscodeProfiles()
600 KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
601 //KSharedConfigPtr config = KGlobal::config();
602 KConfigGroup transConfig(config, "Transcoding");
604 transConfig.deleteGroup();
605 int max = m_configTranscode.profiles_list->topLevelItemCount();
606 for (int i = 0; i < max; i++) {
607 QTreeWidgetItem *item = m_configTranscode.profiles_list->topLevelItem(i);
608 transConfig.writeEntry(item->text(0), item->text(1));
613 void KdenliveSettingsDialog::slotAddTranscode()
615 QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i18n("Name") << i18n("Parameters"));
616 item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
617 m_configTranscode.profiles_list->setCurrentItem(item);
618 m_configTranscode.profiles_list->editItem(item);
619 slotDialogModified();
622 void KdenliveSettingsDialog::slotDeleteTranscode()
624 QTreeWidgetItem *item = m_configTranscode.profiles_list->currentItem();
625 if (item == NULL) return;
627 slotDialogModified();
630 void KdenliveSettingsDialog::slotDialogModified()
633 #if KDE_IS_VERSION(4,3,0)
634 KConfigDialog::updateButtons();
639 bool KdenliveSettingsDialog::hasChanged()
641 if (m_modified) return true;
642 return KConfigDialog::hasChanged();
645 void KdenliveSettingsDialog::slotUpdatev4lDevice()
647 QString device = m_configCapture.kcfg_detectedv4ldevices->itemData(m_configCapture.kcfg_detectedv4ldevices->currentIndex()).toString();
648 if (!device.isEmpty()) m_configCapture.kcfg_video4vdevice->setText(device);
649 QString size = m_configCapture.kcfg_detectedv4ldevices->itemData(m_configCapture.kcfg_detectedv4ldevices->currentIndex(), Qt::UserRole + 1).toString();
650 if (!size.isEmpty()) m_configCapture.kcfg_video4size->setText(size);
654 #include "kdenlivesettingsdialog.moc"