Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Multimedia
Kdenlive
Commits
1aea1472
Commit
1aea1472
authored
Mar 23, 2017
by
Nicolas Carion
Browse files
Very preliminary implementation of QML effectstack
parent
8ef946ba
Changes
16
Hide whitespace changes
Inline
Side-by-side
src/abstractmodel/abstracttreemodel.hpp
View file @
1aea1472
...
...
@@ -32,7 +32,7 @@ class AbstractTreeModel : public QAbstractItemModel
Q_OBJECT
public:
explicit
AbstractTreeModel
(
QObject
*
parent
=
0
);
explicit
AbstractTreeModel
(
QObject
*
parent
=
nullptr
);
virtual
~
AbstractTreeModel
();
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
override
;
...
...
src/assets/CMakeLists.txt
View file @
1aea1472
...
...
@@ -5,5 +5,6 @@ set(kdenlive_SRCS
assets/assetlist/model/assetfilter.cpp
assets/assetlist/model/assettreemodel.cpp
assets/model/assetparametermodel.cpp
assets/view/assetparameterview.cpp
PARENT_SCOPE
)
src/assets/abstractassetsrepository.hpp
View file @
1aea1472
...
...
@@ -47,21 +47,24 @@ public:
*/
bool
exists
(
const
QString
&
assetId
)
const
;
/* @brief Returns a vector of pair (
effec
t id,
effec
t name)
/* @brief Returns a vector of pair (
asse
t id,
asse
t name)
*/
QVector
<
QPair
<
QString
,
QString
>
>
getNames
()
const
;
/* @brief Return type of
effec
t */
AssetType
getType
(
const
QString
&
effec
tId
)
const
;
/* @brief Return type of
asse
t */
AssetType
getType
(
const
QString
&
asse
tId
)
const
;
/* @brief Return name of
effec
t */
QString
getName
(
const
QString
&
effec
tId
)
const
;
/* @brief Return name of
asse
t */
QString
getName
(
const
QString
&
asse
tId
)
const
;
/* @brief Return description of
effec
t */
QString
getDescription
(
const
QString
&
effec
tId
)
const
;
/* @brief Return description of
asse
t */
QString
getDescription
(
const
QString
&
asse
tId
)
const
;
/* @brief Check whether a given effect is favorite */
bool
isFavorite
(
const
QString
&
effectId
)
const
;
/* @brief Check whether a given asset is favorite */
bool
isFavorite
(
const
QString
&
assetId
)
const
;
/* @brief Returns a DomElement representing the asset's properties */
QDomElement
getXml
(
const
QString
&
assetId
)
const
;
protected:
struct
Info
...
...
@@ -100,6 +103,9 @@ protected:
/* @brief Returns the path to custom XML description of the assets*/
virtual
QStringList
assetDirs
()
const
=
0
;
/* @brief Returns the path to the assets' blacklist*/
virtual
QString
assetBlackListPath
()
const
=
0
;
std
::
unordered_map
<
QString
,
Info
>
m_assets
;
...
...
src/assets/abstractassetsrepository.ipp
View file @
1aea1472
...
...
@@ -48,7 +48,7 @@ void AbstractAssetsRepository<AssetType>::init()
#endif
// Parse effects blacklist
parseBlackList(
QStandardPaths::locate(QStandardPaths::AppDataLocation, QStringLiteral("b
lack
l
ist
ed_effects.txt")
));
parseBlackList(
assetB
lack
L
ist
Path(
));
// Retrieve the list of MLT's available assets.
QScopedPointer<Mlt::Properties> assets(retrieveListFromMlt());
...
...
@@ -212,3 +212,15 @@ QString AbstractAssetsRepository<AssetType>::parseInfoFromXml(const QDomElement&
}
return id;
}
template<typename AssetType>
QDomElement AbstractAssetsRepository<AssetType>::getXml(const QString& assetId) const
{
QString path = m_assets.at(assetId).custom_xml_path;
Q_ASSERT(!path.isEmpty());
QFile file(path);
QDomDocument doc;
doc.setContent(&file, false);
file.close();
return doc.documentElement();
}
src/assets/model/assetparametermodel.cpp
View file @
1aea1472
...
...
@@ -28,10 +28,11 @@
AssetParameterModel
::
AssetParameterModel
(
Mlt
::
Properties
*
asset
,
const
QDomElement
&
assetXml
,
QObject
*
parent
)
:
QAbstract
Item
Model
(
parent
)
:
QAbstract
List
Model
(
parent
)
,
m_xml
(
assetXml
)
,
m_asset
(
asset
)
{
Q_ASSERT
(
asset
->
is_valid
());
QDomNodeList
nodeList
=
m_xml
.
elementsByTagName
(
QStringLiteral
(
"parameter"
));
bool
needsLocaleConversion
=
false
;
...
...
@@ -71,8 +72,9 @@ AssetParameterModel::AssetParameterModel(Mlt::Properties *asset, const QDomEleme
if
(
value
.
isNull
())
{
value
=
currentParameter
.
attribute
(
QStringLiteral
(
"default"
));
}
setParameter
(
name
,
value
);
if
(
type
==
QLatin1String
(
"fixed"
))
{
bool
isFixed
=
(
type
==
QLatin1String
(
"fixed"
));
setParameter
(
name
,
value
,
!
isFixed
);
if
(
isFixed
)
{
//fixed parameters are not displayed so we don't store them.
continue
;
}
...
...
@@ -85,8 +87,9 @@ AssetParameterModel::AssetParameterModel(Mlt::Properties *asset, const QDomEleme
}
}
void
AssetParameterModel
::
setParameter
(
const
QString
&
name
,
const
QString
&
value
)
void
AssetParameterModel
::
setParameter
(
const
QString
&
name
,
const
QString
&
value
,
bool
store
)
{
Q_ASSERT
(
m_asset
->
is_valid
());
QLocale
locale
;
locale
.
setNumberOptions
(
QLocale
::
OmitGroupSeparator
);
...
...
@@ -94,10 +97,14 @@ void AssetParameterModel::setParameter(const QString& name, const QString& value
double
doubleValue
=
locale
.
toDouble
(
value
,
&
conversionSuccess
);
if
(
conversionSuccess
)
{
m_asset
->
set
(
name
.
toLatin1
().
constData
(),
doubleValue
);
m_params
[
name
].
value
=
doubleValue
;
if
(
store
)
{
m_params
[
name
].
value
=
doubleValue
;
}
}
else
{
m_asset
->
set
(
name
.
toLatin1
().
constData
(),
value
.
toUtf8
().
constData
());
m_params
[
name
].
value
=
value
;
if
(
store
)
{
m_params
[
name
].
value
=
value
;
}
}
}
...
...
@@ -105,20 +112,18 @@ AssetParameterModel::~AssetParameterModel()
{
}
int
AssetParameterModel
::
columnCount
(
const
QModelIndex
&
parent
)
const
{
Q_UNUSED
(
parent
);
return
1
;
}
QVariant
AssetParameterModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
{
if
(
!
index
.
isValid
())
{
if
(
index
.
row
()
<
0
||
index
.
row
()
>=
m_rows
.
size
()
||
!
index
.
isValid
())
{
return
QVariant
();
}
QString
paramName
=
m_rows
[
index
.
row
()];
const
QDomElement
&
element
=
m_params
.
at
(
paramName
).
xml
;
switch
(
role
)
{
case
Qt
::
DisplayRole
:
case
Qt
::
EditRole
:
case
NameRole
:
return
paramName
;
case
CommentRole
:{
QDomElement
commentElem
=
element
.
firstChildElement
(
QStringLiteral
(
"comment"
));
QString
comment
;
...
...
@@ -142,24 +147,13 @@ QVariant AssetParameterModel::data(const QModelIndex &index, int role) const
return
QVariant
();
}
QModelIndex
AssetParameterModel
::
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
)
const
{
if
(
!
hasIndex
(
row
,
column
,
parent
))
return
QModelIndex
();
return
createIndex
(
row
,
column
);
}
QModelIndex
AssetParameterModel
::
parent
(
const
QModelIndex
&
index
)
const
{
Q_UNUSED
(
index
);
return
QModelIndex
();
}
int
AssetParameterModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
Q_UNUSED
(
parent
);
qDebug
()
<<
"===================================================== Requested rowCount"
<<
parent
<<
m_rows
.
size
();
if
(
parent
.
isValid
())
return
0
;
return
m_rows
.
size
();
}
...
...
src/assets/model/assetparametermodel.hpp
View file @
1aea1472
...
...
@@ -22,7 +22,7 @@
#ifndef ASSETPARAMETERMODEL_H
#define ASSETPARAMETERMODEL_H
#include
<QAbstract
Item
Model>
#include
<QAbstract
List
Model>
#include
<QDomElement>
#include
<unordered_map>
#include
"klocalizedstring.h"
...
...
@@ -30,6 +30,7 @@
#include
"definitions.h"
#include
<mlt++/MltProperties.h>
#include
<memory>
/* @brief This class is the model for a list of parameters.
The behaviour of a transition or an effect is typically controlled by several parameters. This class exposes this parameters as a list that can be rendered using the relevant widgets.
...
...
@@ -57,12 +58,12 @@ enum class ParamType{
Filterjob
,
Readonly
};
class
AssetParameterModel
:
public
QAbstract
Item
Model
class
AssetParameterModel
:
public
QAbstract
List
Model
{
Q_OBJECT
public:
explicit
AssetParameterModel
(
Mlt
::
Properties
*
asset
,
const
QDomElement
&
assetXml
,
QObject
*
parent
=
0
);
explicit
AssetParameterModel
(
Mlt
::
Properties
*
asset
,
const
QDomElement
&
assetXml
,
QObject
*
parent
=
nullptr
);
virtual
~
AssetParameterModel
();
enum
{
NameRole
=
Qt
::
UserRole
+
1
,
...
...
@@ -85,16 +86,14 @@ public:
*/
static
double
parseDoubleAttribute
(
const
QString
&
attribute
,
const
QDomElement
&
element
);
/* @brief Set the parameter with given name to the given value */
void
setParameter
(
const
QString
&
name
,
const
QString
&
value
);
/* @brief Set the parameter with given name to the given value
@param store: if this is true, then the value is also stored in m_params
*/
void
setParameter
(
const
QString
&
name
,
const
QString
&
value
,
bool
store
=
true
);
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
override
;
QModelIndex
index
(
int
row
,
int
column
,
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
QModelIndex
parent
(
const
QModelIndex
&
index
)
const
override
;
int
rowCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
int
columnCount
(
const
QModelIndex
&
parent
=
QModelIndex
())
const
override
;
protected:
...
...
src/assets/view/assetparameterview.cpp
0 → 100644
View file @
1aea1472
/***************************************************************************
* Copyright (C) 2017 by Nicolas Carion *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#include
"assetparameterview.hpp"
#include
"../model/assetparametermodel.hpp"
#include
<QString>
#include
<QDebug>
#include
<QPushButton>
#include
<KDeclarative/KDeclarative>
#include
<QQmlContext>
#include
<QStringListModel>
AssetParameterView
::
AssetParameterView
(
QWidget
*
parent
)
:
QQuickWidget
(
parent
)
{
KDeclarative
::
KDeclarative
kdeclarative
;
kdeclarative
.
setDeclarativeEngine
(
engine
());
kdeclarative
.
setupBindings
();
setResizeMode
(
QQuickWidget
::
SizeRootObjectToView
);
setSource
(
QUrl
(
QStringLiteral
(
"qrc:/qml/assetView.qml"
)));
setFocusPolicy
(
Qt
::
StrongFocus
);
// Set void model for the moment
QStringListModel
*
model
=
new
QStringListModel
();
QStringList
list
;
list
<<
"a"
<<
"b"
<<
"c"
<<
"s"
<<
"w"
;
model
->
setStringList
(
list
);
rootContext
()
->
setContextProperty
(
"paramModel"
,
model
);
}
void
AssetParameterView
::
setModel
(
std
::
shared_ptr
<
AssetParameterModel
>
model
)
{
m_model
=
model
;
rootContext
()
->
setContextProperty
(
"paramModel"
,
model
.
get
());
}
src/assets/view/assetparameterview.hpp
0 → 100644
View file @
1aea1472
/***************************************************************************
* Copyright (C) 2017 by Nicolas Carion *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
#ifndef ASSETPARAMETERVIEW_H
#define ASSETPARAMETERVIEW_H
#include
<QQuickWidget>
#include
"../model/assetparametermodel.hpp"
/* @brief This class is the view for a list of parameters.
*/
class
AssetParameterView
:
public
QQuickWidget
{
Q_OBJECT
public:
AssetParameterView
(
QWidget
*
parent
=
nullptr
);
/* @brief Set the current model to be displayed */
void
setModel
(
std
::
shared_ptr
<
AssetParameterModel
>
model
);
protected:
std
::
shared_ptr
<
AssetParameterModel
>
m_model
;
};
#endif
src/assets/view/qml/assetView.qml
0 → 100644
View file @
1aea1472
/***************************************************************************
* Copyright (C) 2017 by Nicolas Carion *
* This file is part of Kdenlive. See www.kdenlive.org. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) version 3 or any later version accepted by the *
* membership of KDE e.V. (or its successor approved by the membership *
* of KDE e.V.), which shall act as a proxy defined in Section 14 of *
* version 3 of the license. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
import
QtQuick
2.4
import
QtQuick
.
Controls
1.4
import
QtQuick
.
Controls
.
Styles
1.4
import
QtQuick
.
Window
2.2
import
QtQuick
.
Layouts
1.3
import
QtQml
.
Models
2.2
Rectangle
{
id
:
assetRoot
SystemPalette
{
id
:
activePalette
}
color
:
activePalette
.
window
ListView
{
anchors.fill
:
parent
id
:
listView
delegate
:
Label
{
text
:
display
}
model
:
paramModel
}
}
src/effects/effectsrepository.cpp
View file @
1aea1472
...
...
@@ -129,3 +129,8 @@ void EffectsRepository::parseType(QScopedPointer<Mlt::Properties>& metadata, Inf
res
.
type
=
EffectType
::
Audio
;
}
}
QString
EffectsRepository
::
assetBlackListPath
()
const
{
return
QStandardPaths
::
locate
(
QStandardPaths
::
AppDataLocation
,
QStringLiteral
(
"blacklisted_effects.txt"
));
}
src/effects/effectsrepository.hpp
View file @
1aea1472
...
...
@@ -63,6 +63,9 @@ protected:
*/
void
parseCustomAssetFile
(
const
QString
&
file_name
)
override
;
/* @brief Returns the path to the effects' blacklist*/
QString
assetBlackListPath
()
const
override
;
QStringList
assetDirs
()
const
override
;
void
parseType
(
QScopedPointer
<
Mlt
::
Properties
>&
metadata
,
Info
&
res
)
override
;
...
...
src/mainwindow.cpp
View file @
1aea1472
...
...
@@ -43,6 +43,8 @@
#include
"effectslist/effectbasket.h"
#include
"effects/effectlist/view/effectlistwidget.hpp"
#include
"transitions/transitionlist/view/transitionlistwidget.hpp"
#include
"transitions/transitionsrepository.hpp"
#include
"assets/view/assetparameterview.hpp"
#include
"effectstack/effectstackview2.h"
#include
"project/transitionsettings.h"
#include
"mltcontroller/bincontroller.h"
...
...
@@ -115,6 +117,7 @@
#include
<QVBoxLayout>
#include
<QScreen>
static
const
char
version
[]
=
KDENLIVE_VERSION
;
namespace
Mlt
{
...
...
@@ -333,7 +336,15 @@ void MainWindow::init(const QString &MltPath, const QUrl &Url, const QString &cl
connect
(
m_effectStack
,
&
EffectStackView2
::
reloadEffects
,
this
,
&
MainWindow
::
slotReloadEffects
);
connect
(
m_effectStack
,
SIGNAL
(
displayMessage
(
QString
,
int
)),
m_messageLabel
,
SLOT
(
setProgressMessage
(
QString
,
int
)));
m_effectStackDock
=
addDock
(
i18n
(
"Properties"
),
QStringLiteral
(
"effect_stack"
),
m_effectStack
);
std
::
shared_ptr
<
AssetParameterModel
>
model
=
TransitionsRepository
::
get
()
->
getTransition
(
QStringLiteral
(
"composite"
));
AssetParameterView
*
propertiesWidget
=
new
AssetParameterView
(
this
);
propertiesWidget
->
setModel
(
model
);
qDebug
()
<<
"===================================================== creating listview"
<<
model
->
rowCount
();
//m_effectStackDock = addDock(i18n("Properties"), QStringLiteral("effect_stack"), m_effectStack);
m_effectStackDock
=
addDock
(
i18n
(
"Properties"
),
QStringLiteral
(
"effect_stack"
),
propertiesWidget
);
m_effectList
=
new
EffectsListView
();
//m_effectListDock = addDock(i18n("Effects"), QStringLiteral("effect_list"), m_effectList);
...
...
src/profiles/profilemodel.hpp
View file @
1aea1472
...
...
@@ -24,6 +24,7 @@
#include
<memory>
#include
<QString>
#include
"mlt++/MltProfile.h"
/** @brief This is a wrapper around Mlt::Profile to be used by the rest of kdenlive.
...
...
@@ -31,10 +32,6 @@
*
*/
namespace
Mlt
{
class
Profile
;
}
class
ProfileModel
{
...
...
@@ -68,6 +65,10 @@ public:
bool
operator
==
(
const
ProfileModel
&
other
)
const
;
bool
operator
!=
(
const
ProfileModel
&
other
)
const
;
/* @brief get underlying profile. Use with caution*/
Mlt
::
Profile
&
profile
()
{
return
*
m_profile
.
get
();};
protected:
QString
m_path
;
bool
m_invalid
;
...
...
src/transitions/transitionsrepository.cpp
View file @
1aea1472
...
...
@@ -28,6 +28,8 @@
#include
<QTextStream>
#include
<mlt++/Mlt.h>
#include
"assets/model/assetparametermodel.hpp"
#include
"profiles/profilemodel.hpp"
std
::
unique_ptr
<
TransitionsRepository
>
TransitionsRepository
::
instance
;
std
::
once_flag
TransitionsRepository
::
m_onceFlag
;
...
...
@@ -118,3 +120,20 @@ QSet<QString> TransitionsRepository::getSingleTrackTransitions()
{
return
{
QStringLiteral
(
"composite"
),
QStringLiteral
(
"dissolve"
)};
}
QString
TransitionsRepository
::
assetBlackListPath
()
const
{
return
QStandardPaths
::
locate
(
QStandardPaths
::
AppDataLocation
,
QStringLiteral
(
"blacklisted_transitions.txt"
));
}
std
::
shared_ptr
<
AssetParameterModel
>
TransitionsRepository
::
getTransition
(
const
QString
&
transitionId
)
const
{
// We create the Mlt element from its name
Mlt
::
Transition
*
transition
=
new
Mlt
::
Transition
(
pCore
->
getCurrentProfile
()
->
profile
(),
transitionId
.
toLatin1
().
constData
(),
NULL
);
return
std
::
make_shared
<
AssetParameterModel
>
(
transition
,
getXml
(
transitionId
));
}
src/transitions/transitionsrepository.hpp
View file @
1aea1472
...
...
@@ -26,6 +26,7 @@
#include
<mutex>
#include
"definitions.h"
#include
"assets/abstractassetsrepository.hpp"
#include
"assets/model/assetparametermodel.hpp"
/** @brief This class stores all the transitions that can be added by the user.
* You can query any transitions based on its name.
...
...
@@ -49,6 +50,11 @@ public:
//Returns the instance of the Singleton
static
std
::
unique_ptr
<
TransitionsRepository
>&
get
();
/* @brief Creates and return an instance of the parameterModel of a given transition.
The parameter @param parent corresponds to the parent of the created object
*/
std
::
shared_ptr
<
AssetParameterModel
>
getTransition
(
const
QString
&
transitionId
)
const
;
protected:
// Constructor is protected because class is a Singleton
TransitionsRepository
();
...
...
@@ -61,8 +67,12 @@ protected:
*/
void
parseCustomAssetFile
(
const
QString
&
file_name
)
override
;
/* @brief Returns the paths where the custom transitions' descriptions are stored */
QStringList
assetDirs
()
const
override
;
/* @brief Returns the path to the transitions' blacklist*/
QString
assetBlackListPath
()
const
override
;
void
parseType
(
QScopedPointer
<
Mlt
::
Properties
>&
metadata
,
Info
&
res
)
override
;
/* @brief Returns the metadata associated with the given asset*/
...
...
src/uiresources.qrc
View file @
1aea1472
...
...
@@ -22,5 +22,6 @@
<file alias="CornerSelectionShadow.qml">timeline2/view/qml/CornerSelectionShadow.qml</file>
<file alias="Timeline.js">timeline2/view/qml/Timeline.js</file>
<file alias="assetList.qml">assets/assetlist/view/qml/assetList.qml</file>
<file alias="assetView.qml">assets/view/qml/assetView.qml</file>
</qresource>
</RCC>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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