Commit 4ea9a738 authored by Julius Künzel's avatar Julius Künzel
Browse files

Refactor Kdenlive Settings

parent ed99187e
Pipeline #128311 passed with stage
in 5 minutes and 37 seconds
......@@ -14,17 +14,41 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include <QStandardPaths>
#include <QVBoxLayout>
EncodingProfilesDialog::EncodingProfilesDialog(int profileType, QWidget *parent)
QString EncodingProfilesManager::configGroupName(ProfileType type)
{
QString groupName;
switch (type) {
case ProfileType::ProxyClips:
groupName = QStringLiteral("proxy");
break;
case ProfileType::V4LCapture:
groupName = QStringLiteral("video4linux");
break;
case ProfileType::ScreenCapture:
groupName = QStringLiteral("screengrab");
break;
case ProfileType::DecklinkCapture:
groupName = QStringLiteral("decklink");
break;
case ProfileType::TimelinePreview:
default:
groupName = QStringLiteral("timelinepreview");
break;
}
return groupName;
}
EncodingProfilesDialog::EncodingProfilesDialog(EncodingProfilesManager::ProfileType profileType, QWidget *parent)
: QDialog(parent)
, m_configGroup(nullptr)
{
setupUi(this);
setWindowTitle(i18n("Manage Encoding Profiles"));
profile_type->addItem(i18n("Proxy clips"), 0);
profile_type->addItem(i18n("Timeline preview"), 1);
profile_type->addItem(i18n("Video4Linux capture"), 2);
profile_type->addItem(i18n("Screen capture"), 3);
profile_type->addItem(i18n("Decklink capture"), 4);
profile_type->addItem(i18n("Proxy clips"), EncodingProfilesManager::ProxyClips);
profile_type->addItem(i18n("Timeline preview"), EncodingProfilesManager::TimelinePreview);
profile_type->addItem(i18n("Video4Linux capture"), EncodingProfilesManager::V4LCapture);
profile_type->addItem(i18n("Screen capture"), EncodingProfilesManager::ScreenCapture);
profile_type->addItem(i18n("Decklink capture"), EncodingProfilesManager::DecklinkCapture);
button_add->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
button_edit->setIcon(QIcon::fromTheme(QStringLiteral("document-edit")));
......@@ -52,28 +76,9 @@ void EncodingProfilesDialog::slotLoadProfiles()
{
profile_list->blockSignals(true);
profile_list->clear();
QString group;
switch (profile_type->currentIndex()) {
case 0:
group = QStringLiteral("proxy");
break;
case 2:
group = QStringLiteral("video4linux");
break;
case 3:
group = QStringLiteral("screengrab");
break;
case 4:
group = QStringLiteral("decklink");
break;
case 1:
default:
group = QStringLiteral("timelinepreview");
break;
}
delete m_configGroup;
m_configGroup = new KConfigGroup(m_configFile, group);
m_configGroup = new KConfigGroup(m_configFile, EncodingProfilesManager::configGroupName(EncodingProfilesManager::ProfileType(profile_type->currentIndex())));
QMap<QString, QString> values = m_configGroup->entryMap();
QMapIterator<QString, QString> i(values);
while (i.hasNext()) {
......@@ -175,3 +180,111 @@ void EncodingProfilesDialog::slotEditProfile()
}
delete d;
}
EncodingProfilesChooser::EncodingProfilesChooser(QWidget *parent, EncodingProfilesManager::ProfileType type, bool showAutoItem, const QString &configName)
: QWidget(parent)
, m_type(type)
, m_showAutoItem(showAutoItem)
{
QGridLayout *grid = new QGridLayout();
grid->setMargin(0);
setLayout(grid);
m_profilesCombo = new QComboBox();
if (!configName.isEmpty()) {
m_profilesCombo->setObjectName(QStringLiteral("kcfg_%1").arg(configName));
}
QToolButton *buttonConfigure = new QToolButton();
buttonConfigure->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
buttonConfigure->setText(i18n("Configure profiles"));
buttonConfigure->setToolTip(i18n("Manage Encoding Profiles"));
QToolButton *buttonInfo = new QToolButton();
buttonInfo->setCheckable(true);
buttonInfo->setIcon(QIcon::fromTheme(QStringLiteral("help-about")));
buttonConfigure->setToolTip(i18n("Show Profile Parameters"));
m_info = new QPlainTextEdit();
m_info->setVisible(false);
m_info->setReadOnly(true);
m_info->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 3);
grid->addWidget(m_profilesCombo, 0, 0);
grid->addWidget(buttonConfigure, 0, 1);
grid->addWidget(buttonInfo, 0, 2);
grid->addWidget(m_info, 1, 0, -1, -1);
connect(buttonConfigure, &QAbstractButton::clicked, this, &EncodingProfilesChooser::slotManageEncodingProfile);
connect(buttonInfo, &QAbstractButton::clicked, m_info, &QWidget::setVisible);
connect(m_profilesCombo, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&EncodingProfilesChooser::slotUpdateProfile);
loadEncodingProfiles();
if (!configName.isEmpty()) {
KConfigGroup resourceConfig(KSharedConfig::openConfig(), "project");
int ix = resourceConfig.readEntry(configName).toInt();
m_profilesCombo->setCurrentIndex(ix);
slotUpdateProfile(ix);
}
}
void EncodingProfilesChooser::slotManageEncodingProfile()
{
QPointer<EncodingProfilesDialog> dia = new EncodingProfilesDialog(m_type);
dia->exec();
delete dia;
loadEncodingProfiles();
}
void EncodingProfilesChooser::loadEncodingProfiles() {
m_profilesCombo->blockSignals(true);
QString currentItem = m_profilesCombo->currentText();
m_profilesCombo->clear();
if (m_showAutoItem) {
m_profilesCombo->addItem(i18n("Automatic"));
}
KConfig conf(QStringLiteral("encodingprofiles.rc"), KConfig::CascadeConfig, QStandardPaths::AppDataLocation);
KConfigGroup group(&conf, EncodingProfilesManager::configGroupName(m_type));
QMap<QString, QString> values = group.entryMap();
QMapIterator<QString, QString> i(values);
while (i.hasNext()) {
i.next();
if (!i.key().isEmpty()) {
m_profilesCombo->addItem(i.key(), i.value());
}
}
if (!currentItem.isEmpty()) {
int ix = m_profilesCombo->findText(currentItem);
m_profilesCombo->setCurrentIndex(ix);
slotUpdateProfile(ix);
}
m_profilesCombo->blockSignals(false);
}
QString EncodingProfilesChooser::currentExtension()
{
QString profilestr = m_profilesCombo->currentData().toString();
if (profilestr.isEmpty()) {
return {};
}
return profilestr.section(QLatin1Char(';'), 1, 1);
}
QString EncodingProfilesChooser::currentParams()
{
QString profilestr = m_profilesCombo->currentData().toString();
if (profilestr.isEmpty()) {
return {};
}
return profilestr.section(QLatin1Char(';'), 0, 0);
}
void EncodingProfilesChooser::slotUpdateProfile(int ix)
{
m_info->clear();
QString profilestr = m_profilesCombo->itemData(ix).toString();
if (!profilestr.isEmpty()) {
m_info->setPlainText(profilestr.section(QLatin1Char(';'), 0, 0));
}
}
......@@ -12,12 +12,27 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "definitions.h"
#include "ui_manageencodingprofile_ui.h"
class EncodingProfilesManager
{
public:
enum ProfileType {
ProxyClips = 0,
TimelinePreview = 1,
V4LCapture = 2,
ScreenCapture = 3,
DecklinkCapture = 4
};
static QString configGroupName(ProfileType type);
};
class EncodingProfilesDialog : public QDialog, Ui::ManageEncodingProfile_UI
{
Q_OBJECT
public:
explicit EncodingProfilesDialog(int profileType, QWidget *parent = nullptr);
explicit EncodingProfilesDialog(EncodingProfilesManager::ProfileType profileType, QWidget *parent = nullptr);
~EncodingProfilesDialog() override;
private slots:
......@@ -32,4 +47,28 @@ private:
KConfigGroup *m_configGroup;
};
class EncodingProfilesChooser : public QWidget
{
Q_OBJECT
public:
EncodingProfilesChooser(QWidget *parent, EncodingProfilesManager::ProfileType, bool showAutoItem = false, const QString &configname = {});
QString currentExtension();
QString currentParams();
public slots:
void slotUpdateProfile(int ix);
private:
QComboBox *m_profilesCombo;
QPlainTextEdit *m_info;
EncodingProfilesManager::ProfileType m_type;
bool m_showAutoItem;
private slots:
void slotManageEncodingProfile();
void loadEncodingProfiles();
};
#endif
This diff is collapsed.
......@@ -25,6 +25,7 @@ SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
#include "ui_configspeech_ui.h"
#include "pythoninterfaces/speechtotext.h"
#include "encodingprofilesdialog.h"
class ProfileWidget;
class KJob;
......@@ -85,12 +86,6 @@ private slots:
void slotEnableVideoFolder();
void slotUpdatev4lDevice();
void slotUpdatev4lCaptureProfile();
void slotManageEncodingProfile();
void slotUpdateDecklinkProfile(int ix = 0);
void slotUpdateProxyProfile(int ix = 0);
void slotUpdatePreviewProfile(int ix = 0);
void slotUpdateV4lProfile(int ix = 0);
void slotUpdateGrabProfile(int ix = 0);
void slotEditVideo4LinuxProfile();
void slotReloadBlackMagic();
void slotReloadShuttleDevices();
......@@ -136,21 +131,34 @@ private:
SpeechToText *m_stt;
QMap<QString, QString> m_mappable_actions;
QVector<QComboBox *> m_shuttle_buttons;
EncodingProfilesChooser *m_tlPreviewProfiles;
EncodingProfilesChooser *m_proxyProfiles;
EncodingProfilesChooser *m_decklinkProfiles;
EncodingProfilesChooser *m_v4lProfiles;
EncodingProfilesChooser *m_grabProfiles;
void initDevices();
void loadTranscodeProfiles();
void saveTranscodeProfiles();
void loadCurrentV4lProfileInfo();
void saveCurrentV4lProfile();
void loadEncodingProfiles();
void setupJogshuttleBtns(const QString &device);
/** @brief Fill a combobox with the found blackmagic devices */
static bool getBlackMagicDeviceList(QComboBox *devicelist, bool force = false);
static bool getBlackMagicOutputDeviceList(QComboBox *devicelist, bool force = false);
/** @brief Init QtMultimedia audio record settings */
bool initAudioRecDevice();
void initMiscPage();
void initProjectPage();
void initProxyPage();
void initTimelinePage();
void initEnviromentPage();
void initColorsPage();
/** @brief Init Speech to text settings */
void initSpeechPage();
/** @brief Check version of installed python modules for speech to text */
void initCapturePage();
void initJogShuttlePage();
void initSdlPage(bool gpuAllowed);
void initTranscodePage();
signals:
void customChanged();
......
......@@ -777,7 +777,7 @@ void ProjectSettings::slotDeleteMetadataField()
void ProjectSettings::slotManageEncodingProfile()
{
QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(0);
QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(EncodingProfilesManager::ProxyClips);
d->exec();
delete d;
loadProxyProfiles();
......@@ -785,7 +785,7 @@ void ProjectSettings::slotManageEncodingProfile()
void ProjectSettings::slotManagePreviewProfile()
{
QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(1);
QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(EncodingProfilesManager::TimelinePreview);
d->exec();
delete d;
loadPreviewProfiles();
......
This diff is collapsed.
......@@ -77,6 +77,9 @@
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset theme="view-refresh"/>
</property>
</widget>
</item>
<item row="2" column="0">
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>579</width>
<height>250</height>
<height>269</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
......@@ -17,6 +17,9 @@
<property name="topMargin">
<number>0</number>
</property>
<item row="1" column="1">
<widget class="QSpinBox" name="kcfg_videotracks"/>
</item>
<item row="0" column="0" colspan="7">
<widget class="QGroupBox" name="profile_box">
<property name="flat">
......@@ -24,26 +27,34 @@
</property>
</widget>
</item>
<item row="7" column="0" colspan="7">
<widget class="QPlainTextEdit" name="previewparams">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="1" column="4">
<widget class="QLabel" name="label">
<property name="text">
<string>Audio channels</string>
</property>
<property name="readOnly">
<bool>true</bool>
</widget>
</item>
<item row="3" column="0" colspan="6">
<widget class="QCheckBox" name="kcfg_sameprojectfolder">
<property name="text">
<string>Use parent folder of the project file as project folder</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="kcfg_audiotracks"/>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label">
<item row="1" column="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Audio channels</string>
<string>Audio tracks</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Video tracks</string>
</property>
</widget>
</item>
......@@ -72,68 +83,7 @@
</item>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="kcfg_videotracks"/>
</item>
<item row="6" column="0" colspan="7">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_25">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Timeline Preview</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="kcfg_preview_profile">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="preview_showprofileinfo">
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="preview_manageprofile">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Audio tracks</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Video tracks</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -156,7 +106,7 @@
</widget>
</item>
<item>
<widget class="KUrlRequester" name="projecturl" native="true">
<widget class="KUrlRequester" name="projecturl">
<property name="enabled">
<bool>false</bool>
</property>
......@@ -164,12 +114,22 @@
</item>
</layout>
</item>
<item row="3" column="0" colspan="6">
<widget class="QCheckBox" name="kcfg_sameprojectfolder">
<property name="text">
<string>Use parent folder of the project file as project folder</string>
</property>
</widget>
<item row="6" column="0" colspan="6">
<layout class="QHBoxLayout" name="preview_profile_box">
<item>
<widget class="QLabel" name="label_25">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Timeline Preview</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>665</width>
<height>440</height>
<height>278</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
......@@ -48,43 +48,49 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2" colspan="3">
<widget class="QSpinBox" name="kcfg_proxyminsize">
<item row="2" column="2" colspan="2">
<widget class="QSpinBox" name="kcfg_proxyimageminsize">
<property name="suffix">
<string>pixels</string>
</property>
<property name="minimum">
<number>500</number>
</property>
<property name="maximum">
<number>10000</number>
<number>100000</number>
</property>
<property name="value">
<number>1000</number>
<number>2000</number>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="kcfg_externalproxy">
<property name="text">
<string>Use external proxy clips</string>
<item row="4" column="2" colspan="2">
<widget class="QSpinBox" name="kcfg_proxyscale">
<property name="suffix">
<string>pixels</string>
</property>
<property name="minimum">
<number>200</number>
</property>
<property name="maximum">
<number>100000</number>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QToolButton" name="proxy_manageprofile">
<item row="5" column="0">
<widget class="QCheckBox" name="kcfg_externalproxy">
<property name="text">
<string>...</string>
<string>Use external proxy clips</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="5">
<widget class="QPlainTextEdit" name="proxyparams">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="image_label">
<property name="enabled">
<bool>false</bool>
</property>
<property name="readOnly">
<bool>true</bool>
<property name="text">
<string>Proxy image size</string>
</property>
</widget>
</item>
......@@ -101,43 +107,34 @@
</property>
</widget>
</item>
<item row="4" column="2" colspan="3">
<widget class="QSpinBox" name="kcfg_proxyimagesize">
<property name="enabled">
<bool>false</bool>
</property>
<item row="0" column="2" colspan="2">
<widget class="QSpinBox" name="kcfg_proxyminsize">
<property name="suffix">
<string>pixels</string>
</property>
<property name="minimum">
<number>200</number>
</property>
<property name="maximum">
<number>100000</number>
<number>10000</number>
</property>
<property name="value">
<number>800</number>
<number>1000</number>