From 2e349323f0751950e4413e842b6a2096973dfa58 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 25 Jun 2019 09:15:30 -0700 Subject: [PATCH] fixed template function for MostRecentlyFocused panel --- app/core.cpp | 6 +++++- app/panel/panelfocusmanager.cpp | 21 ++++----------------- app/panel/panelfocusmanager.h | 21 +++++++++++++++++++-- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/app/core.cpp b/app/core.cpp index 8f9b5aa24..392195d64 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -26,10 +26,14 @@ #include #include "panel/panelfocusmanager.h" +#include "panel/project/project.h" #include "ui/icons/icons.h" #include "ui/style/style.h" #include "widget/menu/menushared.h" + +#include "panel/viewer/viewer.h" + Core olive::core; Core::Core() : @@ -122,7 +126,7 @@ void Core::ImportFiles(const QStringList &urls) for (int i=0;iMostRecentlyFocused(); } } diff --git a/app/panel/panelfocusmanager.cpp b/app/panel/panelfocusmanager.cpp index 1401ea8ed..cf8889255 100644 --- a/app/panel/panelfocusmanager.cpp +++ b/app/panel/panelfocusmanager.cpp @@ -20,6 +20,9 @@ #include "panelfocusmanager.h" +#include "panel/project/project.h" +#include "panel/viewer/viewer.h" + PanelFocusManager* olive::panel_focus_manager = nullptr; PanelFocusManager::PanelFocusManager(QObject *parent) : @@ -28,7 +31,7 @@ PanelFocusManager::PanelFocusManager(QObject *parent) : } -PanelWidget *PanelFocusManager::CurrentlyFocused() +PanelWidget *PanelFocusManager::CurrentlyFocused() const { if (focus_history_.isEmpty()) { return nullptr; @@ -76,19 +79,3 @@ void PanelFocusManager::FocusChanged(QWidget *old, QWidget *now) parent = parent->parent(); } } - -template -T *PanelFocusManager::MostRecentlyFocused() -{ - T* cast_test; - - for (int i=0;i(focus_history_.at(i)); - - if (cast_test != nullptr) { - return cast_test; - } - } - - return nullptr; -} diff --git a/app/panel/panelfocusmanager.h b/app/panel/panelfocusmanager.h index 30b404f8c..a5668546a 100644 --- a/app/panel/panelfocusmanager.h +++ b/app/panel/panelfocusmanager.h @@ -24,6 +24,7 @@ #include #include +#include "panel/viewer/viewer.h" #include "widget/panel/panel.h" /** @@ -49,9 +50,8 @@ public: /** * @brief Return the currently focused widget, or nullptr if nothing is focused */ - PanelWidget* CurrentlyFocused(); + PanelWidget* CurrentlyFocused() const; - template /** * @brief Get most recently focused panel of a certain type * @@ -59,6 +59,7 @@ public: * * The most recently focused panel of the specified type, or nullptr if none exists */ + template T* MostRecentlyFocused(); public slots: @@ -76,6 +77,22 @@ private: QList focus_history_; }; +template +T* PanelFocusManager::MostRecentlyFocused() +{ + T* cast_test; + + for (int i=0;i(focus_history_.at(i)); + + if (cast_test != nullptr) { + return cast_test; + } + } + + return nullptr; +} + namespace olive { extern PanelFocusManager* panel_focus_manager; }