rewrite nearly complete

This commit is contained in:
itsmattkc
2019-04-03 01:38:01 +11:00
parent 8989333e99
commit 2d4714547b
102 changed files with 3213 additions and 2892 deletions
+73 -44
View File
@@ -49,22 +49,24 @@ void Marker::Draw(QPainter &p, int x, int y, int bottom, bool selected) {
p.drawPolygon(points, 5);
}
void set_marker_internal(Sequence* seq, const QVector<int>& clips) {
// if clips is empty, the marker is being added to the sequence
void Marker::SetOnClips(const QVector<Clip *> &clips)
{
// Don't bother if there are no clips
if (clips.isEmpty()) {
return;
}
// add_marker is used to determine whether we're adding a marker, depending on whether the user input a marker name
// however if (config.set_name_with_marker) is true, we don't need a marker name so we just add
bool add_marker = !olive::CurrentConfig.set_name_with_marker;
bool add_marker = !olive::config.set_name_with_marker;
QString marker_name;
// if (config.set_name_with_marker) is false (set above), ask for a marker name
// if Config::set_name_with_marker is true (set above), ask for a marker name
if (!add_marker) {
QInputDialog d(olive::MainWindow);
d.setWindowTitle(QCoreApplication::translate("Marker", "Set Marker"));
d.setLabelText(clips.size() > 0
? QCoreApplication::translate("Marker", "Set clip marker name:")
: QCoreApplication::translate("Marker", "Set sequence marker name:"));
d.setLabelText(QCoreApplication::translate("Marker", "Set clip marker name:"));
d.setInputMode(QInputDialog::TextInput);
add_marker = (d.exec() == QDialog::Accepted);
marker_name = d.textValue();
@@ -75,43 +77,16 @@ void set_marker_internal(Sequence* seq, const QVector<int>& clips) {
ComboAction* ca = new ComboAction();
if (clips.size() > 0) {
// add a marker action for each clip
foreach (int i, clips) {
ClipPtr c = seq->clips.at(i);
ca->append(new AddMarkerAction(&c->get_markers(),
seq->playhead - c->timeline_in() + c->clip_in(),
marker_name));
}
} else {
// if no clips are selected, we're adding a marker to the sequence
// kind of hacky, we get the correct marker structure from the viewer panel object that the sequence is attached to
if (seq == panel_footage_viewer->seq.get()) {
// get correct marker reference from footage viewer
ca->append(new AddMarkerAction(panel_footage_viewer->marker_ref, seq->playhead, marker_name));
} else if (seq == panel_sequence_viewer->seq.get()) {
// get correct marker reference from sequence viewer
ca->append(new AddMarkerAction(panel_sequence_viewer->marker_ref, seq->playhead, marker_name));
} else {
// fallback to using markers from sequence provided
ca->append(new AddMarkerAction(&seq->markers, seq->playhead, marker_name));
}
// add a marker action for each clip
foreach (Clip* c, clips) {
ca->append(new AddMarkerAction(&c->get_markers(),
c->track()->sequence()->playhead - c->timeline_in() + c->clip_in(),
marker_name));
}
// push action
olive::UndoStack.push(ca);
olive::undo_stack.push(ca);
// redraw UI for new markers
update_ui(false);
@@ -120,11 +95,65 @@ void set_marker_internal(Sequence* seq, const QVector<int>& clips) {
}
}
void set_marker_internal(Sequence *seq) {
// create empty clip array
QVector<int> clips;
void Marker::SetOnSequence(Sequence *seq) {
// Don't bother if there is no sequence
if (seq == nullptr) {
return;
}
// add_marker is used to determine whether we're adding a marker, depending on whether the user input a marker name
// however if (config.set_name_with_marker) is true, we don't need a marker name so we just add
bool add_marker = !olive::config.set_name_with_marker;
QString marker_name;
// if Config::set_name_with_marker is true (set above), ask for a marker name
if (!add_marker) {
QInputDialog d(olive::MainWindow);
d.setWindowTitle(QCoreApplication::translate("Marker", "Set Marker"));
d.setLabelText(QCoreApplication::translate("Marker", "Set sequence marker name:"));
d.setInputMode(QInputDialog::TextInput);
add_marker = (d.exec() == QDialog::Accepted);
marker_name = d.textValue();
}
// if we've decided to add a marker
if (add_marker) {
ComboAction* ca = new ComboAction();
// FIXME kind of hacky, we get the correct marker structure from the viewer panel object that the sequence is
// attached to, as the viewers will give us the footage marker set if its footage rather than the sequence marker
// set
if (seq == panel_footage_viewer->seq.get()) {
// get correct marker reference from footage viewer
ca->append(new AddMarkerAction(panel_footage_viewer->marker_ref, seq->playhead, marker_name));
} else if (seq == panel_sequence_viewer->seq.get()) {
// get correct marker reference from sequence viewer
ca->append(new AddMarkerAction(panel_sequence_viewer->marker_ref, seq->playhead, marker_name));
} else {
// fallback to using markers from sequence provided
ca->append(new AddMarkerAction(&seq->markers, seq->playhead, marker_name));
}
// push action
olive::undo_stack.push(ca);
// redraw UI for new markers
update_ui(false);
panel_footage_viewer->update_viewer();
}
set_marker_internal(seq, clips);
}
void Marker::Save(QXmlStreamWriter &stream) const