Warn and force project profile must be a multiple of 8

CCBUG: 357326
parent e5484b9f
......@@ -23,7 +23,9 @@
#include <KMessageBox>
#include <KMessageWidget>
#include "klocalizedstring.h"
#include <QDir>
#include <QScriptEngine>
#include <QCloseEvent>
......@@ -37,6 +39,13 @@ ProfilesDialog::ProfilesDialog(QWidget * parent) :
{
m_view.setupUi(this);
// Add message widget
QGridLayout *lay = (QGridLayout *)layout();
m_infoMessage = new KMessageWidget;
lay->addWidget(m_infoMessage, 2, 0, 1, -1);
m_infoMessage->setCloseButtonVisible(true);
m_infoMessage->hide();
// Fill colorspace list (see mlt_profile.h)
m_view.colorspace->addItem(getColorspaceDescription(601), 601);
m_view.colorspace->addItem(getColorspaceDescription(709), 709);
......@@ -71,6 +80,7 @@ ProfilesDialog::ProfilesDialog(QWidget * parent) :
connect(m_view.progressive, SIGNAL(stateChanged(int)), this, SLOT(slotProfileEdited()));
connect(m_view.size_h, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
connect(m_view.size_w, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
connect(m_view.size_w, &QAbstractSpinBox::editingFinished, this, &ProfilesDialog::slotAdjustWidth);
}
......@@ -82,6 +92,13 @@ ProfilesDialog::ProfilesDialog(QString profilePath, QWidget * parent) :
{
m_view.setupUi(this);
// Add message widget
QGridLayout *lay = (QGridLayout *)layout();
m_infoMessage = new KMessageWidget;
lay->addWidget(m_infoMessage, 2, 0, 1, -1);
m_infoMessage->setCloseButtonVisible(true);
m_infoMessage->hide();
// Fill colorspace list (see mlt_profile.h)
m_view.colorspace->addItem(getColorspaceDescription(601), 601);
m_view.colorspace->addItem(getColorspaceDescription(709), 709);
......@@ -112,6 +129,26 @@ ProfilesDialog::ProfilesDialog(QString profilePath, QWidget * parent) :
connect(m_view.progressive, SIGNAL(stateChanged(int)), this, SLOT(slotProfileEdited()));
connect(m_view.size_h, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
connect(m_view.size_w, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
connect(m_view.size_w, &QAbstractSpinBox::editingFinished, this, &ProfilesDialog::slotAdjustWidth);
}
void ProfilesDialog::slotAdjustWidth()
{
// A profile's width should always be a multiple of 8
m_view.size_w->blockSignals(true);
int val = m_view.size_w->value();
int correctedWidth = (val + 7) / 8 * 8;
if (val == correctedWidth) {
// Ok, no action required, width is a multiple of 8
m_infoMessage->animatedHide();
} else {
m_view.size_w->setValue(correctedWidth);
m_infoMessage->setText(i18n("Profile width must be a multiple of 8. It was adjusted to %1", correctedWidth));
m_infoMessage->setWordWrap(m_infoMessage->text().length() > 35);
m_infoMessage->setMessageType(KMessageWidget::Warning);
m_infoMessage->animatedShow();
}
m_view.size_w->blockSignals(false);
}
void ProfilesDialog::slotProfileEdited()
......@@ -179,6 +216,13 @@ 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();
return;
}
int ix = m_view.profiles_list->currentIndex();
QString path = m_view.profiles_list->itemData(ix).toString();
if (!path.isEmpty()) KdenliveSettings::setDefault_profile(path);
......@@ -186,6 +230,8 @@ void ProfilesDialog::slotSetDefaultProfile()
bool ProfilesDialog::slotSaveProfile()
{
slotAdjustWidth();
if (!m_customProfilePath.isEmpty()) {
saveProfile(m_customProfilePath);
return true;
......
......@@ -26,6 +26,8 @@
#include "ui_profiledialog_ui.h"
#include <mlt++/Mlt.h>
class KMessageWidget;
class ProfilesDialog : public QDialog
{
Q_OBJECT
......@@ -86,6 +88,7 @@ private slots:
void slotDeleteProfile();
void slotSetDefaultProfile();
void slotProfileEdited();
void slotAdjustWidth();
virtual void accept();
virtual void reject();
......@@ -96,6 +99,7 @@ private:
bool m_isCustomProfile;
/** @brief If we are in single profile editing, should contain the path for this profile. */
QString m_customProfilePath;
KMessageWidget *m_infoMessage;
void saveProfile(QString path);
bool askForSave();
};
......
......@@ -6,37 +6,27 @@
<rect>
<x>0</x>
<y>0</y>
<width>376</width>
<height>458</height>
<width>430</width>
<height>502</height>
</rect>
</property>
<property name="windowTitle">
<string>Profiles</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<item row="0" column="5">
<widget class="QToolButton" name="button_delete">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Profile</string>
<string>D</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="KComboBox" name="profiles_list"/>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="7">
<widget class="QGroupBox" name="properties">
<property name="title">
......@@ -236,20 +226,26 @@
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QPushButton" name="button_default">
<property name="text">
<string>Use as default</string>
</property>
</widget>
</item>
<item row="2" column="4" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="button_save">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>S</string>
</property>
</widget>
</item>
......@@ -260,27 +256,31 @@
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="button_save">
<property name="enabled">
<bool>false</bool>
<item row="3" column="4" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="text">
<string>S</string>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="button_delete">
<property name="enabled">
<bool>false</bool>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="button_default">
<property name="text">
<string>Use as default</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>D</string>
<string>Profile</string>
</property>
</widget>
</item>
<item row="2" column="2" colspan="2">
<item row="3" column="2" colspan="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -293,6 +293,22 @@
</property>
</spacer>
</item>
<item row="2" column="0" colspan="6">
<widget class="QFrame" name="messageFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
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