support for adding markers #123
This commit is contained in:
@@ -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()));
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
+11
-1
@@ -37,7 +37,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>653</width>
|
||||
<height>16</height>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
@@ -98,6 +98,8 @@
|
||||
<addaction name="actionClear_In_Out"/>
|
||||
<addaction name="actionDelete_In_Out"/>
|
||||
<addaction name="actionRipple_Delete_In_Out"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSet_Edit_Marker"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuWindow">
|
||||
<property name="title">
|
||||
@@ -779,6 +781,14 @@
|
||||
<string>Auto-scale by Default</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSet_Edit_Marker">
|
||||
<property name="text">
|
||||
<string>Set/Edit Marker</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>M</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
||||
+18
-2
@@ -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()) {
|
||||
//<clip id="0" name="Brock_Drying_Pan.gif" clipin="0" in="44" out="144" track="-1" r="192" g="128" b="128" media="2" stream="0">
|
||||
if (stream.name() == "marker" && stream.isStartElement()) {
|
||||
Marker m;
|
||||
for (int j=0;j<stream.attributes().size();j++) {
|
||||
const QXmlStreamAttribute& attr = stream.attributes().at(j);
|
||||
if (attr.name() == "frame") {
|
||||
m.frame = attr.value().toLong();
|
||||
} else if (attr.name() == "name") {
|
||||
m.name = attr.value().toString();
|
||||
}
|
||||
}
|
||||
s->markers.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;j<s->markers.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();
|
||||
}
|
||||
}
|
||||
|
||||
+7
-12
@@ -24,6 +24,7 @@
|
||||
#include <QScreen>
|
||||
#include <QPainter>
|
||||
#include <QMenu>
|
||||
#include <QInputDialog>
|
||||
|
||||
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;i<sequence->markers.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()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;i<sequence->markers.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;
|
||||
}
|
||||
|
||||
@@ -463,4 +463,18 @@ public:
|
||||
QVector<Clip*> 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
|
||||
|
||||
Reference in New Issue
Block a user