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