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