]> git.sesse.net Git - kdenlive/blobdiff - src/profilesdialog.cpp
Const'ref
[kdenlive] / src / profilesdialog.cpp
index d86ee605db75aad7ac27b99adf43608269d8cb20..1e9c86410c4b0da43bb960d8f36410b7f8f0850d 100644 (file)
 #include <KIO/NetAccess>
 
 #include <QDir>
+#include <qscriptengine.h>
 #include <QCloseEvent>
+#include <QScriptEngine>
 
 ProfilesDialog::ProfilesDialog(QWidget * parent) :
-        QDialog(parent),
-        m_profileIsModified(false),
-        m_isCustomProfile(false)
+    QDialog(parent),
+    m_profileIsModified(false),
+    m_isCustomProfile(false)
 {
     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 << "*";
 
@@ -53,7 +61,48 @@ ProfilesDialog::ProfilesDialog(QWidget * parent) :
     connect(m_view.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteProfile()));
     connect(m_view.button_default, SIGNAL(clicked()), this, SLOT(slotSetDefaultProfile()));
 
-    connect(m_view.description, SIGNAL(textChanged(const QString &)), this, SLOT(slotProfileEdited()));
+    connect(m_view.description, SIGNAL(textChanged(QString)), this, SLOT(slotProfileEdited()));
+    connect(m_view.frame_num, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
+    connect(m_view.frame_den, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
+    connect(m_view.aspect_num, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
+    connect(m_view.aspect_den, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
+    connect(m_view.display_num, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
+    connect(m_view.display_den, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
+    connect(m_view.progressive, SIGNAL(stateChanged(int)), this, SLOT(slotProfileEdited()));
+    connect(m_view.size_h, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
+    connect(m_view.size_w, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
+}
+
+
+ProfilesDialog::ProfilesDialog(QString profilePath, QWidget * parent) :
+    QDialog(parent),
+    m_profileIsModified(false),
+    m_isCustomProfile(true),
+    m_customProfilePath(profilePath)
+{
+    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 << "*";
+
+    m_view.button_save->setIcon(KIcon("document-save"));
+    m_view.button_save->setToolTip(i18n("Save profile"));
+    m_view.button_create->setHidden(true);
+    m_view.profiles_list->setHidden(true);
+    m_view.button_delete->setHidden(true);
+    m_view.button_default->setHidden(true);
+    m_view.description->setEnabled(false);
+
+    slotUpdateDisplay(profilePath);
+    connect(m_view.button_save, SIGNAL(clicked()), this, SLOT(slotSaveProfile()));
+
+    connect(m_view.description, SIGNAL(textChanged(QString)), this, SLOT(slotProfileEdited()));
     connect(m_view.frame_num, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
     connect(m_view.frame_den, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
     connect(m_view.aspect_num, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
@@ -70,9 +119,9 @@ void ProfilesDialog::slotProfileEdited()
     m_profileIsModified = true;
 }
 
-void ProfilesDialog::fillList(const QString selectedProfile)
+void ProfilesDialog::fillList(const QString &selectedProfile)
 {
-    // List the Mlt profiles
+    // List the Mlt profiles
     m_view.profiles_list->clear();
     QMap <QString, QString> profilesInfo = ProfilesDialog::getProfilesInfo();
     QMapIterator<QString, QString> i(profilesInfo);
@@ -82,7 +131,7 @@ void ProfilesDialog::fillList(const QString selectedProfile)
     }
 
     if (!KdenliveSettings::default_profile().isEmpty()) {
-        for (int i = 0; i < m_view.profiles_list->count(); i++) {
+        for (int i = 0; i < m_view.profiles_list->count(); ++i) {
             if (m_view.profiles_list->itemData(i).toString() == KdenliveSettings::default_profile()) {
                 m_view.profiles_list->setCurrentIndex(i);
                 break;
@@ -132,6 +181,10 @@ void ProfilesDialog::slotSetDefaultProfile()
 
 bool ProfilesDialog::slotSaveProfile()
 {
+    if (!m_customProfilePath.isEmpty()) {
+        saveProfile(m_customProfilePath);
+        return true;
+    }
     const QString profileDesc = m_view.description->text();
     int ix = m_view.profiles_list->findText(profileDesc);
     if (ix != -1) {
@@ -148,7 +201,7 @@ bool ProfilesDialog::slotSaveProfile()
         QString profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
         kDebug() << " TYING PROFILE FILE: " << profilePath;
         while (KIO::NetAccess::exists(KUrl(profilePath), KIO::NetAccess::SourceSide, this)) {
-            i++;
+            ++i;
             profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
         }
         saveProfile(profilePath);
@@ -159,7 +212,7 @@ bool ProfilesDialog::slotSaveProfile()
     return true;
 }
 
-void ProfilesDialog::saveProfile(const QString path)
+void ProfilesDialog::saveProfile(QString path)
 {
     QFile file(path);
     if (!file.open(QIODevice::WriteOnly)) {
@@ -167,7 +220,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));
     }
@@ -184,7 +237,7 @@ void ProfilesDialog::slotDeleteProfile()
 }
 
 // static
-MltVideoProfile ProfilesDialog::getVideoProfile(QString name)
+MltVideoProfile ProfilesDialog::getVideoProfile(const QString &name)
 {
     MltVideoProfile result;
     QStringList profilesNames;
@@ -196,7 +249,7 @@ MltVideoProfile ProfilesDialog::getVideoProfile(QString name)
     if (name.contains('/')) isCustom = true;
 
     if (!isCustom) {
-        // List the Mlt profiles
+        // List the Mlt profiles
         profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
         if (profilesFiles.contains(name)) path = KdenliveSettings::mltpath() + name;
     }
@@ -206,7 +259,7 @@ MltVideoProfile ProfilesDialog::getVideoProfile(QString name)
 
     if (path.isEmpty() || !QFile::exists(path)) {
         if (name == "dv_pal") {
-            kDebug() << "!!! WARNING, COULD NOT FIND DEFAULT MLT PROFILE";
+            kDebug() << "!!! WARNING, COULD NOT FIND DEFAULT MLT PROFILE";
             return result;
         }
         if (name == KdenliveSettings::default_profile()) KdenliveSettings::setDefault_profile("dv_pal");
@@ -225,9 +278,21 @@ 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;
 }
 
+// static
+double ProfilesDialog::getStringEval(const MltVideoProfile &profile, QString eval, const QPoint& frameSize)
+{
+    QScriptEngine sEngine;
+    sEngine.globalObject().setProperty("maxWidth", profile.width > frameSize.x() ? profile.width : frameSize.x());
+    sEngine.globalObject().setProperty("maxHeight", profile.height > frameSize.y() ? profile.height : frameSize.y());
+    sEngine.globalObject().setProperty("width", profile.width);
+    sEngine.globalObject().setProperty("height", profile.height);
+    return sEngine.evaluate(eval.remove('%')).toNumber();
+}
+
 
 // static
 bool ProfilesDialog::existingProfileDescription(const QString &desc)
@@ -235,7 +300,7 @@ bool ProfilesDialog::existingProfileDescription(const QString &desc)
     QStringList profilesFilter;
     profilesFilter << "*";
 
-    // List the Mlt profiles
+    // List the Mlt profiles
     QStringList profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
     for (int i = 0; i < profilesFiles.size(); ++i) {
         KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
@@ -255,13 +320,13 @@ bool ProfilesDialog::existingProfileDescription(const QString &desc)
 }
 
 // static
-QString ProfilesDialog::existingProfile(MltVideoProfile profile)
+QString ProfilesDialog::existingProfile(const MltVideoProfile &profile)
 {
     // Check if the profile has a matching entry in existing ones
     QStringList profilesFilter;
     profilesFilter << "*";
 
-    // Check the Mlt profiles
+    // Check the Mlt profiles
     QStringList profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
     for (int i = 0; i < profilesFiles.size(); ++i) {
         KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
@@ -274,6 +339,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);
     }
 
@@ -292,6 +358,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);
         }
     }
@@ -305,7 +372,7 @@ QMap <QString, QString> ProfilesDialog::getProfilesInfo()
     QStringList profilesFilter;
     profilesFilter << "*";
 
-    // List the Mlt profiles
+    // List the Mlt profiles
     QStringList profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
     for (int i = 0; i < profilesFiles.size(); ++i) {
         KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
@@ -327,7 +394,7 @@ QMap <QString, QString> ProfilesDialog::getProfilesInfo()
 }
 
 // static
-QMap< QString, QString > ProfilesDialog::getSettingsFromFile(const QString path)
+QMap< QString, QString > ProfilesDialog::getSettingsFromFile(const QString& path)
 {
     QStringList profilesNames;
     QStringList profilesFiles;
@@ -346,14 +413,14 @@ QMap< QString, QString > ProfilesDialog::getSettingsFromFile(const QString path)
 }
 
 // static
-QMap< QString, QString > ProfilesDialog::getSettingsForProfile(const QString profileName)
+QMap< QString, QString > ProfilesDialog::getSettingsForProfile(const QString& profileName)
 {
     QStringList profilesNames;
     QStringList profilesFiles;
     QStringList profilesFilter;
     profilesFilter << "*";
 
-    // List the Mlt profiles
+    // List the Mlt profiles
     profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
     for (int i = 0; i < profilesFiles.size(); ++i) {
         KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
@@ -368,11 +435,11 @@ QMap< QString, QString > ProfilesDialog::getSettingsForProfile(const QString pro
     QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
     for (int i = 0; i < customProfiles.size(); ++i) {
         QStringList profiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
-        for (int i = 0; i < profiles.size(); ++i) {
-            KConfig confFile(customProfiles.at(i) + profiles.at(i), KConfig::SimpleConfig);
+        for (int j = 0; j < profiles.size(); ++j) {
+            KConfig confFile(customProfiles.at(i) + profiles.at(j), KConfig::SimpleConfig);
             QMap< QString, QString > values = confFile.entryMap();
             if (values.value("description") == profileName) {
-                values.insert("path", customProfiles.at(i) + profiles.at(i));
+                values.insert("path", customProfiles.at(i) + profiles.at(j));
                 return values;
             }
         }
@@ -381,14 +448,71 @@ QMap< QString, QString > ProfilesDialog::getSettingsForProfile(const QString pro
 }
 
 // static
-QString ProfilesDialog::getPathFromDescription(const QString profileDesc)
+bool ProfilesDialog::matchProfile(int width, int height, double fps, double par, bool isImage, const MltVideoProfile &profile)
+{
+    int profileWidth;
+    if (isImage) {
+        // when using image, compare with display width
+        profileWidth = profile.height * profile.display_aspect_num / profile.display_aspect_den + 0.5;
+    } else profileWidth = profile.width;
+    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;
+    return true;
+}
+
+// static
+QMap <QString, QString> ProfilesDialog::getProfilesFromProperties(int width, int height, double fps, double par, bool useDisplayWidth)
+{
+    QStringList profilesNames;
+    QStringList profilesFiles;
+    QStringList profilesFilter;
+    QMap <QString, QString> result;
+    profilesFilter << "*";
+    // List the Mlt profiles
+    profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
+    for (int i = 0; i < profilesFiles.size(); ++i) {
+        KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
+        QMap< QString, QString > values = confFile.entryMap();
+        int profileWidth;
+        if (useDisplayWidth) profileWidth = values.value("height").toInt() * values.value("display_aspect_num").toInt() / values.value("display_aspect_den").toInt() + 0.5;
+        else profileWidth = values.value("width").toInt();
+        if (profileWidth == width && values.value("height").toInt() == height) {
+            double profile_fps = values.value("frame_rate_num").toDouble() / values.value("frame_rate_den").toDouble();
+            double profile_par = values.value("sample_aspect_num").toDouble() / values.value("sample_aspect_den").toDouble();
+            if ((fps <= 0 || qAbs(profile_fps - fps) < 0.5) && (par <= 0 || qAbs(profile_par - par) < 0.1))
+                result.insert(profilesFiles.at(i), values.value("description"));
+        }
+    }
+
+    // List custom profiles
+    QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
+    for (int i = 0; i < customProfiles.size(); ++i) {
+        QStringList profiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
+        for (int j = 0; j < profiles.size(); j++) {
+            KConfig confFile(customProfiles.at(i) + profiles.at(j), KConfig::SimpleConfig);
+            QMap< QString, QString > values = confFile.entryMap();
+            int profileWidth;
+            if (useDisplayWidth) profileWidth = values.value("height").toInt() * values.value("display_aspect_num").toInt() / values.value("display_aspect_den").toInt() + 0.5;
+            else profileWidth = values.value("width").toInt();
+            if (profileWidth == width && values.value("height").toInt() == height) {
+                double profile_fps = values.value("frame_rate_num").toDouble() / values.value("frame_rate_den").toDouble();
+                double profile_par = values.value("sample_aspect_num").toDouble() / values.value("sample_aspect_den").toDouble();
+                if ((fps <= 0 || qAbs(profile_fps - fps) < 0.5) && (par <= 0 || qAbs(profile_par - par) < 0.1))
+                    result.insert(customProfiles.at(i) + profiles.at(j), values.value("description"));
+            }
+        }
+    }
+    return result;
+}
+
+// static
+QString ProfilesDialog::getPathFromDescription(const QString& profileDesc)
 {
     QStringList profilesNames;
     QStringList profilesFiles;
     QStringList profilesFilter;
     profilesFilter << "*";
 
-    // List the Mlt profiles
+    // List the Mlt profiles
     profilesFiles = QDir(KdenliveSettings::mltpath()).entryList(profilesFilter, QDir::Files);
     for (int i = 0; i < profilesFiles.size(); ++i) {
         KConfig confFile(KdenliveSettings::mltpath() + profilesFiles.at(i), KConfig::SimpleConfig);
@@ -400,25 +524,27 @@ QString ProfilesDialog::getPathFromDescription(const QString profileDesc)
     QStringList customProfiles = KGlobal::dirs()->findDirs("appdata", "profiles");
     for (int i = 0; i < customProfiles.size(); ++i) {
         QStringList profiles = QDir(customProfiles.at(i)).entryList(profilesFilter, QDir::Files);
-        for (int i = 0; i < profiles.size(); ++i) {
-            KConfig confFile(customProfiles.at(i) + profiles.at(i), KConfig::SimpleConfig);
+        for (int j = 0; j < profiles.size(); ++j) {
+            KConfig confFile(customProfiles.at(i) + profiles.at(j), KConfig::SimpleConfig);
             QMap< QString, QString > values = confFile.entryMap();
-            if (values.value("description") == profileDesc) return customProfiles.at(i) + profiles.at(i);
+            if (values.value("description") == profileDesc) return customProfiles.at(i) + profiles.at(j);
         }
     }
     return QString();
 }
 
 // static
-void ProfilesDialog::saveProfile(MltVideoProfile &profile)
+void ProfilesDialog::saveProfile(MltVideoProfile &profile, QString profilePath)
 {
-    int i = 0;
-    QString customName = "profiles/customprofile";
-    QString profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
-    kDebug() << " TYING PROFILE FILE: " << profilePath;
-    while (KIO::NetAccess::exists(KUrl(profilePath), KIO::NetAccess::SourceSide, 0)) {
-        i++;
+    if (profilePath.isEmpty()) {
+        int i = 0;
+        QString customName = "profiles/customprofile";
         profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
+        kDebug() << " TYING PROFILE FILE: " << profilePath;
+        while (KIO::NetAccess::exists(KUrl(profilePath), KIO::NetAccess::SourceSide, 0)) {
+            ++i;
+            profilePath = KStandardDirs::locateLocal("appdata", customName + QString::number(i));
+        }
     }
     QFile file(profilePath);
     if (!file.open(QIODevice::WriteOnly)) {
@@ -426,7 +552,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));
     }
@@ -435,7 +561,7 @@ void ProfilesDialog::saveProfile(MltVideoProfile &profile)
 }
 
 
-void ProfilesDialog::slotUpdateDisplay()
+void ProfilesDialog::slotUpdateDisplay(QString currentProfile)
 {
     if (askForSave() == false) {
         m_view.profiles_list->blockSignals(true);
@@ -443,10 +569,12 @@ void ProfilesDialog::slotUpdateDisplay()
         m_view.profiles_list->blockSignals(false);
         return;
     }
-
+    QLocale locale;
     m_selectedProfileIndex = m_view.profiles_list->currentIndex();
-    QString currentProfile = m_view.profiles_list->itemData(m_view.profiles_list->currentIndex()).toString();
+    if (currentProfile.isEmpty())
+        currentProfile = m_view.profiles_list->itemData(m_view.profiles_list->currentIndex()).toString();
     m_isCustomProfile = currentProfile.contains('/');
+    m_view.button_create->setEnabled(true);
     m_view.button_delete->setEnabled(m_isCustomProfile);
     m_view.properties->setEnabled(m_isCustomProfile);
     m_view.button_save->setEnabled(m_isCustomProfile);
@@ -461,9 +589,41 @@ void ProfilesDialog::slotUpdateDisplay()
     m_view.frame_num->setValue(values.value("frame_rate_num").toInt());
     m_view.frame_den->setValue(values.value("frame_rate_den").toInt());
     m_view.progressive->setChecked(values.value("progressive").toInt());
+    if (values.value("progressive").toInt()) {
+        m_view.fields->setText(locale.toString((double) values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2));
+    } else {
+        m_view.fields->setText(locale.toString((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");
+    }
+}
+
+//static
+int ProfilesDialog::getColorspaceFromDescription(const QString &description)
+{
+    //TODO: should the descriptions be translated?
+    if (description == "SMPTE240M") return 240;
+    if (description == "ITU-R 709") return 709;
+    return 601;
+}
 
 #include "profilesdialog.moc"