toggle for moving locked panels implemented
This commit is contained in:
@@ -20,10 +20,11 @@
|
||||
|
||||
#include "panelmanager.h"
|
||||
|
||||
PanelManager* olive::panel_focus_manager = nullptr;
|
||||
PanelManager* olive::panel_manager = nullptr;
|
||||
|
||||
PanelManager::PanelManager(QObject *parent) :
|
||||
QObject(parent)
|
||||
QObject(parent),
|
||||
locked_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -44,6 +45,11 @@ PanelWidget *PanelManager::CurrentlyFocused() const
|
||||
return focus_history_.first();
|
||||
}
|
||||
|
||||
bool PanelManager::ArePanelsLocked()
|
||||
{
|
||||
return locked_;
|
||||
}
|
||||
|
||||
void PanelManager::FocusChanged(QWidget *old, QWidget *now)
|
||||
{
|
||||
Q_UNUSED(old)
|
||||
@@ -83,3 +89,12 @@ void PanelManager::FocusChanged(QWidget *old, QWidget *now)
|
||||
parent = parent->parent();
|
||||
}
|
||||
}
|
||||
|
||||
void PanelManager::SetPanelsLocked(bool locked)
|
||||
{
|
||||
foreach (PanelWidget* panel, focus_history_) {
|
||||
panel->SetMovementLocked(locked);
|
||||
}
|
||||
|
||||
locked_ = locked;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,11 @@ public:
|
||||
*/
|
||||
T* CreatePanel(QWidget* parent);
|
||||
|
||||
/**
|
||||
* @brief Get whether panels are currently prevented from moving
|
||||
*/
|
||||
bool ArePanelsLocked();
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Connect this to a QApplication's SIGNAL(focusChanged())
|
||||
@@ -80,11 +85,21 @@ public slots:
|
||||
*/
|
||||
void FocusChanged(QWidget* old, QWidget* now);
|
||||
|
||||
/**
|
||||
* @brief Sets whether panels should be prevented from moving
|
||||
*/
|
||||
void SetPanelsLocked(bool locked);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief History array for traversing through (see MostRecentlyFocused())
|
||||
*/
|
||||
QList<PanelWidget*> focus_history_;
|
||||
|
||||
/**
|
||||
* @brief Internal panel movement is locked value
|
||||
*/
|
||||
bool locked_;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
@@ -92,6 +107,8 @@ T *PanelManager::CreatePanel(QWidget *parent)
|
||||
{
|
||||
T* panel = new T(parent);
|
||||
|
||||
panel->SetMovementLocked(locked_);
|
||||
|
||||
// Add panel to the bottom of the focus history
|
||||
focus_history_.append(panel);
|
||||
|
||||
@@ -115,7 +132,7 @@ T* PanelManager::MostRecentlyFocused()
|
||||
}
|
||||
|
||||
namespace olive {
|
||||
extern PanelManager* panel_focus_manager;
|
||||
extern PanelManager* panel_manager;
|
||||
}
|
||||
|
||||
#endif // PANELFOCUSMANAGER_H
|
||||
|
||||
Reference in New Issue
Block a user