From a1bec067bd32e1b489c8be5d3968b45b4645d659 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Tue, 7 Jun 2011 08:30:32 +0000 Subject: [PATCH] Use the new profile selection combobox for project proxy settings svn path=/trunk/kdenlive/; revision=5675 --- src/projectsettings.cpp | 59 +++++++++++++++++++++---- src/projectsettings.h | 2 + src/widgets/projectsettings_ui.ui | 73 +++++++++++++++++++++++-------- 3 files changed, 106 insertions(+), 28 deletions(-) diff --git a/src/projectsettings.cpp b/src/projectsettings.cpp index d6762537..41deae0f 100644 --- a/src/projectsettings.cpp +++ b/src/projectsettings.cpp @@ -65,32 +65,67 @@ 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 + QString profileFile = KStandardDirs::locateLocal("appdata", "encodingprofiles.rc"); + KConfig conf(profileFile, KConfig::SimpleConfig); + KConfigGroup group(&conf, "proxy"); + QMap values = group.entryMap(); + QMapIterator 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 (params == proxyparameters && extension == proxyextension) { + // 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); @@ -372,12 +407,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 @@ -493,7 +530,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" diff --git a/src/projectsettings.h b/src/projectsettings.h index 1209fb9c..dec739bc 100644 --- a/src/projectsettings.h +++ b/src/projectsettings.h @@ -47,6 +47,8 @@ public: QString proxyExtension() const; static QStringList extractPlaylistUrls(QString path); static QStringList extractSlideshowUrls(KUrl url); + /** @brief Update the displayed proxy parameters when user changes selection. */ + void slotUpdateProxyParams(); public slots: virtual void accept(); diff --git a/src/widgets/projectsettings_ui.ui b/src/widgets/projectsettings_ui.ui index 73d200a8..a565118c 100644 --- a/src/widgets/projectsettings_ui.ui +++ b/src/widgets/projectsettings_ui.ui @@ -6,8 +6,8 @@ 0 0 - 337 - 527 + 332 + 529 @@ -32,7 +32,7 @@ QFrame::Raised - + Qt::Horizontal @@ -42,6 +42,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -247,14 +260,14 @@ false - + Generate for videos larger than - + pixels @@ -267,14 +280,14 @@ - + Generate for images larger than - + pixels @@ -290,27 +303,49 @@ - - + + + + + 0 + 0 + + - FFmpeg video transcoding parameters + Encoding profile - - + + + + + 0 + 0 + + + - - - - File extension + + + + + 0 + 0 + + + + true - - + + - avi + ... + + + true -- 2.39.2