Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Multimedia
Kdenlive
Commits
d46ea7aa
Commit
d46ea7aa
authored
Jun 14, 2020
by
Simon Eugster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decimal separator: Replace time codes
parent
64357493
Pipeline
#23663
passed with stage
in 30 minutes and 42 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
11 deletions
+48
-11
src/doc/documentvalidator.cpp
src/doc/documentvalidator.cpp
+48
-11
No files found.
src/doc/documentvalidator.cpp
View file @
d46ea7aa
...
...
@@ -1730,8 +1730,16 @@ auto DocumentValidator::upgradeTo100(const QLocale &documentLocale) -> QString {
if
(
decimalPoint
!=
'.'
)
{
qDebug
()
<<
"Decimal point is NOT OK and needs fixing. Converting to . from "
<<
decimalPoint
;
auto
fixTimecode
=
[
decimalPoint
]
(
QString
&
value
)
{
QRegExp
reTimecode
(
"(
\\
d+:
\\
d+:
\\
d+)"
+
QString
(
decimalPoint
)
+
"(
\\
d+)"
);
QRegExp
reValue
(
"(=
\\
d+)"
+
QString
(
decimalPoint
)
+
"(
\\
d+)"
);
value
.
replace
(
reTimecode
,
"
\\
1.
\\
2"
)
.
replace
(
reValue
,
"
\\
1.
\\
2"
);
};
// List of properties which always need to be fixed
QList
<
QString
>
generalPropertiesToFix
=
{
"warp_speed"
};
QList
<
QString
>
generalPropertiesToFix
=
{
"warp_speed"
,
"length"
};
// Fix properties just by name, anywhere in the file
auto
props
=
m_doc
.
elementsByTagName
(
QStringLiteral
(
"property"
));
...
...
@@ -1743,24 +1751,23 @@ auto DocumentValidator::upgradeTo100(const QLocale &documentLocale) -> QString {
QDomText
text
=
element
.
firstChild
().
toText
();
if
(
!
text
.
isNull
())
{
bool
d
oReplace
=
propName
.
endsWith
(
"frame_rate"
)
||
(
generalPropertiesToFix
.
indexOf
(
propName
)
>=
0
);
bool
aut
oReplace
=
propName
.
endsWith
(
"frame_rate"
)
||
(
generalPropertiesToFix
.
indexOf
(
propName
)
>=
0
);
bool
replaced
=
true
;
QString
originalValue
=
text
.
nodeValue
();
QString
value
(
originalValue
);
if
(
propName
==
"resource"
)
{
// Fix entries like <property name="resource">0,500000:/path/to/video
value
.
replace
(
QRegExp
(
"^(
\\
d+)"
+
QString
(
decimalPoint
)
+
"(
\\
d+:)
)
"
),
"
\\
1.
\\
2"
);
}
else
if
(
d
oReplace
)
{
value
.
replace
(
QRegExp
(
"^(
\\
d+)"
+
QString
(
decimalPoint
)
+
"(
\\
d+:)"
),
"
\\
1.
\\
2"
);
}
else
if
(
aut
oReplace
)
{
// Just replace decimal point
value
.
replace
(
decimalPoint
,
'.'
);
}
else
{
replaced
=
false
;
fixTimecode
(
value
)
;
}
if
(
replaced
)
{
if
(
originalValue
!=
value
)
{
text
.
setNodeValue
(
value
);
qDebug
()
<<
"Decimal
separator
: Converted "
<<
propName
<<
" from "
<<
originalValue
<<
" to "
qDebug
()
<<
"Decimal
point
: Converted "
<<
propName
<<
" from "
<<
originalValue
<<
" to "
<<
value
;
}
}
...
...
@@ -1780,6 +1787,7 @@ auto DocumentValidator::upgradeTo100(const QLocale &documentLocale) -> QString {
servicePropertiesToFix
.
insert
(
"volume"
,
{
"level"
});
servicePropertiesToFix
.
insert
(
"lumaliftgaingamma"
,
{
"lift"
,
"gain"
,
"gamma"
});
// Fix filter properties.
// Note that effect properties will be fixed when the effect is loaded
// as there is more information available about the parameter type.
...
...
@@ -1796,19 +1804,48 @@ auto DocumentValidator::upgradeTo100(const QLocale &documentLocale) -> QString {
propertiesToFix
.
append
(
servicePropertiesToFix
.
value
(
mltService
));
}
qDebug
()
<<
"Found MLT service"
<<
mltService
<<
"and will fix
decimal separators for
"
<<
propertiesToFix
;
qDebug
()
<<
"
Decimal point:
Found MLT service"
<<
mltService
<<
"and will fix "
<<
propertiesToFix
;
for
(
const
QString
&
property
:
propertiesToFix
)
{
QString
value
=
Xml
::
getXmlProperty
(
filter
,
property
);
if
(
!
value
.
isEmpty
())
{
QString
newValue
=
QString
(
value
).
replace
(
decimalPoint
,
"."
);
Xml
::
setXmlProperty
(
filter
,
property
,
newValue
);
qDebug
()
<<
"Filter property"
<<
mltService
<<
"changed from "
<<
value
<<
"to"
<<
newValue
;
if
(
value
!=
newValue
)
{
Xml
::
setXmlProperty
(
filter
,
property
,
newValue
);
qDebug
()
<<
"Decimal point: Property"
<<
mltService
<<
"converted from "
<<
value
<<
"to"
<<
newValue
;
}
}
}
}
auto
fixAttribute
=
[
fixTimecode
](
QDomElement
&
el
,
const
QString
&
attributeName
)
{
if
(
el
.
nodeName
()
==
"blank"
)
{
qDebug
()
<<
"This is a blank!"
;
}
if
(
el
.
hasAttribute
(
attributeName
))
{
QString
oldValue
=
el
.
attribute
(
attributeName
,
""
);
QString
newValue
(
oldValue
);
fixTimecode
(
newValue
);
if
(
oldValue
!=
newValue
)
{
el
.
setAttribute
(
attributeName
,
newValue
);
qDebug
()
<<
"Decimal point: Converted"
<<
oldValue
<<
"to"
<<
newValue
<<
"in"
<<
el
.
nodeName
()
<<
attributeName
;
}
}
};
// Fix attributes
QList
<
QString
>
tagsToFix
=
{
"producer"
,
"filter"
,
"tractor"
,
"entry"
,
"transition"
,
"blank"
};
for
(
const
QString
&
tag
:
tagsToFix
)
{
QDomNodeList
elements
=
m_doc
.
elementsByTagName
(
tag
);
for
(
int
i
=
0
;
i
<
elements
.
count
();
i
++
)
{
QDomElement
el
=
elements
.
at
(
i
).
toElement
();
fixAttribute
(
el
,
"in"
);
fixAttribute
(
el
,
"out"
);
fixAttribute
(
el
,
"length"
);
}
}
modified
=
true
;
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment