Warn and force project profile must be a multiple of 8

CCBUG: 357326
parent e5484b9f
...@@ -23,7 +23,9 @@ ...@@ -23,7 +23,9 @@
#include <KMessageBox> #include <KMessageBox>
#include <KMessageWidget>
#include "klocalizedstring.h" #include "klocalizedstring.h"
#include <QDir> #include <QDir>
#include <QScriptEngine> #include <QScriptEngine>
#include <QCloseEvent> #include <QCloseEvent>
...@@ -37,6 +39,13 @@ ProfilesDialog::ProfilesDialog(QWidget * parent) : ...@@ -37,6 +39,13 @@ ProfilesDialog::ProfilesDialog(QWidget * parent) :
{ {
m_view.setupUi(this); 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) // Fill colorspace list (see mlt_profile.h)
m_view.colorspace->addItem(getColorspaceDescription(601), 601); m_view.colorspace->addItem(getColorspaceDescription(601), 601);
m_view.colorspace->addItem(getColorspaceDescription(709), 709); m_view.colorspace->addItem(getColorspaceDescription(709), 709);
...@@ -71,6 +80,7 @@ ProfilesDialog::ProfilesDialog(QWidget * parent) : ...@@ -71,6 +80,7 @@ ProfilesDialog::ProfilesDialog(QWidget * parent) :
connect(m_view.progressive, SIGNAL(stateChanged(int)), this, SLOT(slotProfileEdited())); 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_h, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
connect(m_view.size_w, 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) : ...@@ -82,6 +92,13 @@ ProfilesDialog::ProfilesDialog(QString profilePath, QWidget * parent) :
{ {
m_view.setupUi(this); 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) // Fill colorspace list (see mlt_profile.h)
m_view.colorspace->addItem(getColorspaceDescription(601), 601); m_view.colorspace->addItem(getColorspaceDescription(601), 601);
m_view.colorspace->addItem(getColorspaceDescription(709), 709); m_view.colorspace->addItem(getColorspaceDescription(709), 709);
...@@ -112,6 +129,26 @@ ProfilesDialog::ProfilesDialog(QString profilePath, QWidget * parent) : ...@@ -112,6 +129,26 @@ ProfilesDialog::ProfilesDialog(QString profilePath, QWidget * parent) :
connect(m_view.progressive, SIGNAL(stateChanged(int)), this, SLOT(slotProfileEdited())); 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_h, SIGNAL(valueChanged(int)), this, SLOT(slotProfileEdited()));
connect(m_view.size_w, 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() void ProfilesDialog::slotProfileEdited()
...@@ -179,6 +216,13 @@ void ProfilesDialog::slotCreateProfile() ...@@ -179,6 +216,13 @@ void ProfilesDialog::slotCreateProfile()
void ProfilesDialog::slotSetDefaultProfile() 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(); int ix = m_view.profiles_list->currentIndex();
QString path = m_view.profiles_list->itemData(ix).toString(); QString path = m_view.profiles_list->itemData(ix).toString();
if (!path.isEmpty()) KdenliveSettings::setDefault_profile(path); if (!path.isEmpty()) KdenliveSettings::setDefault_profile(path);
...@@ -186,6 +230,8 @@ void ProfilesDialog::slotSetDefaultProfile() ...@@ -186,6 +230,8 @@ void ProfilesDialog::slotSetDefaultProfile()
bool ProfilesDialog::slotSaveProfile() bool ProfilesDialog::slotSaveProfile()
{ {
slotAdjustWidth();
if (!m_customProfilePath.isEmpty()) { if (!m_customProfilePath.isEmpty()) {
saveProfile(m_customProfilePath); saveProfile(m_customProfilePath);
return true; return true;
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include "ui_profiledialog_ui.h" #include "ui_profiledialog_ui.h"
#include <mlt++/Mlt.h> #include <mlt++/Mlt.h>
class KMessageWidget;
class ProfilesDialog : public QDialog class ProfilesDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
...@@ -86,6 +88,7 @@ private slots: ...@@ -86,6 +88,7 @@ private slots:
void slotDeleteProfile(); void slotDeleteProfile();
void slotSetDefaultProfile(); void slotSetDefaultProfile();
void slotProfileEdited(); void slotProfileEdited();
void slotAdjustWidth();
virtual void accept(); virtual void accept();
virtual void reject(); virtual void reject();
...@@ -96,6 +99,7 @@ private: ...@@ -96,6 +99,7 @@ private:
bool m_isCustomProfile; bool m_isCustomProfile;
/** @brief If we are in single profile editing, should contain the path for this profile. */ /** @brief If we are in single profile editing, should contain the path for this profile. */
QString m_customProfilePath; QString m_customProfilePath;
KMessageWidget *m_infoMessage;
void saveProfile(QString path); void saveProfile(QString path);
bool askForSave(); bool askForSave();
}; };
......
...@@ -6,37 +6,27 @@ ...@@ -6,37 +6,27 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>376</width> <width>430</width>
<height>458</height> <height>502</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Profiles</string> <string>Profiles</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="5">
<widget class="QLabel" name="label"> <widget class="QToolButton" name="button_delete">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Profile</string> <string>D</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="KComboBox" name="profiles_list"/> <widget class="KComboBox" name="profiles_list"/>
</item> </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"> <item row="1" column="0" colspan="7">
<widget class="QGroupBox" name="properties"> <widget class="QGroupBox" name="properties">
<property name="title"> <property name="title">
...@@ -236,20 +226,26 @@ ...@@ -236,20 +226,26 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="2"> <item row="0" column="2">
<widget class="QPushButton" name="button_default"> <spacer name="horizontalSpacer">
<property name="text">
<string>Use as default</string>
</property>
</widget>
</item>
<item row="2" column="4" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons"> <property name="sizeHint" stdset="0">
<set>QDialogButtonBox::Close</set> <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> </property>
</widget> </widget>
</item> </item>
...@@ -260,27 +256,31 @@ ...@@ -260,27 +256,31 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="4"> <item row="3" column="4" colspan="3">
<widget class="QToolButton" name="button_save"> <widget class="QDialogButtonBox" name="buttonBox">
<property name="enabled"> <property name="orientation">
<bool>false</bool> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="text"> <property name="standardButtons">
<string>S</string> <set>QDialogButtonBox::Close</set>
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="5"> <item row="3" column="0" colspan="2">
<widget class="QToolButton" name="button_delete"> <widget class="QPushButton" name="button_default">
<property name="enabled"> <property name="text">
<bool>false</bool> <string>Use as default</string>
</property> </property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>D</string> <string>Profile</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2" colspan="2"> <item row="3" column="2" colspan="2">
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
...@@ -293,6 +293,22 @@ ...@@ -293,6 +293,22 @@
</property> </property>
</spacer> </spacer>
</item> </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> </layout>
</widget> </widget>
<customwidgets> <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