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