diff --git a/app/panel/panelfocusmanager.cpp b/app/panel/panelfocusmanager.cpp index 61d5a273f..b04d53b08 100644 --- a/app/panel/panelfocusmanager.cpp +++ b/app/panel/panelfocusmanager.cpp @@ -1,8 +1,26 @@ +/*** + + Olive - Non-Linear Video Editor + Copyright (C) 2019 Olive Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +***/ + #include "panelfocusmanager.h" -#include - -PanelFocusManager* olive::panel_focus_manager; +PanelFocusManager* olive::panel_focus_manager = nullptr; PanelFocusManager::PanelFocusManager(QObject *parent) : QObject(parent) @@ -58,3 +76,19 @@ 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 618f5d0e7..8d10456fe 100644 --- a/app/panel/panelfocusmanager.h +++ b/app/panel/panelfocusmanager.h @@ -14,6 +14,9 @@ public: PanelWidget* CurrentlyFocused(); + template + PanelWidget* MostRecentlyFocused(); + public slots: void FocusChanged(QWidget* old, QWidget* now);