Skip to content
GitLab
Menu
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
28dcebc4
Commit
28dcebc4
authored
Jul 03, 2021
by
Julius Künzel
Browse files
Keyframes widget: add option to copy values at cursor pos to clipboard
BUG: 439284
parent
001b843c
Pipeline
#68377
passed with stage
in 8 minutes and 58 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/assets/model/assetparametermodel.cpp
View file @
28dcebc4
...
...
@@ -835,6 +835,64 @@ QJsonDocument AssetParameterModel::toJson(bool includeFixed) const
return
QJsonDocument
(
list
);
}
QJsonDocument
AssetParameterModel
::
valueAsJson
(
int
pos
,
bool
includeFixed
)
const
{
QJsonArray
list
;
if
(
!
m_keyframes
)
{
return
QJsonDocument
(
list
);
}
if
(
includeFixed
)
{
for
(
const
auto
&
fixed
:
m_fixedParams
)
{
QJsonObject
currentParam
;
QModelIndex
ix
=
index
(
m_rows
.
indexOf
(
fixed
.
first
),
0
);
auto
value
=
m_keyframes
->
getInterpolatedValue
(
pos
,
ix
);
currentParam
.
insert
(
QLatin1String
(
"name"
),
QJsonValue
(
fixed
.
first
));
currentParam
.
insert
(
QLatin1String
(
"value"
),
QJsonValue
(
QStringLiteral
(
"0=%1"
).
arg
(
value
.
type
()
==
QVariant
::
Double
?
QString
::
number
(
value
.
toDouble
())
:
value
.
toString
())));
int
type
=
data
(
ix
,
AssetParameterModel
::
TypeRole
).
toInt
();
double
min
=
data
(
ix
,
AssetParameterModel
::
MinRole
).
toDouble
();
double
max
=
data
(
ix
,
AssetParameterModel
::
MaxRole
).
toDouble
();
double
factor
=
data
(
ix
,
AssetParameterModel
::
FactorRole
).
toDouble
();
if
(
factor
>
0
)
{
min
/=
factor
;
max
/=
factor
;
}
currentParam
.
insert
(
QLatin1String
(
"type"
),
QJsonValue
(
type
));
currentParam
.
insert
(
QLatin1String
(
"min"
),
QJsonValue
(
min
));
currentParam
.
insert
(
QLatin1String
(
"max"
),
QJsonValue
(
max
));
currentParam
.
insert
(
QLatin1String
(
"in"
),
QJsonValue
(
0
));
currentParam
.
insert
(
QLatin1String
(
"out"
),
QJsonValue
(
0
));
list
.
push_back
(
currentParam
);
}
}
for
(
const
auto
&
param
:
m_params
)
{
if
(
!
includeFixed
&&
param
.
second
.
type
!=
ParamType
::
KeyframeParam
&&
param
.
second
.
type
!=
ParamType
::
AnimatedRect
)
{
continue
;
}
QJsonObject
currentParam
;
QModelIndex
ix
=
index
(
m_rows
.
indexOf
(
param
.
first
),
0
);
auto
value
=
m_keyframes
->
getInterpolatedValue
(
pos
,
ix
);
currentParam
.
insert
(
QLatin1String
(
"name"
),
QJsonValue
(
param
.
first
));
currentParam
.
insert
(
QLatin1String
(
"value"
),
QJsonValue
(
QStringLiteral
(
"0=%1"
).
arg
(
value
.
type
()
==
QVariant
::
Double
?
QString
::
number
(
value
.
toDouble
())
:
value
.
toString
())));
int
type
=
data
(
ix
,
AssetParameterModel
::
TypeRole
).
toInt
();
double
min
=
data
(
ix
,
AssetParameterModel
::
MinRole
).
toDouble
();
double
max
=
data
(
ix
,
AssetParameterModel
::
MaxRole
).
toDouble
();
double
factor
=
data
(
ix
,
AssetParameterModel
::
FactorRole
).
toDouble
();
if
(
factor
>
0
)
{
min
/=
factor
;
max
/=
factor
;
}
currentParam
.
insert
(
QLatin1String
(
"type"
),
QJsonValue
(
type
));
currentParam
.
insert
(
QLatin1String
(
"min"
),
QJsonValue
(
min
));
currentParam
.
insert
(
QLatin1String
(
"max"
),
QJsonValue
(
max
));
currentParam
.
insert
(
QLatin1String
(
"in"
),
QJsonValue
(
0
));
currentParam
.
insert
(
QLatin1String
(
"out"
),
QJsonValue
(
0
));
list
.
push_back
(
currentParam
);
}
return
QJsonDocument
(
list
);
}
void
AssetParameterModel
::
deletePreset
(
const
QString
&
presetFile
,
const
QString
&
presetName
)
{
QJsonObject
object
;
...
...
src/assets/model/assetparametermodel.hpp
View file @
28dcebc4
...
...
@@ -160,6 +160,9 @@ public:
QVector
<
QPair
<
QString
,
QVariant
>>
getAllParameters
()
const
;
/** @brief Returns a json definition of the effect with all param values */
QJsonDocument
toJson
(
bool
includeFixed
=
true
)
const
;
/** @brief Returns the interpolated value at the given position with all param values as json*/
QJsonDocument
valueAsJson
(
int
pos
,
bool
includeFixed
=
true
)
const
;
void
savePreset
(
const
QString
&
presetFile
,
const
QString
&
presetName
);
void
deletePreset
(
const
QString
&
presetFile
,
const
QString
&
presetName
);
const
QStringList
getPresetList
(
const
QString
&
presetFile
)
const
;
...
...
src/assets/view/widgets/keyframewidget.cpp
View file @
28dcebc4
...
...
@@ -159,6 +159,8 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
// copy/paste keyframes from clipboard
QAction
*
copy
=
new
QAction
(
i18n
(
"Copy keyframes to clipboard"
),
this
);
connect
(
copy
,
&
QAction
::
triggered
,
this
,
&
KeyframeWidget
::
slotCopyKeyframes
);
QAction
*
copyValue
=
new
QAction
(
i18n
(
"Copy value at cursor position to clipboard"
),
this
);
connect
(
copyValue
,
&
QAction
::
triggered
,
this
,
&
KeyframeWidget
::
slotCopyValueAtCursorPos
);
QAction
*
paste
=
new
QAction
(
i18n
(
"Import keyframes from clipboard"
),
this
);
connect
(
paste
,
&
QAction
::
triggered
,
this
,
&
KeyframeWidget
::
slotImportKeyframes
);
// Remove keyframes
...
...
@@ -195,6 +197,7 @@ KeyframeWidget::KeyframeWidget(std::shared_ptr<AssetParameterModel> model, QMode
auto
*
container
=
new
QMenu
(
this
);
container
->
addAction
(
seekKeyframe
);
container
->
addAction
(
copy
);
container
->
addAction
(
copyValue
);
container
->
addAction
(
paste
);
container
->
addSeparator
();
container
->
addAction
(
kfType
);
...
...
@@ -658,6 +661,16 @@ void KeyframeWidget::slotCopyKeyframes()
clipboard
->
setText
(
QString
(
effectDoc
.
toJson
()));
}
void
KeyframeWidget
::
slotCopyValueAtCursorPos
()
{
QJsonDocument
effectDoc
=
m_model
->
valueAsJson
(
getPosition
(),
false
);
if
(
effectDoc
.
isEmpty
())
{
return
;
}
QClipboard
*
clipboard
=
QApplication
::
clipboard
();
clipboard
->
setText
(
QString
(
effectDoc
.
toJson
()));
}
void
KeyframeWidget
::
slotImportKeyframes
()
{
QClipboard
*
clipboard
=
QApplication
::
clipboard
();
...
...
src/assets/view/widgets/keyframewidget.hpp
View file @
28dcebc4
...
...
@@ -77,6 +77,7 @@ private slots:
void
slotEditKeyframeType
(
QAction
*
action
);
void
slotUpdateKeyframesFromMonitor
(
const
QPersistentModelIndex
&
index
,
const
QVariant
&
res
);
void
slotCopyKeyframes
();
void
slotCopyValueAtCursorPos
();
void
slotImportKeyframes
();
void
slotRemoveNextKeyframes
();
void
slotSeekToKeyframe
(
int
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