fixed #125
This commit is contained in:
@@ -1488,3 +1488,20 @@ void SetBool::undo() {
|
|||||||
void SetBool::redo() {
|
void SetBool::redo() {
|
||||||
*boolean = new_setting;
|
*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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ struct Sequence;
|
|||||||
struct Media;
|
struct Media;
|
||||||
|
|
||||||
#include "project/marker.h"
|
#include "project/marker.h"
|
||||||
|
#include "project/selection.h"
|
||||||
|
|
||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
#include <QUndoCommand>
|
#include <QUndoCommand>
|
||||||
@@ -524,4 +525,16 @@ private:
|
|||||||
bool new_setting;
|
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
|
#endif // UNDO_H
|
||||||
|
|||||||
+28
-14
@@ -35,6 +35,8 @@
|
|||||||
#define MAX_TEXT_WIDTH 20
|
#define MAX_TEXT_WIDTH 20
|
||||||
|
|
||||||
TimelineWidget::TimelineWidget(QWidget *parent) : QWidget(parent) {
|
TimelineWidget::TimelineWidget(QWidget *parent) : QWidget(parent) {
|
||||||
|
selection_command = NULL;
|
||||||
|
|
||||||
bottom_align = false;
|
bottom_align = false;
|
||||||
track_resizing = false;
|
track_resizing = false;
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
@@ -690,13 +692,14 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
|||||||
bool repaint = false;
|
bool repaint = false;
|
||||||
bool redraw = false;
|
bool redraw = false;
|
||||||
|
|
||||||
|
ComboAction* ca = new ComboAction();
|
||||||
|
bool push_undo = false;
|
||||||
|
|
||||||
if (panel_timeline->creating) {
|
if (panel_timeline->creating) {
|
||||||
if (panel_timeline->ghosts.size() > 0) {
|
if (panel_timeline->ghosts.size() > 0) {
|
||||||
const Ghost& g = panel_timeline->ghosts.at(0);
|
const Ghost& g = panel_timeline->ghosts.at(0);
|
||||||
|
|
||||||
if (g.in != g.out) {
|
if (g.in != g.out) {
|
||||||
ComboAction* ca = new ComboAction();
|
|
||||||
|
|
||||||
Clip* c = new Clip(sequence);
|
Clip* c = new Clip(sequence);
|
||||||
c->media = NULL;
|
c->media = NULL;
|
||||||
c->timeline_in = qMin(g.in, g.out);
|
c->timeline_in = qMin(g.in, g.out);
|
||||||
@@ -759,8 +762,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
|||||||
areas.append(s);
|
areas.append(s);
|
||||||
panel_timeline->delete_areas_and_relink(ca, areas);
|
panel_timeline->delete_areas_and_relink(ca, areas);
|
||||||
|
|
||||||
undo_stack.push(ca);
|
push_undo = true;
|
||||||
|
|
||||||
redraw = true;
|
redraw = true;
|
||||||
|
|
||||||
if (!shift) {
|
if (!shift) {
|
||||||
@@ -771,9 +773,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
|||||||
} else if (panel_timeline->moving_proc) {
|
} else if (panel_timeline->moving_proc) {
|
||||||
repaint = true;
|
repaint = true;
|
||||||
if (panel_timeline->ghosts.size() > 0) {
|
if (panel_timeline->ghosts.size() > 0) {
|
||||||
const Ghost& first_ghost = panel_timeline->ghosts.at(0);
|
const Ghost& first_ghost = panel_timeline->ghosts.at(0);
|
||||||
|
|
||||||
ComboAction* ca = new ComboAction();
|
|
||||||
|
|
||||||
// if we were RIPPLING, move all the clips
|
// if we were RIPPLING, move all the clips
|
||||||
if (panel_timeline->tool == TIMELINE_TOOL_RIPPLE) {
|
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;
|
redraw = true;
|
||||||
}
|
}
|
||||||
} else if (panel_timeline->selecting || panel_timeline->rect_select_proc) {
|
} else if (panel_timeline->selecting || panel_timeline->rect_select_proc) {
|
||||||
repaint = true;
|
repaint = true;
|
||||||
} else if (panel_timeline->splitting) {
|
} else if (panel_timeline->splitting) {
|
||||||
ComboAction* ca = new ComboAction();
|
|
||||||
bool split = false;
|
bool split = false;
|
||||||
for (int i=0;i<panel_timeline->split_tracks.size();i++) {
|
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));
|
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) {
|
if (split) {
|
||||||
undo_stack.push(ca);
|
push_undo = true;
|
||||||
redraw = true;
|
redraw = true;
|
||||||
} else {
|
|
||||||
delete ca;
|
|
||||||
}
|
}
|
||||||
panel_timeline->split_cache.clear();
|
panel_timeline->split_cache.clear();
|
||||||
}
|
}
|
||||||
@@ -961,6 +958,19 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
|
|||||||
// remove duplicate selections
|
// remove duplicate selections
|
||||||
panel_timeline->clean_up_selections(sequence->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
|
// destroy all ghosts
|
||||||
panel_timeline->ghosts.clear();
|
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->moving_proc = true;
|
||||||
}
|
}
|
||||||
panel_timeline->repaint_timeline(false);
|
panel_timeline->repaint_timeline(false);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ struct Clip;
|
|||||||
class Timeline;
|
class Timeline;
|
||||||
class TimelineAction;
|
class TimelineAction;
|
||||||
class QScrollArea;
|
class QScrollArea;
|
||||||
|
class SetSelectionsCommand;
|
||||||
|
|
||||||
bool same_sign(int a, int b);
|
bool same_sign(int a, int b);
|
||||||
|
|
||||||
@@ -68,6 +69,8 @@ private:
|
|||||||
|
|
||||||
QTimer tooltip_timer;
|
QTimer tooltip_timer;
|
||||||
int tooltip_clip;
|
int tooltip_clip;
|
||||||
|
|
||||||
|
SetSelectionsCommand* selection_command;
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|||||||
Reference in New Issue
Block a user