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

Several fixes for keyframes, fix bug in clip resize start undo and cleanup

svn path=/trunk/kdenlive/; revision=3851
parent 9bd1abf4
......@@ -142,7 +142,7 @@ void AbstractClipItem::resizeStart(int posx, double speed)
}*/
}
void AbstractClipItem::resizeEnd(int posx, double speed, bool /*updateKeyFrames*/)
void AbstractClipItem::resizeEnd(int posx, double speed)
{
GenTime durationDiff = GenTime(posx, m_fps) - endPos();
if (durationDiff == GenTime()) return;
......@@ -294,7 +294,7 @@ void AbstractClipItem::updateKeyFramePos(const GenTime pos, const double value)
if (!m_keyframes.contains(m_selectedKeyframe)) return;
int newpos = (int) pos.frames(m_fps);
int start = cropStart().frames(m_fps);
int end = (cropStart() + cropDuration()).frames(m_fps);
int end = (cropStart() + cropDuration()).frames(m_fps) - 1;
newpos = qMax(newpos, start);
newpos = qMin(newpos, end);
if (value < -50 && m_selectedKeyframe != start && m_selectedKeyframe != end) {
......@@ -330,7 +330,7 @@ void AbstractClipItem::addKeyFrame(const GenTime pos, const double value)
QRectF br = sceneBoundingRect();
double maxh = 100.0 / br.height() / m_keyframeFactor;
int newval = (br.bottom() - value) * maxh;
kDebug() << "Rect: " << br << "/ SCENE: " << sceneBoundingRect() << ", VALUE: " << value << ", MAX: " << maxh << ", NEWVAL: " << newval;
//kDebug() << "Rect: " << br << "/ SCENE: " << sceneBoundingRect() << ", VALUE: " << value << ", MAX: " << maxh << ", NEWVAL: " << newval;
int newpos = (int) pos.frames(m_fps) ;
m_keyframes[newpos] = newval;
m_selectedKeyframe = newpos;
......
......@@ -55,7 +55,7 @@ public:
virtual GenTime cropStart() const ;
virtual GenTime cropDuration() const ;
virtual void resizeStart(int posx, double speed = 1.0);
virtual void resizeEnd(int posx, double speed = 1.0, bool updateKeyFrames = true);
virtual void resizeEnd(int posx, double speed = 1.0);
virtual double fps() const;
virtual GenTime maxDuration() const;
virtual void setCropStart(GenTime pos);
......
......@@ -305,7 +305,7 @@ bool ClipItem::checkKeyFrames()
void ClipItem::setKeyframes(const int ix, const QString keyframes)
{
QDomElement effect = effectAt(ix);
QDomElement effect = getEffectAt(ix);
if (effect.attribute("disabled") == "1") return;
QDomNodeList params = effect.elementsByTagName("parameter");
for (int i = 0; i < params.count(); i++) {
......@@ -1074,7 +1074,6 @@ void ClipItem::resizeStart(int posx, double /*speed*/)
const int previous = cropStart().frames(m_fps);
AbstractClipItem::resizeStart(posx, m_speed);
if ((int) cropStart().frames(m_fps) != previous) {
checkEffectsKeyframesPos(previous, cropStart().frames(m_fps), true);
if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
/*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
m_startThumbTimer.start(150);
......@@ -1082,16 +1081,16 @@ void ClipItem::resizeStart(int posx, double /*speed*/)
}
}
void ClipItem::resizeEnd(int posx, double /*speed*/, bool updateKeyFrames)
void ClipItem::resizeEnd(int posx, double /*speed*/)
{
const int max = (startPos() - cropStart() + maxDuration()).frames(m_fps);
if (posx > max && maxDuration() != GenTime()) posx = max;
if (posx == endPos().frames(m_fps)) return;
//kDebug() << "// NEW POS: " << posx << ", OLD END: " << endPos().frames(m_fps);
const int previous = (cropStart() + cropDuration()).frames(m_fps);
const int previous = (int)(cropStart() + cropDuration()).frames(m_fps) - 1;
AbstractClipItem::resizeEnd(posx, m_speed);
if ((int)(cropStart() + cropDuration()).frames(m_fps) != previous) {
if (updateKeyFrames) checkEffectsKeyframesPos(previous, (cropStart() + cropDuration()).frames(m_fps), false);
const int current = (int)(cropStart() + cropDuration()).frames(m_fps) - 1;
if (current != previous) {
if (m_hasThumbs && KdenliveSettings::videothumbnails()) {
/*connect(m_clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));*/
m_endThumbTimer.start(150);
......@@ -1100,8 +1099,9 @@ void ClipItem::resizeEnd(int posx, double /*speed*/, bool updateKeyFrames)
}
void ClipItem::checkEffectsKeyframesPos(const int previous, const int current, bool fromStart)
bool ClipItem::checkEffectsKeyframesPos(const int previous, const int current, bool fromStart)
{
bool modified = false;
for (int i = 0; i < m_effectList.count(); i++) {
QDomElement effect = m_effectList.at(i);
QDomNodeList params = effect.elementsByTagName("parameter");
......@@ -1116,24 +1116,31 @@ void ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
foreach(const QString &str, keyframes) {
pos = str.section(':', 0, 0).toInt();
val = str.section(':', 1, 1).toDouble();
if (pos == previous) kfr[current] = val;
else {
if (fromStart && pos >= current) kfr[pos] = val;
else if (!fromStart && pos <= current) kfr[pos] = val;
if (pos == previous) {
kfr[current] = val;
modified = true;
} else {
if ((fromStart && pos >= current) || (!fromStart && pos <= current)) {
kfr[pos] = val;
modified = true;
}
}
}
QString newkfr;
QMap<int, double>::const_iterator k = kfr.constBegin();
while (k != kfr.constEnd()) {
newkfr.append(QString::number(k.key()) + ':' + QString::number(k.value()) + ';');
++k;
if (modified) {
QString newkfr;
QMap<int, double>::const_iterator k = kfr.constBegin();
while (k != kfr.constEnd()) {
newkfr.append(QString::number(k.key()) + ':' + QString::number(k.value()) + ';');
++k;
}
e.setAttribute("keyframes", newkfr);
break;
}
e.setAttribute("keyframes", newkfr);
break;
}
}
}
if (m_selectedEffect >= 0) setSelectedEffect(m_selectedEffect);
if (modified && m_selectedEffect >= 0) setSelectedEffect(m_selectedEffect);
return modified;
}
//virtual
......@@ -1248,8 +1255,7 @@ void ClipItem::setEffectAt(int ix, QDomElement effect)
}
//kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
effect.setAttribute("kdenlive_ix", ix + 1);
m_effectList.insert(ix, effect);
m_effectList.removeAt(ix + 1);
m_effectList.replace(ix, effect);
m_effectNames = m_effectList.effectNames().join(" / ");
QString id = effect.attribute("id");
if (id == "fadein" || id == "fadeout" || id == "fade_from_black" || id == "fade_to_black")
......
......@@ -48,7 +48,7 @@ public:
QWidget *);
virtual int type() const;
void resizeStart(int posx, double speed = 1.0);
void resizeEnd(int posx, double speed = 1.0, bool updateKeyFrames = true);
void resizeEnd(int posx, double speed = 1.0);
OPERATIONTYPE operationMode(QPointF pos);
const QString clipProducer() const;
int clipType() const;
......@@ -112,6 +112,8 @@ public:
void setAudioOnly(bool force);
bool isVideoOnly() const;
bool isAudioOnly() const;
/** Called when clip start is resized, adjust keyframes values */
bool checkEffectsKeyframesPos(const int previous, const int current, bool fromStart);
protected:
//virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * event);
......@@ -153,8 +155,7 @@ private:
QMap<int, QPixmap> m_audioThumbCachePic;
bool m_audioThumbReady;
double m_framePixelWidth;
/** Called when clip start is resized, adjust keyframes values */
void checkEffectsKeyframesPos(const int previous, const int current, bool fromStart);
QPixmap m_videoPix;
QPixmap m_audioPix;
......
This diff is collapsed.
......@@ -54,11 +54,11 @@ public:
void changeTrack(int ix, TrackInfo type);
int cursorPos();
void checkAutoScroll();
void moveClip(const ItemInfo start, const ItemInfo end);
void moveClip(const ItemInfo start, const ItemInfo end, bool refresh);
void moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime offset, const int trackOffset, bool reverseMove = false);
/** move transition, startPos = (old start, old end), endPos = (new start, new end) */
void moveTransition(const ItemInfo start, const ItemInfo end);
void resizeClip(const ItemInfo start, const ItemInfo end);
void moveTransition(const ItemInfo start, const ItemInfo end, bool m_refresh);
void resizeClip(const ItemInfo start, const ItemInfo end, bool dontWorry = false);
void addClip(QDomElement xml, const QString &clipId, ItemInfo info, EffectsList list = EffectsList(), bool refresh = true);
void deleteClip(ItemInfo info, bool refresh = true);
void slotDeleteClipMarker(const QString &comment, const QString &id, const GenTime &position);
......@@ -70,7 +70,7 @@ public:
void slotAddGroupEffect(QDomElement effect, AbstractGroupItem *group);
void addEffect(int track, GenTime pos, QDomElement effect);
void deleteEffect(int track, GenTime pos, QDomElement effect);
void updateEffect(int track, GenTime pos, QDomElement effect, int ix, bool triggeredByUser = true);
void updateEffect(int track, GenTime pos, QDomElement insertedEffect, int ix, bool triggeredByUser = true);
void moveEffect(int track, GenTime pos, int oldPos, int newPos);
void addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh);
void deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh);
......
......@@ -23,8 +23,8 @@
#include <KLocale>
EditEffectCommand::EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, int stackPos, bool doIt) :
QUndoCommand(),
EditEffectCommand::EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, int stackPos, bool doIt, QUndoCommand *parent) :
QUndoCommand(parent),
m_view(view),
m_track(track),
m_oldeffect(oldeffect),
......@@ -59,13 +59,11 @@ bool EditEffectCommand::mergeWith(const QUndoCommand * other)
// virtual
void EditEffectCommand::undo()
{
//kDebug() << "---- undoing action";
m_view->updateEffect(m_track, m_pos, m_oldeffect, m_stackPos, false);
}
// virtual
void EditEffectCommand::redo()
{
//kDebug() << "---- redoing action";
m_view->updateEffect(m_track, m_pos, m_effect, m_stackPos, m_doIt);
m_doIt = false;
}
......
......@@ -31,7 +31,7 @@ class CustomTrackView;
class EditEffectCommand : public QUndoCommand
{
public:
EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, int stackPos, bool doIt);
EditEffectCommand(CustomTrackView *view, const int track, GenTime pos, QDomElement oldeffect, QDomElement effect, int stackPos, bool doIt, QUndoCommand *parent = 0);
virtual int id() const;
virtual bool mergeWith(const QUndoCommand * command);
......
......@@ -44,6 +44,7 @@ EditKeyFrameCommand::EditKeyFrameCommand(CustomTrackView *view, const int track,
void EditKeyFrameCommand::undo()
{
m_view->editKeyFrame(m_pos, m_track, m_index, m_oldkfr);
m_doIt = true;
}
// virtual
void EditKeyFrameCommand::redo()
......
......@@ -221,7 +221,14 @@ QDomElement EffectsList::item(int ix)
void EffectsList::insert(int ix, QDomElement effect)
{
QDomNodeList effects = m_baseElement.childNodes();
if (ix >= effects.count()) m_baseElement.appendChild(effect);
else m_baseElement.insertBefore(effect, effects.at(ix));
if (ix >= effects.count()) m_baseElement.appendChild(importNode(effect, true));
else m_baseElement.insertBefore(importNode(effect, true), effects.at(ix));
}
void EffectsList::replace(int ix, QDomElement effect)
{
QDomNodeList effects = m_baseElement.childNodes();
if (ix < effects.count()) m_baseElement.removeChild(effects.at(ix));
if (ix == effects.count()) m_baseElement.appendChild(importNode(effect, true));
else m_baseElement.insertBefore(importNode(effect, true), effects.at(ix));
}
......@@ -49,6 +49,7 @@ public:
void removeAt(int ix);
QDomElement item(int ix);
void insert(int ix, QDomElement effect);
void replace(int ix, QDomElement effect);
static bool hasKeyFrames(QDomElement effect);
static void setParameter(QDomElement effect, const QString &name, const QString &value);
static QString parameter(QDomElement effect, const QString &name);
......
......@@ -65,26 +65,19 @@ class Wipeval: public QWidget, public Ui::Wipeval_UI
QMap<QString, QImage> EffectStackEdit::iconCache;
EffectStackEdit::EffectStackEdit(QWidget *parent) :
QObject(parent),
QScrollArea(parent),
m_in(0),
m_out(0),
m_frameSize(QPoint())
{
QVBoxLayout *vbox1 = new QVBoxLayout(parent);
vbox1->setContentsMargins(0, 0, 0, 0);
vbox1->setSpacing(0);
QScrollArea *area = new QScrollArea;
m_baseWidget = new QWidget(parent);
area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
area->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
area->setFrameStyle(QFrame::NoFrame);
parent->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
area->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
vbox1->addWidget(area);
area->setWidget(m_baseWidget);
area->setWidgetResizable(true);
m_baseWidget = new QWidget(this);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
setFrameStyle(QFrame::NoFrame);
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
setWidget(m_baseWidget);
setWidgetResizable(true);
m_vbox = new QVBoxLayout(m_baseWidget);
m_vbox->setContentsMargins(0, 0, 0, 0);
m_vbox->setSpacing(0);
......@@ -241,7 +234,7 @@ void EffectStackEdit::transferParamDesc(const QDomElement d, int in, int out)
} else if (type == "keyframe") {
// keyframe editor widget
kDebug() << "min: " << m_in << ", MAX: " << m_out;
KeyframeEdit *geo = new KeyframeEdit(pa, m_out - m_in, pa.attribute("min").toInt(), pa.attribute("max").toInt(), m_timecode);
KeyframeEdit *geo = new KeyframeEdit(pa, m_out - m_in - 1, pa.attribute("min").toInt(), pa.attribute("max").toInt(), m_timecode);
//geo->setupParam(100, pa.attribute("min").toInt(), pa.attribute("max").toInt(), pa.attribute("keyframes"));
//connect(geo, SIGNAL(seekToPos(int)), this, SLOT(slotSeekToPos(int)));
//geo->setupParam(pa, minFrame, maxFrame);
......@@ -538,8 +531,9 @@ void EffectStackEdit::clearAllItems()
//qDeleteAll(m_uiItems);
QLayoutItem *child;
while ((child = m_vbox->takeAt(0)) != 0) {
if (child->widget()) delete child->widget();
QWidget *wid = child->widget();
delete child;
if (wid) delete wid;
}
blockSignals(false);
}
......@@ -27,6 +27,7 @@
#include <QVBoxLayout>
#include <QList>
#include <QMap>
#include <QScrollArea>
enum WIPE_DIRECTON { UP = 0, DOWN = 1, LEFT = 2, RIGHT = 3, CENTER = 4 };
......@@ -39,7 +40,7 @@ struct wipeInfo {
class QFrame;
class EffectStackEdit : public QObject
class EffectStackEdit : public QScrollArea
{
Q_OBJECT
public:
......
......@@ -38,7 +38,12 @@ EffectStackView::EffectStackView(QWidget *parent) :
QWidget(parent)
{
m_ui.setupUi(this);
QVBoxLayout *vbox1 = new QVBoxLayout(m_ui.frame);
m_effectedit = new EffectStackEdit(m_ui.frame);
vbox1->setContentsMargins(0, 0, 0, 0);
vbox1->setSpacing(0);
vbox1->addWidget(m_effectedit);
m_ui.frame->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
//m_ui.effectlist->horizontalHeader()->setVisible(false);
//m_ui.effectlist->verticalHeader()->setVisible(false);
m_clipref = NULL;
......@@ -145,6 +150,7 @@ void EffectStackView::slotClipItemSelected(ClipItem* c, int ix)
double factor = c->baseClip()->getProperty("aspect_ratio").toDouble();
QPoint p((int)(size.section('x', 0, 0).toInt() * factor + 0.5), size.section('x', 1, 1).toInt());
m_effectedit->setFrameSize(p);
m_effectedit->setFrameSize(p);
} else ix = 0;
}
if (m_clipref == NULL) {
......
......@@ -33,62 +33,70 @@ KeyframeEdit::KeyframeEdit(QDomElement e, int maxFrame, int minVal, int maxVal,
m_timecode(tc),
m_previousPos(0)
{
m_ui.setupUi(this);
m_ui.keyframe_list->setFont(KGlobalSettings::generalFont());
m_ui.keyframe_list->setHeaderLabels(QStringList() << i18n("Position") << i18n("Value"));
setupUi(this);
keyframe_list->setFont(KGlobalSettings::generalFont());
keyframe_list->setHeaderLabels(QStringList() << i18n("Position") << i18n("Value"));
//setResizeMode(1, QHeaderView::Interactive);
m_ui.button_add->setIcon(KIcon("document-new"));
m_ui.button_delete->setIcon(KIcon("edit-delete"));
connect(m_ui.keyframe_list, SIGNAL(itemSelectionChanged()/*itemClicked(QTreeWidgetItem *, int)*/), this, SLOT(slotAdjustKeyframeInfo()));
button_add->setIcon(KIcon("document-new"));
button_delete->setIcon(KIcon("edit-delete"));
connect(keyframe_list, SIGNAL(itemSelectionChanged()/*itemClicked(QTreeWidgetItem *, int)*/), this, SLOT(slotAdjustKeyframeInfo()));
setupParam();
m_ui.keyframe_list->header()->resizeSections(QHeaderView::ResizeToContents);
connect(m_ui.button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteKeyframe()));
connect(m_ui.button_add, SIGNAL(clicked()), this, SLOT(slotAddKeyframe()));
connect(m_ui.keyframe_list, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotGenerateParams(QTreeWidgetItem *, int)));
connect(m_ui.keyframe_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotSaveCurrentParam(QTreeWidgetItem *, int)));
connect(m_ui.keyframe_pos, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustKeyframeValue(int)));
m_ui.keyframe_pos->setPageStep(1);
m_ui.keyframe_list->setItemDelegate(new KeyItemDelegate(minVal, maxVal));
keyframe_list->header()->resizeSections(QHeaderView::ResizeToContents);
connect(button_delete, SIGNAL(clicked()), this, SLOT(slotDeleteKeyframe()));
connect(button_add, SIGNAL(clicked()), this, SLOT(slotAddKeyframe()));
connect(keyframe_list, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotGenerateParams(QTreeWidgetItem *, int)));
connect(keyframe_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)), this, SLOT(slotSaveCurrentParam(QTreeWidgetItem *, int)));
connect(keyframe_pos, SIGNAL(valueChanged(int)), this, SLOT(slotAdjustKeyframeValue(int)));
keyframe_pos->setPageStep(1);
m_delegate = new KeyItemDelegate(minVal, maxVal);
keyframe_list->setItemDelegate(m_delegate);
}
KeyframeEdit::~KeyframeEdit()
{
keyframe_list->blockSignals(true);
keyframe_list->clear();
delete m_delegate;
}
void KeyframeEdit::setupParam(QDomElement e)
{
if (!e.isNull()) m_param = e;
m_ui.keyframe_list->clear();
keyframe_list->clear();
QStringList frames = m_param.attribute("keyframes").split(";", QString::SkipEmptyParts);
for (int i = 0; i < frames.count(); i++) {
QString framePos = m_timecode.getTimecodeFromFrames(frames.at(i).section(':', 0, 0).toInt());
QTreeWidgetItem *item = new QTreeWidgetItem(QStringList() << framePos << frames.at(i).section(':', 1, 1));
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
m_ui.keyframe_list->addTopLevelItem(item);
keyframe_list->addTopLevelItem(item);
}
QTreeWidgetItem *first = m_ui.keyframe_list->topLevelItem(0);
if (first) m_ui.keyframe_list->setCurrentItem(first);
QTreeWidgetItem *first = keyframe_list->topLevelItem(0);
if (first) keyframe_list->setCurrentItem(first);
slotAdjustKeyframeInfo();
m_ui.button_delete->setEnabled(m_ui.keyframe_list->topLevelItemCount() > 2);
button_delete->setEnabled(keyframe_list->topLevelItemCount() > 2);
}
void KeyframeEdit::slotDeleteKeyframe()
{
if (m_ui.keyframe_list->topLevelItemCount() < 3) return;
QTreeWidgetItem *item = m_ui.keyframe_list->currentItem();
if (keyframe_list->topLevelItemCount() < 3) return;
QTreeWidgetItem *item = keyframe_list->currentItem();
if (item) {
delete item;
slotGenerateParams();
}
m_ui.button_delete->setEnabled(m_ui.keyframe_list->topLevelItemCount() > 2);
button_delete->setEnabled(keyframe_list->topLevelItemCount() > 2);
}
void KeyframeEdit::slotAddKeyframe()
{
m_ui.keyframe_list->blockSignals(true);
keyframe_list->blockSignals(true);
int pos2;
QTreeWidgetItem *item = m_ui.keyframe_list->currentItem();
QTreeWidgetItem *item = keyframe_list->currentItem();
if (item == NULL) return;
int ix = m_ui.keyframe_list->indexOfTopLevelItem(item);
int ix = keyframe_list->indexOfTopLevelItem(item);
int pos1 = m_timecode.getFrameCount(item->text(0));
QTreeWidgetItem *below = m_ui.keyframe_list->topLevelItem(ix + 1);
if (below == NULL) below = m_ui.keyframe_list->topLevelItem(ix - 1);
QTreeWidgetItem *below = keyframe_list->topLevelItem(ix + 1);
if (below == NULL) below = keyframe_list->topLevelItem(ix - 1);
if (below == NULL) {
if (pos1 == 0) pos2 = m_max;
else pos2 = 0;
......@@ -100,11 +108,11 @@ void KeyframeEdit::slotAddKeyframe()
if (result > pos1) ix++;
QTreeWidgetItem *newItem = new QTreeWidgetItem(QStringList() << m_timecode.getTimecodeFromFrames(result) << item->text(1));
newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
m_ui.keyframe_list->insertTopLevelItem(ix, newItem);
m_ui.keyframe_list->setCurrentItem(newItem);
keyframe_list->insertTopLevelItem(ix, newItem);
keyframe_list->setCurrentItem(newItem);
slotAdjustKeyframeInfo();
m_ui.keyframe_list->blockSignals(false);
m_ui.button_delete->setEnabled(m_ui.keyframe_list->topLevelItemCount() > 2);
keyframe_list->blockSignals(false);
button_delete->setEnabled(keyframe_list->topLevelItemCount() > 2);
slotGenerateParams();
}
......@@ -122,7 +130,7 @@ void KeyframeEdit::slotGenerateParams(QTreeWidgetItem *item, int column)
pos = m_max;
val = m_timecode.getTimecodeFromFrames(pos);
}
QList<QTreeWidgetItem *> duplicates = m_ui.keyframe_list->findItems(val, Qt::MatchExactly, 0);
QList<QTreeWidgetItem *> duplicates = keyframe_list->findItems(val, Qt::MatchExactly, 0);
duplicates.removeAll(item);
if (!duplicates.isEmpty()) {
// Trying to insert a keyframe at existing value, revert it
......@@ -136,8 +144,8 @@ void KeyframeEdit::slotGenerateParams(QTreeWidgetItem *item, int column)
}
}
QString keyframes;
for (int i = 0; i < m_ui.keyframe_list->topLevelItemCount(); i++) {
QTreeWidgetItem *item = m_ui.keyframe_list->topLevelItem(i);
for (int i = 0; i < keyframe_list->topLevelItemCount(); i++) {
QTreeWidgetItem *item = keyframe_list->topLevelItem(i);
keyframes.append(QString::number(m_timecode.getFrameCount(item->text(0))) + ':' + item->text(1) + ';');
}
m_param.setAttribute("keyframes", keyframes);
......@@ -146,23 +154,23 @@ void KeyframeEdit::slotGenerateParams(QTreeWidgetItem *item, int column)
void KeyframeEdit::slotAdjustKeyframeInfo()
{
QTreeWidgetItem *item = m_ui.keyframe_list->currentItem();
QTreeWidgetItem *item = keyframe_list->currentItem();
if (!item) return;
int min = 0;
int max = m_max;
QTreeWidgetItem *above = m_ui.keyframe_list->itemAbove(item);
QTreeWidgetItem *below = m_ui.keyframe_list->itemBelow(item);
QTreeWidgetItem *above = keyframe_list->itemAbove(item);
QTreeWidgetItem *below = keyframe_list->itemBelow(item);
if (above) min = m_timecode.getFrameCount(above->text(0)) + 1;
if (below) max = m_timecode.getFrameCount(below->text(0)) - 1;
m_ui.keyframe_pos->blockSignals(true);
m_ui.keyframe_pos->setRange(min, max);
m_ui.keyframe_pos->setValue(m_timecode.getFrameCount(item->text(0)));
m_ui.keyframe_pos->blockSignals(false);
keyframe_pos->blockSignals(true);
keyframe_pos->setRange(min, max);
keyframe_pos->setValue(m_timecode.getFrameCount(item->text(0)));
keyframe_pos->blockSignals(false);
}
void KeyframeEdit::slotAdjustKeyframeValue(int value)
{
QTreeWidgetItem *item = m_ui.keyframe_list->currentItem();
QTreeWidgetItem *item = keyframe_list->currentItem();
item->setText(0, m_timecode.getTimecodeFromFrames(value));
}
......
......@@ -71,21 +71,22 @@ private:
int m_max;
};
class KeyframeEdit : public QWidget
class KeyframeEdit : public QWidget, public Ui::KeyframeEditor_UI
{
Q_OBJECT
public:
explicit KeyframeEdit(QDomElement e, int maxFrame, int minVal, int maxVal, Timecode tc, QWidget* parent = 0);
virtual ~KeyframeEdit();
void setupParam(QDomElement e = QDomElement());
private:
Ui::KeyframeEditor_UI m_ui;
QDomElement m_param;
int m_max;
int m_minVal;
int m_maxVal;
Timecode m_timecode;
int m_previousPos;
KeyItemDelegate *m_delegate;
public slots:
......
......@@ -31,6 +31,10 @@ MoveClipCommand::MoveClipCommand(CustomTrackView *view, const ItemInfo start, co
m_doIt(doIt)
{
setText(i18n("Move clip"));
if (parent) {
// command has a parent, so there are several operations ongoing, do not refresh monitor
m_refresh = false;
} else m_refresh = true;
}
......@@ -39,14 +43,14 @@ void MoveClipCommand::undo()
{
// kDebug()<<"---- undoing action";
m_doIt = true;
m_view->moveClip(m_endPos, m_startPos);
m_view->moveClip(m_endPos, m_startPos, m_refresh);
}
// virtual
void MoveClipCommand::redo()
{
//kDebug() << "---- redoing action";
if (m_doIt)
m_view->moveClip(m_startPos, m_endPos);
m_view->moveClip(m_startPos, m_endPos, m_refresh);
m_doIt = true;
}
......@@ -39,6 +39,7 @@ private:
const ItemInfo m_startPos;
const ItemInfo m_endPos;
bool m_doIt;
bool m_refresh;
};
#endif
......
......@@ -28,6 +28,10 @@ MoveTransitionCommand::MoveTransitionCommand(CustomTrackView *view, const ItemIn
m_doIt(doIt)
{
setText(i18n("Move transition"));
if (parent) {
// command has a parent, so there are several operations ongoing, do not refresh monitor
m_refresh = false;
} else m_refresh = true;
}
......@@ -36,13 +40,13 @@ void MoveTransitionCommand::undo()
{
// kDebug()<<"---- undoing action";
m_doIt = true;
m_view->moveTransition(m_endPos, m_startPos);
m_view->moveTransition(m_endPos, m_startPos, m_refresh);
}
// virtual
void MoveTransitionCommand::redo()
{
//kDebug() << "---- redoing action";
if (m_doIt) m_view->moveTransition(m_startPos, m_endPos);
if (m_doIt) m_view->moveTransition(m_startPos, m_endPos, m_refresh);
m_doIt = true;
}
......
......@@ -36,6 +36,7 @@ private:
ItemInfo m_startPos;
ItemInfo m_endPos;
bool m_doIt;
bool m_refresh;
};
#endif
......
......@@ -103,8 +103,8 @@ ProjectList::ProjectList(QWidget *parent) :
connect(m_listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int)));
connect(m_listView, SIGNAL(showProperties(DocClipBase *)), this, SIGNAL(showClipProperties(DocClipBase *)));
ItemDelegate *listViewDelegate = new ItemDelegate(m_listView);
m_listView->setItemDelegate(listViewDelegate);
m_listViewDelegate = new ItemDelegate(m_listView);
m_listView->setItemDelegate(m_listViewDelegate);
if (KdenliveSettings::activate_nepomuk()) {
Nepomuk::ResourceManager::instance()->init();
......@@ -119,6 +119,9 @@ ProjectList::~ProjectList()
{
delete m_menu;
delete m_toolbar;
m_listView->blockSignals(true);
m_listView->clear();
delete m_listViewDelegate;
}
void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction)
......
......@@ -172,6 +172,7 @@ private:
QMenu *m_transcodeAction;
KdenliveDoc *m_doc;
ProjectItem *m_selectedItem;
ItemDelegate *m_listViewDelegate;
bool m_refreshed;
QToolButton *m_addButton;
QMap <QString, QDomElement> m_infoQueue;
......
......@@ -156,7 +156,8 @@ RenderWidget::RenderWidget(const QString &projectfolder, QWidget * parent) :
m_view.out_file->setMode(KFile::File);