undos now save the modified flag state
This commit is contained in:
@@ -36,8 +36,7 @@ void EffectControls::menu_select(QAction* q) {
|
||||
}
|
||||
}
|
||||
undo_stack.push(ta);
|
||||
reload_clips();
|
||||
project_changed = true;
|
||||
reload_clips();
|
||||
}
|
||||
|
||||
void EffectControls::show_menu(bool video) {
|
||||
@@ -146,7 +145,6 @@ void EffectControls::delete_effects() {
|
||||
}
|
||||
if (command->clips.size() > 0) {
|
||||
undo_stack.push(command);
|
||||
project_changed = true;
|
||||
} else {
|
||||
delete command;
|
||||
}
|
||||
@@ -192,34 +190,3 @@ bool EffectControls::is_focused() {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
EffectDeleteCommand::EffectDeleteCommand() : done(false) {}
|
||||
|
||||
EffectDeleteCommand::~EffectDeleteCommand() {
|
||||
if (done) {
|
||||
for (int i=0;i<deleted_objects.size();i++) {
|
||||
delete deleted_objects.at(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EffectDeleteCommand::undo() {
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
Clip* c = clips.at(i);
|
||||
c->effects.insert(fx.at(i), deleted_objects.at(i));
|
||||
}
|
||||
panel_effect_controls->reload_clips();
|
||||
done = false;
|
||||
}
|
||||
|
||||
void EffectDeleteCommand::redo() {
|
||||
deleted_objects.clear();
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
Clip* c = clips.at(i);
|
||||
int fx_id = fx.at(i);
|
||||
deleted_objects.append(c->effects.at(fx_id));
|
||||
c->effects.removeAt(fx_id);
|
||||
}
|
||||
panel_effect_controls->reload_clips();
|
||||
done = true;
|
||||
}
|
||||
|
||||
@@ -56,17 +56,4 @@ private:
|
||||
bool done;
|
||||
};*/
|
||||
|
||||
class EffectDeleteCommand : public QUndoCommand {
|
||||
public:
|
||||
EffectDeleteCommand();
|
||||
~EffectDeleteCommand();
|
||||
void undo();
|
||||
void redo();
|
||||
QVector<Clip*> clips;
|
||||
QVector<int> fx;
|
||||
private:
|
||||
bool done;
|
||||
QVector<Effect*> deleted_objects;
|
||||
};
|
||||
|
||||
#endif // EFFECTCONTROLS_H
|
||||
|
||||
+2
-6
@@ -155,9 +155,7 @@ void Project::new_sequence(TimelineAction *ta, Sequence *s, bool open, QTreeWidg
|
||||
parent->addChild(item);
|
||||
}
|
||||
if (open) set_sequence(s);
|
||||
}
|
||||
|
||||
project_changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
void Project::start_preview_generator(QTreeWidgetItem* item, Media* media, bool replacing) {
|
||||
@@ -316,9 +314,7 @@ void Project::delete_selected_media() {
|
||||
// redraw clips
|
||||
if (redraw) {
|
||||
panel_timeline->redraw_all_clips(true);
|
||||
}
|
||||
|
||||
project_changed = true;
|
||||
}
|
||||
} else {
|
||||
delete ta;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ void Effect::init() {
|
||||
|
||||
void Effect::field_changed() {
|
||||
panel_viewer->viewer_widget->update();
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
void Effect::checkbox_command() {
|
||||
|
||||
+105
-2
@@ -464,7 +464,7 @@ void TimelineAction::redo() {
|
||||
done = true;
|
||||
}
|
||||
|
||||
LinkCommand::LinkCommand() : link(true) {}
|
||||
LinkCommand::LinkCommand() : link(true), old_project_changed(project_changed) {}
|
||||
|
||||
void LinkCommand::undo() {
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
@@ -475,6 +475,7 @@ void LinkCommand::undo() {
|
||||
c->linked = old_links.at(i);
|
||||
}
|
||||
}
|
||||
project_changed = old_project_changed;
|
||||
}
|
||||
|
||||
void LinkCommand::redo() {
|
||||
@@ -492,21 +493,24 @@ void LinkCommand::redo() {
|
||||
c->linked.clear();
|
||||
}
|
||||
}
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
CheckboxCommand::CheckboxCommand(QCheckBox* b) : box(b), checked(box->isChecked()), done(true) {}
|
||||
CheckboxCommand::CheckboxCommand(QCheckBox* b) : box(b), checked(box->isChecked()), done(true), old_project_changed(project_changed) {}
|
||||
|
||||
CheckboxCommand::~CheckboxCommand() {}
|
||||
|
||||
void CheckboxCommand::undo() {
|
||||
box->setChecked(!checked);
|
||||
done = false;
|
||||
project_changed = old_project_changed;
|
||||
}
|
||||
|
||||
void CheckboxCommand::redo() {
|
||||
if (!done) {
|
||||
box->setChecked(checked);
|
||||
}
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
ReplaceMediaCommand::ReplaceMediaCommand(QTreeWidgetItem* i, QString s) :
|
||||
@@ -605,3 +609,102 @@ void ReplaceClipMediaCommand::redo() {
|
||||
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
EffectDeleteCommand::EffectDeleteCommand() : done(false), old_project_changed(project_changed) {}
|
||||
|
||||
EffectDeleteCommand::~EffectDeleteCommand() {
|
||||
if (done) {
|
||||
for (int i=0;i<deleted_objects.size();i++) {
|
||||
delete deleted_objects.at(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EffectDeleteCommand::undo() {
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
Clip* c = clips.at(i);
|
||||
c->effects.insert(fx.at(i), deleted_objects.at(i));
|
||||
}
|
||||
panel_effect_controls->reload_clips();
|
||||
done = false;
|
||||
project_changed = old_project_changed;
|
||||
}
|
||||
|
||||
void EffectDeleteCommand::redo() {
|
||||
deleted_objects.clear();
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
Clip* c = clips.at(i);
|
||||
int fx_id = fx.at(i);
|
||||
deleted_objects.append(c->effects.at(fx_id));
|
||||
c->effects.removeAt(fx_id);
|
||||
}
|
||||
panel_effect_controls->reload_clips();
|
||||
done = true;
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
MediaMove::MediaMove(SourceTable *s) : table(s), old_project_changed(project_changed) {}
|
||||
|
||||
void MediaMove::undo() {
|
||||
for (int i=0;i<items.size();i++) {
|
||||
if (to == NULL) {
|
||||
table->takeTopLevelItem(table->indexOfTopLevelItem(items.at(i)));
|
||||
} else {
|
||||
to->removeChild(items.at(i));
|
||||
}
|
||||
if (froms.at(i) == NULL) {
|
||||
table->addTopLevelItem(items.at(i));
|
||||
} else {
|
||||
froms.at(i)->addChild(items.at(i));
|
||||
}
|
||||
}
|
||||
project_changed = old_project_changed;
|
||||
}
|
||||
|
||||
void MediaMove::redo() {
|
||||
for (int i=0;i<items.size();i++) {
|
||||
QTreeWidgetItem* parent = items.at(i)->parent();
|
||||
froms.append(parent);
|
||||
if (parent == NULL) {
|
||||
table->takeTopLevelItem(table->indexOfTopLevelItem(items.at(i)));
|
||||
} else {
|
||||
parent->removeChild(items.at(i));
|
||||
}
|
||||
if (to == NULL) {
|
||||
table->addTopLevelItem(items.at(i));
|
||||
} else {
|
||||
to->addChild(items.at(i));
|
||||
}
|
||||
}
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
MediaRename::MediaRename() : done(true), old_project_changed(project_changed) {}
|
||||
|
||||
void MediaRename::undo() {
|
||||
item->setText(0, from);
|
||||
done = false;
|
||||
project_changed = old_project_changed;
|
||||
}
|
||||
|
||||
void MediaRename::redo() {
|
||||
if (!done) {
|
||||
item->setText(0, to);
|
||||
}
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
ValueChangeCommand::ValueChangeCommand() : done(true), old_project_changed(project_changed) {}
|
||||
|
||||
void ValueChangeCommand::undo() {
|
||||
source->set_value(old_val);
|
||||
done = false;
|
||||
project_changed = old_project_changed;
|
||||
}
|
||||
|
||||
void ValueChangeCommand::redo() {
|
||||
if (!done) {
|
||||
source->set_value(new_val);
|
||||
}
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
@@ -102,6 +102,7 @@ public:
|
||||
bool link;
|
||||
private:
|
||||
QVector< QVector<int> > old_links;
|
||||
bool old_project_changed;
|
||||
};
|
||||
|
||||
class CheckboxCommand : public QUndoCommand {
|
||||
@@ -114,6 +115,7 @@ private:
|
||||
QCheckBox* box;
|
||||
bool checked;
|
||||
bool done;
|
||||
bool old_project_changed;
|
||||
};
|
||||
|
||||
class ReplaceMediaCommand : public QUndoCommand {
|
||||
@@ -147,4 +149,57 @@ private:
|
||||
void replace(bool undo);
|
||||
};
|
||||
|
||||
class EffectDeleteCommand : public QUndoCommand {
|
||||
public:
|
||||
EffectDeleteCommand();
|
||||
~EffectDeleteCommand();
|
||||
void undo();
|
||||
void redo();
|
||||
QVector<Clip*> clips;
|
||||
QVector<int> fx;
|
||||
private:
|
||||
bool done;
|
||||
bool old_project_changed;
|
||||
QVector<Effect*> deleted_objects;
|
||||
};
|
||||
|
||||
class MediaMove : public QUndoCommand {
|
||||
public:
|
||||
MediaMove(SourceTable* s);
|
||||
QVector<QTreeWidgetItem*> items;
|
||||
QTreeWidgetItem* to;
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
QVector<QTreeWidgetItem*> froms;
|
||||
SourceTable* table;
|
||||
bool old_project_changed;
|
||||
};
|
||||
|
||||
class MediaRename : public QUndoCommand {
|
||||
public:
|
||||
MediaRename();
|
||||
QTreeWidgetItem* item;
|
||||
QString from;
|
||||
QString to;
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
bool done;
|
||||
bool old_project_changed;
|
||||
};
|
||||
|
||||
class ValueChangeCommand : public QUndoCommand {
|
||||
public:
|
||||
ValueChangeCommand();
|
||||
LabelSlider* source;
|
||||
float old_val;
|
||||
float new_val;
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
bool done;
|
||||
bool old_project_changed;
|
||||
};
|
||||
|
||||
#endif // UNDO_H
|
||||
|
||||
@@ -114,16 +114,3 @@ void LabelSlider::mouseReleaseEvent(QMouseEvent*) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ValueChangeCommand::ValueChangeCommand() : done(true) {}
|
||||
|
||||
void ValueChangeCommand::undo() {
|
||||
source->set_value(old_val);
|
||||
done = false;
|
||||
}
|
||||
|
||||
void ValueChangeCommand::redo() {
|
||||
if (!done) {
|
||||
source->set_value(new_val);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,16 +39,4 @@ signals:
|
||||
void valueChanged();
|
||||
};
|
||||
|
||||
class ValueChangeCommand : public QUndoCommand {
|
||||
public:
|
||||
ValueChangeCommand();
|
||||
LabelSlider* source;
|
||||
float old_val;
|
||||
float new_val;
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
bool done;
|
||||
};
|
||||
|
||||
#endif // LABELSLIDER_H
|
||||
|
||||
@@ -204,55 +204,7 @@ void SourceTable::dropEvent(QDropEvent* event) {
|
||||
mm->to = drop_item;
|
||||
mm->items = move_items;
|
||||
undo_stack.push(mm);
|
||||
project_changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MediaMove::MediaMove(SourceTable *s) : table(s) {}
|
||||
|
||||
void MediaMove::undo() {
|
||||
for (int i=0;i<items.size();i++) {
|
||||
if (to == NULL) {
|
||||
table->takeTopLevelItem(table->indexOfTopLevelItem(items.at(i)));
|
||||
} else {
|
||||
to->removeChild(items.at(i));
|
||||
}
|
||||
if (froms.at(i) == NULL) {
|
||||
table->addTopLevelItem(items.at(i));
|
||||
} else {
|
||||
froms.at(i)->addChild(items.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MediaMove::redo() {
|
||||
for (int i=0;i<items.size();i++) {
|
||||
QTreeWidgetItem* parent = items.at(i)->parent();
|
||||
froms.append(parent);
|
||||
if (parent == NULL) {
|
||||
table->takeTopLevelItem(table->indexOfTopLevelItem(items.at(i)));
|
||||
} else {
|
||||
parent->removeChild(items.at(i));
|
||||
}
|
||||
if (to == NULL) {
|
||||
table->addTopLevelItem(items.at(i));
|
||||
} else {
|
||||
to->addChild(items.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MediaRename::MediaRename() : done(true) {}
|
||||
|
||||
void MediaRename::undo() {
|
||||
item->setText(0, from);
|
||||
done = false;
|
||||
}
|
||||
|
||||
void MediaRename::redo() {
|
||||
if (!done) {
|
||||
item->setText(0, to);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,28 +30,4 @@ private slots:
|
||||
void show_context_menu(const QPoint& pos);
|
||||
};
|
||||
|
||||
class MediaMove : public QUndoCommand {
|
||||
public:
|
||||
MediaMove(SourceTable* s);
|
||||
QVector<QTreeWidgetItem*> items;
|
||||
QTreeWidgetItem* to;
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
QVector<QTreeWidgetItem*> froms;
|
||||
SourceTable* table;
|
||||
};
|
||||
|
||||
class MediaRename : public QUndoCommand {
|
||||
public:
|
||||
MediaRename();
|
||||
QTreeWidgetItem* item;
|
||||
QString from;
|
||||
QString to;
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
bool done;
|
||||
};
|
||||
|
||||
#endif // SOURCETABLE_H
|
||||
|
||||
+19
-15
@@ -524,7 +524,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
||||
ta->ripple(sequence, ripple_point, ripple_length, ignore_clips);
|
||||
}
|
||||
|
||||
if (panel_timeline->tool == TIMELINE_TOOL_POINTER && (event->modifiers() & Qt::AltModifier)) { // if holding alt, duplicate rather than move
|
||||
if (panel_timeline->tool == TIMELINE_TOOL_POINTER
|
||||
&& (event->modifiers() & Qt::AltModifier)
|
||||
&& panel_timeline->trim_target == -1) { // if holding alt (and not trimming), duplicate rather than move
|
||||
// duplicate clips
|
||||
QVector<int> old_clips;
|
||||
QVector<Clip*> new_clips;
|
||||
@@ -808,6 +810,11 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
|
||||
if (validator > g.media_length) frame_diff += validator - g.media_length;
|
||||
}
|
||||
} else if (g.trimming) {
|
||||
MediaStream* ms = NULL;
|
||||
if (c->media_type == MEDIA_TYPE_FOOTAGE) {
|
||||
ms = static_cast<Media*>(c->media)->get_stream_from_file_index(c->media_stream);
|
||||
}
|
||||
|
||||
if (g.trim_in) {
|
||||
// prevent clip/transition length from being less than 1 frame long
|
||||
validator = g.ghost_length - frame_diff;
|
||||
@@ -819,26 +826,23 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
|
||||
if (validator < 0) frame_diff -= validator;
|
||||
}
|
||||
|
||||
if (g.transition == NULL || g.transition == c->opening_transition) {
|
||||
// prevent clip_in from going below 0
|
||||
if (c->media_type == MEDIA_TYPE_SEQUENCE
|
||||
|| (c->media_type == MEDIA_TYPE_FOOTAGE && !static_cast<Media*>(c->media)->get_stream_from_file_index(c->media_stream)->infinite_length)) {
|
||||
validator = g.old_clip_in + frame_diff;
|
||||
if (validator < 0) frame_diff -= validator;
|
||||
}
|
||||
// prevent clip_in from going below 0
|
||||
if (c->media_type == MEDIA_TYPE_SEQUENCE
|
||||
|| (ms != NULL && !ms->infinite_length)) {
|
||||
validator = g.old_clip_in + frame_diff;
|
||||
if (validator < 0) frame_diff -= validator;
|
||||
}
|
||||
} else {
|
||||
// prevent clip length from being less than 1 frame long
|
||||
validator = g.ghost_length + frame_diff;
|
||||
if (validator < 1) frame_diff += (1 - validator);
|
||||
|
||||
if (g.transition == NULL) {
|
||||
// prevent clip length exceeding media length
|
||||
if (c->media_type == MEDIA_TYPE_SEQUENCE
|
||||
|| (c->media_type == MEDIA_TYPE_FOOTAGE && !static_cast<Media*>(c->media)->get_stream_from_file_index(c->media_stream)->infinite_length)) {
|
||||
validator = g.old_clip_in + g.ghost_length + frame_diff;
|
||||
if (validator > g.media_length) frame_diff -= validator - g.media_length;
|
||||
}
|
||||
// prevent clip length exceeding media length
|
||||
if (c->media_type == MEDIA_TYPE_SEQUENCE
|
||||
|| (ms != NULL && !ms->infinite_length)) {
|
||||
validator = g.old_clip_in + g.ghost_length + frame_diff;
|
||||
qDebug() << i << validator;
|
||||
if (validator > g.media_length) frame_diff -= validator - g.media_length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user