diff --git a/dialogs/speeddialog.cpp b/dialogs/speeddialog.cpp
index 1a8d5878b..fd3fa75bb 100644
--- a/dialogs/speeddialog.cpp
+++ b/dialogs/speeddialog.cpp
@@ -37,4 +37,5 @@ SpeedDialog::SpeedDialog(QWidget *parent) : QDialog(parent) {
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
layout->addWidget(buttonBox, 4, 0, 2, 1);
+ connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
}
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 4808601cc..0924c91fb 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -793,3 +793,7 @@ void MainWindow::on_actionEnable_Drag_Files_to_Timeline_triggered() {
void MainWindow::on_actionAuto_scale_by_Default_triggered() {
config.autoscale_by_default = !config.autoscale_by_default;
}
+
+void MainWindow::on_actionSet_Edit_Marker_triggered() {
+ if (sequence != NULL) panel_timeline->set_marker();
+}
diff --git a/mainwindow.h b/mainwindow.h
index 5442d9db0..3c48019aa 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -186,6 +186,8 @@ private slots:
void on_actionAuto_scale_by_Default_triggered();
+ void on_actionSet_Edit_Marker_triggered();
+
private:
Ui::MainWindow *ui;
void setup_layout();
diff --git a/mainwindow.ui b/mainwindow.ui
index d6ac96579..2b8e236f1 100644
--- a/mainwindow.ui
+++ b/mainwindow.ui
@@ -37,7 +37,7 @@
0
0
653
- 16
+ 20
diff --git a/panels/project.cpp b/panels/project.cpp
index e22d317b6..9592f6544 100644
--- a/panels/project.cpp
+++ b/panels/project.cpp
@@ -778,8 +778,18 @@ bool Project::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
// load all clips and clip information
while (!(stream.name() == child_search && stream.isEndElement()) && !stream.atEnd()) {
stream.readNextStartElement();
- if (stream.name() == "clip" && stream.isStartElement()) {
- //
+ if (stream.name() == "marker" && stream.isStartElement()) {
+ Marker m;
+ for (int j=0;jmarkers.append(m);
+ } else if (stream.name() == "clip" && stream.isStartElement()) {
int media_id, stream_id;
Clip* c = new Clip(s);
@@ -1147,6 +1157,12 @@ void Project::save_folder(QXmlStreamWriter& stream, QTreeWidgetItem* parent, int
stream.writeEndElement(); // clip
}
}
+ for (int j=0;jmarkers.size();j++) {
+ stream.writeStartElement("marker");
+ stream.writeAttribute("frame", QString::number(s->markers.at(j).frame));
+ stream.writeAttribute("name", s->markers.at(j).name);
+ stream.writeEndElement();
+ }
stream.writeEndElement();
}
}
diff --git a/panels/timeline.cpp b/panels/timeline.cpp
index af1c7f84a..f9a727eee 100644
--- a/panels/timeline.cpp
+++ b/panels/timeline.cpp
@@ -24,6 +24,7 @@
#include
#include
#include
+#include
long refactor_frame_number(long framenumber, double source_frame_rate, double target_frame_rate) {
if (source_frame_rate == target_frame_rate) return framenumber;
@@ -1092,18 +1093,12 @@ void Timeline::snap_to_clip(long* l, bool playhead_inclusive) {
}
void Timeline::set_marker() {
- /* TODO make undoable */
- bool found = false;
- for (int i=0;imarkers.size();i++) {
- if (sequence->markers.at(i).frame == sequence->playhead) {
- found = true;
- break;
- }
- }
- if (!found) {
- Marker m;
- m.frame = sequence->playhead;
- sequence->markers.append(m);
+ QInputDialog d(this);
+ d.setWindowTitle("Set Marker");
+ d.setLabelText("Set marker name:");
+ d.setInputMode(QInputDialog::TextInput);
+ if (d.exec() == QDialog::Accepted) {
+ undo_stack.push(new AddMarkerAction(sequence, sequence->playhead, d.textValue()));
}
}
diff --git a/project/undo.cpp b/project/undo.cpp
index be3acf7b0..f9720f78e 100644
--- a/project/undo.cpp
+++ b/project/undo.cpp
@@ -1378,3 +1378,41 @@ void SetAutoscaleAction::redo() {
}
panel_viewer->viewer_widget->update();
}
+
+AddMarkerAction::AddMarkerAction(Sequence* s, long t, QString n) :
+ seq(s),
+ time(t),
+ name(n),
+ old_project_changed(project_changed)
+{}
+
+void AddMarkerAction::undo() {
+ if (index == -1) {
+ sequence->markers.removeLast();
+ } else {
+ sequence->markers[index].name = old_name;
+ }
+
+ project_changed = old_project_changed;
+}
+
+void AddMarkerAction::redo() {
+ index = -1;
+ for (int i=0;imarkers.size();i++) {
+ if (sequence->markers.at(i).frame == time) {
+ index = i;
+ break;
+ }
+ }
+
+ if (index == -1) {
+ Marker m;
+ m.frame = time;
+ sequence->markers.append(m);
+ } else {
+ old_name = sequence->markers.at(index).name;
+ sequence->markers[index].name = name;
+ }
+
+ project_changed = true;
+}
diff --git a/project/undo.h b/project/undo.h
index 1cdda6b5c..6ef023498 100644
--- a/project/undo.h
+++ b/project/undo.h
@@ -463,4 +463,18 @@ public:
QVector clips;
};
+class AddMarkerAction : public QUndoCommand {
+public:
+ AddMarkerAction(Sequence* s, long t, QString n);
+ void undo();
+ void redo();
+private:
+ Sequence* seq;
+ long time;
+ QString name;
+ QString old_name;
+ bool old_project_changed;
+ int index;
+};
+
#endif // UNDO_H