}*/
}
-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;
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) {
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;
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);
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++) {
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);
}
}
-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);
}
-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");
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
}
//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")
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;
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);
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;
ItemInfo startInfo = clipInfo;
clipInfo.endPos = clipInfo.startPos + d.duration();
clipInfo.cropStart = d.cropStart();
- new ResizeClipCommand(this, startInfo, clipInfo, true, moveCommand);
+ new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
}
if (d.startPos() != clipInfo.startPos) {
ItemInfo startInfo = clipInfo;
ItemInfo startInfo = clipInfo;
clipInfo.endPos = clipInfo.startPos + d.duration();
clipInfo.cropStart = d.cropStart();
- new ResizeClipCommand(this, startInfo, clipInfo, true, moveCommand);
+ new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
}
m_commandStack->push(moveCommand);
}
ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()), track);
if (clip) {
clip->setKeyframes(index, keyframes);
- updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(index), index);
+ updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(index), index, false);
} else emit displayMessage(i18n("Cannot find clip with keyframe"), ErrorMessage);
}
setDocumentModified();
}
-void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement effect, int ix, bool triggeredByUser)
+void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedEffect, int ix, bool triggeredByUser)
{
ClipItem *clip = getClipItemAt((int)pos.frames(m_document->fps()) + 1, m_document->tracksCount() - track);
+ QDomElement effect = insertedEffect.cloneNode().toElement();
if (clip) {
-
// Special case: speed effect
if (effect.attribute("id") == "speed") {
ItemInfo info = clip->info();
new MoveTransitionCommand(this, trInfo, newTrInfo, true, resizeCommand);
}
}
- updateClipFade(static_cast <ClipItem *>(m_dragItem));
- new ResizeClipCommand(this, m_dragItemInfo, info, false, resizeCommand);
+
+ ClipItem *clip = static_cast < ClipItem * >(m_dragItem);
+ updateClipFade(clip);
+
+ // check keyframes
+ QDomDocument doc;
+ QDomElement root = doc.createElement("list");
+ doc.appendChild(root);
+ QList <int> indexes;
+ for (int i = 0; i < clip->effectsCount(); i++) {
+ QDomElement effect = clip->effectAt(i);
+ if (EffectsList::hasKeyFrames(effect)) {
+ doc.appendChild(doc.importNode(effect, true));
+ indexes.append(i);
+ }
+ }
+
+ if (clip->checkEffectsKeyframesPos(m_dragItemInfo.cropStart.frames(m_document->fps()), clip->cropStart().frames(m_document->fps()), true)) {
+ // Keyframes were modified, updateClip
+ QDomNodeList effs = doc.elementsByTagName("effect");
+ // Hack:
+ // Since we must always resize clip before updating the keyframes, we
+ // put a resize command before & after checking keyframes so that
+ // we are sure the resize is performed before whenever we do or undo the action
+
+ new ResizeClipCommand(this, m_dragItemInfo, info, false, true, resizeCommand);
+ for (int i = 0; i < indexes.count(); i++) {
+ new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, resizeCommand);
+ updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
+ }
+ new ResizeClipCommand(this, m_dragItemInfo, info, false, true, resizeCommand);
+ emit clipItemSelected(clip);
+ } else new ResizeClipCommand(this, m_dragItemInfo, info, false, false, resizeCommand);
+
m_commandStack->push(resizeCommand);
} else {
m_dragItem->resizeStart((int) m_dragItemInfo.startPos.frames(m_document->fps()));
}
}
- new ResizeClipCommand(this, m_dragItemInfo, info, false, resizeCommand);
+ // check keyframes
+ ClipItem *clip = static_cast < ClipItem * >(m_dragItem);
+ QDomDocument doc;
+ QDomElement root = doc.createElement("list");
+ doc.appendChild(root);
+ QList <int> indexes;
+ for (int i = 0; i < clip->effectsCount(); i++) {
+ QDomElement effect = clip->effectAt(i);
+ if (EffectsList::hasKeyFrames(effect)) {
+ doc.appendChild(doc.importNode(effect, true));
+ indexes.append(i);
+ }
+ }
+
+ if (clip->checkEffectsKeyframesPos((m_dragItemInfo.cropStart + m_dragItemInfo.endPos - m_dragItemInfo.startPos).frames(m_document->fps()) - 1, (clip->cropStart() + clip->cropDuration()).frames(m_document->fps()) - 1, false)) {
+ // Keyframes were modified, updateClip
+ QDomNodeList effs = doc.elementsByTagName("effect");
+ // Hack:
+ // Since we must always resize clip before updating the keyframes, we
+ // put a resize command before & after checking keyframes so that
+ // we are sure the resize is performed before whenever we do or undo the action
+
+ new ResizeClipCommand(this, m_dragItemInfo, info, false, true, resizeCommand);
+ for (int i = 0; i < indexes.count(); i++) {
+ new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, resizeCommand);
+ updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
+ }
+ new ResizeClipCommand(this, m_dragItemInfo, info, false, true, resizeCommand);
+ emit clipItemSelected(clip);
+ } else new ResizeClipCommand(this, m_dragItemInfo, info, false, false, resizeCommand);
+
m_commandStack->push(resizeCommand);
- updateClipFade(static_cast <ClipItem *>(m_dragItem));
+ updateClipFade(clip);
} else {
m_dragItem->resizeEnd((int) m_dragItemInfo.endPos.frames(m_document->fps()));
emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
return clip;
}
-void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end)
+void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end, bool refresh)
{
if (m_selectionGroup) resetSelectionGroup(false);
ClipItem *item = getClipItemAt((int) start.startPos.frames(m_document->fps()), start.track);
// undo last move and emit error message
emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(end.startPos.frames(m_document->fps()))), ErrorMessage);
}
- m_document->renderer()->doRefresh();
+ if (refresh) m_document->renderer()->doRefresh();
//kDebug() << " // MOVED CLIP TO: " << end.startPos.frames(25) << ", ITEM START: " << item->startPos().frames(25);
}
} else kDebug() << "///////// WARNING; NO GROUP TO MOVE";
}
-void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end)
+void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end, bool m_refresh)
{
Transition *item = getTransitionItemAt(start.startPos, start.track);
if (!item) {
}
emit transitionItemSelected(item, getPreviousVideoTrack(item->track()), p);
}
- m_document->renderer()->doRefresh();
+ if (m_refresh) m_document->renderer()->doRefresh();
}
-void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end)
+void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end, bool dontWorry)
{
- bool resizeClipStart = true;
- if (start.startPos == end.startPos) resizeClipStart = false;
- /*if (resizeClipStart) offset = 1;
- else offset = -1;*/
- ClipItem *item = getClipItemAt((int)(start.startPos.frames(m_document->fps())), start.track);
+ bool resizeClipStart = (start.startPos != end.startPos);
+ ClipItem *item = getClipItemAtStart(start.startPos, start.track);
if (!item) {
+ if (dontWorry) return;
emit displayMessage(i18n("Cannot move clip at time: %1 on track %2", m_document->timecode().getTimecodeFromFrames(start.startPos.frames(m_document->fps())), start.track), ErrorMessage);
kDebug() << "---------------- ERROR, CANNOT find clip to resize at... "; // << startPos;
return;
// Item is part of a group, reset group
resetSelectionGroup();
}
+
bool snap = KdenliveSettings::snaptopoints();
KdenliveSettings::setSnaptopoints(false);
- if (resizeClipStart && start.startPos != end.startPos) {
+ if (resizeClipStart) {
ItemInfo clipinfo = item->info();
clipinfo.track = m_document->tracksCount() - clipinfo.track;
- bool success = m_document->renderer()->mltResizeClipStart(clipinfo, end.startPos - item->startPos());
+ bool success = m_document->renderer()->mltResizeClipStart(clipinfo, end.startPos - clipinfo.startPos);
if (success) {
kDebug() << "RESIZE CLP STRAT TO:" << end.startPos.frames(m_document->fps()) << ", OLD ST: " << start.startPos.frames(25);
item->resizeStart((int) end.startPos.frames(m_document->fps()));
updateClipFade(item);
} else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
- } else if (!resizeClipStart) {
+ } else {
ItemInfo clipinfo = item->info();
clipinfo.track = m_document->tracksCount() - clipinfo.track;
bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, end.endPos - clipinfo.startPos);
updateClipFade(item);
} else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
}
- if (end.cropStart != start.cropStart) {
+ if (!resizeClipStart && end.cropStart != start.cropStart) {
kDebug() << "// RESIZE CROP, DIFF: " << (end.cropStart - start.cropStart).frames(25);
ItemInfo clipinfo = end;
clipinfo.track = m_document->tracksCount() - end.track;
}
if (clip->type() == TRANSITIONWIDGET) {
m_commandStack->push(new MoveTransitionCommand(this, startInfo, endInfo, true));
- } else m_commandStack->push(new ResizeClipCommand(this, startInfo, endInfo, true));
+ } else m_commandStack->push(new ResizeClipCommand(this, startInfo, endInfo, true, false));
}
void CustomTrackView::setOutPoint()
if (clip->type() == TRANSITIONWIDGET) {
m_commandStack->push(new MoveTransitionCommand(this, startInfo, endInfo, true));
- } else m_commandStack->push(new ResizeClipCommand(this, startInfo, endInfo, true));
+ } else m_commandStack->push(new ResizeClipCommand(this, startInfo, endInfo, true, false));
}
void CustomTrackView::slotUpdateAllThumbs()
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);
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);
#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),
// 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;
}
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);
void EditKeyFrameCommand::undo()
{
m_view->editKeyFrame(m_pos, m_track, m_index, m_oldkfr);
+ m_doIt = true;
}
// virtual
void EditKeyFrameCommand::redo()
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));
+}
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);
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);
} 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);
//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);
}
#include <QVBoxLayout>
#include <QList>
#include <QMap>
+#include <QScrollArea>
enum WIPE_DIRECTON { UP = 0, DOWN = 1, LEFT = 2, RIGHT = 3, CENTER = 4 };
class QFrame;
-class EffectStackEdit : public QObject
+class EffectStackEdit : public QScrollArea
{
Q_OBJECT
public:
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;
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) {
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;
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();
}
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
}
}
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);
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));
}
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:
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;
}
{
// 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;
}
const ItemInfo m_startPos;
const ItemInfo m_endPos;
bool m_doIt;
+ bool m_refresh;
};
#endif
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;
}
{
// 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;
}
ItemInfo m_startPos;
ItemInfo m_endPos;
bool m_doIt;
+ bool m_refresh;
};
#endif
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();
{
delete m_menu;
delete m_toolbar;
+ m_listView->blockSignals(true);
+ m_listView->clear();
+ delete m_listViewDelegate;
}
void ProjectList::setupMenu(QMenu *addMenu, QAction *defaultAction)
QMenu *m_transcodeAction;
KdenliveDoc *m_doc;
ProjectItem *m_selectedItem;
+ ItemDelegate *m_listViewDelegate;
bool m_refreshed;
QToolButton *m_addButton;
QMap <QString, QDomElement> m_infoQueue;
m_view.out_file->setMode(KFile::File);
m_view.running_jobs->setHeaderLabels(QStringList() << QString() << i18n("File") << i18n("Progress"));
- m_view.running_jobs->setItemDelegate(new RenderViewDelegate(this));
+ m_jobsDelegate = new RenderViewDelegate(this);
+ m_view.running_jobs->setItemDelegate(m_jobsDelegate);
QHeaderView *header = m_view.running_jobs->header();
QFontMetrics fm = fontMetrics();
m_view.scripts_list->setHeaderLabels(QStringList() << QString() << i18n("Script Files"));
- m_view.scripts_list->setItemDelegate(new RenderViewDelegate(this));
+ m_scriptsDelegate = new RenderViewDelegate(this);
+ m_view.scripts_list->setItemDelegate(m_scriptsDelegate);
header = m_view.scripts_list->header();
header->setResizeMode(0, QHeaderView::Fixed);
header->resizeSection(0, 30);
focusFirstVisibleItem();
}
+RenderWidget::~RenderWidget()
+{
+ m_view.running_jobs->blockSignals(true);
+ m_view.scripts_list->blockSignals(true);
+ m_view.running_jobs->clear();
+ m_view.scripts_list->clear();
+ delete m_jobsDelegate;
+ delete m_scriptsDelegate;
+}
+
void RenderWidget::slotEditItem(QListWidgetItem *item)
{
QString edit = item->data(EditableRole).toString();
public:
explicit RenderWidget(const QString &projectfolder, QWidget * parent = 0);
+ virtual ~RenderWidget();
void setGuides(QDomElement guidesxml, double duration);
void focusFirstVisibleItem();
void setProfile(MltVideoProfile profile);
Ui::RenderWidget_UI m_view;
MltVideoProfile m_profile;
QString m_projectFolder;
+ RenderViewDelegate *m_scriptsDelegate;
+ RenderViewDelegate *m_jobsDelegate;
bool m_blockProcessing;
QString m_renderer;
void parseProfiles(QString meta = QString(), QString group = QString(), QString profile = QString());
#include <KLocale>
-ResizeClipCommand::ResizeClipCommand(CustomTrackView *view, const ItemInfo start, const ItemInfo end, bool doIt, QUndoCommand * parent) :
+ResizeClipCommand::ResizeClipCommand(CustomTrackView *view, const ItemInfo start, const ItemInfo end, bool doIt, bool dontWorry, QUndoCommand * parent) :
QUndoCommand(parent),
m_view(view),
m_startPos(start),
m_endPos(end),
- m_doIt(doIt)
+ m_doIt(doIt),
+ m_dontWorry(dontWorry)
{
setText(i18n("Resize clip"));
}
{
// kDebug()<<"---- undoing action";
m_doIt = true;
- if (m_doIt) m_view->resizeClip(m_endPos, m_startPos);
+ if (m_doIt) m_view->resizeClip(m_endPos, m_startPos, m_dontWorry);
}
// virtual
void ResizeClipCommand::redo()
{
kDebug() << "---- redoing action";
- if (m_doIt) m_view->resizeClip(m_startPos, m_endPos);
+ if (m_doIt) m_view->resizeClip(m_startPos, m_endPos, m_dontWorry);
m_doIt = true;
}
class ResizeClipCommand : public QUndoCommand
{
public:
- ResizeClipCommand(CustomTrackView *view, const ItemInfo start, const ItemInfo end, bool doIt, QUndoCommand * parent = 0);
+ ResizeClipCommand(CustomTrackView *view, const ItemInfo start, const ItemInfo end, bool doIt, bool dontWorry, QUndoCommand * parent = 0);
virtual void undo();
virtual void redo();
ItemInfo m_startPos;
ItemInfo m_endPos;
bool m_doIt;
+ bool m_dontWorry;
};
#endif
const QStyleOptionGraphicsItem *option,
QWidget */*widget*/)
{
- const double scale = option->matrix.m11();
const QRectF exposed = option->exposedRect;
painter->setClipRect(exposed);
const QRectF br = rect();
m_autoTrackTransition(0)
{
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));
connect(m_effectEdit, SIGNAL(seekTimeline(int)), this, SIGNAL(seekTimeline(int)));
setEnabled(false);