Skip to content

Commit

Permalink
Clean up cmd+w shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyschoen committed Jan 25, 2025
1 parent 9b7aa92 commit e562353
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 29 deletions.
1 change: 0 additions & 1 deletion Source/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ enum CommandIDs {
OpenObjectBrowser,
ToggleDSP,
ShowCommandInput,
CloseDialogs,
NumItems // <-- the total number of items in this enum
};

Expand Down
52 changes: 24 additions & 28 deletions Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand All @@ -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(
Expand All @@ -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();
Expand Down

0 comments on commit e562353

Please sign in to comment.