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