Commit e0be8f3a authored by Christoph Feck's avatar Christoph Feck

Merge branch 'master' of invent.kde.org:multimedia/kdenlive

parents 6f46e728 e17e4f21
Pipeline #29712 passed with stage
in 34 minutes and 57 seconds
......@@ -3,7 +3,7 @@
<name>Volume (keyframable)</name>
<description>Adjust audio volume with keyframes</description>
<author>Dan Dennedy</author>
<parameter type="animated" name="level" default="0" max="60" min="-100" suffix="dB" scale="-1">
<parameter type="animated" name="level" default="0" max="50" min="-50" suffix="dB" scale="-1">
<name>Gain</name>
</parameter>
</effect>
......@@ -305,9 +305,9 @@ bool KeyframeModel::updateKeyframe(int pos, double newVal)
int logRole = ptr->data(m_index, AssetParameterModel::ScaleRole).toInt();
double realValue;
if (logRole == -1) {
// Logarythmic scale for lower than norm values
// Logarythmic scale
if (newVal >= 0.5) {
realValue = norm + (2 * (newVal - 0.5) * (max / factor - norm));
realValue = norm + pow(2 * (newVal - 0.5), 10.0 / 6) * (max / factor - norm);
} else {
realValue = norm - pow(2 * (0.5 - newVal), 10.0 / 6) * (norm - min / factor);
}
......@@ -461,11 +461,12 @@ QVariant KeyframeModel::data(const QModelIndex &index, int role) const
int logRole = ptr->data(m_index, AssetParameterModel::ScaleRole).toInt();
double linear = val * factor;
if (logRole == -1) {
// Logarythmic scale for lower than norm values
// Logarythmic scale
// transform current value to 0..1 scale
if (linear >= norm) {
return 0.5 + (linear - norm) / (max * factor - norm) * 0.5;
double scaled = (linear - norm) / (max * factor - norm);
return 0.5 + pow(scaled, 0.6) * 0.5;
}
// transform current value to 0..1 scale
double scaled = (linear - norm) / (min * factor - norm);
// Log scale
return 0.5 - pow(scaled, 0.6) * 0.5;
......@@ -896,9 +897,9 @@ QVariant KeyframeModel::getNormalizedValue(double newVal) const
int logRole = ptr->data(m_index, AssetParameterModel::ScaleRole).toInt();
double realValue;
if (logRole == -1) {
// Logarythmic scale for lower than norm values
// Logarythmic scale
if (newVal >= 0.5) {
realValue = norm + (2 * (newVal - 0.5) * (max / factor - norm));
realValue = norm + pow(2 * (newVal - 0.5), 10.0 / 6) * (max / factor - norm);
} else {
realValue = norm - pow(2 * (0.5 - newVal), 10.0 / 6) * (norm - min / factor);
}
......
......@@ -130,3 +130,4 @@ void KeyframeMonitorHelper::slotUpdateFromMonitorData(const QVariantList &center
break;
}
}
......@@ -446,6 +446,9 @@ void KeyframeWidget::slotUpdateKeyframesFromMonitor(const QPersistentModelIndex
m_keyframes->updateKeyframe(pos, res, index);
} else if (m_keyframes->hasKeyframe(getPosition()) || m_keyframes->singleKeyframe()) {
GenTime pos(getPosition(), pCore->getCurrentFps());
if (m_keyframes->singleKeyframe() && KdenliveSettings::autoKeyframe() && m_neededScene == MonitorSceneType::MonitorSceneRoto) {
m_keyframes->addKeyframe(pos, KeyframeType::Linear);
}
m_keyframes->updateKeyframe(pos, res, index);
}
}
......
......@@ -811,6 +811,11 @@
<label>Divide monitor resolution by this factor to speedup preview.</label>
<default>1</default>
</entry>
<entry name="autoKeyframe" type="Bool">
<label>Automatically create a new keyframe on keyframe move.</label>
<default>true</default>
</entry>
<entry name="clipMonitorOverlayGuides" type="Int">
<label>index of current guides overlay for clip monitor.</label>
......
......@@ -21,12 +21,12 @@ auto LocaleHandling::setLocale(const QString &lcName) -> QString
localesToTest << lcName << lcName + ".utf-8" << lcName + ".UTF-8" << lcName + ".utf8" << lcName + ".UTF8";
for (const auto &locale : qAsConst(localesToTest)) {
#ifdef Q_OS_FREEBSD
auto *result = setlocale(LC_ALL, locale.toStdString().c_str());
auto *result = setlocale(LC_NUMERIC, locale.toStdString().c_str());
#else
auto *result = std::setlocale(LC_ALL, locale.toStdString().c_str());
auto *result = std::setlocale(LC_NUMERIC, locale.toStdString().c_str());
#endif
if (result != nullptr) {
::qputenv("LC_ALL", locale.toStdString().c_str());
::qputenv("LC_NUMERIC", locale.toStdString().c_str());
newLocale = locale;
break;
}
......@@ -40,12 +40,12 @@ auto LocaleHandling::setLocale(const QString &lcName) -> QString
void LocaleHandling::resetLocale()
{
#ifdef Q_OS_FREEBSD
setlocale(LC_ALL, "C");
setlocale(LC_NUMERIC, "C");
#else
std::setlocale(LC_ALL, "C");
std::setlocale(LC_NUMERIC, "C");
#endif
::qputenv("LC_ALL", "C");
qDebug() << "LC_ALL reset to C";
::qputenv("LC_NUMERIC", "C");
qDebug() << "LC_NUMERIC reset to C";
}
QPair<QLocale, LocaleHandling::MatchType> LocaleHandling::getQLocaleForDecimalPoint(const QString &requestedLocale, const QString &decimalPoint)
......
......@@ -371,6 +371,7 @@ signals:
void acceptRipple(bool);
void switchTrimMode(int);
void activateTrack(int);
void autoKeyframeChanged();
};
#endif
......@@ -372,3 +372,14 @@ bool MonitorProxy::audioThumbFormat() const
{
return KdenliveSettings::displayallchannels();
}
void MonitorProxy::switchAutoKeyframe()
{
KdenliveSettings::setAutoKeyframe(!KdenliveSettings::autoKeyframe());
emit autoKeyframeChanged();
}
bool MonitorProxy::autoKeyframe() const
{
return KdenliveSettings::autoKeyframe();
}
......@@ -49,6 +49,7 @@ class MonitorProxy : public QObject
Q_PROPERTY(int overlayType READ overlayType WRITE setOverlayType NOTIFY overlayTypeChanged)
Q_PROPERTY(QColor thumbColor1 READ thumbColor1 NOTIFY colorsChanged)
Q_PROPERTY(QColor thumbColor2 READ thumbColor2 NOTIFY colorsChanged)
Q_PROPERTY(bool autoKeyframe READ autoKeyframe NOTIFY autoKeyframeChanged)
Q_PROPERTY(bool audioThumbFormat READ audioThumbFormat NOTIFY audioThumbFormatChanged)
/** @brief: Returns true if current clip in monitor has Audio and Video
* */
......@@ -97,6 +98,8 @@ public:
Q_INVOKABLE void startZoneMove();
Q_INVOKABLE void endZoneMove();
Q_INVOKABLE double fps() const;
Q_INVOKABLE void switchAutoKeyframe();
Q_INVOKABLE bool autoKeyframe() const;
QPoint profile();
void setClipProperties(int clipId, ClipType::ProducerType type, bool hasAV, const QString clipName);
void setAudioThumb(const QList <int> streamIndexes = QList <int>(), QList <int> channels = QList <int>());
......@@ -129,6 +132,7 @@ signals:
void colorsChanged();
void audioThumbFormatChanged();
void profileChanged();
void autoKeyframeChanged();
private:
GLWidget *q;
......
......@@ -9,6 +9,7 @@ Rectangle {
width: fullscreenButton.width
property bool rightSide: true
property bool barContainsMouse
property bool showAutoKeyframe: false
height: childrenRect.height
color: Qt.rgba(activePalette.window.r, activePalette.window.g, activePalette.window.b, 0.7)
radius: 4
......@@ -88,6 +89,14 @@ Rectangle {
tooltip: i18n("Zoom out")
onClicked: controller.triggerAction('monitor_zoomout')
}
ToolButton {
iconName: "media-record"
tooltip: i18n("Automatic Keyframes")
onClicked: controller.switchAutoKeyframe()
checkable: true
checked: controller.autoKeyframe
visible: showAutoKeyframe
}
ToolButton {
objectName: "moveBar"
iconName: "transform-move-horizontal"
......
......@@ -36,6 +36,7 @@ Item {
onScaleyChanged: canvas.requestPaint()
onSourcedarChanged: refreshdar()
property bool iskeyframe : true
property bool autoKeyframe: controller.autoKeyframe
property bool isDefined: false
property int requestedKeyFrame : -1
property int requestedSubKeyFrame : -1
......@@ -70,6 +71,13 @@ Item {
onIskeyframeChanged: {
console.log('KEYFRAME CHANGED: ', iskeyframe)
if (root.displayResize && !controller.autoKeyframe) {
root.displayResize = false
}
canvas.requestPaint()
}
onAutoKeyframeChanged: {
canvas.requestPaint()
}
......@@ -161,7 +169,7 @@ Item {
}
c2 = convertPoint(root.centerPointsTypes[2*i])
ctx.bezierCurveTo(c1.x, c1.y, c2.x, c2.y, p1.x, p1.y);
if (iskeyframe && !root.displayResize) {
if ((iskeyframe || autoKeyframe) && !root.displayResize) {
// Draw control points and segments
if (subkf) {
ctx.fillStyle = Qt.rgba(1, 1, 0, 0.8)
......@@ -365,6 +373,9 @@ Item {
}
onDoubleClicked: {
if (root.isDefined) {
if (root.iskeyframe == false && controller.autoKeyframe) {
controller.addRemoveKeyframe();
}
if (root.displayResize) {
// Disable resize mode
root.displayResize = false
......@@ -448,7 +459,13 @@ Item {
}
onPositionChanged: {
if (root.iskeyframe == false) return;
if (pressed && root.iskeyframe == false) {
if (controller.autoKeyframe) {
controller.addRemoveKeyframe();
} else {
return;
}
}
if (pressed) {
if (root.resizeContainsMouse > 0) {
// resizing shape
......@@ -543,7 +560,7 @@ Item {
canvas.requestPaint()
root.effectPolygonChanged()
}
} else if (root.centerPoints.length > 0) {
} else if ((root.iskeyframe || controller.autoKeyframe) && root.centerPoints.length > 0) {
// Check if we are over a keyframe
if (!root.displayResize) {
addPointPossible = Qt.point(0, 0)
......@@ -675,6 +692,7 @@ Item {
EffectToolBar {
id: effectToolBar
barContainsMouse: effectToolBar.rightSide ? global.mouseX >= x - 10 : global.mouseX < x + width + 10
showAutoKeyframe: true
onBarContainsMouseChanged: {
effectToolBar.opacity = 1
effectToolBar.visible = effectToolBar.barContainsMouse
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment