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
8ccda514
Commit
8ccda514
authored
Oct 09, 2020
by
Vivek Yadav
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit name and description of custom effects
parent
bb3b4265
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
125 additions
and
1 deletion
+125
-1
src/assets/assetlist/model/assettreemodel.cpp
src/assets/assetlist/model/assettreemodel.cpp
+76
-0
src/assets/assetlist/model/assettreemodel.hpp
src/assets/assetlist/model/assettreemodel.hpp
+1
-0
src/assets/assetlist/view/assetlistwidget.cpp
src/assets/assetlist/view/assetlistwidget.cpp
+31
-0
src/assets/assetlist/view/assetlistwidget.hpp
src/assets/assetlist/view/assetlistwidget.hpp
+1
-1
src/assets/assetlist/view/qml/assetList.qml
src/assets/assetlist/view/qml/assetList.qml
+8
-0
src/effects/effectlist/view/effectlistwidget.hpp
src/effects/effectlist/view/effectlistwidget.hpp
+8
-0
No files found.
src/assets/assetlist/model/assettreemodel.cpp
View file @
8ccda514
...
...
@@ -24,6 +24,8 @@
#include "effects/effectsrepository.hpp"
#include "transitions/transitionsrepository.hpp"
#include <QMessageBox>
int
AssetTreeModel
::
nameCol
=
0
;
int
AssetTreeModel
::
idCol
=
1
;
int
AssetTreeModel
::
typeCol
=
2
;
...
...
@@ -88,6 +90,80 @@ QString AssetTreeModel::getDescription(bool isEffect, const QModelIndex &index)
return
QString
();
}
QString
AssetTreeModel
::
editCustomEffectInfo
(
const
QString
newName
,
const
QString
newDescription
,
const
QModelIndex
&
index
)
{
std
::
shared_ptr
<
TreeItem
>
item
=
getItemById
((
int
)
index
.
internalId
());
QString
currentName
=
item
->
dataColumn
(
AssetTreeModel
::
nameCol
).
toString
();
QDomDocument
doc
;
QDomElement
effect
=
EffectsRepository
::
get
()
->
getXml
(
currentName
);
QDir
dir
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
)
+
QStringLiteral
(
"/effects/"
));
QString
oldpath
=
dir
.
absoluteFilePath
(
currentName
+
QStringLiteral
(
".xml"
));
doc
.
appendChild
(
doc
.
importNode
(
effect
,
true
));
if
(
!
newDescription
.
trimmed
().
isEmpty
()){
QDomElement
root
=
doc
.
documentElement
();
QDomElement
nodelist
=
root
.
firstChildElement
(
"description"
);
QDomElement
newNodeTag
=
doc
.
createElement
(
QString
(
"description"
));
QDomText
text
=
doc
.
createTextNode
(
newDescription
);
newNodeTag
.
appendChild
(
text
);
root
.
replaceChild
(
newNodeTag
,
nodelist
);
}
if
(
!
newName
.
trimmed
().
isEmpty
())
{
QDir
dir
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
)
+
QStringLiteral
(
"/effects/"
));
if
(
!
dir
.
exists
())
{
dir
.
mkpath
(
QStringLiteral
(
"."
));
}
if
(
dir
.
exists
(
newName
+
QStringLiteral
(
".xml"
))){
QMessageBox
message
;
message
.
critical
(
0
,
i18n
(
"Error"
),
i18n
(
"Effect name %1 already exists.
\n
Try another name?"
,
newName
));
message
.
setFixedSize
(
400
,
200
);
return
oldpath
;
}
QFile
file
(
dir
.
absoluteFilePath
(
newName
+
QStringLiteral
(
".xml"
)));
QDomElement
root
=
doc
.
documentElement
();
QDomElement
nodelist
=
root
.
firstChildElement
(
"name"
);
QDomElement
newNodeTag
=
doc
.
createElement
(
QString
(
"name"
));
QDomText
text
=
doc
.
createTextNode
(
newName
);
newNodeTag
.
appendChild
(
text
);
root
.
replaceChild
(
newNodeTag
,
nodelist
);
QDomElement
e
=
doc
.
documentElement
();
e
.
setAttribute
(
"id"
,
newName
);
if
(
file
.
open
(
QFile
::
WriteOnly
|
QFile
::
Truncate
))
{
QTextStream
out
(
&
file
);
out
<<
doc
.
toString
();
}
file
.
close
();
deleteEffect
(
index
);
QString
path
=
dir
.
absoluteFilePath
(
newName
+
QStringLiteral
(
".xml"
));
return
path
;
}
else
{
QFile
file
(
dir
.
absoluteFilePath
(
currentName
+
QStringLiteral
(
".xml"
)));
if
(
file
.
open
(
QFile
::
WriteOnly
|
QFile
::
Truncate
))
{
QTextStream
out
(
&
file
);
out
<<
doc
.
toString
();
}
file
.
close
();
return
oldpath
;
}
}
QVariant
AssetTreeModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
if
(
!
index
.
isValid
())
{
...
...
src/assets/assetlist/model/assettreemodel.hpp
View file @
8ccda514
...
...
@@ -44,6 +44,7 @@ public:
QString
getDescription
(
bool
isEffect
,
const
QModelIndex
&
index
)
const
;
// Helper function to retrieve if an effect is categorized as favorite
bool
isFavorite
(
const
QModelIndex
&
index
)
const
;
QString
editCustomEffectInfo
(
const
QString
newName
,
const
QString
newDescription
,
const
QModelIndex
&
index
);
QHash
<
int
,
QByteArray
>
roleNames
()
const
override
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
override
;
virtual
void
reloadAssetMenu
(
QMenu
*
effectsMenu
,
KActionCategory
*
effectActions
)
=
0
;
...
...
src/assets/assetlist/view/assetlistwidget.cpp
View file @
8ccda514
...
...
@@ -29,6 +29,11 @@
#include <QQuickItem>
#include <QStandardPaths>
#include <kdeclarative_version.h>
#include <QFormLayout>
#include <QDialog>
#include <QDialogButtonBox>
#include <QLineEdit>
#include <QTextEdit>
AssetListWidget
::
AssetListWidget
(
QWidget
*
parent
)
:
QQuickWidget
(
parent
)
...
...
@@ -84,6 +89,32 @@ QString AssetListWidget::getDescription(bool isEffect, const QModelIndex &index)
return
m_model
->
getDescription
(
isEffect
,
m_proxyModel
->
mapToSource
(
index
));
}
QString
AssetListWidget
::
editCustomEffectInfo
(
const
QModelIndex
&
index
)
{
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
()
&&
enteredDescription
.
trimmed
().
isEmpty
())
{
return
index
.
data
().
toString
();
}
return
m_model
->
editCustomEffectInfo
(
name
,
enteredDescription
,
m_proxyModel
->
mapToSource
(
index
));
}
return
index
.
data
().
toString
();
}
void
AssetListWidget
::
setFilterName
(
const
QString
&
pattern
)
{
m_proxyModel
->
setFilterName
(
!
pattern
.
isEmpty
(),
pattern
);
...
...
src/assets/assetlist/view/assetlistwidget.hpp
View file @
8ccda514
...
...
@@ -55,7 +55,7 @@ public:
/* @brief Delete a custom effect */
void
deleteCustomEffect
(
const
QModelIndex
&
index
);
virtual
void
reloadCustomEffectIx
(
const
QModelIndex
&
index
)
=
0
;
QString
editCustomEffectInfo
(
const
QModelIndex
&
index
);
/* @brief Returns the description of the asset given its model index */
QString
getDescription
(
bool
isEffect
,
const
QModelIndex
&
index
)
const
;
...
...
src/assets/assetlist/view/qml/assetList.qml
View file @
8ccda514
...
...
@@ -338,6 +338,14 @@ Rectangle {
assetlist
.
reloadCustomEffectIx
(
sel
.
currentIndex
)
}
}
MenuItem
{
id
:
editMenu
text
:
i18n
(
"
Edit Info
"
)
visible
:
isEffectList
&&
assetContextMenu
.
isCustom
onTriggered
:
{
assetlist
.
editCustomEffectInfo
(
sel
.
currentIndex
)
}
}
}
TableViewColumn
{
role
:
"
identifier
"
;
title
:
i18n
(
"
Name
"
);
}
...
...
src/effects/effectlist/view/effectlistwidget.hpp
View file @
8ccda514
...
...
@@ -81,6 +81,14 @@ public:
}
Q_INVOKABLE
void
deleteCustomEffect
(
const
QModelIndex
&
index
)
{
q
->
deleteCustomEffect
(
index
);
}
Q_INVOKABLE
QString
getDescription
(
const
QModelIndex
&
index
)
const
{
return
q
->
getDescription
(
true
,
index
);
}
Q_INVOKABLE
void
editCustomEffectInfo
(
const
QModelIndex
&
index
)
{
QString
pathToUpdate
=
q
->
editCustomEffectInfo
(
index
);
if
(
index
.
data
().
toString
()
!=
pathToUpdate
)
{
q
->
reloadCustomEffect
(
pathToUpdate
);
}
}
Q_INVOKABLE
QVariantMap
getMimeData
(
const
QString
&
assetId
)
const
{
return
q
->
getMimeData
(
assetId
);
}
Q_INVOKABLE
void
activate
(
const
QModelIndex
&
ix
)
{
q
->
activate
(
ix
);
}
...
...
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