Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Allow adding effects by dropping into monitor, fix crash on cut

parent a2fdb7fc
......@@ -2406,7 +2406,7 @@ void Bin::slotItemDropped(const QStringList &ids, const QModelIndex &parent)
m_doc->commandStack()->push(moveCommand);
}
void Bin::slotAddEffect(QString id, const QString &effectId)
void Bin::slotAddEffect(QString id, const QStringList &effectData)
{
if (id.isEmpty()) {
id = m_monitor->activeClipId();
......@@ -2414,7 +2414,13 @@ void Bin::slotAddEffect(QString id, const QString &effectId)
if (!id.isEmpty()) {
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(id);
if (clip) {
clip->addEffect(effectId);
if (effectData.count() == 4) {
// Paste effect from another stack
std::shared_ptr<EffectStackModel> sourceStack = pCore->getItemEffectStack(effectData.at(1).toInt(), effectData.at(2).toInt());
clip->copyEffect(sourceStack, effectData.at(3).toInt());
} else {
clip->addEffect(effectData.constFirst());
}
return;
}
}
......
......@@ -419,7 +419,7 @@ public slots:
/** @brief Pass some important properties to timeline track producers. */
void updateTimelineProducers(const QString &id, const QMap<QString, QString> &passProperties);
/** @brief Add effect to active Bin clip (used when double clicking an effect in list). */
void slotAddEffect(QString id, const QString &effectID);
void slotAddEffect(QString id, const QStringList &effectData);
/** @brief Request current frame from project monitor.
* @param clipId is the id of a clip we want to hide from screenshot
* @param request true to start capture process, false to end it. It is necessary to emit a false after image is received
......
......@@ -282,7 +282,7 @@ void MainWindow::init()
connect(m_loopClip, &QAction::triggered, m_projectMonitor, &Monitor::slotLoopClip);
pCore->monitorManager()->initMonitors(m_clipMonitor, m_projectMonitor);
connect(m_clipMonitor, SIGNAL(addMasterEffect(QString, QDomElement)), pCore->bin(), SLOT(slotEffectDropped(QString, QDomElement)));
connect(m_clipMonitor, &Monitor::addMasterEffect, pCore->bin(), &Bin::slotAddEffect);
m_timelineTabs = new TimelineTabs(this);
ctnLay->addWidget(m_timelineTabs);
......
......@@ -74,7 +74,7 @@ bool QuickEventEater::eventFilter(QObject *obj, QEvent *event)
switch (event->type()) {
case QEvent::DragEnter: {
QDragEnterEvent *ev = reinterpret_cast<QDragEnterEvent *>(event);
if (ev->mimeData()->hasFormat(QStringLiteral("kdenlive/effectslist"))) {
if (ev->mimeData()->hasFormat(QStringLiteral("kdenlive/effect"))) {
ev->acceptProposedAction();
return true;
}
......@@ -82,7 +82,7 @@ bool QuickEventEater::eventFilter(QObject *obj, QEvent *event)
}
case QEvent::DragMove: {
QDragEnterEvent *ev = reinterpret_cast<QDragEnterEvent *>(event);
if (ev->mimeData()->hasFormat(QStringLiteral("kdenlive/effectslist"))) {
if (ev->mimeData()->hasFormat(QStringLiteral("kdenlive/effect"))) {
ev->acceptProposedAction();
return true;
}
......@@ -91,10 +91,11 @@ bool QuickEventEater::eventFilter(QObject *obj, QEvent *event)
case QEvent::Drop: {
QDropEvent *ev = static_cast<QDropEvent *>(event);
if (ev) {
const QString effects = QString::fromUtf8(ev->mimeData()->data(QStringLiteral("kdenlive/effectslist")));
QDomDocument doc;
doc.setContent(effects, true);
emit addEffect(doc.documentElement());
QStringList effectData;
effectData << QString::fromUtf8(ev->mimeData()->data(QStringLiteral("kdenlive/effect")));
QStringList source = QString::fromUtf8(ev->mimeData()->data(QStringLiteral("kdenlive/effectsource"))).split(QLatin1Char('-'));
effectData << source;
emit addEffect(effectData);
ev->accept();
return true;
}
......@@ -390,7 +391,7 @@ void Monitor::slotGetCurrentImage(bool request)
}
}
void Monitor::slotAddEffect(const QDomElement &effect)
void Monitor::slotAddEffect(const QStringList &effect)
{
if (m_id == Kdenlive::ClipMonitor) {
if (m_controller) {
......
......@@ -64,7 +64,7 @@ protected:
bool eventFilter(QObject *obj, QEvent *event) override;
signals:
void addEffect(const QDomElement &);
void addEffect(const QStringList&);
};
class QuickMonitorEventEater : public QObject
......@@ -259,7 +259,7 @@ private slots:
/** @brief Display a non blocking error message to user **/
void warningMessage(const QString &text, int timeout = 5000, const QList<QAction *> &actions = QList<QAction *>());
void slotLockMonitor(bool lock);
void slotAddEffect(const QDomElement &effect);
void slotAddEffect(const QStringList &effect);
void slotSwitchPlay();
void slotEditInlineMarker();
/** @brief Pass keypress event to mainwindow */
......@@ -358,8 +358,8 @@ signals:
void showConfigDialog(int, int);
/** @brief Request display of current bin clip. */
void refreshCurrentClip();
void addEffect(const QDomElement &);
void addMasterEffect(const QString &, const QDomElement &);
void addEffect(const QStringList &);
void addMasterEffect(QString, const QStringList &);
void passKeyPress(QKeyEvent *);
/** @brief Enable / disable project monitor multitrack view (split view with one track in each quarter). */
void multitrackView(bool);
......
......@@ -877,7 +877,9 @@ void ProjectManager::activateAsset(const QVariantMap effectData)
pCore->window()->getMainTimeline()->controller()->addAsset(effectData);
} else {
QString effect = effectData.value(QStringLiteral("kdenlive/effect")).toString();
pCore->bin()->slotAddEffect(QString(), effect);
QStringList effectString;
effectString << effect;
pCore->bin()->slotAddEffect(QString(), effectString);
}
}
......
......@@ -99,6 +99,18 @@ int TimelineModel::getTracksCount() const
return count - 1;
}
int TimelineModel::getTrackIndexFromPosition(int pos) const
{
Q_ASSERT(pos >= 0 && pos < m_allTracks.size());
READ_LOCK();
auto it = m_allTracks.begin();
while (pos > 0) {
it++;
pos--;
}
return (*it)->getId();
}
int TimelineModel::getClipsCount() const
{
READ_LOCK();
......
......@@ -141,6 +141,9 @@ public:
/* @brief returns the number of tracks */
int getTracksCount() const;
/* @brief returns the track index (id) from its position */
int getTrackIndexFromPosition(int pos) const;
/* @brief returns the number of clips */
int getClipsCount() const;
......
......@@ -431,11 +431,14 @@ int TrackModel::getId() const
int TrackModel::getClipByPosition(int position)
{
READ_LOCK();
QSharedPointer<Mlt::Producer> prod(m_playlists[0].get_clip_at(position));
if (prod->is_blank()) {
QSharedPointer<Mlt::Producer> prod(m_playlists[1].get_clip_at(position));
QSharedPointer<Mlt::Producer> prod(nullptr);
if (m_playlists[0].count() > 0) {
prod = QSharedPointer<Mlt::Producer>(m_playlists[0].get_clip_at(position));
}
if (prod->is_blank()) {
if ((!prod || prod->is_blank()) && m_playlists[1].count() > 0) {
prod = QSharedPointer<Mlt::Producer>(m_playlists[1].get_clip_at(position));
}
if (!prod || prod->is_blank()) {
return -1;
}
return prod->get_int("_kdenlive_cid");
......
......@@ -548,3 +548,23 @@ QStringList TimelineController::extractCompositionLumas() const
{
return m_model->extractCompositionLumas();
}
void TimelineController::addEffectToCurrentClip(const QStringList &effectData)
{
QList <int> activeClips;
for (int track = m_model->getTracksCount() - 1; track > 0; track--) {
int trackIx = m_model->getTrackIndexFromPosition(track);
int cid = m_model->getClipByPosition(trackIx, m_position);
if (cid > -1) {
activeClips << cid;
}
}
if (!activeClips.isEmpty()) {
if (effectData.count() == 4) {
QString effectString = effectData.at(1) + QStringLiteral("-") + effectData.at(2) + QStringLiteral("-") + effectData.at(3);
m_model->copyClipEffect(activeClips.first(), effectString);
} else {
m_model->addClipEffect(activeClips.first(), effectData.constFirst());
}
}
}
......@@ -224,6 +224,7 @@ public slots:
void selectMultitrack();
Q_INVOKABLE void setSeekPosition(int position);
void onSeeked(int position);
void addEffectToCurrentClip(const QStringList &effectData);
private:
QQuickItem *m_root;
......
......@@ -42,6 +42,7 @@ TimelineTabs::TimelineTabs(QWidget *parent)
tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0);
connect(pCore->monitorManager()->projectMonitor(), &Monitor::zoneUpdated, m_mainTimeline, &TimelineWidget::zoneUpdated);
connect(m_mainTimeline, &TimelineWidget::zoneMoved, pCore->monitorManager()->projectMonitor(), &Monitor::slotLoadClipZone);
connect(pCore->monitorManager()->projectMonitor(), &Monitor::addEffect, m_mainTimeline->controller(), &TimelineController::addEffectToCurrentClip);
}
TimelineWidget *TimelineTabs::getMainTimeline() const
......
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