1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
20 #include "projectsettings.h"
21 #include "kdenlivesettings.h"
22 #include "profilesdialog.h"
24 #include <KStandardDirs>
25 #include <KMessageBox>
29 #include <kmessagebox.h>
31 ProjectSettings::ProjectSettings(int videotracks, int audiotracks, const QString projectPath, bool readOnlyTracks, bool savedProject, QWidget * parent) :
32 QDialog(parent), m_savedProject(savedProject)
36 QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
37 QMapIterator<QString, QString> i(profilesInfo);
40 profiles_list->addItem(i.key(), i.value());
42 project_folder->setMode(KFile::Directory);
43 project_folder->setUrl(KUrl(projectPath));
44 QString currentProf = KdenliveSettings::current_profile();
46 for (int i = 0; i < profiles_list->count(); i++) {
47 if (profiles_list->itemData(i).toString() == currentProf) {
48 profiles_list->setCurrentIndex(i);
53 m_buttonOk = buttonBox->button(QDialogButtonBox::Ok);
54 //buttonOk->setEnabled(false);
55 audio_thumbs->setChecked(KdenliveSettings::audiothumbnails());
56 video_thumbs->setChecked(KdenliveSettings::videothumbnails());
57 audio_tracks->setValue(audiotracks);
58 video_tracks->setValue(videotracks);
60 video_tracks->setEnabled(false);
61 audio_tracks->setEnabled(false);
64 connect(profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
65 connect(project_folder, SIGNAL(textChanged(const QString &)), this, SLOT(slotUpdateButton(const QString &)));
68 void ProjectSettings::accept()
70 if (!m_savedProject && selectedProfile() != KdenliveSettings::current_profile())
71 if (KMessageBox::warningContinueCancel(this, i18n("Changing the profile of your project cannot be undone.\nIt is recommended to save your project before attempting this operation that might cause some corruption in transitions.\n Are you sure you want to proceed?"), i18n("Confirm profile change")) == KMessageBox::Cancel) return;
75 void ProjectSettings::slotUpdateDisplay()
77 QString currentProfile = profiles_list->itemData(profiles_list->currentIndex()).toString();
78 QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
79 p_size->setText(values.value("width") + 'x' + values.value("height"));
80 p_fps->setText(values.value("frame_rate_num") + '/' + values.value("frame_rate_den"));
81 p_aspect->setText(values.value("sample_aspect_num") + '/' + values.value("sample_aspect_den"));
82 p_display->setText(values.value("display_aspect_num") + '/' + values.value("display_aspect_den"));
83 if (values.value("progressive").toInt() == 0) p_progressive->setText(i18n("Interlaced"));
84 else p_progressive->setText(i18n("Progressive"));
87 void ProjectSettings::slotUpdateButton(const QString &path)
89 if (path.isEmpty()) m_buttonOk->setEnabled(false);
90 else m_buttonOk->setEnabled(true);
93 QString ProjectSettings::selectedProfile() const
95 return profiles_list->itemData(profiles_list->currentIndex()).toString();
98 KUrl ProjectSettings::selectedFolder() const
100 return project_folder->url();
103 QPoint ProjectSettings::tracks()
106 p.setX(video_tracks->value());
107 p.setY(audio_tracks->value());
111 bool ProjectSettings::enableVideoThumbs() const
113 return video_thumbs->isChecked();
116 bool ProjectSettings::enableAudioThumbs() const
118 return audio_thumbs->isChecked();
121 #include "projectsettings.moc"