toggle for moving locked panels implemented

This commit is contained in:
itsmattkc
2019-09-24 17:43:16 +10:00
parent cad9fc8e48
commit c33a0b50ce
9 changed files with 110 additions and 33 deletions
+9 -9
View File
@@ -170,7 +170,7 @@ void Core::DialogImportShow()
if (!files.isEmpty()) {
// Locate the most recently focused Project panel (assume that's the panel the user wants to import into)
ProjectPanel* active_project_panel = olive::panel_focus_manager->MostRecentlyFocused<ProjectPanel>();
ProjectPanel* active_project_panel = olive::panel_manager->MostRecentlyFocused<ProjectPanel>();
Project* active_project;
if (active_project_panel == nullptr // Check that we found a Project panel
@@ -189,7 +189,7 @@ void Core::DialogImportShow()
void Core::CreateNewFolder()
{
// Locate the most recently focused Project panel (assume that's the panel the user wants to import into)
ProjectPanel* active_project_panel = olive::panel_focus_manager->MostRecentlyFocused<ProjectPanel>();
ProjectPanel* active_project_panel = olive::panel_manager->MostRecentlyFocused<ProjectPanel>();
Project* active_project;
if (active_project_panel == nullptr // Check that we found a Project panel
@@ -234,7 +234,7 @@ void Core::CreateNewFolder()
void Core::CreateNewSequence()
{
// Locate the most recently focused Project panel (assume that's the panel the user wants to import into)
ProjectPanel* active_project_panel = olive::panel_focus_manager->MostRecentlyFocused<ProjectPanel>();
ProjectPanel* active_project_panel = olive::panel_manager->MostRecentlyFocused<ProjectPanel>();
Project* active_project;
if (active_project_panel == nullptr // Check that we found a Project panel
@@ -311,9 +311,9 @@ void Core::CreateNewSequence()
// Connect timeline end point to renderer
NodeParam::ConnectEdge(tb->length_output(), rp->length_input());
olive::panel_focus_manager->MostRecentlyFocused<ViewerPanel>()->ConnectViewerNode(vo);
olive::panel_focus_manager->MostRecentlyFocused<TimelinePanel>()->ConnectTimelineNode(tb);
olive::panel_focus_manager->MostRecentlyFocused<NodePanel>()->SetGraph(new_sequence.get());
olive::panel_manager->MostRecentlyFocused<ViewerPanel>()->ConnectViewerNode(vo);
olive::panel_manager->MostRecentlyFocused<TimelinePanel>()->ConnectTimelineNode(tb);
olive::panel_manager->MostRecentlyFocused<NodePanel>()->SetGraph(new_sequence.get());
olive::undo_stack.push(aic);
}
@@ -343,12 +343,12 @@ void Core::StartGUI(bool full_screen)
olive::menu_shared.Initialize();
// Since we're starting GUI mode, create a PanelFocusManager (auto-deletes with QObject)
olive::panel_focus_manager = new PanelManager(this);
olive::panel_manager = new PanelManager(this);
// Connect the PanelFocusManager to the application's focus change signal
connect(qApp,
SIGNAL(focusChanged(QWidget*, QWidget*)),
olive::panel_focus_manager,
olive::panel_manager,
SLOT(FocusChanged(QWidget*, QWidget*)));
// Create main window and open it
@@ -369,7 +369,7 @@ void Core::StartGUI(bool full_screen)
Project *Core::GetActiveProject()
{
// Locate the most recently focused Project panel (assume that's the panel the user wants to import into)
ProjectPanel* active_project_panel = olive::panel_focus_manager->MostRecentlyFocused<ProjectPanel>();
ProjectPanel* active_project_panel = olive::panel_manager->MostRecentlyFocused<ProjectPanel>();
// If we couldn't find one, return nullptr
if (active_project_panel == nullptr) {
+17 -2
View File
@@ -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;
}
+18 -1
View File
@@ -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
@@ -171,7 +171,7 @@ void NodeParamViewWidgetBridge::CreateWidgets()
// FIXME: Test code
// Pretty hacky way of getting the root folder for this node's sequence
ProjectPanel* pp = olive::panel_focus_manager->MostRecentlyFocused<ProjectPanel>();
ProjectPanel* pp = olive::panel_manager->MostRecentlyFocused<ProjectPanel>();
footage_combobox->SetRoot(pp->project()->root());
// Use multiple values
+17
View File
@@ -32,6 +32,23 @@ PanelWidget::PanelWidget(QWidget *parent) :
setFocusPolicy(Qt::ClickFocus);
}
void PanelWidget::SetMovementLocked(bool locked)
{
if (locked) {
// Disable moving on QDockWidget
setFeatures(features() & ~QDockWidget::DockWidgetMovable);
// Hide the title bar (only real way to do this is to replace it with an empty QWidget)
setTitleBarWidget(new QWidget(this));
} else {
// Re-enable moving on QDockWidget
setFeatures(features() | QDockWidget::DockWidgetMovable);
// Set the "custom" titlebar to null so the default gets restored
setTitleBarWidget(nullptr);
}
}
void PanelWidget::SetBorderVisible(bool enabled)
{
border_visible_ = enabled;
+5
View File
@@ -40,6 +40,11 @@ public:
*/
PanelWidget(QWidget* parent);
/**
* @brief Set whether panel movement is locked or not
*/
void SetMovementLocked(bool locked);
/**
* @brief Set visibility of panel's highlighted border, mostly used for showing panel focus
*
+30 -13
View File
@@ -191,11 +191,10 @@ MainMenu::MainMenu(QMainWindow *parent) :
//
// WINDOW MENU
//
window_menu_ = new Menu(this);
window_menu_->addAction("No window support");
window_menu_->addSeparator();
window_menu_ = new Menu(this, this, SLOT(WindowMenuAboutToShow()));
window_menu_separator_ = window_menu_->addSeparator();
window_maximize_panel_item_ = window_menu_->AddItem("maximizepanel", nullptr, nullptr, "`");
window_lock_layout_item_ = window_menu_->AddItem("lockpanels", nullptr, nullptr);
window_lock_layout_item_ = window_menu_->AddItem("lockpanels", olive::panel_manager, SLOT(SetPanelsLocked(bool)));
window_lock_layout_item_->setCheckable(true);
window_menu_->addSeparator();
window_reset_layout_item_ = window_menu_->AddItem("resetdefaultlayout", nullptr, nullptr);
@@ -345,49 +344,67 @@ void MainMenu::ToolsMenuAboutToShow()
tools_snapping_item_->setChecked(olive::core.snapping());
}
void MainMenu::WindowMenuAboutToShow()
{
// QMainWindow generates a perfectly usable menu for this purpose, we just need to copy it to the window menu
QMenu* panel_menu = static_cast<QMainWindow*>(parentWidget())->createPopupMenu();
QList<QAction*> panel_menu_actions = panel_menu->actions();
// Make sure when we delete the panel_menu, it doesn't delete the actions
foreach (QAction* panel_action, panel_menu_actions) {
panel_action->setParent(window_menu_);
}
delete panel_menu;
window_menu_->insertActions(window_menu_separator_, panel_menu_actions);
window_lock_layout_item_->setChecked(olive::panel_manager->ArePanelsLocked());
}
void MainMenu::ZoomInTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->ZoomIn();
olive::panel_manager->CurrentlyFocused()->ZoomIn();
}
void MainMenu::ZoomOutTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->ZoomOut();
olive::panel_manager->CurrentlyFocused()->ZoomOut();
}
void MainMenu::GoToStartTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->GoToStart();
olive::panel_manager->CurrentlyFocused()->GoToStart();
}
void MainMenu::PrevFrameTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->PrevFrame();
olive::panel_manager->CurrentlyFocused()->PrevFrame();
}
void MainMenu::PlayPauseTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->PlayPause();
olive::panel_manager->CurrentlyFocused()->PlayPause();
}
void MainMenu::NextFrameTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->NextFrame();
olive::panel_manager->CurrentlyFocused()->NextFrame();
}
void MainMenu::GoToEndTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->GoToEnd();
olive::panel_manager->CurrentlyFocused()->GoToEnd();
}
void MainMenu::SelectAllTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->SelectAll();
olive::panel_manager->CurrentlyFocused()->SelectAll();
}
void MainMenu::DeselectAllTriggered()
{
olive::panel_focus_manager->CurrentlyFocused()->DeselectAll();
olive::panel_manager->CurrentlyFocused()->DeselectAll();
}
void MainMenu::Retranslate()
+6
View File
@@ -66,6 +66,11 @@ private slots:
*/
void ToolsMenuAboutToShow();
/**
* @brief Slot triggered just before the Window menu shows
*/
void WindowMenuAboutToShow();
/**
* @brief Slot for zooming in
*
@@ -163,6 +168,7 @@ private:
QAction* playback_loop_item_;
Menu* window_menu_;
QAction* window_menu_separator_;
QAction* window_maximize_panel_item_;
QAction* window_lock_layout_item_;
QAction* window_reset_layout_item_;
+7 -7
View File
@@ -67,23 +67,23 @@ void olive::MainWindow::SetFullscreen(bool fullscreen)
void olive::MainWindow::ProjectOpen(Project* p)
{
// FIXME Use settings data to create panels and restore state if they exist
NodePanel* node_panel = olive::panel_focus_manager->CreatePanel<NodePanel>(this);
NodePanel* node_panel = olive::panel_manager->CreatePanel<NodePanel>(this);
addDockWidget(Qt::TopDockWidgetArea, node_panel);
ParamPanel* param_panel = olive::panel_focus_manager->CreatePanel<ParamPanel>(this);
ParamPanel* param_panel = olive::panel_manager->CreatePanel<ParamPanel>(this);
addDockWidget(Qt::TopDockWidgetArea, param_panel);
ViewerPanel* viewer_panel2 = olive::panel_focus_manager->CreatePanel<ViewerPanel>(this);
ViewerPanel* viewer_panel2 = olive::panel_manager->CreatePanel<ViewerPanel>(this);
addDockWidget(Qt::TopDockWidgetArea, viewer_panel2);
ProjectPanel* project_panel = olive::panel_focus_manager->CreatePanel<ProjectPanel>(this);
ProjectPanel* project_panel = olive::panel_manager->CreatePanel<ProjectPanel>(this);
project_panel->set_project(p);
addDockWidget(Qt::BottomDockWidgetArea, project_panel);
ToolPanel* tool_panel = olive::panel_focus_manager->CreatePanel<ToolPanel>(this);
ToolPanel* tool_panel = olive::panel_manager->CreatePanel<ToolPanel>(this);
addDockWidget(Qt::BottomDockWidgetArea, tool_panel);
TimelinePanel* timeline_panel = olive::panel_focus_manager->CreatePanel<TimelinePanel>(this);
TimelinePanel* timeline_panel = olive::panel_manager->CreatePanel<TimelinePanel>(this);
addDockWidget(Qt::BottomDockWidgetArea, timeline_panel);
connect(node_panel, SIGNAL(SelectionChanged(QList<Node*>)), param_panel, SLOT(SetNodes(QList<Node*>)));
@@ -96,7 +96,7 @@ void olive::MainWindow::ProjectOpen(Project* p)
void olive::MainWindow::closeEvent(QCloseEvent *e)
{
olive::panel_focus_manager->DeleteAllPanels();
olive::panel_manager->DeleteAllPanels();
// FIXME: Test code - We have no cache management and the cache is very much testing only, so we delete it on close
// as to not clog up HDD space