Allow proxy profile management from project settings dialog

BUG: 356644
parent 923fa40d
......@@ -271,8 +271,11 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
connect(m_configProject.manage_profiles, SIGNAL(clicked(bool)), this, SLOT(slotEditProfiles()));
// proxy profile stuff
m_configProject.proxy_showprofileinfo->setIcon(KoIconUtils::themedIcon("help-about"));
m_configProject.proxy_manageprofile->setIcon(KoIconUtils::themedIcon("configure"));
m_configProject.proxy_showprofileinfo->setIcon(KoIconUtils::themedIcon(QStringLiteral("help-about")));
m_configProject.proxy_showprofileinfo->setToolTip(i18n("Show default profile parameters"));
m_configProject.proxy_manageprofile->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure")));
m_configProject.proxy_manageprofile->setToolTip(i18n("Manage proxy profiles"));
m_configProject.kcfg_proxy_profile->setToolTip(i18n("Select default proxy profile"));
m_configProject.proxyparams->setVisible(false);
m_configProject.proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
m_configProject.proxyparams->setPlainText(KdenliveSettings::proxyparams());
......
......@@ -24,8 +24,10 @@
#include "doc/kdenlivedoc.h"
#include "utils/KoIconUtils.h"
#include "titler/titlewidget.h"
#include "utils/KoIconUtils.h"
#include "effectslist/effectslist.h"
#include "dialogs/profilesdialog.h"
#include "dialogs/encodingprofilesdialog.h"
#include "mltcontroller/clipcontroller.h"
#include "mltcontroller/bincontroller.h"
......@@ -58,75 +60,51 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap <QString, QString> metad
video_tracks->setValue(videotracks);
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 (doc) {
enable_proxy->setChecked(doc->getDocumentProperty("enableproxy").toInt());
generate_proxy->setChecked(doc->getDocumentProperty("generateproxy").toInt());
proxy_minsize->setValue(doc->getDocumentProperty("proxyminsize").toInt());
proxyparameters = doc->getDocumentProperty("proxyparams");
generate_imageproxy->setChecked(doc->getDocumentProperty("generateimageproxy").toInt());
proxy_imageminsize->setValue(doc->getDocumentProperty("proxyimageminsize").toInt());
proxyextension = doc->getDocumentProperty("proxyextension");
enable_proxy->setChecked(doc->getDocumentProperty(QStringLiteral("enableproxy")).toInt());
generate_proxy->setChecked(doc->getDocumentProperty(QStringLiteral("generateproxy")).toInt());
proxy_minsize->setValue(doc->getDocumentProperty(QStringLiteral("proxyminsize")).toInt());
m_proxyparameters = doc->getDocumentProperty(QStringLiteral("proxyparams"));
generate_imageproxy->setChecked(doc->getDocumentProperty(QStringLiteral("generateimageproxy")).toInt());
proxy_imageminsize->setValue(doc->getDocumentProperty(QStringLiteral("proxyimageminsize")).toInt());
m_proxyextension = doc->getDocumentProperty(QStringLiteral("proxyextension"));
}
else {
enable_proxy->setChecked(KdenliveSettings::enableproxy());
generate_proxy->setChecked(KdenliveSettings::generateproxy());
proxy_minsize->setValue(KdenliveSettings::proxyminsize());
proxyparameters = KdenliveSettings::proxyparams();
m_proxyparameters = KdenliveSettings::proxyparams();
generate_imageproxy->setChecked(KdenliveSettings::generateimageproxy());
proxy_imageminsize->setValue(KdenliveSettings::proxyimageminsize());
proxyextension = KdenliveSettings::proxyextension();
m_proxyextension = KdenliveSettings::proxyextension();
}
proxy_minsize->setEnabled(generate_proxy->isChecked());
proxy_imageminsize->setEnabled(generate_imageproxy->isChecked());
// load proxy profiles
KConfig conf("encodingprofiles.rc", KConfig::CascadeConfig, QStandardPaths::DataLocation);
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();
// Project profiles
manage_profiles->setIcon(KoIconUtils::themedIcon("configure"));
manage_profiles->setToolTip(i18n("Manage Project Profiles"));
connect(manage_profiles, SIGNAL(clicked(bool)), this, SLOT(slotEditProfiles()));
loadProxyProfiles();
// Proxy GUI stuff
proxy_showprofileinfo->setIcon(KoIconUtils::themedIcon("help-about"));
proxy_showprofileinfo->setIcon(KoIconUtils::themedIcon(QStringLiteral("help-about")));
proxy_showprofileinfo->setToolTip(i18n("Show default profile parameters"));
proxy_manageprofile->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure")));
proxy_manageprofile->setToolTip(i18n("Manage proxy profiles"));
connect(proxy_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
proxy_profile->setToolTip(i18n("Select default proxy profile"));
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);
audio_tracks->setEnabled(false);
}
// Metadata list
QTreeWidgetItem *item = new QTreeWidgetItem(metadata_list, QStringList() << i18n("Title"));
item->setData(0, Qt::UserRole, QString("meta.attr.title.markup"));
......@@ -180,8 +158,8 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap <QString, QString> metad
connect(add_metadata, SIGNAL(clicked()), this, SLOT(slotAddMetadataField()));
connect(delete_metadata, SIGNAL(clicked()), this, SLOT(slotDeleteMetadataField()));
add_metadata->setIcon(KoIconUtils::themedIcon("list-add"));
delete_metadata->setIcon(KoIconUtils::themedIcon("list-remove"));
add_metadata->setIcon(KoIconUtils::themedIcon(QStringLiteral("list-add")));
delete_metadata->setIcon(KoIconUtils::themedIcon(QStringLiteral("list-remove")));
slotUpdateDisplay();
if (doc != NULL) {
......@@ -292,25 +270,25 @@ void ProjectSettings::slotUpdateFiles(bool cacheOnly)
// Setup categories
QTreeWidgetItem *videos = new QTreeWidgetItem(files_list, QStringList() << i18n("Video clips"));
videos->setIcon(0, KoIconUtils::themedIcon("video-x-generic"));
videos->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("video-x-generic")));
videos->setExpanded(true);
QTreeWidgetItem *sounds = new QTreeWidgetItem(files_list, QStringList() << i18n("Audio clips"));
sounds->setIcon(0, KoIconUtils::themedIcon("audio-x-generic"));
sounds->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("audio-x-generic")));
sounds->setExpanded(true);
QTreeWidgetItem *images = new QTreeWidgetItem(files_list, QStringList() << i18n("Image clips"));
images->setIcon(0, KoIconUtils::themedIcon("image-x-generic"));
images->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("image-x-generic")));
images->setExpanded(true);
QTreeWidgetItem *slideshows = new QTreeWidgetItem(files_list, QStringList() << i18n("Slideshow clips"));
slideshows->setIcon(0, KoIconUtils::themedIcon("image-x-generic"));
slideshows->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("image-x-generic")));
slideshows->setExpanded(true);
QTreeWidgetItem *texts = new QTreeWidgetItem(files_list, QStringList() << i18n("Text clips"));
texts->setIcon(0, KoIconUtils::themedIcon("text-plain"));
texts->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("text-plain")));
texts->setExpanded(true);
QTreeWidgetItem *playlists = new QTreeWidgetItem(files_list, QStringList() << i18n("Playlist clips"));
playlists->setIcon(0, KoIconUtils::themedIcon("video-mlt-playlist"));
playlists->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("video-mlt-playlist")));
playlists->setExpanded(true);
QTreeWidgetItem *others = new QTreeWidgetItem(files_list, QStringList() << i18n("Other clips"));
others->setIcon(0, KoIconUtils::themedIcon("unknown"));
others->setIcon(0, KoIconUtils::themedIcon(QStringLiteral("unknown")));
others->setExpanded(true);
int count = 0;
QStringList allFonts;
......@@ -678,4 +656,41 @@ void ProjectSettings::slotEditProfiles()
delete w;
}
void ProjectSettings::slotManageEncodingProfile()
{
QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(0);
d->exec();
delete d;
loadProxyProfiles();
}
void ProjectSettings::loadProxyProfiles()
{
// load proxy profiles
KConfig conf(QStringLiteral("encodingprofiles.rc"), KConfig::CascadeConfig, QStandardPaths::DataLocation);
KConfigGroup group(&conf, "proxy");
QMap <QString, QString> values = group.entryMap();
QMapIterator<QString, QString> k(values);
int ix = -1;
proxy_profile->clear();
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 == m_proxyparameters && extension == m_proxyextension) || (m_proxyparameters.isEmpty() || m_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(m_proxyparameters + ';' + m_proxyextension));
}
proxy_profile->setCurrentIndex(ix);
slotUpdateProxyParams();
}
......@@ -71,12 +71,18 @@ private slots:
void slotDeleteMetadataField();
/** @brief Open project profile management dialog. */
void slotEditProfiles();
/** @brief Display proxy profiles management dialog. */
void slotManageEncodingProfile();
private:
QPushButton *m_buttonOk;
bool m_savedProject;
QStringList m_lumas;
void loadProfiles();
QString m_proxyparameters;
QString m_proxyextension;
/** @brief Fill the proxy profiles combobox. */
void loadProxyProfiles();
signals:
/** @brief User deleted proxies, so disable them in project. */
......
......@@ -264,19 +264,6 @@
</property>
</widget>
</item>
<item row="0" column="2" colspan="3">
<widget class="QSpinBox" name="proxy_minsize">
<property name="suffix">
<string>pixels</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="generate_imageproxy">
<property name="text">
......@@ -284,22 +271,6 @@
</property>
</widget>
</item>
<item row="1" column="2" colspan="3">
<widget class="QSpinBox" name="proxy_imageminsize">
<property name="suffix">
<string>pixels</string>
</property>
<property name="minimum">
<number>500</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="value">
<number>2000</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_24">
<property name="sizePolicy">
......@@ -323,7 +294,24 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="5">
<item row="2" column="4">
<widget class="QToolButton" name="proxy_showprofileinfo">
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="5">
<widget class="QToolButton" name="proxy_manageprofile">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="6">
<widget class="QPlainTextEdit" name="proxyparams">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
......@@ -336,13 +324,32 @@
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QToolButton" name="proxy_showprofileinfo">
<property name="text">
<string>...</string>
<item row="1" column="2" colspan="4">
<widget class="QSpinBox" name="proxy_imageminsize">
<property name="suffix">
<string>pixels</string>
</property>
<property name="checkable">
<bool>true</bool>
<property name="minimum">
<number>500</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="value">
<number>2000</number>
</property>
</widget>
</item>
<item row="0" column="2" colspan="4">
<widget class="QSpinBox" name="proxy_minsize">
<property name="suffix">
<string>pixels</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget>
</item>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment