From b26743704ac69f2b001846ddcdf582500e75de06 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 28 Sep 2010 16:21:10 +0000 Subject: [PATCH] Show the recently introduced colorspace info in profile dialogs svn path=/trunk/kdenlive/; revision=4950 --- src/definitions.h | 3 +- src/profilesdialog.cpp | 31 ++++++- src/profilesdialog.h | 5 ++ src/projectsettings.cpp | 5 +- src/widgets/profiledialog_ui.ui | 40 +++++---- src/widgets/projectsettings_ui.ui | 140 ++++++++++++++++-------------- 6 files changed, 139 insertions(+), 85 deletions(-) diff --git a/src/definitions.h b/src/definitions.h index 33bffbd4..f67c4736 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -91,6 +91,7 @@ struct MltVideoProfile { int sample_aspect_den; int display_aspect_num; int display_aspect_den; + int colorspace; }; @@ -149,7 +150,7 @@ class CommentedTime public: CommentedTime(): t(GenTime(0)) {} CommentedTime(const GenTime time, QString comment) - : t(time), c(comment) { } + : t(time), c(comment) { } QString comment() const { return (c.isEmpty() ? i18n("Marker") : c); diff --git a/src/profilesdialog.cpp b/src/profilesdialog.cpp index fca5e8ea..0486072f 100644 --- a/src/profilesdialog.cpp +++ b/src/profilesdialog.cpp @@ -35,6 +35,12 @@ ProfilesDialog::ProfilesDialog(QWidget * parent) : { m_view.setupUi(this); + // Fill colorspace list (see mlt_profile.h) + m_view.colorspace->addItem(getColorspaceDescription(601), 601); + m_view.colorspace->addItem(getColorspaceDescription(709), 709); + m_view.colorspace->addItem(getColorspaceDescription(240), 240); + m_view.colorspace->addItem(getColorspaceDescription(0), 0); + QStringList profilesFilter; profilesFilter << "*"; @@ -167,7 +173,7 @@ void ProfilesDialog::saveProfile(const QString path) return; } QTextStream out(&file); - 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"; + 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"; if (file.error() != QFile::NoError) { KMessageBox::error(this, i18n("Cannot write to file %1", path)); } @@ -225,6 +231,7 @@ MltVideoProfile ProfilesDialog::getVideoProfile(QString name) result.sample_aspect_den = confFile.entryMap().value("sample_aspect_den").toInt(); result.display_aspect_num = confFile.entryMap().value("display_aspect_num").toInt(); result.display_aspect_den = confFile.entryMap().value("display_aspect_den").toInt(); + result.colorspace = confFile.entryMap().value("colorspace").toInt(); return result; } @@ -288,6 +295,7 @@ QString ProfilesDialog::existingProfile(MltVideoProfile profile) if (profile.frame_rate_den != confFile.entryMap().value("frame_rate_den").toInt()) continue; if (profile.frame_rate_num != confFile.entryMap().value("frame_rate_num").toInt()) continue; if (profile.progressive != confFile.entryMap().value("progressive").toInt()) continue; + if (profile.colorspace != confFile.entryMap().value("colorspace").toInt()) continue; return profilesFiles.at(i); } @@ -306,6 +314,7 @@ QString ProfilesDialog::existingProfile(MltVideoProfile profile) if (profile.frame_rate_den != confFile.entryMap().value("frame_rate_den").toInt()) continue; if (profile.frame_rate_num != confFile.entryMap().value("frame_rate_num").toInt()) continue; if (profile.progressive != confFile.entryMap().value("progressive").toInt()) continue; + if (profile.colorspace != confFile.entryMap().value("colorspace").toInt()) continue; return customProfiles.at(i) + profilesFiles.at(j); } } @@ -497,7 +506,7 @@ void ProfilesDialog::saveProfile(MltVideoProfile &profile) return; } QTextStream out(&file); - 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"; + 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"; if (file.error() != QFile::NoError) { KMessageBox::error(0, i18n("Cannot write to file %1", profilePath)); } @@ -538,9 +547,27 @@ void ProfilesDialog::slotUpdateDisplay() } else { m_view.fields->setText(QString::number((double) 2 * values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2)); } + + int colorix = m_view.colorspace->findData(values.value("colorspace").toInt()); + if (colorix > -1) m_view.colorspace->setCurrentIndex(colorix); m_profileIsModified = false; } +//static +QString ProfilesDialog::getColorspaceDescription(int colorspace) +{ + //TODO: should the descriptions be translated? + switch (colorspace) { + case 601: + return QString("ITU-R 601"); + case 709: + return QString("ITU-R 709"); + case 240: + return QString("SMPTE240M"); + default: + return i18n("Unknown"); + } +} #include "profilesdialog.moc" diff --git a/src/profilesdialog.h b/src/profilesdialog.h index 54d263af..ef4ea086 100644 --- a/src/profilesdialog.h +++ b/src/profilesdialog.h @@ -67,6 +67,11 @@ public: * @return the evaluated value */ static double getStringEval(const MltVideoProfile &profile, QString eval); + /** @brief Get the descriptive text for given colorspace code (defined by MLT) + * @param colorspace An int as defined in mlt_profile.h + * @return The string description */ + static QString getColorspaceDescription(int colorspace); + protected: virtual void closeEvent(QCloseEvent *event); diff --git a/src/projectsettings.cpp b/src/projectsettings.cpp index fdfdb832..bed29b1e 100644 --- a/src/projectsettings.cpp +++ b/src/projectsettings.cpp @@ -34,7 +34,7 @@ #include ProjectSettings::ProjectSettings(ProjectList *projectlist, QStringList lumas, int videotracks, int audiotracks, const QString projectPath, bool readOnlyTracks, bool savedProject, QWidget * parent) : - QDialog(parent), m_savedProject(savedProject), m_projectList(projectlist), m_lumas(lumas) + QDialog(parent), m_savedProject(savedProject), m_projectList(projectlist), m_lumas(lumas) { setupUi(this); @@ -198,10 +198,11 @@ void ProjectSettings::slotUpdateDisplay() p_display->setText(values.value("display_aspect_num") + '/' + values.value("display_aspect_den")); if (values.value("progressive").toInt() == 0) { p_progressive->setText(i18n("Interlaced (%1 fields per second)", - QString::number((double)2*values.value("frame_rate_num").toInt()/values.value("frame_rate_den").toInt(), 'f', 2))); + QString::number((double)2 * values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2))); } else { p_progressive->setText(i18n("Progressive")); } + p_colorspace->setText(ProfilesDialog::getColorspaceDescription(values.value("colorspace").toInt())); } void ProjectSettings::slotUpdateButton(const QString &path) diff --git a/src/widgets/profiledialog_ui.ui b/src/widgets/profiledialog_ui.ui index 5a385c85..f326bfb5 100644 --- a/src/widgets/profiledialog_ui.ui +++ b/src/widgets/profiledialog_ui.ui @@ -6,8 +6,8 @@ 0 0 - 385 - 332 + 334 + 296 @@ -174,14 +174,7 @@ - - - - Progressive - - - - + Qt::Vertical @@ -215,6 +208,23 @@ + + + + Colorspace + + + + + + + + + + Progressive + + + @@ -278,6 +288,11 @@ + + KIntSpinBox + QSpinBox +
knuminput.h
+
KPushButton QPushButton @@ -293,11 +308,6 @@ QComboBox
kcombobox.h
- - KIntSpinBox - QSpinBox -
knuminput.h
-
diff --git a/src/widgets/projectsettings_ui.ui b/src/widgets/projectsettings_ui.ui index da2dca90..6f5c4e68 100644 --- a/src/widgets/projectsettings_ui.ui +++ b/src/widgets/projectsettings_ui.ui @@ -6,7 +6,7 @@ 0 0 - 349 + 295 320 @@ -23,7 +23,7 @@ Settings - + @@ -39,7 +39,7 @@ Video Profile - + @@ -50,67 +50,77 @@ - - - - - - Size: - - - - - - - 720x576 - - - - - - - Frame rate: - - - - - - - 25/1 - - - - - - - Pixel aspect ratio: - - - - - - - 59/54 - - - - - - - Display aspect ratio: - - - - - - - 4/3 - - - - + + + + Size: + + + + + + + 720x576 + + + + + + + Frame rate: + + + + + + + 25/1 + + + + + + + Pixel aspect ratio: + + + + + + + 59/54 + + + + + + + Display aspect ratio: + + + + + + + 4/3 + + + + + + + Colorspace + + + + + + + + + - + Interlaced @@ -174,7 +184,7 @@ - + Qt::Horizontal @@ -187,7 +197,7 @@ - + Qt::Vertical -- 2.39.2