fixed template function for MostRecentlyFocused panel
This commit is contained in:
+5
-1
@@ -26,10 +26,14 @@
|
||||
#include <QDebug>
|
||||
|
||||
#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;i<urls.size();i++) {
|
||||
//const QString& url = urls.at(i);
|
||||
|
||||
|
||||
//qDebug() << olive::panel_focus_manager->MostRecentlyFocused<ViewerPanel>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<typename T>
|
||||
T *PanelFocusManager::MostRecentlyFocused()
|
||||
{
|
||||
T* cast_test;
|
||||
|
||||
for (int i=0;i<focus_history_.size();i++) {
|
||||
cast_test = dynamic_cast<T*>(focus_history_.at(i));
|
||||
|
||||
if (cast_test != nullptr) {
|
||||
return cast_test;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
|
||||
#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<typename T>
|
||||
/**
|
||||
* @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<class T>
|
||||
T* MostRecentlyFocused();
|
||||
|
||||
public slots:
|
||||
@@ -76,6 +77,22 @@ private:
|
||||
QList<PanelWidget*> focus_history_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
T* PanelFocusManager::MostRecentlyFocused()
|
||||
{
|
||||
T* cast_test;
|
||||
|
||||
for (int i=0;i<focus_history_.size();i++) {
|
||||
cast_test = dynamic_cast<T*>(focus_history_.at(i));
|
||||
|
||||
if (cast_test != nullptr) {
|
||||
return cast_test;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
namespace olive {
|
||||
extern PanelFocusManager* panel_focus_manager;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user