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 "profilesdialog.h"
21 #include "kdenlivesettings.h"
23 #include <KStandardDirs>
25 #include <KMessageBox>
26 #include <KIO/NetAccess>
29 #include <QCloseEvent>
31 ProfilesDialog::ProfilesDialog(QWidget * parent) :
33 m_profileIsModified(false),
34 m_isCustomProfile(false)
38 // Fill colorspace list (see mlt_profile.h)
39 m_view.colorspace->addItem(getColorspaceDescription(601), 601);
40 m_view.colorspace->addItem(getColorspaceDescription(709), 709);
41 m_view.colorspace->addItem(getColorspaceDescription(240), 240);
42 m_view.colorspace->addItem(getColorspaceDescription(0), 0);
44 QStringList profilesFilter;
45 profilesFilter << "*";
47 m_view.button_delete->setIcon(KIcon("trash-empty"));
48 m_view.button_delete->setToolTip(i18n("Delete profile"));
49 m_view.button_save->setIcon(KIcon("document-save"));
50 m_view.button_save->setToolTip(i18n("Save profile"));
51 m_view.button_create->setIcon(KIcon("document-new"));
52 m_view.button_create->setToolTip(i18n("Create new profile"));
56 connect(m_view.profiles_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDisplay()));
57 connect(m_view.button_create, SIGNAL(clicked()), this, SLOT(slotCreateProfile()));
58 connect(m_view.button_save, SIGNAL(clicked()), this, SLOT(slotSaveProfile()));
59 connect(m_view.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteProfile()));
60 connect(m_view.button_default, SIGNAL(clicked()), this, SLOT(slotSetDefaultProfile()));
62 connect(m_view.description, SIGNAL(textChanged(const QString &)), this, SLOT(slotProfileEdited()));
63 connect(m_view.frame_num, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
64 connect(m_view.frame_den, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
65 connect(m_view.aspect_num, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
66 connect(m_view.aspect_den, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
67 connect(m_view.display_num, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
68 connect(m_view.display_den, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
69 connect(m_view.progressive, SIGNAL(stateChanged(int)), this, SLOT(slotProfileEdited()));
70 connect(m_view.size_h, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
71 connect(m_view.size_w, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
74 void ProfilesDialog::slotProfileEdited()
76 m_profileIsModified = true;
79 void ProfilesDialog::fillList(const QString selectedProfile)
81 // List the Mlt profiles
82 m_view.profiles_list->clear();
83 QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
84 QMapIterator<QString, QString> i(profilesInfo);
87 m_view.profiles_list->addItem(i.key(), i.value());
90 if (!KdenliveSettings::default_profile().isEmpty()) {
91 for (int i = 0; i < m_view.profiles_list->count(); i++) {
92 if (m_view.profiles_list->itemData(i).toString() == KdenliveSettings::default_profile()) {
93 m_view.profiles_list->setCurrentIndex(i);
98 int ix = m_view.profiles_list->findText(selectedProfile);
99 if (ix != -1) m_view.profiles_list->setCurrentIndex(ix);
100 m_selectedProfileIndex = m_view.profiles_list->currentIndex();
103 void ProfilesDialog::accept()
105 if (askForSave()) QDialog::accept();
108 void ProfilesDialog::closeEvent(QCloseEvent *event)
117 bool ProfilesDialog::askForSave()
119 if (!m_profileIsModified) return true;
120 if (KMessageBox::questionYesNo(this, i18n("The custom profile was modified, do you want to save it?")) != KMessageBox::Yes) return true;
121 return slotSaveProfile();
124 void ProfilesDialog::slotCreateProfile()
126 m_view.button_delete->setEnabled(false);
127 m_view.button_create->setEnabled(false);
128 m_view.button_save->setEnabled(true);
129 m_view.properties->setEnabled(true);
132 void ProfilesDialog::slotSetDefaultProfile()
134 int ix = m_view.profiles_list->currentIndex();
135 QString path = m_view.profiles_list->itemData(ix).toString();
136 if (!path.isEmpty()) KdenliveSettings::setDefault_profile(path);
139 bool ProfilesDialog::slotSaveProfile()
141 const QString profileDesc = m_view.description->text();
142 int ix = m_view.profiles_list->findText(profileDesc);
144 // this profile name already exists
145 const QString path = m_view.profiles_list->itemData(ix).toString();
146 if (!path.contains('/')) {
147 KMessageBox::sorry(this, i18n("A profile with same name already exists in MLT's default profiles, please choose another description for your custom profile."));
153 QString customName = "profiles/customprofile";
154 QString profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
155 kDebug() << " TYING PROFILE FILE: " << profilePath;
156 while (KIO::NetAccess::exists(KUrl(profilePath), KIO::NetAccess::SourceSide, this)) {
158 profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
160 saveProfile(profilePath);
162 m_profileIsModified = false;
163 fillList(profileDesc);
164 m_view.button_create->setEnabled(true);
168 void ProfilesDialog::saveProfile(const QString path)
171 if (!file.open(QIODevice::WriteOnly)) {
172 KMessageBox::sorry(this, i18n("Cannot write to file %1", path));
175 QTextStream out(&file);
176 out << "description=" << m_view.description->text() << "\n" << "frame_rate_num=" << m_view.frame_num->value() << "\n" << "frame_rate_den=" << m_view.frame_den->value() << "\n" << "width=" << m_view.size_w->value() << "\n" << "height=" << m_view.size_h->value() << "\n" << "progressive=" << m_view.progressive->isChecked() << "\n" << "sample_aspect_num=" << m_view.aspect_num->value() << "\n" << "sample_aspect_den=" << m_view.aspect_den->value() << "\n" << "display_aspect_num=" << m_view.display_num->value() << "\n" << "display_aspect_den=" << m_view.display_den->value() << "\n" << "colorspace=" << m_view.colorspace->itemData(m_view.colorspace->currentIndex()).toInt() << "\n";
177 if (file.error() != QFile::NoError) {
178 KMessageBox::error(this, i18n("Cannot write to file %1", path));
183 void ProfilesDialog::slotDeleteProfile()
185 const QString path = m_view.profiles_list->itemData(m_view.profiles_list->currentIndex()).toString();
186 if (path.contains('/')) {
187 KIO::NetAccess::del(KUrl(path), this);
189 } else kDebug() << "//// Cannot delete profile " << path << ", does not seem to be custom one";
193 MltVideoProfile ProfilesDialog::getVideoProfile(QString name)
195 MltVideoProfile result;
196 QStringList profilesNames;
197 QStringList profilesFiles;
198 QStringList profilesFilter;
199 profilesFilter << "*";
201 bool isCustom = false;
202 if (name.contains('/')) isCustom = true;
205 // List the Mlt profiles
206 profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
207 if (profilesFiles.contains(name)) path = KdenliveSettings::mltpath() + name;
209 if (isCustom || path.isEmpty()) {
213 if (path.isEmpty() || !QFile::exists(path)) {
214 if (name == "dv_pal") {
215 kDebug() << "!!! WARNING, COULD NOT FIND DEFAULT MLT PROFILE";
218 if (name == KdenliveSettings::default_profile()) KdenliveSettings::setDefault_profile("dv_pal");
219 kDebug() << "// WARNING, COULD NOT FIND PROFILE " << name;
222 KConfig confFile(path, KConfig::SimpleConfig);
224 result.description = confFile.entryMap().value("description");
225 result.frame_rate_num = confFile.entryMap().value("frame_rate_num").toInt();
226 result.frame_rate_den = confFile.entryMap().value("frame_rate_den").toInt();
227 result.width = confFile.entryMap().value("width").toInt();
228 result.height = confFile.entryMap().value("height").toInt();
229 result.progressive = confFile.entryMap().value("progressive").toInt();
230 result.sample_aspect_num = confFile.entryMap().value("sample_aspect_num").toInt();
231 result.sample_aspect_den = confFile.entryMap().value("sample_aspect_den").toInt();
232 result.display_aspect_num = confFile.entryMap().value("display_aspect_num").toInt();
233 result.display_aspect_den = confFile.entryMap().value("display_aspect_den").toInt();
234 result.colorspace = confFile.entryMap().value("colorspace").toInt();
239 double ProfilesDialog::getStringEval(const MltVideoProfile &profile, QString eval)
242 eval.replace("%width", QString::number(profile.width));
243 eval.replace("%height", QString::number(profile.height));
244 if (eval.contains('/')) result = (double) eval.section('/', 0, 0).toInt() / eval.section('/', 1, 1).toInt();
245 else if (eval.contains('*')) result = (double) eval.section('*', 0, 0).toInt() * eval.section('*', 1, 1).toInt();
246 else if (eval.contains('+')) result = (double) eval.section('+', 0, 0).toInt() + eval.section('+', 1, 1).toInt();
247 else if (eval.contains('-')) result = (double) eval.section('-', 0, 0).toInt() - eval.section('-', 1, 1).toInt();
248 else result = eval.toDouble();
254 bool ProfilesDialog::existingProfileDescription(const QString &desc)
256 QStringList profilesFilter;
257 profilesFilter << "*";
259 // List the Mlt profiles
260 QStringList profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
261 for (int i = 0; i < profilesFiles.size(); ++i) {
262 KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
263 if (desc == confFile.entryMap().value("description")) return true;
266 // List custom profiles
267 QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
268 for (int i = 0; i < customProfiles.size(); ++i) {
269 profilesFiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
270 for (int j = 0; j < profilesFiles.size(); ++j) {
271 KConfig confFile(customProfiles.at(i) + profilesFiles.at(j), KConfig::SimpleConfig);
272 if (desc == confFile.entryMap().value("description")) return true;
279 QString ProfilesDialog::existingProfile(MltVideoProfile profile)
281 // Check if the profile has a matching entry in existing ones
282 QStringList profilesFilter;
283 profilesFilter << "*";
285 // Check the Mlt profiles
286 QStringList profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
287 for (int i = 0; i < profilesFiles.size(); ++i) {
288 KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
289 if (profile.display_aspect_den != confFile.entryMap().value("display_aspect_den").toInt()) continue;
290 if (profile.display_aspect_num != confFile.entryMap().value("display_aspect_num").toInt()) continue;
291 if (profile.sample_aspect_den != confFile.entryMap().value("sample_aspect_den").toInt()) continue;
292 if (profile.sample_aspect_num != confFile.entryMap().value("sample_aspect_num").toInt()) continue;
293 if (profile.width != confFile.entryMap().value("width").toInt()) continue;
294 if (profile.height != confFile.entryMap().value("height").toInt()) continue;
295 if (profile.frame_rate_den != confFile.entryMap().value("frame_rate_den").toInt()) continue;
296 if (profile.frame_rate_num != confFile.entryMap().value("frame_rate_num").toInt()) continue;
297 if (profile.progressive != confFile.entryMap().value("progressive").toInt()) continue;
298 if (profile.colorspace != confFile.entryMap().value("colorspace").toInt()) continue;
299 return profilesFiles.at(i);
302 // Check custom profiles
303 QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
304 for (int i = 0; i < customProfiles.size(); ++i) {
305 profilesFiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
306 for (int j = 0; j < profilesFiles.size(); ++j) {
307 KConfig confFile(customProfiles.at(i) + profilesFiles.at(j), KConfig::SimpleConfig);
308 if (profile.display_aspect_den != confFile.entryMap().value("display_aspect_den").toInt()) continue;
309 if (profile.display_aspect_num != confFile.entryMap().value("display_aspect_num").toInt()) continue;
310 if (profile.sample_aspect_den != confFile.entryMap().value("sample_aspect_den").toInt()) continue;
311 if (profile.sample_aspect_num != confFile.entryMap().value("sample_aspect_num").toInt()) continue;
312 if (profile.width != confFile.entryMap().value("width").toInt()) continue;
313 if (profile.height != confFile.entryMap().value("height").toInt()) continue;
314 if (profile.frame_rate_den != confFile.entryMap().value("frame_rate_den").toInt()) continue;
315 if (profile.frame_rate_num != confFile.entryMap().value("frame_rate_num").toInt()) continue;
316 if (profile.progressive != confFile.entryMap().value("progressive").toInt()) continue;
317 if (profile.colorspace != confFile.entryMap().value("colorspace").toInt()) continue;
318 return customProfiles.at(i) + profilesFiles.at(j);
325 QMap <QString, QString> ProfilesDialog::getProfilesInfo()
327 QMap <QString, QString> result;
328 QStringList profilesFilter;
329 profilesFilter << "*";
331 // List the Mlt profiles
332 QStringList profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
333 for (int i = 0; i < profilesFiles.size(); ++i) {
334 KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
335 QString desc = confFile.entryMap().value("description");
336 if (!desc.isEmpty()) result.insert(desc, profilesFiles.at(i));
339 // List custom profiles
340 QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
341 for (int i = 0; i < customProfiles.size(); ++i) {
342 profilesFiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
343 for (int j = 0; j < profilesFiles.size(); ++j) {
344 KConfig confFile(customProfiles.at(i) + profilesFiles.at(j), KConfig::SimpleConfig);
345 QString desc = confFile.entryMap().value("description");
346 if (!desc.isEmpty()) result.insert(desc, customProfiles.at(i) + profilesFiles.at(j));
353 QMap< QString, QString > ProfilesDialog::getSettingsFromFile(const QString path)
355 QStringList profilesNames;
356 QStringList profilesFiles;
357 QStringList profilesFilter;
358 profilesFilter << "*";
360 if (!path.contains('/')) {
361 // This is an MLT profile
362 KConfig confFile(KdenliveSettings::mltpath() + path, KConfig::SimpleConfig);
363 return confFile.entryMap();
365 // This is a custom profile
366 KConfig confFile(path, KConfig::SimpleConfig);
367 return confFile.entryMap();
372 QMap< QString, QString > ProfilesDialog::getSettingsForProfile(const QString profileName)
374 QStringList profilesNames;
375 QStringList profilesFiles;
376 QStringList profilesFilter;
377 profilesFilter << "*";
379 // List the Mlt profiles
380 profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
381 for (int i = 0; i < profilesFiles.size(); ++i) {
382 KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
383 QMap< QString, QString > values = confFile.entryMap();
384 if (values.value("description") == profileName) {
385 values.insert("path", profilesFiles.at(i));
390 // List custom profiles
391 QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
392 for (int i = 0; i < customProfiles.size(); ++i) {
393 QStringList profiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
394 for (int j = 0; j < profiles.size(); ++j) {
395 KConfig confFile(customProfiles.at(i) + profiles.at(j), KConfig::SimpleConfig);
396 QMap< QString, QString > values = confFile.entryMap();
397 if (values.value("description") == profileName) {
398 values.insert("path", customProfiles.at(i) + profiles.at(j));
403 return QMap< QString, QString >();
407 bool ProfilesDialog::matchProfile(int width, int height, double fps, double par, bool isImage, MltVideoProfile profile)
411 // when using image, compare with display width
412 profileWidth = profile.height * profile.display_aspect_num / profile.display_aspect_den + 0.5;
413 } else profileWidth = profile.width;
414 if (width != profileWidth || height != profile.height || (fps > 0 && qAbs((double) profile.frame_rate_num / profile.frame_rate_den - fps) > 0.4) || (!isImage && par > 0 && qAbs((double) profile.sample_aspect_num / profile.sample_aspect_den - par) > 0.1)) return false;
419 QMap <QString, QString> ProfilesDialog::getProfilesFromProperties(int width, int height, double fps, double par, bool useDisplayWidth)
421 QStringList profilesNames;
422 QStringList profilesFiles;
423 QStringList profilesFilter;
424 QMap <QString, QString> result;
425 profilesFilter << "*";
426 // List the Mlt profiles
427 profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
428 for (int i = 0; i < profilesFiles.size(); ++i) {
429 KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
430 QMap< QString, QString > values = confFile.entryMap();
432 if (useDisplayWidth) profileWidth = values.value("height").toInt() * values.value("display_aspect_num").toInt() / values.value("display_aspect_den").toInt() + 0.5;
433 else profileWidth = values.value("width").toInt();
434 if (profileWidth == width && values.value("height").toInt() == height) {
435 double profile_fps = values.value("frame_rate_num").toDouble() / values.value("frame_rate_den").toDouble();
436 double profile_par = values.value("sample_aspect_num").toDouble() / values.value("sample_aspect_den").toDouble();
437 if ((fps <= 0 || qAbs(profile_fps - fps) < 0.5) && (par <= 0 || qAbs(profile_par - par) < 0.1))
438 result.insert(profilesFiles.at(i), values.value("description"));
442 // List custom profiles
443 QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
444 for (int i = 0; i < customProfiles.size(); ++i) {
445 QStringList profiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
446 for (int j = 0; j < profiles.size(); j++) {
447 KConfig confFile(customProfiles.at(i) + profiles.at(j), KConfig::SimpleConfig);
448 QMap< QString, QString > values = confFile.entryMap();
450 if (useDisplayWidth) profileWidth = values.value("height").toInt() * values.value("display_aspect_num").toInt() / values.value("display_aspect_den").toInt() + 0.5;
451 else profileWidth = values.value("width").toInt();
452 if (profileWidth == width && values.value("height").toInt() == height) {
453 double profile_fps = values.value("frame_rate_num").toDouble() / values.value("frame_rate_den").toDouble();
454 double profile_par = values.value("sample_aspect_num").toDouble() / values.value("sample_aspect_den").toDouble();
455 if ((fps <= 0 || qAbs(profile_fps - fps) < 0.5) && (par <= 0 || qAbs(profile_par - par) < 0.1))
456 result.insert(customProfiles.at(i) + profiles.at(j), values.value("description"));
464 QString ProfilesDialog::getPathFromDescription(const QString profileDesc)
466 QStringList profilesNames;
467 QStringList profilesFiles;
468 QStringList profilesFilter;
469 profilesFilter << "*";
471 // List the Mlt profiles
472 profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
473 for (int i = 0; i < profilesFiles.size(); ++i) {
474 KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
475 QMap< QString, QString > values = confFile.entryMap();
476 if (values.value("description") == profileDesc) return profilesFiles.at(i);
479 // List custom profiles
480 QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
481 for (int i = 0; i < customProfiles.size(); ++i) {
482 QStringList profiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
483 for (int j = 0; j < profiles.size(); ++j) {
484 KConfig confFile(customProfiles.at(i) + profiles.at(j), KConfig::SimpleConfig);
485 QMap< QString, QString > values = confFile.entryMap();
486 if (values.value("description") == profileDesc) return customProfiles.at(i) + profiles.at(j);
493 void ProfilesDialog::saveProfile(MltVideoProfile &profile)
496 QString customName = "profiles/customprofile";
497 QString profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
498 kDebug() << " TYING PROFILE FILE: " << profilePath;
499 while (KIO::NetAccess::exists(KUrl(profilePath), KIO::NetAccess::SourceSide, 0)) {
501 profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
503 QFile file(profilePath);
504 if (!file.open(QIODevice::WriteOnly)) {
505 KMessageBox::sorry(0, i18n("Cannot write to file %1", profilePath));
508 QTextStream out(&file);
509 out << "description=" << profile.description << "\n" << "frame_rate_num=" << profile.frame_rate_num << "\n" << "frame_rate_den=" << profile.frame_rate_den << "\n" << "width=" << profile.width << "\n" << "height=" << profile.height << "\n" << "progressive=" << profile.progressive << "\n" << "sample_aspect_num=" << profile.sample_aspect_num << "\n" << "sample_aspect_den=" << profile.sample_aspect_den << "\n" << "display_aspect_num=" << profile.display_aspect_num << "\n" << "display_aspect_den=" << profile.display_aspect_den << "\n" << "colorspace=" << profile.colorspace << "\n";
510 if (file.error() != QFile::NoError) {
511 KMessageBox::error(0, i18n("Cannot write to file %1", profilePath));
514 profile.path = profilePath;
518 void ProfilesDialog::slotUpdateDisplay()
520 if (askForSave() == false) {
521 m_view.profiles_list->blockSignals(true);
522 m_view.profiles_list->setCurrentIndex(m_selectedProfileIndex);
523 m_view.profiles_list->blockSignals(false);
527 m_selectedProfileIndex = m_view.profiles_list->currentIndex();
528 QString currentProfile = m_view.profiles_list->itemData(m_view.profiles_list->currentIndex()).toString();
529 m_isCustomProfile = currentProfile.contains('/');
530 m_view.button_create->setEnabled(true);
531 m_view.button_delete->setEnabled(m_isCustomProfile);
532 m_view.properties->setEnabled(m_isCustomProfile);
533 m_view.button_save->setEnabled(m_isCustomProfile);
534 QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
535 m_view.description->setText(values.value("description"));
536 m_view.size_w->setValue(values.value("width").toInt());
537 m_view.size_h->setValue(values.value("height").toInt());
538 m_view.aspect_num->setValue(values.value("sample_aspect_num").toInt());
539 m_view.aspect_den->setValue(values.value("sample_aspect_den").toInt());
540 m_view.display_num->setValue(values.value("display_aspect_num").toInt());
541 m_view.display_den->setValue(values.value("display_aspect_den").toInt());
542 m_view.frame_num->setValue(values.value("frame_rate_num").toInt());
543 m_view.frame_den->setValue(values.value("frame_rate_den").toInt());
544 m_view.progressive->setChecked(values.value("progressive").toInt());
545 if (values.value("progressive").toInt()) {
546 m_view.fields->setText(QString::number((double) values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2));
548 m_view.fields->setText(QString::number((double) 2 * values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2));
551 int colorix = m_view.colorspace->findData(values.value("colorspace").toInt());
552 if (colorix > -1) m_view.colorspace->setCurrentIndex(colorix);
553 m_profileIsModified = false;
557 QString ProfilesDialog::getColorspaceDescription(int colorspace)
559 //TODO: should the descriptions be translated?
560 switch (colorspace) {
562 return QString("ITU-R 601");
564 return QString("ITU-R 709");
566 return QString("SMPTE240M");
568 return i18n("Unknown");
572 #include "profilesdialog.moc"