Commit 9dd1aed1 authored by Julius Künzel's avatar Julius Künzel
Browse files

[Project Profile Editor] Face lift and refactoring

Includes first steps for setting the field order too (not enabled yet)
parent 1e4ac5e9
Pipeline #145075 passed with stage
in 5 minutes and 30 seconds
......@@ -4,6 +4,7 @@
SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "effects/effectsrepository.hpp"
#include "profilesdialog.h"
#include "core.h"
#include "kdenlivesettings.h"
......@@ -26,13 +27,10 @@ ProfilesDialog::ProfilesDialog(const QString &profileDescription, QWidget *paren
ProfileRepository::get()->refresh();
m_view.setupUi(this);
// Add message widget
auto *lay = static_cast<QGridLayout *>(layout());
m_infoMessage = new KMessageWidget;
lay->addWidget(m_infoMessage, 2, 0, 1, -1);
m_infoMessage->setCloseButtonVisible(true);
m_infoMessage->hide();
m_view.info_message->hide();
// TODO setting the fied order is not implemented yet
m_view.label_field_order->setVisible(false);
m_view.field_order->setVisible(false);
// Fill colorspace list (see mlt_profile.h)
m_view.colorspace->addItem(ProfileRepository::getColorspaceDescription(601), 601);
......@@ -43,13 +41,6 @@ ProfilesDialog::ProfilesDialog(const QString &profileDescription, QWidget *paren
QStringList profilesFilter;
profilesFilter << QStringLiteral("*");
m_view.button_delete->setIcon(QIcon::fromTheme(QStringLiteral("trash-empty")));
m_view.button_delete->setToolTip(i18n("Delete profile"));
m_view.button_save->setIcon(QIcon::fromTheme(QStringLiteral("document-save")));
m_view.button_save->setToolTip(i18n("Save profile"));
m_view.button_create->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
m_view.button_create->setToolTip(i18n("Create new profile"));
fillList(profileDescription);
slotUpdateDisplay();
connectDialog();
......@@ -70,7 +61,8 @@ void ProfilesDialog::connectDialog()
connect(m_view.aspect_den, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ProfilesDialog::slotProfileEdited);
connect(m_view.display_num, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ProfilesDialog::slotProfileEdited);
connect(m_view.display_den, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ProfilesDialog::slotProfileEdited);
connect(m_view.progressive, &QCheckBox::stateChanged, this, &ProfilesDialog::slotProfileEdited);
connect(m_view.scanning, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ProfilesDialog::slotProfileEdited);
connect(m_view.scanning, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &ProfilesDialog::slotScanningChanged);
connect(m_view.size_h, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &ProfilesDialog::slotProfileEdited);
connect(m_view.size_h, &QAbstractSpinBox::editingFinished, this, &ProfilesDialog::slotAdjustHeight);
m_view.size_h->setSingleStep(2);
......@@ -85,13 +77,10 @@ ProfilesDialog::ProfilesDialog(const QString &profilePath, bool, QWidget *parent
, m_customProfilePath(profilePath)
{
m_view.setupUi(this);
// Add message widget
auto *lay = static_cast<QGridLayout *>(layout());
m_infoMessage = new KMessageWidget;
lay->addWidget(m_infoMessage, 2, 0, 1, -1);
m_infoMessage->setCloseButtonVisible(true);
m_infoMessage->hide();
m_view.info_message->hide();
// TODO setting the fied order is not implemented yet
m_view.label_field_order->setVisible(false);
m_view.field_order->setVisible(false);
// Fill colorspace list (see mlt_profile.h)
m_view.colorspace->addItem(ProfileRepository::getColorspaceDescription(601), 601);
......@@ -102,8 +91,6 @@ ProfilesDialog::ProfilesDialog(const QString &profilePath, bool, QWidget *parent
QStringList profilesFilter;
profilesFilter << QStringLiteral("*");
m_view.button_save->setIcon(QIcon::fromTheme(QStringLiteral("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);
......@@ -122,13 +109,12 @@ void ProfilesDialog::slotAdjustWidth()
int correctedWidth = val + (val % 2);
if (val == correctedWidth) {
// Ok, no action required, width is a multiple of 2
m_infoMessage->animatedHide();
m_view.info_message->animatedHide();
} else {
m_view.size_w->setValue(correctedWidth);
m_infoMessage->setText(i18n("Profile width must be a multiple of 2. It was adjusted to %1", correctedWidth));
m_infoMessage->setWordWrap(m_infoMessage->text().length() > 35);
m_infoMessage->setMessageType(KMessageWidget::Warning);
m_infoMessage->animatedShow();
m_view.info_message->setText(i18n("Profile width must be a multiple of 2. It was adjusted to %1", correctedWidth));
m_view.info_message->setMessageType(KMessageWidget::Warning);
m_view.info_message->animatedShow();
}
}
......@@ -140,13 +126,23 @@ void ProfilesDialog::slotAdjustHeight()
int correctedHeight = val + (val % 2);
if (val == correctedHeight) {
// Ok, no action required, height is a multiple of 2
m_infoMessage->animatedHide();
m_view.info_message->animatedHide();
} else {
m_view.size_h->setValue(correctedHeight);
m_infoMessage->setText(i18n("Profile height must be a multiple of 2. It was adjusted to %1", correctedHeight));
m_infoMessage->setWordWrap(m_infoMessage->text().length() > 35);
m_infoMessage->setMessageType(KMessageWidget::Warning);
m_infoMessage->animatedShow();
m_view.info_message->setText(i18n("Profile height must be a multiple of 2. It was adjusted to %1", correctedHeight));
m_view.info_message->setMessageType(KMessageWidget::Warning);
m_view.info_message->animatedShow();
}
}
void ProfilesDialog::slotScanningChanged(int ix)
{
m_view.field_order->setEnabled(ix == 0);
m_view.label_field_order->setEnabled(ix == 0);
if (ix == 0 && !EffectsRepository::get()->hasInternalEffect(QStringLiteral("avfilter.fieldorder"))) {
m_view.effect_warning->show();
} else {
m_view.effect_warning->hide();
}
}
......@@ -228,10 +224,9 @@ void ProfilesDialog::slotCreateProfile()
void ProfilesDialog::slotSetDefaultProfile()
{
if (m_profileIsModified) {
m_infoMessage->setText(i18n("Save your profile before setting it to default"));
m_infoMessage->setWordWrap(m_infoMessage->text().length() > 35);
m_infoMessage->setMessageType(KMessageWidget::Warning);
m_infoMessage->animatedShow();
m_view.info_message->setText(i18n("Save your profile before setting it to default"));
m_view.info_message->setMessageType(KMessageWidget::Warning);
m_view.info_message->animatedShow();
return;
}
int ix = m_view.profiles_list->currentIndex();
......@@ -289,7 +284,7 @@ void ProfilesDialog::saveProfile(const QString &path)
profile->m_frame_rate_den = m_view.frame_den->value();
profile->m_width = m_view.size_w->value();
profile->m_height = m_view.size_h->value();
profile->m_progressive = static_cast<int>(m_view.progressive->isChecked());
profile->m_progressive = m_view.scanning->currentIndex() == 1;
profile->m_sample_aspect_num = m_view.aspect_num->value();
profile->m_sample_aspect_den = m_view.aspect_den->value();
profile->m_display_aspect_num = m_view.display_num->value();
......@@ -338,7 +333,8 @@ void ProfilesDialog::slotUpdateDisplay(QString currentProfilePath)
m_view.display_den->setValue(curProfile->display_aspect_den());
m_view.frame_num->setValue(curProfile->frame_rate_num());
m_view.frame_den->setValue(curProfile->frame_rate_den());
m_view.progressive->setChecked(curProfile->progressive() != 0);
m_view.scanning->setCurrentIndex(curProfile->progressive() ? 1 : 0);
slotScanningChanged(m_view.scanning->currentIndex());
if (curProfile->progressive() != 0) {
m_view.fields->setText(locale.toString(double(curProfile->frame_rate_num() / curProfile->frame_rate_den()), 'f', 2));
} else {
......
......@@ -38,6 +38,7 @@ private slots:
void slotAdjustWidth();
/** @brief Make sure the profile's height is always a multiple of 2 */
void slotAdjustHeight();
void slotScanningChanged(int ix);
void accept() override;
void reject() override;
......@@ -50,7 +51,6 @@ private:
QString m_customProfilePath;
/** @brief True if a profile was saved / deleted and profile tree requires a reload. */
bool m_profilesChanged{false};
KMessageWidget *m_infoMessage;
void saveProfile(const QString &path);
bool askForSave();
void connectDialog();
......
......@@ -17,6 +17,7 @@
#include <KMessageBox>
#include <QComboBox>
#include <QCheckBox>
#include <QDir>
#include <QFile>
#include <QMenu>
......
......@@ -14,23 +14,17 @@
<string>Profiles</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="6">
<widget class="QToolButton" name="button_delete">
<property name="enabled">
<bool>false</bool>
<item row="0" column="4">
<widget class="QToolButton" name="button_create">
<property name="toolTip">
<string>Create new profile</string>
</property>
<property name="text">
<string>D</string>
<string>C</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="button_save">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>S</string>
<property name="icon">
<iconset theme="document-new">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
......@@ -41,10 +35,20 @@
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="button_create">
<item row="0" column="6">
<widget class="QToolButton" name="button_delete">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Delete profile</string>
</property>
<property name="text">
<string>C</string>
<string>D</string>
</property>
<property name="icon">
<iconset theme="delete">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
......@@ -54,16 +58,16 @@
<string>Properties</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Description:</string>
<item row="4" column="3">
<widget class="QSpinBox" name="aspect_den">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="description"/>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="size_w">
<property name="minimum">
......@@ -74,19 +78,6 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>x</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="size_h">
<property name="minimum">
......@@ -97,25 +88,41 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<item row="3" column="3">
<widget class="QLabel" name="fields">
<property name="text">
<string>Frame rate:</string>
<string notr="true">interl: 2*fps</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QSpinBox" name="frame_num">
<property name="minimum">
<number>1</number>
<item row="5" column="0">
<widget class="QLabel" name="label_dar">
<property name="text">
<string>Display aspect ratio:</string>
</property>
<property name="maximum">
<number>500000</number>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_4">
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Frame rate:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QLineEdit" name="description"/>
</item>
<item row="7" column="1" colspan="3">
<widget class="KComboBox" name="colorspace"/>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
......@@ -127,8 +134,22 @@
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QSpinBox" name="frame_den">
<item row="9" column="1" colspan="3">
<widget class="QComboBox" name="field_order">
<item>
<property name="text">
<string>Top Field First</string>
</property>
</item>
<item>
<property name="text">
<string>Bottom Field First</string>
</property>
</item>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="display_num">
<property name="minimum">
<number>1</number>
</property>
......@@ -137,10 +158,26 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_9">
<item row="8" column="0">
<widget class="QLabel" name="label_scanning">
<property name="text">
<string>Pixel aspect ratio:</string>
<string>Scanning:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>/</string>
</property>
</widget>
</item>
......@@ -154,8 +191,8 @@
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QLabel" name="label_7">
<item row="1" column="2">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
......@@ -163,47 +200,41 @@
</sizepolicy>
</property>
<property name="text">
<string>/</string>
<string>x</string>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QSpinBox" name="aspect_den">
<property name="minimum">
<number>1</number>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Description:</string>
</property>
<property name="maximum">
<number>10000</number>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Display aspect ratio:</string>
</property>
<item row="8" column="1" colspan="3">
<widget class="QComboBox" name="scanning">
<item>
<property name="text">
<string>Interlaced</string>
</property>
</item>
<item>
<property name="text">
<string>Progressive</string>
</property>
</item>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="display_num">
<item row="2" column="1">
<widget class="QSpinBox" name="frame_num">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_8">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>/</string>
<number>500000</number>
</property>
</widget>
</item>
......@@ -217,7 +248,7 @@
</property>
</widget>
</item>
<item row="9" column="0" colspan="2">
<item row="11" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -230,41 +261,93 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Pixel aspect ratio:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Colorspace:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_11">
<item row="9" column="0">
<widget class="QLabel" name="label_field_order">
<property name="text">
<string>Fields per second:</string>
<string>Field order:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QLabel" name="fields">
<item row="4" column="2">
<widget class="QLabel" name="label_7">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">interl: 2*fps</string>
<string>/</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Colorspace:</string>
<item row="2" column="3">
<widget class="QSpinBox" name="frame_den">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="KComboBox" name="colorspace"/>
<item row="3" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Fields per second:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="progressive">
<item row="10" column="1" colspan="3">
<widget class="KMessageWidget" name="effect_warning">
<property name="text">
<string>Progressive</string>
<string>The &quot;avfilter.fieldorder&quot; effect is internally used to set the field order, but the effect was not found.
This feature will not work as expected.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="closeButtonVisible">
<bool>false</bool>
</property>
<property name="messageType">
<enum>KMessageWidget::Warning</enum>
</property>
</widget>
</item>
......@@ -284,29 +367,20 @@
</property>
</spacer>
</item>
<item row="2" column="0" colspan="7">
<widget class="QFrame" name="messageFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<item row="0" column="5">
<widget class="QToolButton" name="button_save">
<property name="enabled">
<bool>false</bool>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
<property name="toolTip">
<string>Save profile</string>
</property>
</widget>
</item>
<item row="3" column="5" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<property name="text">
<string>S</string>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
<property name="icon">