]> git.sesse.net Git - kdenlive/blob - src/projectsettings.cpp
Correctly use plural in i18n calls, add warning message when user wants to change...
[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 <KMessageBox>
26 #include <KDebug>
27
28 #include <QDir>
29 #include <kmessagebox.h>
30
31 ProjectSettings::ProjectSettings(int videotracks, int audiotracks, const QString projectPath, bool readOnlyTracks, bool savedProject, QWidget * parent) :
32         QDialog(parent), m_savedProject(savedProject)
33 {
34     setupUi(this);
35
36     QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
37     QMapIterator<QString, QString> i(profilesInfo);
38     while (i.hasNext()) {
39         i.next();
40         profiles_list->addItem(i.key(), i.value());
41     }
42     project_folder->setMode(KFile::Directory);
43     project_folder->setUrl(KUrl(projectPath));
44     QString currentProf = KdenliveSettings::current_profile();
45
46     for (int i = 0; i < profiles_list->count(); i++) {
47         if (profiles_list->itemData(i).toString() == currentProf) {
48             profiles_list->setCurrentIndex(i);
49             break;
50         }
51     }
52
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);
59     if (readOnlyTracks) {
60         video_tracks->setEnabled(false);
61         audio_tracks->setEnabled(false);
62     }
63     slotUpdateDisplay();
64     connect(profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
65     connect(project_folder, SIGNAL(textChanged(const QString &)), this, SLOT(slotUpdateButton(const QString &)));
66 }
67
68 void ProjectSettings::accept()
69 {
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;
72     QDialog::accept();
73 }
74
75 void ProjectSettings::slotUpdateDisplay()
76 {
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"));
85 }
86
87 void ProjectSettings::slotUpdateButton(const QString &path)
88 {
89     if (path.isEmpty()) m_buttonOk->setEnabled(false);
90     else m_buttonOk->setEnabled(true);
91 }
92
93 QString ProjectSettings::selectedProfile() const
94 {
95     return profiles_list->itemData(profiles_list->currentIndex()).toString();
96 }
97
98 KUrl ProjectSettings::selectedFolder() const
99 {
100     return project_folder->url();
101 }
102
103 QPoint ProjectSettings::tracks()
104 {
105     QPoint p;
106     p.setX(video_tracks->value());
107     p.setY(audio_tracks->value());
108     return p;
109 }
110
111 bool ProjectSettings::enableVideoThumbs() const
112 {
113     return video_thumbs->isChecked();
114 }
115
116 bool ProjectSettings::enableAudioThumbs() const
117 {
118     return audio_thumbs->isChecked();
119 }
120
121 #include "projectsettings.moc"
122
123