Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Kdenlive
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
259
Issues
259
List
Boards
Labels
Service Desk
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Multimedia
Kdenlive
Commits
be57dcda
Commit
be57dcda
authored
Sep 27, 2020
by
Vivek Yadav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added comments feature in custom effects
parent
78e4acad
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
53 deletions
+81
-53
src/effects/effectstack/view/collapsibleeffectview.cpp
src/effects/effectstack/view/collapsibleeffectview.cpp
+81
-53
No files found.
src/effects/effectstack/view/collapsibleeffectview.cpp
View file @
be57dcda
...
...
@@ -43,6 +43,8 @@
#include <QVBoxLayout>
#include <QWheelEvent>
#include <QPointer>
#include <QTextEdit>
#include <QFormLayout>
#include <QComboBox>
#include <KDualAction>
...
...
@@ -417,67 +419,93 @@ void CollapsibleEffectView::slotEffectDown()
{
emit
moveEffect
(
m_model
->
row
()
+
2
,
m_model
);
}
void
CollapsibleEffectView
::
slotSaveEffect
()
{
QString
name
=
QInputDialog
::
getText
(
this
,
i18n
(
"Save Effect"
),
i18n
(
"Name for saved effect: "
));
if
(
name
.
trimmed
().
isEmpty
())
{
return
;
}
QDir
dir
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
)
+
QStringLiteral
(
"/effects/"
));
if
(
!
dir
.
exists
())
{
dir
.
mkpath
(
QStringLiteral
(
"."
));
}
if
(
dir
.
exists
(
name
+
QStringLiteral
(
".xml"
)))
if
(
KMessageBox
::
questionYesNo
(
this
,
i18n
(
"File %1 already exists.
\n
Do you want to overwrite it?"
,
name
+
QStringLiteral
(
".xml"
)))
==
KMessageBox
::
No
)
{
// QString name = QInputDialog::getText(this, i18n("Save Effect"), i18n("Name for saved effect: "));
QDialog
dialog
(
this
);
QFormLayout
form
(
&
dialog
);
QLineEdit
*
effectName
=
new
QLineEdit
(
&
dialog
);
QTextEdit
*
descriptionBox
=
new
QTextEdit
(
&
dialog
);
QString
label_Name
=
QString
(
"Name : "
);
form
.
addRow
(
label_Name
,
effectName
);
QString
label
=
QString
(
"Comments : "
);
form
.
addRow
(
label
,
descriptionBox
);
QDialogButtonBox
buttonBox
(
QDialogButtonBox
::
Ok
|
QDialogButtonBox
::
Cancel
,
Qt
::
Horizontal
,
&
dialog
);
form
.
addRow
(
&
buttonBox
);
QObject
::
connect
(
&
buttonBox
,
SIGNAL
(
accepted
()),
&
dialog
,
SLOT
(
accept
()));
QObject
::
connect
(
&
buttonBox
,
SIGNAL
(
rejected
()),
&
dialog
,
SLOT
(
reject
()));
if
(
dialog
.
exec
()
==
QDialog
::
Accepted
)
{
QString
name
=
effectName
->
text
();
QString
enteredDescription
=
descriptionBox
->
toPlainText
();
if
(
name
.
trimmed
().
isEmpty
())
{
return
;
}
QDir
dir
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
)
+
QStringLiteral
(
"/effects/"
));
if
(
!
dir
.
exists
())
{
dir
.
mkpath
(
QStringLiteral
(
"."
));
}
QDomDocument
doc
;
// Get base effect xml
QString
effectId
=
m_model
->
getAssetId
();
QDomElement
effect
=
EffectsRepository
::
get
()
->
getXml
(
effectId
);
// Adjust param values
QVector
<
QPair
<
QString
,
QVariant
>>
currentValues
=
m_model
->
getAllParameters
();
QMap
<
QString
,
QString
>
values
;
for
(
const
auto
&
param
:
currentValues
)
{
values
.
insert
(
param
.
first
,
param
.
second
.
toString
());
}
QDomNodeList
params
=
effect
.
elementsByTagName
(
"parameter"
);
for
(
int
i
=
0
;
i
<
params
.
count
();
++
i
)
{
const
QString
paramName
=
params
.
item
(
i
).
toElement
().
attribute
(
"name"
);
const
QString
paramType
=
params
.
item
(
i
).
toElement
().
attribute
(
"type"
);
if
(
paramType
==
QLatin1String
(
"fixed"
)
||
!
values
.
contains
(
paramName
))
{
continue
;
if
(
dir
.
exists
(
name
+
QStringLiteral
(
".xml"
)))
if
(
KMessageBox
::
questionYesNo
(
this
,
i18n
(
"File %1 already exists.
\n
Do you want to overwrite it?"
,
name
+
QStringLiteral
(
".xml"
)))
==
KMessageBox
::
No
)
{
return
;
}
QDomDocument
doc
;
// Get base effect xml
QString
effectId
=
m_model
->
getAssetId
();
QDomElement
effect
=
EffectsRepository
::
get
()
->
getXml
(
effectId
);
// Adjust param values
QVector
<
QPair
<
QString
,
QVariant
>>
currentValues
=
m_model
->
getAllParameters
();
QMap
<
QString
,
QString
>
values
;
for
(
const
auto
&
param
:
currentValues
)
{
values
.
insert
(
param
.
first
,
param
.
second
.
toString
());
}
QDomNodeList
params
=
effect
.
elementsByTagName
(
"parameter"
);
for
(
int
i
=
0
;
i
<
params
.
count
();
++
i
)
{
const
QString
paramName
=
params
.
item
(
i
).
toElement
().
attribute
(
"name"
);
const
QString
paramType
=
params
.
item
(
i
).
toElement
().
attribute
(
"type"
);
if
(
paramType
==
QLatin1String
(
"fixed"
)
||
!
values
.
contains
(
paramName
))
{
continue
;
}
params
.
item
(
i
).
toElement
().
setAttribute
(
QStringLiteral
(
"value"
),
values
.
value
(
paramName
));
}
params
.
item
(
i
).
toElement
().
setAttribute
(
QStringLiteral
(
"value"
),
values
.
value
(
paramName
));
doc
.
appendChild
(
doc
.
importNode
(
effect
,
true
));
effect
=
doc
.
firstChild
().
toElement
();
effect
.
removeAttribute
(
QStringLiteral
(
"kdenlive_ix"
));
effect
.
setAttribute
(
QStringLiteral
(
"id"
),
name
);
QString
masterType
=
effect
.
attribute
(
QLatin1String
(
"type"
));
effect
.
setAttribute
(
QStringLiteral
(
"type"
),
(
masterType
==
QLatin1String
(
"audio"
)
||
masterType
==
QLatin1String
(
"customAudio"
))
?
QStringLiteral
(
"customAudio"
)
:
QStringLiteral
(
"customVideo"
));
QDomElement
effectname
=
effect
.
firstChildElement
(
QStringLiteral
(
"name"
));
effect
.
removeChild
(
effectname
);
effectname
=
doc
.
createElement
(
QStringLiteral
(
"name"
));
QDomText
nametext
=
doc
.
createTextNode
(
name
);
effectname
.
appendChild
(
nametext
);
effect
.
insertBefore
(
effectname
,
QDomNode
());
QDomElement
effectprops
=
effect
.
firstChildElement
(
QStringLiteral
(
"properties"
));
effectprops
.
setAttribute
(
QStringLiteral
(
"id"
),
name
);
effectprops
.
setAttribute
(
QStringLiteral
(
"type"
),
QStringLiteral
(
"custom"
));
QFile
file
(
dir
.
absoluteFilePath
(
name
+
QStringLiteral
(
".xml"
)));
if
(
!
enteredDescription
.
trimmed
().
isEmpty
()){
QDomElement
root
=
doc
.
documentElement
();
QDomElement
nodelist
=
root
.
firstChildElement
(
"description"
);
QDomElement
newNodeTag
=
doc
.
createElement
(
QString
(
"description"
));
QDomText
text
=
doc
.
createTextNode
(
enteredDescription
);
newNodeTag
.
appendChild
(
text
);
root
.
replaceChild
(
newNodeTag
,
nodelist
);
}
if
(
file
.
open
(
QFile
::
WriteOnly
|
QFile
::
Truncate
))
{
QTextStream
out
(
&
file
);
out
<<
doc
.
toString
();
}
file
.
close
();
emit
reloadEffect
(
dir
.
absoluteFilePath
(
name
+
QStringLiteral
(
".xml"
)));
}
doc
.
appendChild
(
doc
.
importNode
(
effect
,
true
));
effect
=
doc
.
firstChild
().
toElement
();
effect
.
removeAttribute
(
QStringLiteral
(
"kdenlive_ix"
));
effect
.
setAttribute
(
QStringLiteral
(
"id"
),
name
);
QString
masterType
=
effect
.
attribute
(
QLatin1String
(
"type"
));
effect
.
setAttribute
(
QStringLiteral
(
"type"
),
(
masterType
==
QLatin1String
(
"audio"
)
||
masterType
==
QLatin1String
(
"customAudio"
))
?
QStringLiteral
(
"customAudio"
)
:
QStringLiteral
(
"customVideo"
));
QDomElement
effectname
=
effect
.
firstChildElement
(
QStringLiteral
(
"name"
));
effect
.
removeChild
(
effectname
);
effectname
=
doc
.
createElement
(
QStringLiteral
(
"name"
));
QDomText
nametext
=
doc
.
createTextNode
(
name
);
effectname
.
appendChild
(
nametext
);
effect
.
insertBefore
(
effectname
,
QDomNode
());
QDomElement
effectprops
=
effect
.
firstChildElement
(
QStringLiteral
(
"properties"
));
effectprops
.
setAttribute
(
QStringLiteral
(
"id"
),
name
);
effectprops
.
setAttribute
(
QStringLiteral
(
"type"
),
QStringLiteral
(
"custom"
));
QFile
file
(
dir
.
absoluteFilePath
(
name
+
QStringLiteral
(
".xml"
)));
if
(
file
.
open
(
QFile
::
WriteOnly
|
QFile
::
Truncate
))
{
QTextStream
out
(
&
file
);
out
<<
doc
.
toString
();
}
file
.
close
();
emit
reloadEffect
(
dir
.
absoluteFilePath
(
name
+
QStringLiteral
(
".xml"
)));
}
QDomDocument
CollapsibleEffectView
::
toXml
()
const
{
QDomDocument
doc
;
...
...
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