From 9b6028430ff89a84d3b74233de5d9b967e6659a1 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Wed, 23 Oct 2019 00:47:41 +1100 Subject: [PATCH] fixed segfault when right clicking empty space in project explorer --- .../projectexplorer/projectexplorer.cpp | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/app/widget/projectexplorer/projectexplorer.cpp b/app/widget/projectexplorer/projectexplorer.cpp index a4aa4b9a5..668c5e0c6 100644 --- a/app/widget/projectexplorer/projectexplorer.cpp +++ b/app/widget/projectexplorer/projectexplorer.cpp @@ -219,6 +219,9 @@ void ProjectExplorer::RenameTimerSlot() rename_timer_.stop(); } +// FIXME: This is down here because of the code in ShowContextMenu() which may be unnecessary allowing this to be removed +#include "core.h" + void ProjectExplorer::ShowContextMenu() { QMenu menu; @@ -226,10 +229,21 @@ void ProjectExplorer::ShowContextMenu() // FIXME: Support for multiple items and items other than Footage QList selected_items = SelectedItems(); - QAction* properties_action = menu.addAction(tr("P&roperties")); + if (selected_items.isEmpty()) { + // FIXME: These are both duplicates of items from MainMenu, is there any way to re-use the code? + QAction* import_action = menu.addAction(tr("&Import...")); + connect(import_action, SIGNAL(triggered(bool)), &olive::core, SLOT(DialogImportShow())); - if (selected_items.first()->type() == Item::kFootage) { - connect(properties_action, SIGNAL(triggered(bool)), this, SLOT(ShowFootagePropertiesDialog())); + menu.addSeparator(); + + QAction* project_properties = menu.addAction(tr("&Project Properties...")); + connect(project_properties, SIGNAL(triggered(bool)), &olive::core, SLOT(DialogProjectPropertiesShow())); + } else { + QAction* properties_action = menu.addAction(tr("P&roperties")); + + if (selected_items.first()->type() == Item::kFootage) { + connect(properties_action, SIGNAL(triggered(bool)), this, SLOT(ShowFootagePropertiesDialog())); + } } menu.exec(QCursor::pos());