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