From 27c4520e58fce5dabdac7f0e6d5bccf2ff322dce Mon Sep 17 00:00:00 2001 From: alcomposer Date: Tue, 18 Dec 2018 19:52:33 +1030 Subject: [PATCH] Add right click menu to clear I/O points when they exist in timelineheader --- mainwindow.h | 3 +-- ui/timelineheader.cpp | 17 +++++++++++++++++ ui/timelineheader.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/mainwindow.h b/mainwindow.h index 5908ccd6b..fafdfe1b1 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -31,6 +31,7 @@ public slots: void new_project(); void autorecover_interval(); void on_actionNest_triggered(); + void on_actionClear_In_Out_triggered(); protected: void closeEvent(QCloseEvent *); @@ -157,8 +158,6 @@ private slots: void on_actionSet_Out_Point_triggered(); - void on_actionClear_In_Out_triggered(); - void on_actionDelete_In_Out_triggered(); void on_actionRipple_Delete_In_Out_triggered(); diff --git a/ui/timelineheader.cpp b/ui/timelineheader.cpp index d39976bbd..329bac195 100644 --- a/ui/timelineheader.cpp +++ b/ui/timelineheader.cpp @@ -1,5 +1,6 @@ #include "timelineheader.h" +#include "mainwindow.h" #include "panels/panels.h" #include "panels/timeline.h" #include "project/sequence.h" @@ -12,6 +13,8 @@ #include #include #include +#include +#include #define CLICK_RANGE 5 #define PLAYHEAD_SIZE 6 @@ -45,6 +48,9 @@ TimelineHeader::TimelineHeader(QWidget *parent) : setMouseTracking(true); setFocusPolicy(Qt::ClickFocus); show_text(true); + + setContextMenuPolicy(Qt::CustomContextMenu); + connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(show_context_menu(const QPoint &))); } void TimelineHeader::set_scroll(int s) { @@ -394,3 +400,14 @@ void TimelineHeader::paintEvent(QPaintEvent*) { p.fillPath(path, Qt::red); } } + +void TimelineHeader::show_context_menu(const QPoint &pos) +{ + QMenu contextMenu(tr("Context menu"), this); + + QAction clear_in_out("Clear In/Out Points", this); + if (!viewer->seq->using_workarea) clear_in_out.setVisible(false); + connect(&clear_in_out, SIGNAL(triggered()), mainWindow, SLOT(on_actionClear_In_Out_triggered())); + contextMenu.addAction(&clear_in_out); + contextMenu.exec(mapToGlobal(pos)); +} diff --git a/ui/timelineheader.h b/ui/timelineheader.h index 88adc3151..4bced42af 100644 --- a/ui/timelineheader.h +++ b/ui/timelineheader.h @@ -29,6 +29,7 @@ public: public slots: void set_scroll(int); void set_visible_in(long i); + void show_context_menu(const QPoint &pos); protected: void paintEvent(QPaintEvent*);