diff --git a/app/panel/node/node.cpp b/app/panel/node/node.cpp index 05f911882..894f3ad84 100644 --- a/app/panel/node/node.cpp +++ b/app/panel/node/node.cpp @@ -23,6 +23,9 @@ NodePanel::NodePanel(QWidget *parent) : PanelWidget(parent) { + // FIXME: This won't work if there's ever more than one of this panel + setObjectName("NodePanel"); + // Create NodeView widget node_view_ = new NodeView(this); diff --git a/app/panel/panelmanager.cpp b/app/panel/panelmanager.cpp index 5c0107936..a2d329468 100644 --- a/app/panel/panelmanager.cpp +++ b/app/panel/panelmanager.cpp @@ -50,6 +50,17 @@ PanelWidget *PanelManager::CurrentlyFocused() const return focus_history_.first(); } +PanelWidget *PanelManager::CurrentlyHovered() const +{ + foreach (PanelWidget* panel, focus_history_) { + if (panel->underMouse()) { + return panel; + } + } + + return nullptr; +} + bool PanelManager::ArePanelsLocked() { return locked_; diff --git a/app/panel/panelmanager.h b/app/panel/panelmanager.h index 9717af9b7..3334b13cf 100644 --- a/app/panel/panelmanager.h +++ b/app/panel/panelmanager.h @@ -63,9 +63,18 @@ public: /** * @brief Return the currently focused widget, or nullptr if nothing is focused + * + * This result == CurrentlyFocused() if HoverFocus is true */ PanelWidget* CurrentlyFocused() const; + /** + * @brief Return the widget that the mouse is currently hovering over, or nullptr if nothing is hovered over + * + * This result == CurrentlyFocused() if HoverFocus is true + */ + PanelWidget* CurrentlyHovered() const; + template /** * @brief Get most recently focused panel of a certain type diff --git a/app/panel/param/param.cpp b/app/panel/param/param.cpp index 6900fa2a9..e4c3bd5eb 100644 --- a/app/panel/param/param.cpp +++ b/app/panel/param/param.cpp @@ -23,6 +23,9 @@ ParamPanel::ParamPanel(QWidget* parent) : PanelWidget(parent) { + // FIXME: This won't work if there's ever more than one of this panel + setObjectName("ParamPanel"); + view_ = new NodeParamView(this); setWidget(view_); diff --git a/app/panel/project/project.cpp b/app/panel/project/project.cpp index fc261efc0..4306c715b 100644 --- a/app/panel/project/project.cpp +++ b/app/panel/project/project.cpp @@ -30,6 +30,9 @@ ProjectPanel::ProjectPanel(QWidget *parent) : PanelWidget(parent) { + // FIXME: This won't work if there's ever more than one of this panel + setObjectName("ProjectPanel"); + // Create main widget and its layout QWidget* central_widget = new QWidget(this); QVBoxLayout* layout = new QVBoxLayout(central_widget); diff --git a/app/panel/taskmanager/taskmanager.cpp b/app/panel/taskmanager/taskmanager.cpp index 3a6f806f1..f4942738e 100644 --- a/app/panel/taskmanager/taskmanager.cpp +++ b/app/panel/taskmanager/taskmanager.cpp @@ -25,6 +25,9 @@ TaskManagerPanel::TaskManagerPanel(QWidget* parent) : PanelWidget(parent) { + // FIXME: This won't work if there's ever more than one of this panel + setObjectName("TaskManagerPanel"); + // Create task view view_ = new TaskView(this); diff --git a/app/panel/timeline/timeline.cpp b/app/panel/timeline/timeline.cpp index 1c4b2f687..51b9e0f44 100644 --- a/app/panel/timeline/timeline.cpp +++ b/app/panel/timeline/timeline.cpp @@ -26,6 +26,9 @@ TimelinePanel::TimelinePanel(QWidget *parent) : PanelWidget(parent) { + // FIXME: This won't work if there's ever more than one of this panel + setObjectName("TimelinePanel"); + QWidget* main = new QWidget(this); setWidget(main); diff --git a/app/panel/tool/tool.cpp b/app/panel/tool/tool.cpp index b3438d9e3..abd431665 100644 --- a/app/panel/tool/tool.cpp +++ b/app/panel/tool/tool.cpp @@ -26,6 +26,9 @@ ToolPanel::ToolPanel(QWidget *parent) : PanelWidget(parent) { + // FIXME: This won't work if there's ever more than one of this panel + setObjectName("ToolPanel"); + Toolbar* t = new Toolbar(this); t->SetTool(olive::core.tool()); diff --git a/app/panel/viewer/viewer.cpp b/app/panel/viewer/viewer.cpp index fab4c6741..8064f602a 100644 --- a/app/panel/viewer/viewer.cpp +++ b/app/panel/viewer/viewer.cpp @@ -23,6 +23,9 @@ ViewerPanel::ViewerPanel(QWidget *parent) : PanelWidget(parent) { + // FIXME: This won't work if there's ever more than one of this panel + setObjectName("ViewerPanel"); + // QObject system handles deleting this viewer_ = new ViewerWidget(this); connect(viewer_, SIGNAL(TimeChanged(const rational&)), this, SIGNAL(TimeChanged(const rational&))); diff --git a/app/window/mainwindow/mainwindow.cpp b/app/window/mainwindow/mainwindow.cpp index 37bf23750..2d49eea7c 100644 --- a/app/window/mainwindow/mainwindow.cpp +++ b/app/window/mainwindow/mainwindow.cpp @@ -66,16 +66,19 @@ void olive::MainWindow::SetFullscreen(bool fullscreen) void olive::MainWindow::ToggleMaximizedPanel() { - qDebug() << "Hello!"; - if (premaximized_state_.isEmpty()) { // Assume nothing is maximized at the moment // Find the currently focused panel - PanelWidget* currently_focused = olive::panel_manager->CurrentlyFocused(); + PanelWidget* currently_hovered = olive::panel_manager->CurrentlyHovered(); + + // If no panel is hovered, do nothing + if (currently_hovered == nullptr) { + return; + } // If this panel is not actually on the main window, this is a no-op - if (currently_focused->isFloating()) { + if (currently_hovered->isFloating()) { return; } @@ -84,7 +87,7 @@ void olive::MainWindow::ToggleMaximizedPanel() // For every other panel that is on the main window, hide it foreach (PanelWidget* panel, olive::panel_manager->panels()) { - if (!panel->isFloating() && panel != currently_focused) { + if (!panel->isFloating() && panel != currently_hovered) { panel->setVisible(false); } }