Only show relevant effects in timeline clip context menu

parent d61e7579
...@@ -398,3 +398,12 @@ void EffectsRepository::deleteEffect(const QString &id) ...@@ -398,3 +398,12 @@ void EffectsRepository::deleteEffect(const QString &id)
m_assets.erase(id); m_assets.erase(id);
} }
} }
bool EffectsRepository::isAudioEffect(const QString &assetId) const
{
if (m_assets.count(assetId) > 0) {
AssetListType::AssetType type = m_assets.at(assetId).type;
return type == AssetListType::AssetType::Audio || type == AssetListType::AssetType::CustomAudio;
}
return false;
}
...@@ -55,6 +55,7 @@ public: ...@@ -55,6 +55,7 @@ public:
/** @brief Returns true if this is an effect group */ /** @brief Returns true if this is an effect group */
bool isGroup(const QString &assetId) const; bool isGroup(const QString &assetId) const;
void deleteEffect(const QString &id); void deleteEffect(const QString &id);
bool isAudioEffect(const QString &assetId) const;
protected: protected:
// Constructor is protected because class is a Singleton // Constructor is protected because class is a Singleton
......
...@@ -258,7 +258,7 @@ Rectangle { ...@@ -258,7 +258,7 @@ Rectangle {
controller.requestAddToSelection(clipRoot.clipId, true) controller.requestAddToSelection(clipRoot.clipId, true)
} }
root.mainFrame = Math.round(mouse.x / timeline.scaleFactor) root.mainFrame = Math.round(mouse.x / timeline.scaleFactor)
root.showClipMenu() root.showClipMenu(clipRoot.clipId)
} }
} }
Keys.onShortcutOverride: event.accepted = clipRoot.isGrabbed && (event.key === Qt.Key_Left || event.key === Qt.Key_Right || event.key === Qt.Key_Up || event.key === Qt.Key_Down || event.key === Qt.Key_Escape) Keys.onShortcutOverride: event.accepted = clipRoot.isGrabbed && (event.key === Qt.Key_Left || event.key === Qt.Key_Right || event.key === Qt.Key_Up || event.key === Qt.Key_Down || event.key === Qt.Key_Escape)
......
...@@ -15,7 +15,7 @@ Rectangle { ...@@ -15,7 +15,7 @@ Rectangle {
signal clipClicked() signal clipClicked()
signal mousePosChanged(int position) signal mousePosChanged(int position)
signal showClipMenu() signal showClipMenu(int cid)
signal showCompositionMenu() signal showCompositionMenu()
signal showTimelineMenu() signal showTimelineMenu()
signal showRulerMenu() signal showRulerMenu()
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "qmltypes/thumbnailprovider.h" #include "qmltypes/thumbnailprovider.h"
#include "timelinecontroller.h" #include "timelinecontroller.h"
#include "utils/clipboardproxy.hpp" #include "utils/clipboardproxy.hpp"
#include "effects/effectsrepository.hpp"
#include <KDeclarative/KDeclarative> #include <KDeclarative/KDeclarative>
// #include <QUrl> // #include <QUrl>
...@@ -175,7 +176,7 @@ void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, M ...@@ -175,7 +176,7 @@ void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, M
connect(rootObject(), SIGNAL(processingDrag(bool)), pCore->window(), SIGNAL(enableUndo(bool))); connect(rootObject(), SIGNAL(processingDrag(bool)), pCore->window(), SIGNAL(enableUndo(bool)));
connect(m_proxy, &TimelineController::seeked, proxy, &MonitorProxy::setPosition); connect(m_proxy, &TimelineController::seeked, proxy, &MonitorProxy::setPosition);
rootObject()->setProperty("dar", pCore->getCurrentDar()); rootObject()->setProperty("dar", pCore->getCurrentDar());
connect(rootObject(), SIGNAL(showClipMenu()), this, SLOT(showClipMenu())); connect(rootObject(), SIGNAL(showClipMenu(int)), this, SLOT(showClipMenu(int)));
connect(rootObject(), SIGNAL(showCompositionMenu()), this, SLOT(showCompositionMenu())); connect(rootObject(), SIGNAL(showCompositionMenu()), this, SLOT(showCompositionMenu()));
connect(rootObject(), SIGNAL(showTimelineMenu()), this, SLOT(showTimelineMenu())); connect(rootObject(), SIGNAL(showTimelineMenu()), this, SLOT(showTimelineMenu()));
connect(rootObject(), SIGNAL(showRulerMenu()), this, SLOT(showRulerMenu())); connect(rootObject(), SIGNAL(showRulerMenu()), this, SLOT(showRulerMenu()));
...@@ -193,8 +194,24 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) ...@@ -193,8 +194,24 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event)
QQuickWidget::mousePressEvent(event); QQuickWidget::mousePressEvent(event);
} }
void TimelineWidget::showClipMenu() void TimelineWidget::showClipMenu(int cid)
{ {
// Hide not applicable effects
QList <QAction *> effects = m_favEffects->actions();
int tid = model()->getClipTrackId(cid);
bool isAudioTrack = false;
if (tid > -1) {
isAudioTrack = model()->isAudioTrack(tid);
}
m_favCompositions->setEnabled(!isAudioTrack);
for (auto ac : effects) {
const QString &id = ac->data().toString();
if (EffectsRepository::get()->isAudioEffect(id) != isAudioTrack) {
ac->setVisible(false);
} else {
ac->setVisible(true);
}
}
m_timelineClipMenu->popup(m_clickPos); m_timelineClipMenu->popup(m_clickPos);
} }
......
...@@ -72,7 +72,7 @@ public slots: ...@@ -72,7 +72,7 @@ public slots:
private slots: private slots:
void slotUngrabHack(); void slotUngrabHack();
void showClipMenu(); void showClipMenu(int cid);
void showCompositionMenu(); void showCompositionMenu();
void showTimelineMenu(); void showTimelineMenu();
void showRulerMenu(); void showRulerMenu();
......
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