]> git.sesse.net Git - kdenlive/blob - src/kdenlivesettingsdialog.cpp
Captured files should go to project folder if wanted:
[kdenlive] / src / kdenlivesettingsdialog.cpp
1 /***************************************************************************
2  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20 #include "kdenlivesettingsdialog.h"
21 #include "profilesdialog.h"
22 #include "kdenlivesettings.h"
23
24 #include <KStandardDirs>
25 #include <KDebug>
26 #include <kopenwithdialog.h>
27 #include <KConfigDialogManager>
28 #include <kde_file.h>
29 #include <KIO/NetAccess>
30 #include <kdeversion.h>
31
32 #include <QDir>
33 #include <QTimer>
34 #include <QTreeWidgetItem>
35
36 #include <stdlib.h>
37 #include <stdio.h>
38 #include <unistd.h>
39 #include <fcntl.h>
40 #ifndef NO_JOGSHUTTLE
41 #include <linux/input.h>
42 #endif /* NO_JOGSHUTTLE */
43
44
45 KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent) :
46     KConfigDialog(parent, "settings", KdenliveSettings::self()),
47     m_modified(false)
48 {
49
50     QWidget *p1 = new QWidget;
51     m_configMisc.setupUi(p1);
52     m_page1 = addPage(p1, i18n("Misc"), "configure");
53
54     // Hide multi tab option until Kdenlive really supports it
55     m_configMisc.kcfg_activatetabs->setVisible(false);
56
57     QWidget *p8 = new QWidget;
58     m_configProject.setupUi(p8);
59     m_page8 = addPage(p8, i18n("Project Defaults"), "document-new");
60
61     QWidget *p3 = new QWidget;
62     m_configTimeline.setupUi(p3);
63     m_page3 = addPage(p3, i18n("Timeline"), "video-display");
64
65     QWidget *p2 = new QWidget;
66     m_configEnv.setupUi(p2);
67     m_configEnv.mltpathurl->setMode(KFile::Directory);
68     m_configEnv.mltpathurl->lineEdit()->setObjectName("kcfg_mltpath");
69     m_configEnv.rendererpathurl->lineEdit()->setObjectName("kcfg_rendererpath");
70     m_configEnv.tmppathurl->setMode(KFile::Directory);
71     m_configEnv.tmppathurl->lineEdit()->setObjectName("kcfg_currenttmpfolder");
72     m_configEnv.projecturl->setMode(KFile::Directory);
73     m_configEnv.projecturl->lineEdit()->setObjectName("kcfg_defaultprojectfolder");
74     m_configEnv.capturefolderurl->setMode(KFile::Directory);
75     m_configEnv.capturefolderurl->lineEdit()->setObjectName("kcfg_capturefolder");
76     m_configEnv.capturefolderurl->setEnabled(!KdenliveSettings::capturetoprojectfolder());
77     connect(m_configEnv.kcfg_capturetoprojectfolder, SIGNAL(clicked()), this, SLOT(slotEnableCaptureFolder()));
78     m_page2 = addPage(p2, i18n("Environment"), "application-x-executable-script");
79
80     QWidget *p4 = new QWidget;
81     m_configCapture.setupUi(p4);
82     m_page4 = addPage(p4, i18n("Capture"), "media-record");
83     m_configCapture.tabWidget->setCurrentIndex(KdenliveSettings::defaultcapture());
84 #ifdef Q_WS_MAC
85     m_configCapture.tabWidget->setEnabled(false);
86     m_configCapture.kcfg_defaultcapture->setEnabled(false);
87     m_configCapture.label->setText(i18n("Capture is not yet available on OS X."));
88 #endif
89
90     QWidget *p5 = new QWidget;
91     m_configShuttle.setupUi(p5);
92 #ifndef NO_JOGSHUTTLE
93     connect(m_configShuttle.kcfg_enableshuttle, SIGNAL(stateChanged(int)), this, SLOT(slotCheckShuttle(int)));
94     connect(m_configShuttle.shuttledevicelist, SIGNAL(activated(int)), this, SLOT(slotUpdateShuttleDevice(int)));
95     slotCheckShuttle(KdenliveSettings::enableshuttle());
96     m_configShuttle.shuttledisabled->hide();
97 #else
98     m_configShuttle.kcfg_enableshuttle->hide();
99     m_configShuttle.kcfg_enableshuttle->setDisabled(true);
100 #endif /* NO_JOGSHUTTLE */
101     m_page5 = addPage(p5, i18n("JogShuttle"), "input-mouse");
102
103     QWidget *p6 = new QWidget;
104     m_configSdl.setupUi(p6);
105
106     // Disable drop B frames, see Kdenlive issue #1330
107     m_configSdl.groupBox->setHidden(true);
108
109     m_page6 = addPage(p6, i18n("Playback"), "media-playback-start");
110
111     QWidget *p7 = new QWidget;
112     m_configTranscode.setupUi(p7);
113     m_page7 = addPage(p7, i18n("Transcode"), "edit-copy");
114     connect(m_configTranscode.button_add, SIGNAL(clicked()), this, SLOT(slotAddTranscode()));
115     connect(m_configTranscode.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteTranscode()));
116     connect(m_configTranscode.profiles_list, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotDialogModified()));
117
118     QStringList actions;
119     actions << i18n("Do nothing");
120     actions << i18n("Play / Pause");
121     actions << i18n("Cut");
122     m_configShuttle.kcfg_shuttle1->addItems(actions);
123     m_configShuttle.kcfg_shuttle2->addItems(actions);
124     m_configShuttle.kcfg_shuttle3->addItems(actions);
125     m_configShuttle.kcfg_shuttle4->addItems(actions);
126     m_configShuttle.kcfg_shuttle5->addItems(actions);
127
128     connect(m_configCapture.kcfg_video4vdevice, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
129     connect(m_configCapture.kcfg_video4adevice, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
130     connect(m_configCapture.kcfg_video4vcodec, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
131     connect(m_configCapture.kcfg_video4acodec, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
132     connect(m_configCapture.kcfg_video4vformat, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
133     connect(m_configCapture.kcfg_video4aformat, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
134     connect(m_configCapture.kcfg_video4size, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
135     connect(m_configCapture.kcfg_video4rate, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
136
137     connect(m_configCapture.kcfg_rmd_capture_audio, SIGNAL(clicked(bool)), m_configCapture.audio_group, SLOT(setVisible(bool)));
138
139     m_configCapture.audio_group->setVisible(KdenliveSettings::rmd_capture_audio());
140
141     connect(m_configEnv.kp_image, SIGNAL(clicked()), this, SLOT(slotEditImageApplication()));
142     connect(m_configEnv.kp_audio, SIGNAL(clicked()), this, SLOT(slotEditAudioApplication()));
143     connect(m_configEnv.kp_player, SIGNAL(clicked()), this, SLOT(slotEditVideoApplication()));
144
145     checkProfile();
146
147     slotUpdateDisplay();
148
149     connect(m_configSdl.kcfg_audio_driver, SIGNAL(currentIndexChanged(int)), this, SLOT(slotCheckAlsaDriver()));
150     initDevices();
151     connect(m_configProject.kcfg_profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
152     connect(m_configCapture.kcfg_rmd_capture_type, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateRmdRegionStatus()));
153
154     slotUpdateRmdRegionStatus();
155     loadTranscodeProfiles();
156
157
158     //HACK: check dvgrab version, because only dvgrab >= 3.3 supports
159     //   --timestamp option without bug
160
161     if (KdenliveSettings::dvgrab_path().isEmpty() || !QFile::exists(KdenliveSettings::dvgrab_path())) {
162         QString dvgrabpath = KStandardDirs::findExe("dvgrab");
163         KdenliveSettings::setDvgrab_path(dvgrabpath);
164     }
165
166
167     double dvgrabVersion = 0;
168     if (!KdenliveSettings::dvgrab_path().isEmpty()) {
169         QProcess *versionCheck = new QProcess;
170         versionCheck->setProcessChannelMode(QProcess::MergedChannels);
171         versionCheck->start("dvgrab", QStringList() << "--version");
172         if (versionCheck->waitForFinished()) {
173             QString version = QString(versionCheck->readAll()).simplified();
174             if (version.contains(' ')) version = version.section(' ', -1);
175             dvgrabVersion = version.toDouble();
176
177             kDebug() << "// FOUND DVGRAB VERSION: " << dvgrabVersion;
178         }
179         delete versionCheck;
180         if (dvgrabVersion < 3.3) {
181             KdenliveSettings::setFirewiretimestamp(false);
182             m_configCapture.kcfg_firewiretimestamp->setEnabled(false);
183         }
184         m_configCapture.dvgrab_info->setText(i18n("dvgrab version %1 at %2", dvgrabVersion, KdenliveSettings::dvgrab_path()));
185     } else m_configCapture.dvgrab_info->setText(i18n("<strong><em>dvgrab</em> utility not found, please install it for firewire capture</strong>"));
186
187     if (KdenliveSettings::rmd_path().isEmpty() || !QFile::exists(KdenliveSettings::rmd_path())) {
188         QString rmdpath = KStandardDirs::findExe("recordmydesktop");
189         KdenliveSettings::setRmd_path(rmdpath);
190     }
191     if (KdenliveSettings::rmd_path().isEmpty())
192         m_configCapture.rmd_info->setText(i18n("<strong><em>Recordmydesktop</em> utility not found, please install it for screen grabs</strong>"));
193     else
194         m_configCapture.rmd_info->setText(i18n("Recordmydesktop found at: %1", KdenliveSettings::rmd_path()));
195 }
196
197 KdenliveSettingsDialog::~KdenliveSettingsDialog() {}
198
199 void KdenliveSettingsDialog::slotUpdateRmdRegionStatus()
200 {
201     m_configCapture.region_group->setHidden(m_configCapture.kcfg_rmd_capture_type->currentIndex() != 1);
202 }
203
204 void KdenliveSettingsDialog::slotEnableCaptureFolder()
205 {
206     m_configEnv.capturefolderurl->setEnabled(!m_configEnv.kcfg_capturetoprojectfolder->isChecked());
207 }
208
209 void KdenliveSettingsDialog::checkProfile()
210 {
211     m_configProject.kcfg_profiles_list->clear();
212     QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
213     QMapIterator<QString, QString> i(profilesInfo);
214     while (i.hasNext()) {
215         i.next();
216         m_configProject.kcfg_profiles_list->addItem(i.key(), i.value());
217     }
218
219     if (!KdenliveSettings::default_profile().isEmpty()) {
220         for (int i = 0; i < m_configProject.kcfg_profiles_list->count(); i++) {
221             if (m_configProject.kcfg_profiles_list->itemData(i).toString() == KdenliveSettings::default_profile()) {
222                 m_configProject.kcfg_profiles_list->setCurrentIndex(i);
223                 KdenliveSettings::setProfiles_list(i);
224                 break;
225             }
226         }
227     }
228 }
229
230 void KdenliveSettingsDialog::initDevices()
231 {
232     // Fill audio drivers
233     m_configSdl.kcfg_audio_driver->addItem(i18n("Automatic"), QString());
234 #ifndef Q_WS_MAC
235     m_configSdl.kcfg_audio_driver->addItem(i18n("OSS"), "dsp");
236     m_configSdl.kcfg_audio_driver->addItem(i18n("ALSA"), "alsa");
237     m_configSdl.kcfg_audio_driver->addItem(i18n("PulseAudio"), "pulse");
238     m_configSdl.kcfg_audio_driver->addItem(i18n("OSS with DMA access"), "dma");
239     m_configSdl.kcfg_audio_driver->addItem(i18n("Esound daemon"), "esd");
240     m_configSdl.kcfg_audio_driver->addItem(i18n("ARTS daemon"), "artsc");
241 #endif
242
243     if (!KdenliveSettings::audiodrivername().isEmpty())
244         for (int i = 1; i < m_configSdl.kcfg_audio_driver->count(); i++) {
245             if (m_configSdl.kcfg_audio_driver->itemData(i).toString() == KdenliveSettings::audiodrivername()) {
246                 m_configSdl.kcfg_audio_driver->setCurrentIndex(i);
247                 KdenliveSettings::setAudio_driver((uint) i);
248             }
249         }
250
251     // Fill video drivers
252     m_configSdl.kcfg_video_driver->addItem(i18n("Automatic"), QString());
253 #ifndef Q_WS_MAC
254     m_configSdl.kcfg_video_driver->addItem(i18n("XVideo"), "x11");
255     m_configSdl.kcfg_video_driver->addItem(i18n("X11"), "x11_noaccel");
256     m_configSdl.kcfg_video_driver->addItem(i18n("XFree86 DGA 2.0"), "dga");
257     m_configSdl.kcfg_video_driver->addItem(i18n("Nano X"), "nanox");
258     m_configSdl.kcfg_video_driver->addItem(i18n("Framebuffer console"), "fbcon");
259     m_configSdl.kcfg_video_driver->addItem(i18n("Direct FB"), "directfb");
260     m_configSdl.kcfg_video_driver->addItem(i18n("SVGAlib"), "svgalib");
261     m_configSdl.kcfg_video_driver->addItem(i18n("General graphics interface"), "ggi");
262     m_configSdl.kcfg_video_driver->addItem(i18n("Ascii art library"), "aalib");
263 #endif
264
265     // Fill the list of audio playback devices
266     m_configSdl.kcfg_audio_device->addItem(i18n("Default"), QString());
267     m_configCapture.kcfg_rmd_alsa_device->addItem(i18n("Default"), QString());
268     if (!KStandardDirs::findExe("aplay").isEmpty()) {
269         m_readProcess.setOutputChannelMode(KProcess::OnlyStdoutChannel);
270         m_readProcess.setProgram("aplay", QStringList() << "-l");
271         connect(&m_readProcess, SIGNAL(readyReadStandardOutput()) , this, SLOT(slotReadAudioDevices()));
272         m_readProcess.execute(5000);
273     } else {
274         // If aplay is not installed on the system, parse the /proc/asound/pcm file
275         QFile file("/proc/asound/pcm");
276         if (file.open(QIODevice::ReadOnly)) {
277             QTextStream stream(&file);
278             QString line;
279             QString deviceId;
280             while (!stream.atEnd()) {
281                 line = stream.readLine();
282                 if (line.contains("playback")) {
283                     deviceId = line.section(':', 0, 0);
284                     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()));
285                 }
286                 if (line.contains("capture")) {
287                     deviceId = line.section(':', 0, 0);
288                     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()));
289                 }
290             }
291             file.close();
292         }
293     }
294     if (!KdenliveSettings::audiodevicename().isEmpty()) {
295         // Select correct alsa device
296         int ix = m_configSdl.kcfg_audio_device->findData(KdenliveSettings::audiodevicename());
297         m_configSdl.kcfg_audio_device->setCurrentIndex(ix);
298         KdenliveSettings::setAudio_device(ix);
299     }
300     if (!KdenliveSettings::rmd_alsadevicename().isEmpty()) {
301         // Select correct alsa device
302         int ix = m_configCapture.kcfg_rmd_alsa_device->findData(KdenliveSettings::rmd_alsadevicename());
303         m_configCapture.kcfg_rmd_alsa_device->setCurrentIndex(ix);
304         KdenliveSettings::setRmd_alsa_device(ix);
305     }
306 }
307
308
309 void KdenliveSettingsDialog::slotReadAudioDevices()
310 {
311     QString result = QString(m_readProcess.readAllStandardOutput());
312     kDebug() << "// / / / / / READING APLAY: ";
313     kDebug() << result;
314     QStringList lines = result.split('\n');
315     foreach(const QString & data, lines) {
316         kDebug() << "// READING LINE: " << data;
317         if (data.simplified().startsWith("card")) {
318             QString card = data.section(':', 0, 0).section(' ', -1);
319             QString device = data.section(':', 1, 1).section(' ', -1);
320             m_configSdl.kcfg_audio_device->addItem(data.section(':', -1), "plughw:" + card + ',' + device);
321             m_configCapture.kcfg_rmd_alsa_device->addItem(data.section(':', -1), "plughw:" + card + ',' + device);
322         }
323     }
324 }
325
326 void KdenliveSettingsDialog::showPage(int page, int option)
327 {
328     switch (page) {
329     case 1:
330         setCurrentPage(m_page1);
331         break;
332     case 2:
333         setCurrentPage(m_page2);
334         break;
335     case 3:
336         setCurrentPage(m_page3);
337         break;
338     case 4:
339         setCurrentPage(m_page4);
340         m_configCapture.tabWidget->setCurrentIndex(option);
341         break;
342     case 5:
343         setCurrentPage(m_page5);
344         break;
345     case 6:
346         setCurrentPage(m_page6);
347         break;
348     case 7:
349         setCurrentPage(m_page7);
350         break;
351     default:
352         setCurrentPage(m_page1);
353     }
354 }
355
356 void KdenliveSettingsDialog::slotEditVideoApplication()
357 {
358     KService::Ptr service;
359     KOpenWithDialog dlg(KUrl::List(), i18n("Select default video player"), m_configEnv.kcfg_defaultplayerapp->text(), this);
360     if (dlg.exec() != QDialog::Accepted)
361         return;
362
363     service = dlg.service();
364     m_configEnv.kcfg_defaultplayerapp->setText(service->exec());
365 }
366
367 void KdenliveSettingsDialog::slotEditAudioApplication()
368 {
369     KService::Ptr service;
370     KOpenWithDialog dlg(KUrl::List(), i18n("Select default audio editor"), m_configEnv.kcfg_defaultaudioapp->text(), this);
371     if (dlg.exec() != QDialog::Accepted)
372         return;
373
374     service = dlg.service();
375     m_configEnv.kcfg_defaultaudioapp->setText(service->exec());
376 }
377
378 void KdenliveSettingsDialog::slotEditImageApplication()
379 {
380     KService::Ptr service;
381     KOpenWithDialog dlg(KUrl::List(), i18n("Select default image editor"), m_configEnv.kcfg_defaultimageapp->text(), this);
382     if (dlg.exec() != QDialog::Accepted)
383         return;
384
385     service = dlg.service();
386     m_configEnv.kcfg_defaultimageapp->setText(service->exec());
387 }
388
389 #ifndef NO_JOGSHUTTLE
390 void KdenliveSettingsDialog::slotCheckShuttle(int state)
391 {
392     m_configShuttle.config_group->setEnabled(state);
393     if (m_configShuttle.shuttledevicelist->count() == 0) {
394         // parse devices
395         QString baseName = "/dev/input/event";
396         int fd;
397         for (int i = 0; i < 30; i++) {
398             QString filename = baseName + QString::number(i);
399             kDebug() << "/// CHECKING OFR: " << filename;
400
401             char name[256] = "unknown";
402             fd = KDE_open((char *) filename.toUtf8().data(), O_RDONLY);
403             if (fd >= 0 && ioctl(fd, EVIOCGNAME(sizeof(name)), name) >= 0) {
404                 m_configShuttle.shuttledevicelist->addItem(name, filename);
405             }
406             ::close(fd);
407         }
408         if (KdenliveSettings::shuttledevice().isEmpty()) QTimer::singleShot(1500, this, SLOT(slotUpdateShuttleDevice()));
409     }
410 }
411
412 void KdenliveSettingsDialog::slotUpdateShuttleDevice(int ix)
413 {
414     QString device = m_configShuttle.shuttledevicelist->itemData(ix).toString();
415     //KdenliveSettings::setShuttledevice(device);
416     m_configShuttle.kcfg_shuttledevice->setText(device);
417 }
418 #endif /* NO_JOGSHUTTLE */
419
420 void KdenliveSettingsDialog::rebuildVideo4Commands()
421 {
422     QString captureCommand;
423     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();
424
425     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();
426     m_configCapture.kcfg_video4capture->setText(captureCommand);
427 }
428
429
430 void KdenliveSettingsDialog::updateSettings()
431 {
432     //kDebug() << "// // // KCONFIG UPDATE called";
433
434     m_defaultProfile = m_configProject.kcfg_profiles_list->currentText();
435     KdenliveSettings::setDefault_profile(m_defaultPath);
436
437     bool resetProfile = false;
438     bool updateCapturePath = false;
439
440     if (m_configEnv.kcfg_capturetoprojectfolder->isChecked() != KdenliveSettings::capturetoprojectfolder()) {
441         KdenliveSettings::setCapturetoprojectfolder(m_configEnv.kcfg_capturetoprojectfolder->isChecked());
442         updateCapturePath = true;
443     }
444
445     if (m_configEnv.capturefolderurl->url().path() != KdenliveSettings::capturefolder()) {
446         KdenliveSettings::setCapturefolder(m_configEnv.capturefolderurl->url().path());
447         updateCapturePath = true;
448     }
449
450     if (m_configCapture.kcfg_dvgrabfilename->text() != KdenliveSettings::dvgrabfilename()) {
451         KdenliveSettings::setDvgrabfilename(m_configCapture.kcfg_dvgrabfilename->text());
452         updateCapturePath = true;
453     }
454
455     if ((uint) m_configCapture.kcfg_firewireformat->currentIndex() != KdenliveSettings::firewireformat()) {
456         KdenliveSettings::setFirewireformat(m_configCapture.kcfg_firewireformat->currentIndex());
457         updateCapturePath = true;
458     }
459
460     if (updateCapturePath) emit updateCaptureFolder();
461
462     QString value = m_configCapture.kcfg_rmd_alsa_device->itemData(m_configCapture.kcfg_rmd_alsa_device->currentIndex()).toString();
463     if (value != KdenliveSettings::rmd_alsadevicename()) {
464         KdenliveSettings::setRmd_alsadevicename(value);
465     }
466
467     value = m_configCapture.kcfg_rmd_audio_freq->itemText(m_configCapture.kcfg_rmd_audio_freq->currentIndex());
468     kDebug() << "// AUDIO FREQ VALUE: " << value << ", CURRENT: " << KdenliveSettings::rmd_freq() << ", IX: " << m_configCapture.kcfg_rmd_audio_freq->currentIndex();
469     if (value != KdenliveSettings::rmd_freq()) {
470         kDebug() << "// SETTING AUDIO FREQ TO: " << value;
471         KdenliveSettings::setRmd_freq(value);
472     }
473
474     value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
475     if (value != KdenliveSettings::audiodrivername()) {
476         KdenliveSettings::setAudiodrivername(value);
477         resetProfile = true;
478     }
479
480     if (value == "alsa") {
481         // Audio device setting is only valid for alsa driver
482         value = m_configSdl.kcfg_audio_device->itemData(m_configSdl.kcfg_audio_device->currentIndex()).toString();
483         if (value != KdenliveSettings::audiodevicename()) {
484             KdenliveSettings::setAudiodevicename(value);
485             resetProfile = true;
486         }
487     } else if (KdenliveSettings::audiodevicename().isEmpty() == false) {
488         KdenliveSettings::setAudiodevicename(QString::null);
489         resetProfile = true;
490     }
491
492     value = m_configSdl.kcfg_video_driver->itemData(m_configSdl.kcfg_video_driver->currentIndex()).toString();
493     if (value != KdenliveSettings::videodrivername()) {
494         KdenliveSettings::setVideodrivername(value);
495         resetProfile = true;
496     }
497
498     if (m_configSdl.kcfg_window_background->color() != KdenliveSettings::window_background()) {
499         KdenliveSettings::setWindow_background(m_configSdl.kcfg_window_background->color());
500         resetProfile = true;
501     }
502
503     if (m_configSdl.kcfg_volume->value() != KdenliveSettings::volume()) {
504         KdenliveSettings::setVolume(m_configSdl.kcfg_volume->value());
505         resetProfile = true;
506     }
507
508     bool updatePreview = false;
509     if (m_configSdl.kcfg_dropbframes->isChecked() != KdenliveSettings::dropbframes()) {
510         KdenliveSettings::setDropbframes(m_configSdl.kcfg_dropbframes->isChecked());
511         updatePreview = true;
512     }
513
514     if (m_modified) {
515         // The transcoding profiles were modified, save.
516         m_modified = false;
517         saveTranscodeProfiles();
518     }
519
520 #if KDE_IS_VERSION(4,3,0)
521     KConfigDialog::settingsChangedSlot();
522 #endif
523
524     //KConfigDialog::updateSettings();
525     if (resetProfile) emit doResetProfile();
526     if (updatePreview) emit updatePreviewSettings();
527 }
528
529 void KdenliveSettingsDialog::slotUpdateDisplay()
530 {
531     QString currentProfile = m_configProject.kcfg_profiles_list->itemData(m_configProject.kcfg_profiles_list->currentIndex()).toString();
532     QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
533     m_configProject.p_size->setText(values.value("width") + 'x' + values.value("height"));
534     m_configProject.p_fps->setText(values.value("frame_rate_num") + '/' + values.value("frame_rate_den"));
535     m_configProject.p_aspect->setText(values.value("sample_aspect_num") + '/' + values.value("sample_aspect_den"));
536     m_configProject.p_display->setText(values.value("display_aspect_num") + '/' + values.value("display_aspect_den"));
537     if (values.value("progressive").toInt() == 0)
538         m_configProject.p_progressive->setText(i18n("Interlaced"));
539     else
540         m_configProject.p_progressive->setText(i18n("Progressive"));
541     m_defaultProfile = m_configProject.kcfg_profiles_list->itemText(m_configProject.kcfg_profiles_list->currentIndex());
542     m_defaultPath = currentProfile;
543 }
544
545 void KdenliveSettingsDialog::slotCheckAlsaDriver()
546 {
547     QString value = m_configSdl.kcfg_audio_driver->itemData(m_configSdl.kcfg_audio_driver->currentIndex()).toString();
548     m_configSdl.kcfg_audio_device->setEnabled(value == "alsa");
549 }
550
551 void KdenliveSettingsDialog::loadTranscodeProfiles()
552 {
553     KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
554     KConfigGroup transConfig(config, "Transcoding");
555     // read the entries
556     m_configTranscode.profiles_list->blockSignals(true);
557     QMap< QString, QString > profiles = transConfig.entryMap();
558     QMapIterator<QString, QString> i(profiles);
559     while (i.hasNext()) {
560         i.next();
561         QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i.key() << i.value());
562         item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
563     }
564     m_configTranscode.profiles_list->blockSignals(false);
565 }
566
567 void KdenliveSettingsDialog::saveTranscodeProfiles()
568 {
569     KSharedConfigPtr config = KSharedConfig::openConfig("kdenlivetranscodingrc");
570     //KSharedConfigPtr config = KGlobal::config();
571     KConfigGroup transConfig(config, "Transcoding");
572     // read the entries
573     transConfig.deleteGroup();
574     int max = m_configTranscode.profiles_list->topLevelItemCount();
575     for (int i = 0; i < max; i++) {
576         QTreeWidgetItem *item = m_configTranscode.profiles_list->topLevelItem(i);
577         transConfig.writeEntry(item->text(0), item->text(1));
578     }
579     config->sync();
580 }
581
582 void KdenliveSettingsDialog::slotAddTranscode()
583 {
584     QTreeWidgetItem *item = new QTreeWidgetItem(m_configTranscode.profiles_list, QStringList() << i18n("Name") << i18n("Parameters"));
585     item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
586     m_configTranscode.profiles_list->setCurrentItem(item);
587     m_configTranscode.profiles_list->editItem(item);
588     slotDialogModified();
589 }
590
591 void KdenliveSettingsDialog::slotDeleteTranscode()
592 {
593     QTreeWidgetItem *item = m_configTranscode.profiles_list->currentItem();
594     if (item == NULL) return;
595     delete item;
596     slotDialogModified();
597 }
598
599 void KdenliveSettingsDialog::slotDialogModified()
600 {
601     m_modified = true;
602 #if KDE_IS_VERSION(4,3,0)
603     KConfigDialog::updateButtons();
604 #endif
605 }
606
607 //virtual
608 bool KdenliveSettingsDialog::hasChanged()
609 {
610     if (m_modified) return true;
611     return KConfigDialog::hasChanged();
612 }
613
614
615
616 #include "kdenlivesettingsdialog.moc"
617
618