]> git.sesse.net Git - kdenlive/blobdiff - src/projectsettings.cpp
Fix proxy settings sometimes broken (missing extension)
[kdenlive] / src / projectsettings.cpp
index a12eeab42bb851f2348c6a1e47603e5682ae7934..bce75275d7ac0f46bdaf6e359154124c8fd5e1c0 100644 (file)
@@ -65,29 +65,66 @@ ProjectSettings::ProjectSettings(ProjectList *projectlist, QStringList lumas, in
     video_thumbs->setChecked(KdenliveSettings::videothumbnails());
     audio_tracks->setValue(audiotracks);
     video_tracks->setValue(videotracks);
-    proxy_params->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
     connect(generate_proxy, SIGNAL(toggled(bool)), proxy_minsize, SLOT(setEnabled(bool)));
     connect(generate_imageproxy, SIGNAL(toggled(bool)), proxy_imageminsize, SLOT(setEnabled(bool)));
-    
+    QString proxyparameters;
+    QString proxyextension;
     if (projectlist) {
         enable_proxy->setChecked(projectlist->getDocumentProperty("enableproxy").toInt());
         generate_proxy->setChecked(projectlist->getDocumentProperty("generateproxy").toInt());
         proxy_minsize->setValue(projectlist->getDocumentProperty("proxyminsize").toInt());
-        proxy_params->setPlainText(projectlist->getDocumentProperty("proxyparams"));
+        proxyparameters = projectlist->getDocumentProperty("proxyparams");
         generate_imageproxy->setChecked(projectlist->getDocumentProperty("generateimageproxy").toInt());
         proxy_imageminsize->setValue(projectlist->getDocumentProperty("proxyimageminsize").toInt());
-        proxy_extension->setText(projectlist->getDocumentProperty("proxyextension"));
+        proxyextension = projectlist->getDocumentProperty("proxyextension");
     }
     else {
         enable_proxy->setChecked(KdenliveSettings::enableproxy());
         generate_proxy->setChecked(KdenliveSettings::generateproxy());
         proxy_minsize->setValue(KdenliveSettings::proxyminsize());
-        proxy_params->setPlainText(KdenliveSettings::proxyparams());
+        proxyparameters = KdenliveSettings::proxyparams();
         generate_imageproxy->setChecked(KdenliveSettings::generateimageproxy());
         proxy_imageminsize->setValue(KdenliveSettings::proxyimageminsize());
-        proxy_extension->setText(KdenliveSettings::proxyextension());
+        proxyextension = KdenliveSettings::proxyextension();
       
     }
+
+    proxy_minsize->setEnabled(generate_proxy->isChecked());
+    proxy_imageminsize->setEnabled(generate_imageproxy->isChecked());
+
+
+    // load proxy profiles
+    KConfig conf("encodingprofiles.rc", KConfig::FullConfig, "appdata");
+    KConfigGroup group(&conf, "proxy");
+    QMap <QString, QString> values = group.entryMap();
+    QMapIterator<QString, QString> k(values);
+    int ix = -1;
+    while (k.hasNext()) {
+        k.next();
+        if (!k.key().isEmpty()) {
+            QString params = k.value().section(';', 0, 0);
+            QString extension = k.value().section(';', 1, 1);
+            if (ix == -1 && ((params == proxyparameters && extension == proxyextension) || (proxyparameters.isEmpty() || proxyextension.isEmpty()))) {
+                // this is the current profile
+                ix = proxy_profile->count();
+            }
+            proxy_profile->addItem(k.key(), k.value());
+        }
+    }
+    if (ix == -1) {
+        // Current project proxy settings not found
+        ix = proxy_profile->count();
+        proxy_profile->addItem(i18n("Current Settings"), QString(proxyparameters + ';' + proxyextension));
+    }
+    proxy_profile->setCurrentIndex(ix);
+    slotUpdateProxyParams();
+
+    // Proxy GUI stuff
+    proxy_showprofileinfo->setIcon(KIcon("help-about"));
+    connect(proxy_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateProxyParams()));
+    proxyparams->setVisible(false);
+    proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
+    connect(proxy_showprofileinfo, SIGNAL(clicked(bool)), proxyparams, SLOT(setVisible(bool)));
     
     if (readOnlyTracks) {
         video_tracks->setEnabled(false);
@@ -149,8 +186,10 @@ void ProjectSettings::slotClearCache()
 
 void ProjectSettings::slotDeleteProxies()
 {
+    if (KMessageBox::warningContinueCancel(this, i18n("Deleting proxy clips will disable proxies for this project.")) != KMessageBox::Continue) return;
     buttonBox->setEnabled(false);
-    
+    enable_proxy->setChecked(false);
+    emit disableProxies();
     KIO::NetAccess::del(KUrl(project_folder->url().path(KUrl::AddTrailingSlash) + "proxy/"), this);
     KStandardDirs::makeDir(project_folder->url().path(KUrl::AddTrailingSlash) + "proxy/");
     buttonBox->setEnabled(true);
@@ -178,7 +217,7 @@ void ProjectSettings::slotUpdateFiles(bool cacheOnly)
 
     // List all files that are used in the project. That also means:
     // images included in slideshow and titles, files in playlist clips
-    // TODO: images used in luma transitions, files used for LADSPA effects?
+    // TODO: images used in luma transitions?
 
     // Setup categories
     QTreeWidgetItem *videos = new QTreeWidgetItem(files_list, QStringList() << i18n("Video clips"));
@@ -290,6 +329,7 @@ void ProjectSettings::accept()
 
 void ProjectSettings::slotUpdateDisplay()
 {
+    QLocale locale;
     QString currentProfile = profiles_list->itemData(profiles_list->currentIndex()).toString();
     QMap< QString, QString > values = ProfilesDialog::getSettingsFromFile(currentProfile);
     p_size->setText(values.value("width") + 'x' + values.value("height"));
@@ -298,7 +338,7 @@ 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)));
+                                    locale.toString((double)2 * values.value("frame_rate_num").toInt() / values.value("frame_rate_den").toInt(), 'f', 2)));
     } else {
         p_progressive->setText(i18n("Progressive"));
     }
@@ -369,12 +409,14 @@ int ProjectSettings::proxyImageMinSize() const
 
 QString ProjectSettings::proxyParams() const
 {
-    return proxy_params->toPlainText();
+    QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString();
+    return params.section(';', 0, 0);
 }
 
 QString ProjectSettings::proxyExtension() const
 {
-    return proxy_extension->text();
+    QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString();
+    return params.section(';', 1, 1);
 }
 
 //static
@@ -490,7 +532,11 @@ void ProjectSettings::slotExportToText()
     KIO::NetAccess::upload(tmpfile.fileName(), savePath, 0);
 }
 
-
+void ProjectSettings::slotUpdateProxyParams()
+{
+    QString params = proxy_profile->itemData(proxy_profile->currentIndex()).toString();
+    proxyparams->setPlainText(params.section(';', 0, 0));
+}
 
 #include "projectsettings.moc"