]> git.sesse.net Git - kdenlive/blob - src/projectsettings.cpp
3a27d23274e59be4a74bf92599c0dffdaf81a9fe
[kdenlive] / src / projectsettings.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 "projectsettings.h"
21 #include "kdenlivesettings.h"
22 #include "profilesdialog.h"
23
24 #include <KStandardDirs>
25 #include <KDebug>
26
27 #include <QDir>
28
29 ProjectSettings::ProjectSettings(int videotracks, int audiotracks, const QString projectPath, bool readOnlyTracks, QWidget * parent) :
30         QDialog(parent)
31 {
32     m_view.setupUi(this);
33
34     QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
35     QMapIterator<QString, QString> i(profilesInfo);
36     while (i.hasNext()) {
37         i.next();
38         m_view.profiles_list->addItem(i.key(), i.value());
39     }
40     m_view.project_folder->setMode(KFile::Directory);
41     m_view.project_folder->setPath(projectPath);
42     QString currentProf = KdenliveSettings::current_profile();
43
44     for (int i = 0; i < m_view.profiles_list->count(); i++) {
45         if (m_view.profiles_list->itemData(i).toString() == currentProf) {
46             m_view.profiles_list->setCurrentIndex(i);
47             break;
48         }
49     }
50
51     buttonOk = m_view.buttonBox->button(QDialogButtonBox::Ok);
52     //buttonOk->setEnabled(false);
53     m_view.audio_thumbs->setChecked(KdenliveSettings::audiothumbnails());
54     m_view.video_thumbs->setChecked(KdenliveSettings::videothumbnails());
55     m_view.audio_tracks->setValue(audiotracks);
56     m_view.video_tracks->setValue(videotracks);
57     if (readOnlyTracks) {
58         m_view.video_tracks->setEnabled(false);
59         m_view.audio_tracks->setEnabled(false);
60     }
61     slotUpdateDisplay();
62     connect(m_view.profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
63     connect(m_view.project_folder, SIGNAL(textChanged(const QString &)), this, SLOT(slotUpdateButton(const QString &)));
64 }
65
66
67 void ProjectSettings::slotUpdateDisplay()
68 {
69     QString currentProfile = m_view.profiles_list->itemData(m_view.profiles_list->currentIndex()).toString();
70     QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
71     m_view.p_size->setText(values.value("width") + 'x' + values.value("height"));
72     m_view.p_fps->setText(values.value("frame_rate_num") + '/' + values.value("frame_rate_den"));
73     m_view.p_aspect->setText(values.value("sample_aspect_num") + '/' + values.value("sample_aspect_den"));
74     m_view.p_display->setText(values.value("display_aspect_num") + '/' + values.value("display_aspect_den"));
75     if (values.value("progressive").toInt() == 0) m_view.p_progressive->setText(i18n("Interlaced"));
76     else m_view.p_progressive->setText(i18n("Progressive"));
77 }
78
79 void ProjectSettings::slotUpdateButton(const QString &path)
80 {
81     if (path.isEmpty()) buttonOk->setEnabled(false);
82     else buttonOk->setEnabled(true);
83 }
84
85 QString ProjectSettings::selectedProfile() const
86 {
87     return m_view.profiles_list->itemData(m_view.profiles_list->currentIndex()).toString();
88 }
89
90 KUrl ProjectSettings::selectedFolder() const
91 {
92     return m_view.project_folder->url();
93 }
94
95 QPoint ProjectSettings::tracks()
96 {
97     QPoint p;
98     p.setX(m_view.video_tracks->value());
99     p.setY(m_view.audio_tracks->value());
100     return p;
101 }
102
103 bool ProjectSettings::enableVideoThumbs() const
104 {
105     return m_view.video_thumbs->isChecked();
106 }
107
108 bool ProjectSettings::enableAudioThumbs() const
109 {
110     return m_view.audio_thumbs->isChecked();
111 }
112
113 #include "projectsettings.moc"
114
115