Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 75e552cb authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

*Multiple effect fixes for locales with comma as decimal separator

*Minor qml optimizations
parent c3495732
......@@ -3,13 +3,11 @@
<name>Blur</name>
<description>Blur using 2D IIR filters (Exponential, Lowpass, Gaussian)</description>
<author>Marko Cebokli</author>
<parameter type="simplekeyframe" name="Amount" default="40" min="0" max="1000" factor="1000">
<parameter type="keyframe" name="Amount" default="0.4" min="0" max="1000" factor="1000">
<name>Amount</name>
<comment>Amount of blur</comment>
</parameter>
<parameter type="list" name="Type" default="0.5" paramlist="0.0,0.5,0.999">
<parameter type="list" name="Type" default="0.5" paramlist="0.0;0.5;0.999">
<paramlistdisplay>Exponential,Lowpass,Gaussian</paramlistdisplay>
<name>Type</name>
<comment>Select blurring algorithm</comment>
......@@ -20,4 +18,4 @@
<comment>Enable edge compensation</comment>
</parameter>
</effect>
\ No newline at end of file
</effect>
......@@ -267,15 +267,6 @@ template <typename AssetType> QString AbstractAssetsRepository<AssetType>::getDe
template <typename AssetType> bool AbstractAssetsRepository<AssetType>::parseInfoFromXml(const QDomElement &currentAsset, Info &res) const
{
QLocale locale;
// We first deal with locale
if (currentAsset.hasAttribute(QStringLiteral("LC_NUMERIC"))) {
// set a locale for that effect
locale = QLocale(currentAsset.attribute(QStringLiteral("LC_NUMERIC")));
}
locale.setNumberOptions(QLocale::OmitGroupSeparator);
QString tag = currentAsset.attribute(QStringLiteral("tag"), QString());
QString id = currentAsset.attribute(QStringLiteral("id"), QString());
......
......@@ -248,7 +248,7 @@ Rectangle {
// These anchors are important to allow "copy" dragging
anchors.verticalCenter: parent ? parent.verticalCenter : undefined
anchors.right: parent ? parent.right : undefined
property bool isItem : styleData.value != "root" && styleData.value != ""
property bool isItem : styleData.value !== "root" && styleData.value !== ""
property string mimeType : isItem ? assetlist.getMimeType(styleData.value) : ""
height: assetText.implicitHeight + 8
color: "transparent"
......@@ -270,7 +270,7 @@ Rectangle {
Image{
id: assetThumb
visible: assetDelegate.isItem
property bool isFavorite: model == undefined || model.favorite == undefined ? false : model.favorite
property bool isFavorite: model == undefined || model.favorite === undefined ? false : model.favorite
height: parent.height
width: height
source: 'image://asseticon/' + styleData.value
......
......@@ -46,13 +46,14 @@ AssetParameterModel::AssetParameterModel(std::unique_ptr<Mlt::Properties> asset,
bool needsLocaleConversion = false;
QChar separator, oldSeparator;
// Check locale
// Check locale, default effects xml has no LC_NUMERIC defined and always uses the C locale
QLocale locale;
if (assetXml.hasAttribute(QStringLiteral("LC_NUMERIC"))) {
QLocale locale = QLocale(assetXml.attribute(QStringLiteral("LC_NUMERIC")));
if (locale.decimalPoint() != QLocale().decimalPoint()) {
QLocale effectLocale = QLocale(assetXml.attribute(QStringLiteral("LC_NUMERIC")));
if (QLocale::c().decimalPoint() != effectLocale.decimalPoint()) {
needsLocaleConversion = true;
separator = QLocale().decimalPoint();
oldSeparator = locale.decimalPoint();
separator = QLocale::c().decimalPoint();
oldSeparator = effectLocale.decimalPoint();
}
}
......@@ -81,7 +82,6 @@ AssetParameterModel::AssetParameterModel(std::unique_ptr<Mlt::Properties> asset,
ParamRow currentRow;
currentRow.type = paramTypeFromStr(type);
currentRow.xml = currentParameter;
QLocale locale;
if (value.isNull()) {
QVariant defaultValue = parseAttribute(m_ownerId, QStringLiteral("default"), currentParameter);
value = defaultValue.type() == QVariant::Double ? locale.toString(defaultValue.toDouble()) : defaultValue.toString();
......@@ -182,7 +182,7 @@ void AssetParameterModel::setParameter(const QString &name, const QString &param
Q_ASSERT(m_asset->is_valid());
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
qDebug() << "// PROCESSING PARAM CHANGE: " << name << ", UPDATE: "<<update;
qDebug() << "// PROCESSING PARAM CHANGE: " << name << ", UPDATE: "<<update<<", VAL: "<<paramValue;
// TODO: this does not really belong here, but I don't see another way to do it so that undo works
if (data(paramIndex, AssetParameterModel::TypeRole).value<ParamType>() == ParamType::Curve) {
QStringList vals = paramValue.split(QLatin1Char(';'), QString::SkipEmptyParts);
......@@ -508,13 +508,13 @@ QVariant AssetParameterModel::parseAttribute(const ObjectId owner, const QString
p.set("eval", content.toLatin1().constData());
return p.get_double("eval");
}
} else if (type == ParamType::Double) {
} else if (type == ParamType::Double || type == ParamType::Hidden) {
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
if (attribute == QLatin1String("default")) {
int factor = element.attribute(QStringLiteral("factor"), QStringLiteral("1")).toInt();
if (factor > 0) {
return locale.toDouble(content) / factor;
return content.toDouble() / factor;
}
}
return locale.toDouble(content);
......@@ -522,6 +522,19 @@ QVariant AssetParameterModel::parseAttribute(const ObjectId owner, const QString
if (attribute == QLatin1String("default")) {
if (type == ParamType::RestrictedAnim) {
content = getDefaultKeyframes(0, content, true);
} else if (type == ParamType::KeyframeParam) {
return content.toDouble();
} else if (type == ParamType::List) {
bool ok;
double res = content.toDouble(&ok);
if (ok) {
return res;
}
} else if (type == ParamType::Bezier_spline) {
QLocale locale;
if (locale.decimalPoint() != QLocale::c().decimalPoint()) {
return content.replace(QLocale::c().decimalPoint(), locale.decimalPoint());
}
}
}
return content;
......
......@@ -118,6 +118,7 @@ void AssetParameterView::setModel(const std::shared_ptr<AssetParameterModel> &mo
QVector<QPair<QString, QVariant>> AssetParameterView::getDefaultValues() const
{
QLocale locale;
QVector<QPair<QString, QVariant>> values;
for (int i = 0; i < m_model->rowCount(); ++i) {
QModelIndex index = m_model->index(i, 0);
......@@ -125,7 +126,7 @@ QVector<QPair<QString, QVariant>> AssetParameterView::getDefaultValues() const
ParamType type = m_model->data(index, AssetParameterModel::TypeRole).value<ParamType>();
QVariant defaultValue = m_model->data(index, AssetParameterModel::DefaultRole);
if (type == ParamType::KeyframeParam || type == ParamType::AnimatedRect) {
QString val = defaultValue.toString();
QString val = type == ParamType::KeyframeParam ? locale.toString(defaultValue.toDouble()) : defaultValue.toString();
if (!val.contains(QLatin1Char('='))) {
val.prepend(QStringLiteral("%1=").arg(m_model->data(index, AssetParameterModel::ParentInRole).toInt()));
defaultValue = QVariant(val);
......
......@@ -21,7 +21,6 @@
#include "kis_cubic_curve.h"
#include <QList>
#include <QLocale>
#include <QPointF>
#include <QSharedData>
#include <QStringList>
......@@ -405,12 +404,10 @@ void KisCubicCurve::removePoint(int idx)
const QString KisCubicCurve::toString() const
{
QString sCurve;
QLocale locale;
locale.setNumberOptions(QLocale::OmitGroupSeparator);
for (const QPointF &pair : d->data->points) {
sCurve += locale.toString(pair.x());
sCurve += QString::number(pair.x());
sCurve += QStringLiteral("/");
sCurve += locale.toString(pair.y());
sCurve += QString::number(pair.y());
sCurve += QStringLiteral(";");
}
return sCurve;
......@@ -421,12 +418,11 @@ void KisCubicCurve::fromString(const QString &string)
const QStringList data = string.split(QLatin1Char(';'));
QList<QPointF> points;
QLocale locale;
for (const QString &pair : data) {
if (pair.indexOf('/') > -1) {
QPointF p;
p.rx() = locale.toDouble(pair.section(QLatin1Char('/'), 0, 0));
p.ry() = locale.toDouble(pair.section(QLatin1Char('/'), 1, 1));
p.rx() = pair.section(QLatin1Char('/'), 0, 0).toDouble();
p.ry() = pair.section(QLatin1Char('/'), 1, 1).toDouble();
points.append(p);
}
}
......
......@@ -1897,6 +1897,7 @@ void Monitor::loadQmlScene(MonitorSceneType type)
bool sceneWithEdit = type == MonitorSceneGeometry || type == MonitorSceneCorners || type == MonitorSceneRoto;
if ((m_sceneVisibilityAction != nullptr) && !m_sceneVisibilityAction->isChecked() && sceneWithEdit) {
// User doesn't want effect scenes
pCore->displayMessage(i18n("Enable edit mode in monitor to edit effect"), InformationMessage, 500);
type = MonitorSceneDefault;
}
double ratio = (double)m_glMonitor->profileSize().width() / (int)(m_glMonitor->profileSize().height() * m_glMonitor->profile()->dar() + 0.5);
......
......@@ -87,7 +87,6 @@ void QmlManager::setScene(Kdenlive::MonitorId id, MonitorSceneType type, QSize p
root->setProperty("center", displayRect.center());
break;
case MonitorSceneRoto:
// TODO
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitorrotoscene.qml")));
root = m_view->rootObject();
QObject::connect(root, SIGNAL(effectPolygonChanged()), this, SLOT(effectRotoChanged()), Qt::UniqueConnection);
......
......@@ -95,24 +95,18 @@ Item {
source: {
switch(root.overlayType)
{
case 0: {
case 0:
return '';
}
case 1: {
case 1:
return "OverlayStandard.qml";
}
case 2:{
case 2:
return "OverlayMinimal.qml";
}
case 3:{
case 3:
return "OverlayCenter.qml";
}
case 4:{
case 4:
return "OverlayCenterDiagonal.qml";
}
case 5:{
case 5:
return "OverlayThirds.qml";
}
}
}
}
......
......@@ -93,24 +93,18 @@ Item {
source: {
switch(root.overlayType)
{
case 0: {
case 0:
return '';
}
case 1: {
case 1:
return "OverlayStandard.qml";
}
case 2:{
case 2:
return "OverlayMinimal.qml";
}
case 3:{
case 3:
return "OverlayCenter.qml";
}
case 4:{
case 4:
return "OverlayCenterDiagonal.qml";
}
case 5:{
case 5:
return "OverlayThirds.qml";
}
}
}
}
......
......@@ -156,8 +156,8 @@ Item {
}
}
if (root.centerPoints.length > 2) {
var c1 = convertPoint(root.centerPointsTypes[root.centerPointsTypes.length - 1])
var c2 = convertPoint(root.centerPointsTypes[0])
c1 = convertPoint(root.centerPointsTypes[root.centerPointsTypes.length - 1])
c2 = convertPoint(root.centerPointsTypes[0])
ctx.bezierCurveTo(c1.x, c1.y, c2.x, c2.y, startP.x, startP.y);
}
}
......
......@@ -44,8 +44,8 @@ Rectangle {
property var audioLevels
property var markers
property var keyframeModel
property var clipStatus: 0
property var itemType: 0
property int clipStatus: 0
property int itemType: 0
property int fadeIn: 0
property int fadeOut: 0
property int binId: 0
......
......@@ -45,7 +45,7 @@ Rectangle {
rulerRoot.tickSpacing = Math.floor(3 * rulerRoot.fontUnit / timeline.scaleFactor) * timeline.scaleFactor
rulerRoot.labelSpacing = (Math.floor(rulerRoot.labelSize/rulerRoot.tickSpacing) + 1) * rulerRoot.tickSpacing
}
rulerRoot.labelMod = Math.max((1, Math.ceil((rulerRoot.labelSize + rulerRoot.fontUnit) / rulerRoot.tickSpacing)))
rulerRoot.labelMod = Math.max(1, Math.ceil((rulerRoot.labelSize + rulerRoot.fontUnit) / rulerRoot.tickSpacing))
//console.log('LABELMOD: ', Math.ceil((rulerRoot.labelSize + rulerRoot.fontUnit) / rulerRoot.tickSpacing)))
}
......
......@@ -32,7 +32,7 @@ Column{
property bool isLocked: false
property int trackInternalId : -42
property int trackThumbsFormat
property var itemType: 0
property int itemType: 0
height: parent.height
/*function redrawWaveforms() {
......
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