Cleanup & fix selected effect sometimes not showing selected state

parent b433ac9a
......@@ -1570,10 +1570,10 @@ void ClipItem::deleteEffect(QString index)
m_effectList.removeAt(ix);
m_effectNames = m_effectList.effectNames().join(" / ");
if (m_effectList.isEmpty() || m_selectedEffect + 1 == ix) {
if (m_effectList.isEmpty() || m_selectedEffect == ix) {
// Current effect was removed
if (ix > m_effectList.count() - 1) {
setSelectedEffect(m_effectList.count() - 1);
if (ix > m_effectList.count()) {
setSelectedEffect(m_effectList.count());
} else setSelectedEffect(ix);
}
if (needRepaint) update(boundingRect());
......
......@@ -1678,6 +1678,7 @@ void CustomTrackView::addEffect(int track, GenTime pos, QDomElement effect)
EffectsParameterList params = clip->addEffect(effect);
if (!m_document->renderer()->mltAddEffect(track, pos, params))
emit displayMessage(i18n("Problem adding effect to clip"), ErrorMessage);
clip->setSelectedEffect(params.paramValue("kdenlive_ix").toInt());
if (clip->isSelected()) emit clipItemSelected(clip);
} else emit displayMessage(i18n("Cannot find clip to add effect"), ErrorMessage);
}
......@@ -1803,11 +1804,11 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track)
for (int i = 0; i < itemList.count(); i++) {
if (itemList.at(i)->type() == AVWIDGET) {
ClipItem *clip = static_cast<ClipItem *>(itemList.at(i));
clip->setSelectedEffect(clip->effectsCount() - 1);
clip->setSelectedEffect(clip->effectsCount());
if (!clip->isSelected()) {
clearSelection(false);
clip->setSelected(true);
emit clipItemSelected(clip, clip->selectedEffectIndex());
emit clipItemSelected(clip);
}
break;
}
......@@ -1943,7 +1944,7 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
}
clip->updateEffect(effect);
if (updateEffectStack && clip->isSelected())
emit clipItemSelected(clip, ix);
emit clipItemSelected(clip);
if (ix == clip->selectedEffectIndex()) {
// make sure to update display of clip keyframes
clip->setSelectedEffect(ix);
......@@ -1974,7 +1975,7 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
if (success) {
clip->updateEffect(effect);
if (updateEffectStack && clip->isSelected()) {
emit clipItemSelected(clip, ix);
emit clipItemSelected(clip);
}
if (ix == clip->selectedEffectIndex()) {
// make sure to update display of clip keyframes
......@@ -2023,7 +2024,8 @@ void CustomTrackView::moveEffect(int track, GenTime pos, int oldPos, int newPos)
} else if (before.attribute("id") == "speed") {
m_document->renderer()->mltUpdateEffectPosition(track, pos, newPos, oldPos);
} else m_document->renderer()->mltMoveEffect(track, pos, oldPos, newPos);
emit clipItemSelected(clip, newPos);
clip->setSelectedEffect(newPos);
emit clipItemSelected(clip);
setDocumentModified();
} else emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
}
......@@ -2499,7 +2501,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
groupSelectedItems(true);
} else if (items.count() == 1) {
m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
emit clipItemSelected((ClipItem*)m_dragItem, -1, false);
emit clipItemSelected((ClipItem*)m_dragItem, false);
}
event->setDropAction(Qt::MoveAction);
event->accept();
......@@ -3686,7 +3688,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
slotUpdateClipEffect(item, -1, effect, oldeffect, ix);
emit clipItemSelected(item, ix);
emit clipItemSelected(item);
}
} else if (item->fadeIn() != 0 && ix2 == -1) {
QDomElement effect;
......@@ -3709,7 +3711,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
EffectsList::setParameter(oldeffect, "in", QString::number(start));
EffectsList::setParameter(oldeffect, "out", QString::number(end));
slotUpdateClipEffect(item, -1, effect, oldeffect, ix2);
emit clipItemSelected(item, ix2);
emit clipItemSelected(item);
}
}
} else if (m_operationMode == FADEOUT) {
......@@ -3730,7 +3732,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
EffectsList::setParameter(oldeffect, "out", QString::number(end));
// kDebug()<<"EDIT FADE OUT : "<<start<<"x"<<end;
slotUpdateClipEffect(item, -1, effect, oldeffect, ix);
emit clipItemSelected(item, ix);
emit clipItemSelected(item);
}
} else if (item->fadeOut() != 0 && ix2 == -1) {
QDomElement effect;
......@@ -3755,7 +3757,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
EffectsList::setParameter(oldeffect, "out", QString::number(end));
// kDebug()<<"EDIT FADE OUT : "<<start<<"x"<<end;
slotUpdateClipEffect(item, -1, effect, oldeffect, ix2);
emit clipItemSelected(item, ix2);
emit clipItemSelected(item);
}
}
} else if (m_operationMode == KEYFRAME) {
......@@ -3786,7 +3788,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
m_commandStack->push(command);
updateEffect(m_document->tracksCount() - item->track(), item->startPos(), item->selectedEffect(), item->selectedEffectIndex());
emit clipItemSelected(item, item->selectedEffectIndex());
emit clipItemSelected(item);
}
if (m_dragItem && m_dragItem->type() == TRANSITIONWIDGET && m_dragItem->isSelected()) {
// A transition is selected
......@@ -4806,7 +4808,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
// if fade effect is displayed, update the effect edit widget with new clip duration
if (item->isSelected() && effectPos == item->selectedEffectIndex())
emit clipItemSelected(item, effectPos);
emit clipItemSelected(item);
}
}
effectPos = item->hasEffect("brightness", "fade_from_black");
......@@ -4827,7 +4829,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
// if fade effect is displayed, update the effect edit widget with new clip duration
if (item->isSelected() && effectPos == item->selectedEffectIndex())
emit clipItemSelected(item, effectPos);
emit clipItemSelected(item);
}
}
}
......@@ -4853,7 +4855,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
// if fade effect is displayed, update the effect edit widget with new clip duration
if (item->isSelected() && effectPos == item->selectedEffectIndex())
emit clipItemSelected(item, effectPos);
emit clipItemSelected(item);
}
}
effectPos = item->hasEffect("brightness", "fade_to_black");
......@@ -4874,7 +4876,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool
emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
// if fade effect is displayed, update the effect edit widget with new clip duration
if (item->isSelected() && effectPos == item->selectedEffectIndex())
emit clipItemSelected(item, effectPos);
emit clipItemSelected(item);
}
}
}
......@@ -4889,7 +4891,7 @@ void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool
EffectsList::setParameter(eff, "frame", QString::number(freeze_pos));
if (standalone) {
if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") {
emit clipItemSelected(item, item->selectedEffectIndex());
emit clipItemSelected(item);
}
}
}
......@@ -6876,7 +6878,7 @@ void CustomTrackView::slotGotFilterJobResults(const QString &/*id*/, int startPo
}
EditEffectCommand *command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, newEffect, clip->selectedEffectIndex(), true, true);
m_commandStack->push(command);
emit clipItemSelected(clip, clip->selectedEffectIndex());
emit clipItemSelected(clip);
}
}
......
......@@ -472,9 +472,8 @@ signals:
void mousePosition(int);
/** @brief A clip was selected in timeline, update the effect stack
* @param clip The clip
* @param ix The index of currently selected effect
* @param raise If true, the effect stack widget will be raised (come to front). */
void clipItemSelected(ClipItem *clip, int ix = -1, bool raise = true);
void clipItemSelected(ClipItem *clip, bool raise = true);
void transitionItemSelected(Transition*, int track = 0, QPoint p = QPoint(), bool update = false);
void activateDocumentMonitor();
void trackHeightChanged();
......
......@@ -89,7 +89,7 @@ void EffectStackView2::slotRenderPos(int pos)
m_effects.at(i)->slotSyncEffectsPos(pos);
}
void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix)
void EffectStackView2::slotClipItemSelected(ClipItem* c)
{
if (c && !c->isEnabled()) return;
if (c && c == m_clipref) {
......@@ -107,12 +107,9 @@ void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix)
m_ui.checkAll->setText(i18n("Effects for %1").arg(cname));
}
m_ui.checkAll->setEnabled(true);
ix = c->selectedEffectIndex();
QString size = c->baseClip()->getProperty("frame_size");
double factor = c->baseClip()->getProperty("aspect_ratio").toDouble();
m_effectMetaInfo.frameSize = QPoint((int)(size.section('x', 0, 0).toInt() * factor + 0.5), size.section('x', 1, 1).toInt());
} else {
ix = 0;
}
}
if (m_clipref == NULL) {
......@@ -125,7 +122,7 @@ void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix)
setEnabled(true);
m_effectMetaInfo.trackMode = false;
m_currentEffectList = m_clipref->effectList();
setupListView(ix);
setupListView();
}
void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo info)
......@@ -138,11 +135,11 @@ void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo info)
m_ui.checkAll->setToolTip(QString());
m_ui.checkAll->setText(i18n("Effects for track %1").arg(info.trackName.isEmpty() ? QString::number(ix) : info.trackName));
m_trackindex = ix;
setupListView(0);
setupListView();
}
void EffectStackView2::setupListView(int ix)
void EffectStackView2::setupListView()
{
blockSignals(true);
m_draggedEffect = NULL;
......@@ -203,6 +200,7 @@ void EffectStackView2::setupListView(int ix)
kDebug() << "IMPORTED STK: " << doc.toString();*/
ItemInfo info;
bool isSelected = false;
if (m_effectMetaInfo.trackMode) {
info.track = m_trackInfo.type;
info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
......@@ -210,16 +208,24 @@ void EffectStackView2::setupListView(int ix)
info.startPos = GenTime(-1);
info.track = 0;
}
else info = m_clipref->info();
else {
info = m_clipref->info();
}
CollapsibleEffect *currentEffect = new CollapsibleEffect(d, m_currentEffectList.at(i), info, &m_effectMetaInfo, i == m_currentEffectList.count() - 1, view);
if (m_effectMetaInfo.trackMode) {
isSelected = currentEffect->effectIndex() == 1;
}
else {
isSelected = currentEffect->effectIndex() == m_clipref->selectedEffectIndex();
}
if (isSelected) currentEffect->setActive(true);
m_effects.append(currentEffect);
if (group) {
group->addGroupEffect(currentEffect);
} else {
vbox1->addWidget(currentEffect);
}
if (currentEffect->effectIndex() == ix) currentEffect->setActive(true);
// Check drag & drop
currentEffect->installEventFilter( this );
......
......@@ -102,18 +102,16 @@ private:
/** @brief The current number of groups. */
int m_groupIndex;
/** @brief Sets the list of effects according to the clip's effect list.
* @param ix Number of the effect to preselect */
void setupListView(int ix);
/** @brief Sets the list of effects according to the clip's effect list. */
void setupListView();
/** @brief Build the drag info and start it. */
void startDrag();
public slots:
/** @brief Sets the clip whose effect list should be managed.
* @param c Clip whose effect list should be managed
* @param ix Effect to preselect */
void slotClipItemSelected(ClipItem* c, int ix);
* @param c Clip whose effect list should be managed */
void slotClipItemSelected(ClipItem* c);
void slotTrackItemSelected(int ix, const TrackInfo info);
......
......@@ -644,7 +644,7 @@ MainWindow::~MainWindow()
if (m_stopmotion) {
delete m_stopmotion;
}
m_effectStack->slotClipItemSelected(NULL, 0);
m_effectStack->slotClipItemSelected(NULL);
m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
if (m_projectMonitor) m_projectMonitor->stop();
......@@ -2329,7 +2329,7 @@ void MainWindow::slotUpdateProjectProfile(const QString &profile)
}
// Deselect current effect / transition
m_effectStack->slotClipItemSelected(NULL, 0);
m_effectStack->slotClipItemSelected(NULL);
m_transitionConfig->slotTransitionItemSelected(NULL, 0, QPoint(), false);
m_clipMonitor->slotSetClipProducer(NULL);
bool updateFps = m_activeDocument->setProfilePath(profile);
......@@ -2469,12 +2469,9 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
disconnect(m_activeDocument, SIGNAL(signalDeleteProjectClip(const QString &)), this, SLOT(slotDeleteClip(const QString &)));
disconnect(m_activeDocument, SIGNAL(updateClipDisplay(const QString &)), m_projectList, SLOT(slotUpdateClip(const QString &)));
disconnect(m_activeDocument, SIGNAL(selectLastAddedClip(const QString &)), m_projectList, SLOT(slotSelectClip(const QString &)));
disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
disconnect(m_activeTimeline->projectView(), SIGNAL(clipItemSelected(ClipItem*, bool)), this, SLOT(slotTimelineClipSelected(ClipItem*, bool)));
disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
disconnect(m_activeTimeline->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
disconnect(m_activeTimeline->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
disconnect(m_activeTimeline->projectView(), SIGNAL(displayMessage(const QString&, MessageType)), m_messageLabel, SLOT(setMessage(const QString&, MessageType)));
disconnect(m_activeTimeline->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
......@@ -2538,12 +2535,10 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
connect(m_notesWidget, SIGNAL(textChanged()), doc, SLOT(setModified()));
connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_effectStack, SLOT(slotClipItemSelected(ClipItem*, int)));
connect(trackView->projectView(), SIGNAL(updateClipMarkers(DocClipBase *)), this, SLOT(slotUpdateClipMarkers(DocClipBase*)));
connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), m_effectStack, SLOT(slotTrackItemSelected(int, TrackInfo)));
connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotActivateEffectStackView()));
connect(trackView, SIGNAL(showTrackEffects(int, TrackInfo)), this, SLOT(slotTrackSelected(int, TrackInfo)));
connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), this, SLOT(slotActivateEffectStackView(ClipItem*, int, bool)));
connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, bool)), this, SLOT(slotTimelineClipSelected(ClipItem*, bool)));
connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_transitionConfig, SLOT(slotTransitionItemSelected(Transition*, int, QPoint, bool)));
connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), this, SLOT(slotActivateTransitionView(Transition *)));
m_zoomSlider->setValue(doc->zoom().x());
......@@ -2555,7 +2550,6 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //cha
connect(trackView->projectView(), SIGNAL(showClipFrame(DocClipBase *, QPoint, bool, const int)), m_clipMonitor, SLOT(slotSetClipProducer(DocClipBase *, QPoint, bool, const int)));
connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
connect(trackView->projectView(), SIGNAL(clipItemSelected(ClipItem*, int, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(ClipItem*)));
connect(trackView->projectView(), SIGNAL(transitionItemSelected(Transition*, int, QPoint, bool)), m_projectMonitor, SLOT(slotSetSelectedClip(Transition*)));
connect(m_projectList, SIGNAL(gotFilterJobResults(const QString &, int, int, const QString &, stringMap)), trackView->projectView(), SLOT(slotGotFilterJobResults(const QString &, int, int, const QString &, stringMap)));
......@@ -3312,11 +3306,18 @@ void MainWindow::customEvent(QEvent* e)
if (e->type() == QEvent::User)
m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
}
void MainWindow::slotActivateEffectStackView(ClipItem* item, int ix, bool raise)
void MainWindow::slotTimelineClipSelected(ClipItem* item, bool raise)
{
Q_UNUSED(item)
Q_UNUSED(ix)
m_effectStack->slotClipItemSelected(item);
m_projectMonitor->slotSetSelectedClip(item);
if (raise)
m_effectStack->raiseWindow(m_effectStackDock);
}
void MainWindow::slotTrackSelected(int index, TrackInfo info, bool raise)
{
m_effectStack->slotTrackItemSelected(index, info);
if (raise)
m_effectStack->raiseWindow(m_effectStackDock);
}
......
......@@ -422,7 +422,8 @@ private slots:
void slotAddProjectClipList(KUrl::List urls);
void slotShowClipProperties(DocClipBase *clip);
void slotShowClipProperties(QList <DocClipBase *>cliplist, QMap<QString, QString> commonproperties);
void slotActivateEffectStackView(ClipItem* item = NULL, int ix = -1, bool raise = true);
void slotTimelineClipSelected(ClipItem* item, bool raise = true);
void slotTrackSelected(int index, TrackInfo info, bool raise = true);
void slotActivateTransitionView(Transition *);
void slotChangeTool(QAction * action);
void slotChangeEdit(QAction * action);
......
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