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