From 0bca86e3c767e4cc25ade410adc342d7d38fe5fb Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 3 Mar 2020 20:26:01 +1100 Subject: [PATCH] panels: allow insert and overwrite from footageviewerpanel too Makes FootageViewerPanel and ProjectPanel derive from a common base that TimelinePanel searches for when looking for a source to insert/overwrite from. --- app/panel/footageviewer/footageviewer.cpp | 5 +++++ app/panel/footageviewer/footageviewer.h | 5 ++++- app/panel/project/CMakeLists.txt | 1 + app/panel/project/footagemanagementpanel.h | 13 +++++++++++++ app/panel/project/project.h | 5 +++-- app/panel/timeline/timeline.cpp | 6 +++--- 6 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 app/panel/project/footagemanagementpanel.h diff --git a/app/panel/footageviewer/footageviewer.cpp b/app/panel/footageviewer/footageviewer.cpp index 0e5c443c0..011ae9bb5 100644 --- a/app/panel/footageviewer/footageviewer.cpp +++ b/app/panel/footageviewer/footageviewer.cpp @@ -35,6 +35,11 @@ FootageViewerPanel::FootageViewerPanel(QWidget *parent) : Retranslate(); } +QList FootageViewerPanel::GetSelectedFootage() +{ + return {static_cast(GetTimeBasedWidget())->GetFootage()}; +} + void FootageViewerPanel::SetFootage(Footage *f) { static_cast(GetTimeBasedWidget())->SetFootage(f); diff --git a/app/panel/footageviewer/footageviewer.h b/app/panel/footageviewer/footageviewer.h index 817837d04..90cb6d6a7 100644 --- a/app/panel/footageviewer/footageviewer.h +++ b/app/panel/footageviewer/footageviewer.h @@ -24,15 +24,18 @@ #include #include "panel/viewer/viewerbase.h" +#include "panel/project/footagemanagementpanel.h" /** * @brief Dockable wrapper around a ViewerWidget */ -class FootageViewerPanel : public ViewerPanelBase { +class FootageViewerPanel : public ViewerPanelBase, public FootageManagementPanel { Q_OBJECT public: FootageViewerPanel(QWidget* parent); + virtual QList GetSelectedFootage() override; + void SetFootage(Footage* f); protected: diff --git a/app/panel/project/CMakeLists.txt b/app/panel/project/CMakeLists.txt index fcb7ad98a..e274eaa22 100644 --- a/app/panel/project/CMakeLists.txt +++ b/app/panel/project/CMakeLists.txt @@ -16,6 +16,7 @@ set(OLIVE_SOURCES ${OLIVE_SOURCES} + panel/project/footagemanagementpanel.h panel/project/project.h panel/project/project.cpp PARENT_SCOPE diff --git a/app/panel/project/footagemanagementpanel.h b/app/panel/project/footagemanagementpanel.h new file mode 100644 index 000000000..dea3499bc --- /dev/null +++ b/app/panel/project/footagemanagementpanel.h @@ -0,0 +1,13 @@ +#ifndef FOOTAGEMANAGEMENTPANEL_H +#define FOOTAGEMANAGEMENTPANEL_H + +#include + +#include "project/item/footage/footage.h" + +class FootageManagementPanel { +public: + virtual QList GetSelectedFootage() = 0; +}; + +#endif // FOOTAGEMANAGEMENTPANEL_H diff --git a/app/panel/project/project.h b/app/panel/project/project.h index 73df37d30..2ec79f07c 100644 --- a/app/panel/project/project.h +++ b/app/panel/project/project.h @@ -21,6 +21,7 @@ #ifndef PROJECT_PANEL_H #define PROJECT_PANEL_H +#include "footagemanagementpanel.h" #include "project/project.h" #include "widget/panel/panel.h" #include "widget/projectexplorer/projectexplorer.h" @@ -28,7 +29,7 @@ /** * @brief A PanelWidget wrapper around a ProjectExplorer and a ProjectToolbar */ -class ProjectPanel : public PanelWidget +class ProjectPanel : public PanelWidget, public FootageManagementPanel { Q_OBJECT public: @@ -41,7 +42,7 @@ public: Folder* GetSelectedFolder(); - QList GetSelectedFootage(); + virtual QList GetSelectedFootage() override; ProjectViewModel* model(); diff --git a/app/panel/timeline/timeline.cpp b/app/panel/timeline/timeline.cpp index d60107993..80118431c 100644 --- a/app/panel/timeline/timeline.cpp +++ b/app/panel/timeline/timeline.cpp @@ -21,7 +21,7 @@ #include "timeline.h" #include "panel/panelmanager.h" -#include "panel/project/project.h" +#include "panel/project/footagemanagementpanel.h" TimelinePanel::TimelinePanel(QWidget *parent) : TimeBasedPanel(parent) @@ -94,7 +94,7 @@ void TimelinePanel::DecreaseTrackHeight() void TimelinePanel::Insert() { - ProjectPanel* project_panel = PanelManager::instance()->MostRecentlyFocused(); + FootageManagementPanel* project_panel = PanelManager::instance()->MostRecentlyFocused(); if (project_panel) { InsertFootageAtPlayhead(project_panel->GetSelectedFootage()); @@ -103,7 +103,7 @@ void TimelinePanel::Insert() void TimelinePanel::Overwrite() { - ProjectPanel* project_panel = PanelManager::instance()->MostRecentlyFocused(); + FootageManagementPanel* project_panel = PanelManager::instance()->MostRecentlyFocused(); if (project_panel) { OverwriteFootageAtPlayhead(project_panel->GetSelectedFootage());