]> git.sesse.net Git - kdenlive/blob - src/kdenlivesettingsdialog.cpp
4a73a877a18556a17d63ffc9bd0276fe74f48df8
[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 <QDir>
21
22 #include <KStandardDirs>
23 #include <KDebug>
24
25 #include "profilesdialog.h"
26 #include "kdenlivesettings.h"
27 #include "kdenlivesettingsdialog.h"
28
29 KdenliveSettingsDialog::KdenliveSettingsDialog(QWidget * parent): KConfigDialog(parent, "settings", KdenliveSettings::self()) {
30
31     QWidget *p1 = new QWidget;
32     m_configMisc.setupUi(p1);
33     page1 = addPage(p1, i18n("Misc"), "configure");
34
35     QWidget *p3 = new QWidget;
36     m_configDisplay.setupUi(p3);
37     page3 = addPage(p3, i18n("Display"), "display");
38
39     QWidget *p2 = new QWidget;
40     m_configEnv.setupUi(p2);
41     m_configEnv.mltpathurl->setMode(KFile::Directory);
42     m_configEnv.mltpathurl->lineEdit()->setObjectName("kcfg_mltpath");
43     m_configEnv.rendererpathurl->lineEdit()->setObjectName("kcfg_rendererpath");
44     m_configEnv.tmppathurl->setMode(KFile::Directory);
45     m_configEnv.tmppathurl->lineEdit()->setObjectName("kcfg_currenttmpfolder");
46     m_configEnv.capturefolderurl->setMode(KFile::Directory);
47     m_configEnv.capturefolderurl->lineEdit()->setObjectName("kcfg_capturefolder");
48     page2 = addPage(p2, i18n("Environnement"), "terminal");
49
50     QWidget *p4 = new QWidget;
51     m_configCapture.setupUi(p4);
52     page4 = addPage(p4, i18n("Capture"), "audio-card");
53
54     QWidget *p5 = new QWidget;
55     m_configShuttle.setupUi(p5);
56     page5 = addPage(p5, i18n("JogShuttle"), "input-mouse");
57
58     QStringList actions;
59     actions << i18n("Do nothing");
60     actions << i18n("Play / Pause");
61     actions << i18n("Cut");
62     m_configShuttle.kcfg_shuttle1->addItems(actions);
63     m_configShuttle.kcfg_shuttle2->addItems(actions);
64     m_configShuttle.kcfg_shuttle3->addItems(actions);
65     m_configShuttle.kcfg_shuttle4->addItems(actions);
66     m_configShuttle.kcfg_shuttle5->addItems(actions);
67
68     connect(m_configCapture.kcfg_video4vdevice, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
69     connect(m_configCapture.kcfg_video4adevice, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
70     connect(m_configCapture.kcfg_video4vformat, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
71     connect(m_configCapture.kcfg_video4aformat, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
72     connect(m_configCapture.kcfg_video4vencoding, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
73     connect(m_configCapture.kcfg_video4aencoding, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
74     connect(m_configCapture.kcfg_video4size, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
75     connect(m_configCapture.kcfg_video4rate, SIGNAL(editingFinished()), this, SLOT(rebuildVideo4Commands()));
76
77     QStringList profilesNames = ProfilesDialog::getProfileNames();
78     m_configMisc.profiles_list->addItems(profilesNames);
79     m_defaulfProfile = ProfilesDialog::getSettingsFromFile(KdenliveSettings::default_profile()).value("description");
80     if (profilesNames.contains(m_defaulfProfile)) m_configMisc.profiles_list->setCurrentItem(m_defaulfProfile);
81
82     slotUpdateDisplay();
83     connect(m_configMisc.profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
84 }
85
86 KdenliveSettingsDialog::~KdenliveSettingsDialog() {}
87
88
89 void KdenliveSettingsDialog::rebuildVideo4Commands() {
90     QString captureCommand;
91     if (!m_configCapture.kcfg_video4adevice->text().isEmpty()) captureCommand = "-f " + m_configCapture.kcfg_video4aformat->text() + " -i " + m_configCapture.kcfg_video4adevice->text();
92
93     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() + " -f " + m_configCapture.kcfg_video4vencoding->text();
94     m_configCapture.kcfg_video4capture->setText(captureCommand);
95
96     QString playbackCommand;
97     playbackCommand =  "-f " + m_configCapture.kcfg_video4vencoding->text();
98     m_configCapture.kcfg_video4playback->setText(playbackCommand);
99 }
100
101 bool KdenliveSettingsDialog::hasChanged() {
102     kDebug() << "// // // KCONFIG hasChanged called";
103     if (m_configMisc.profiles_list->currentText() != m_defaulfProfile) return true;
104     return KConfigDialog::hasChanged();
105 }
106
107 void KdenliveSettingsDialog::slotUpdateDisplay() {
108     QString currentProfile = m_configMisc.profiles_list->currentText();
109     QMap< QString, QString > values = ProfilesDialog::getSettingsForProfile(currentProfile);
110     m_configMisc.p_size->setText(values.value("width") + "x" + values.value("height"));
111     m_configMisc.p_fps->setText(values.value("frame_rate_num") + "/" + values.value("frame_rate_den"));
112     m_configMisc.p_aspect->setText(values.value("sample_aspect_num") + "/" + values.value("sample_aspect_den"));
113     m_configMisc.p_display->setText(values.value("display_aspect_num") + "/" + values.value("display_aspect_den"));
114     if (values.value("progressive").toInt() == 0) m_configMisc.p_progressive->setText(i18n("Interlaced"));
115     else m_configMisc.p_progressive->setText(i18n("Progressive"));
116 }
117
118
119 #include "kdenlivesettingsdialog.moc"
120
121