Commit 02201a4a authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Remember effect keyframe status (show/hide).

Fixes #1538
parent 2e3a0873
......@@ -264,5 +264,6 @@ signals:
void replugEffect(std::shared_ptr<AssetParameterModel> asset);
void rebuildEffect(std::shared_ptr<AssetParameterModel> asset);
void enabledChange(bool);
void hideKeyframesChange(bool);
void showEffectZone(ObjectId id, QPair<int, int> inOut, bool checked);
};
......@@ -216,6 +216,32 @@ bool EffectItemModel::isCollapsed() const
return filter().get_int("kdenlive:collapsed") == 1;
}
void EffectItemModel::setKeyframesHidden(bool hidden)
{
Fun undo = [this, hidden]() {
filter().set("kdenlive:kfrhidden", hidden ? 0 : 1);
emit hideKeyframesChange(hidden ? false : true);
return true;
};
Fun redo = [this, hidden]() {
filter().set("kdenlive:kfrhidden", hidden ? 1 : 0);
emit hideKeyframesChange(hidden ? true : false);
return true;
};
redo();
pCore->pushUndo(undo, redo, hidden ? i18n("Hide keyframes") : i18n("Show keyframes"));
}
bool EffectItemModel::isKeyframesHidden() const
{
return filter().get_int("kdenlive:kfrhidden") == 1;
}
bool EffectItemModel::keyframesHiddenUnset() const
{
return filter().property_exists("kdenlive:kfrhidden") == false;
}
bool EffectItemModel::hasForcedInOut() const
{
return filter().get_int("kdenlive:force_in_out") == 1;
......
......@@ -45,6 +45,9 @@ public:
void setCollapsed(bool collapsed);
bool isCollapsed() const;
void setKeyframesHidden(bool hidden);
bool isKeyframesHidden() const;
bool keyframesHiddenUnset() const;
bool hasForcedInOut() const;
bool isValid() const;
QPair<int, int> getInOut() const;
......
......@@ -89,6 +89,13 @@ CollapsibleEffectView::CollapsibleEffectView(const std::shared_ptr<EffectItemMod
keyframesButton->setCheckable(true);
keyframesButton->setToolTip(i18n("Enable Keyframes"));
m_keyframesButton = new KDualAction(i18n("Hide Keyframes"), i18n("Show Keyframes"), this);
m_keyframesButton->setActiveIcon(QIcon::fromTheme(QStringLiteral("keyframe-disable")));
m_keyframesButton->setInactiveIcon(QIcon::fromTheme(QStringLiteral("keyframe")));
keyframesButton->setDefaultAction(m_keyframesButton);
connect(m_keyframesButton, &KDualAction::activeChangedByUser, this, &CollapsibleEffectView::slotHideKeyframes);
connect(m_model.get(), &AssetParameterModel::hideKeyframesChange, this, &CollapsibleEffectView::enableHideKeyframes);
// Enable button
m_enabledButton = new KDualAction(i18n("Disable Effect"), i18n("Enable Effect"), this);
m_enabledButton->setActiveIcon(QIcon::fromTheme(QStringLiteral("hint")));
......@@ -198,25 +205,18 @@ CollapsibleEffectView::CollapsibleEffectView(const std::shared_ptr<EffectItemMod
lay->setContentsMargins(0, 0, 0, 0);
lay->setSpacing(0);
lay->addWidget(m_view);
connect(keyframesButton, &QToolButton::toggled, this, [this](bool toggle) {
if (toggle) {
keyframesButton->setIcon(QIcon::fromTheme(QStringLiteral("keyframe")));
} else {
keyframesButton->setIcon(QIcon::fromTheme(QStringLiteral("keyframe-disable")));
}
m_view->toggleKeyframes(toggle);
});
if (!effectParamModel->hasMoreThanOneKeyframe()) {
// No keyframe or only one, allow hiding
bool hideByDefault = effectParamModel->data(effectParamModel->index(0, 0), AssetParameterModel::HideKeyframesFirstRole).toBool();
if (hideByDefault) {
m_view->toggleKeyframes(false);
} else {
keyframesButton->setChecked(true);
if (hideByDefault && m_model->keyframesHiddenUnset()) {
m_model->setKeyframesHidden(true);
}
} else {
keyframesButton->setChecked(true);
}
if (m_model->isKeyframesHidden()) {
m_view->toggleKeyframes(false);
m_keyframesButton->setActive(true);
}
// Presets
presetButton->setIcon(QIcon::fromTheme(QStringLiteral("adjustlevels")));
......@@ -879,6 +879,12 @@ void CollapsibleEffectView::enableView(bool enabled)
}
}
void CollapsibleEffectView::enableHideKeyframes(bool enabled)
{
m_keyframesButton->setActive(enabled);
m_view->toggleKeyframes(!enabled);
}
void CollapsibleEffectView::blockWheelEvent(bool block)
{
m_blockWheel = block;
......@@ -980,3 +986,8 @@ void CollapsibleEffectView::addRemoveKeyframe()
{
emit m_view->addRemoveKeyframe();
}
void CollapsibleEffectView::slotHideKeyframes(bool hide)
{
m_model->setKeyframesHidden(hide);
}
......@@ -93,6 +93,7 @@ public slots:
private slots:
void setWidgetHeight(qreal value);
void enableView(bool enabled);
void enableHideKeyframes(bool enabled);
void slotSwitch(bool expand);
void slotDeleteEffect();
void slotEffectUp();
......@@ -104,6 +105,7 @@ private slots:
void slotUpdateRegionEffectParams(const QDomElement & /*old*/, const QDomElement & /*e*/, int /*ix*/);
void prepareImportClipKeyframes();
void updateEffectZone();
void slotHideKeyframes(bool hide);
private:
AssetParameterView *m_view;
......@@ -120,6 +122,7 @@ private:
/** @brief The add group action. */
QAction *m_groupAction;
KDualAction *m_enabledButton;
KDualAction *m_keyframesButton;
QAction *m_inOutButton;
QLabel *m_colorIcon;
QPixmap m_iconPix;
......
Supports Markdown
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