This commit is contained in:
itsmattkc
2018-10-10 23:30:40 +11:00
parent b741a8ddd5
commit 712f9f160f
4 changed files with 61 additions and 14 deletions
+17
View File
@@ -1488,3 +1488,20 @@ void SetBool::undo() {
void SetBool::redo() {
*boolean = new_setting;
}
SetSelectionsCommand::SetSelectionsCommand(Sequence* s) :
seq(s),
done(true)
{}
void SetSelectionsCommand::undo() {
sequence->selections = old_data;
done = false;
}
void SetSelectionsCommand::redo() {
if (!done) {
sequence->selections = new_data;
done = true;
}
}
+13
View File
@@ -14,6 +14,7 @@ struct Sequence;
struct Media;
#include "project/marker.h"
#include "project/selection.h"
#include <QUndoStack>
#include <QUndoCommand>
@@ -524,4 +525,16 @@ private:
bool new_setting;
};
class SetSelectionsCommand : public QUndoCommand {
public:
SetSelectionsCommand(Sequence *s);
void undo();
void redo();
QVector<Selection> old_data;
QVector<Selection> new_data;
private:
Sequence* seq;
bool done;
};
#endif // UNDO_H
+28 -14
View File
@@ -35,6 +35,8 @@
#define MAX_TEXT_WIDTH 20
TimelineWidget::TimelineWidget(QWidget *parent) : QWidget(parent) {
selection_command = NULL;
bottom_align = false;
track_resizing = false;
setMouseTracking(true);
@@ -690,13 +692,14 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
bool repaint = false;
bool redraw = false;
ComboAction* ca = new ComboAction();
bool push_undo = false;
if (panel_timeline->creating) {
if (panel_timeline->ghosts.size() > 0) {
const Ghost& g = panel_timeline->ghosts.at(0);
if (g.in != g.out) {
ComboAction* ca = new ComboAction();
if (g.in != g.out) {
Clip* c = new Clip(sequence);
c->media = NULL;
c->timeline_in = qMin(g.in, g.out);
@@ -759,8 +762,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
areas.append(s);
panel_timeline->delete_areas_and_relink(ca, areas);
undo_stack.push(ca);
push_undo = true;
redraw = true;
if (!shift) {
@@ -771,9 +773,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
} else if (panel_timeline->moving_proc) {
repaint = true;
if (panel_timeline->ghosts.size() > 0) {
const Ghost& first_ghost = panel_timeline->ghosts.at(0);
ComboAction* ca = new ComboAction();
const Ghost& first_ghost = panel_timeline->ghosts.at(0);
// if we were RIPPLING, move all the clips
if (panel_timeline->tool == TIMELINE_TOOL_RIPPLE) {
@@ -934,14 +934,13 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
}
}
}
}
undo_stack.push(ca);
}
push_undo = true;
redraw = true;
}
} else if (panel_timeline->selecting || panel_timeline->rect_select_proc) {
repaint = true;
} else if (panel_timeline->splitting) {
ComboAction* ca = new ComboAction();
bool split = false;
for (int i=0;i<panel_timeline->split_tracks.size();i++) {
int split_index = getClipIndexFromCoords(panel_timeline->drag_frame_start, panel_timeline->split_tracks.at(i));
@@ -950,10 +949,8 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
}
}
if (split) {
undo_stack.push(ca);
push_undo = true;
redraw = true;
} else {
delete ca;
}
panel_timeline->split_cache.clear();
}
@@ -961,6 +958,19 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
// remove duplicate selections
panel_timeline->clean_up_selections(sequence->selections);
if (selection_command != NULL) {
selection_command->new_data = sequence->selections;
ca->append(selection_command);
selection_command = NULL;
push_undo = true;
}
if (push_undo) {
undo_stack.push(ca);
} else {
delete ca;
}
// destroy all ghosts
panel_timeline->ghosts.clear();
@@ -1502,6 +1512,10 @@ void TimelineWidget::mouseMoveEvent(QMouseEvent *event) {
}
}
// store selections
selection_command = new SetSelectionsCommand(sequence);
selection_command->old_data = sequence->selections;
panel_timeline->moving_proc = true;
}
panel_timeline->repaint_timeline(false);
+3
View File
@@ -16,6 +16,7 @@ struct Clip;
class Timeline;
class TimelineAction;
class QScrollArea;
class SetSelectionsCommand;
bool same_sign(int a, int b);
@@ -68,6 +69,8 @@ private:
QTimer tooltip_timer;
int tooltip_clip;
SetSelectionsCommand* selection_command;
signals:
public slots: