rudimentary linking/unlinking added
This commit is contained in:
@@ -615,3 +615,8 @@ void MainWindow::on_actionScroll_Wheel_Zooms_triggered()
|
||||
{
|
||||
scroll_zooms = !scroll_zooms;
|
||||
}
|
||||
|
||||
void MainWindow::on_actionLink_Unlink_triggered()
|
||||
{
|
||||
panel_timeline->toggle_links();
|
||||
}
|
||||
|
||||
@@ -152,6 +152,8 @@ private slots:
|
||||
|
||||
void on_actionScroll_Wheel_Zooms_triggered();
|
||||
|
||||
void on_actionLink_Unlink_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
void setup_layout();
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSplit_at_Playhead"/>
|
||||
<addaction name="actionAdd_Default_Transition"/>
|
||||
<addaction name="actionLink_Unlink"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuWindow">
|
||||
<property name="title">
|
||||
@@ -612,6 +613,14 @@
|
||||
<string>Scroll Wheel Zooms</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLink_Unlink">
|
||||
<property name="text">
|
||||
<string>Link/Unlink</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+L</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
||||
@@ -842,6 +842,23 @@ void Timeline::snap_to_clip(long* l, bool playhead_inclusive) {
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::toggle_links() {
|
||||
LinkCommand* command = new LinkCommand();
|
||||
for (int i=0;i<sequence->clip_count();i++) {
|
||||
Clip* c = sequence->get_clip(i);
|
||||
command->clips.append(c);
|
||||
if (c->linked.size() > 0) {
|
||||
command->link = false; // prioritize unlinking
|
||||
}
|
||||
}
|
||||
if (command->clips.size() > 0) {
|
||||
undo_stack.push(command);
|
||||
redraw_all_clips(true);
|
||||
} else {
|
||||
delete command;
|
||||
}
|
||||
}
|
||||
|
||||
void Timeline::increase_track_height() {
|
||||
for (int i=0;i<video_track_heights.size();i++) {
|
||||
video_track_heights[i] += TRACK_HEIGHT_INCREMENT;
|
||||
|
||||
@@ -83,6 +83,7 @@ public:
|
||||
void add_transition();
|
||||
QVector<int> get_tracks_of_linked_clips(int i);
|
||||
bool has_clip_been_split(int c);
|
||||
void toggle_links();
|
||||
|
||||
int get_snap_range();
|
||||
int getScreenPointFromFrame(long frame);
|
||||
|
||||
@@ -310,3 +310,33 @@ void TimelineAction::redo() {
|
||||
|
||||
done = true;
|
||||
}
|
||||
|
||||
LinkCommand::LinkCommand() : link(true) {}
|
||||
|
||||
void LinkCommand::undo() {
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
Clip* c = clips.at(i);
|
||||
if (link) {
|
||||
c->linked.clear();
|
||||
} else {
|
||||
c->linked = old_links.at(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LinkCommand::redo() {
|
||||
old_links.clear();
|
||||
for (int i=0;i<clips.size();i++) {
|
||||
Clip* c = clips.at(i);
|
||||
if (link) {
|
||||
for (int j=0;j<clips.size();j++) {
|
||||
if (i != j) {
|
||||
c->linked.append(j);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
old_links.append(c->linked);
|
||||
c->linked.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,4 +59,15 @@ private:
|
||||
void offset_links(QVector<Clip*>& clips, int offset);
|
||||
};
|
||||
|
||||
class LinkCommand : public QUndoCommand {
|
||||
public:
|
||||
LinkCommand();
|
||||
void undo();
|
||||
void redo();
|
||||
QVector<Clip*> clips;
|
||||
bool link;
|
||||
private:
|
||||
QVector< QVector<int> > old_links;
|
||||
};
|
||||
|
||||
#endif // UNDO_H
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ ScrollArea::ScrollArea(QWidget* parent) : QScrollArea(parent) {}
|
||||
void ScrollArea::wheelEvent(QWheelEvent *e) {
|
||||
if (scroll_zooms) {
|
||||
e->ignore();
|
||||
if (e->angleDelta().y() != 0) panel_timeline->set_zoom(e->angleDelta().y() < 0);
|
||||
if (e->angleDelta().y() != 0) panel_timeline->set_zoom(e->angleDelta().y() > 0);
|
||||
} else {
|
||||
QScrollArea::wheelEvent(e);
|
||||
}
|
||||
|
||||
@@ -266,6 +266,7 @@ void TimelineWidget::mousePressEvent(QMouseEvent *event) {
|
||||
}
|
||||
|
||||
Selection s;
|
||||
|
||||
s.in = clip->timeline_in;
|
||||
s.out = clip->timeline_out;
|
||||
s.track = clip->track;
|
||||
|
||||
Reference in New Issue
Block a user