From e562353abab1b74926ad6b798d11526390581fe1 Mon Sep 17 00:00:00 2001 From: Timothy Schoen Date: Sat, 25 Jan 2025 14:10:05 +0100 Subject: [PATCH] Clean up cmd+w shortcut --- Source/Constants.h | 1 - Source/PluginEditor.cpp | 52 +++++++++++++++++++---------------------- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/Source/Constants.h b/Source/Constants.h index cb31417e0..dc2fbc0bf 100644 --- a/Source/Constants.h +++ b/Source/Constants.h @@ -363,7 +363,6 @@ enum CommandIDs { OpenObjectBrowser, ToggleDSP, ShowCommandInput, - CloseDialogs, NumItems // <-- the total number of items in this enum }; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 2310d0608..f2d8cd08c 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -1053,7 +1053,7 @@ void PluginEditor::getCommandInfo(CommandID const commandID, ApplicationCommandI case CommandIDs::CloseTab: { result.setInfo("Close tab", "Close currently opened tab", "General", 0); result.addDefaultKeypress(87, ModifierKeys::commandModifier); - result.setActive(hasCanvas); + result.setActive(hasCanvas || openedDialog); break; } case CommandIDs::Undo: { @@ -1247,12 +1247,6 @@ void PluginEditor::getCommandInfo(CommandID const commandID, ApplicationCommandI result.setActive(true); break; } - case CommandIDs::CloseDialogs: { - result.setInfo("Close dialogs", "Close all opened dialogs", "Edit", 0); - result.addDefaultKeypress(87, ModifierKeys::commandModifier); - result.setActive(true); - break; - } case CommandIDs::ShowSettings: { result.setInfo("Open Settings", "Open settings panel", "View", 0); result.addDefaultKeypress(44, ModifierKeys::commandModifier); // Cmd + , to open settings @@ -1421,10 +1415,6 @@ bool PluginEditor::perform(InvocationInfo const& info) sidebar->clearConsole(); return true; } - case CommandIDs::CloseDialogs: { - openedDialog.reset(nullptr); - return true; - } case CommandIDs::ShowSettings: { if(openedDialog) { @@ -1436,24 +1426,14 @@ bool PluginEditor::perform(InvocationInfo const& info) return true; } - } - - auto* cnv = getCurrentCanvas(); - - if (!cnv) - return false; - - switch (info.commandID) { - case CommandIDs::SaveProject: { - cnv->save(); - return true; - } - case CommandIDs::SaveProjectAs: { - cnv->saveAs(); - return true; - } case CommandIDs::CloseTab: { - if (cnv) { + if(openedDialog) + { + openedDialog.reset(nullptr); + return true; + } + + if (auto* cnv = getCurrentCanvas()) { MessageManager::callAsync([this, cnv = SafePointer(cnv)]() mutable { if (cnv && cnv->patch.isDirty()) { Dialogs::showAskToSaveDialog( @@ -1475,6 +1455,22 @@ bool PluginEditor::perform(InvocationInfo const& info) return true; } + } + + auto* cnv = getCurrentCanvas(); + + if (!cnv) + return false; + + switch (info.commandID) { + case CommandIDs::SaveProject: { + cnv->save(); + return true; + } + case CommandIDs::SaveProjectAs: { + cnv->saveAs(); + return true; + } case CommandIDs::Copy: { cnv = getCurrentCanvas(); cnv->copySelection();