mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-02-06 04:00:08 +00:00
Introjucer: tidied up some document saving behaviour.
This commit is contained in:
parent
f2426cc7de
commit
d2aa3a666b
9 changed files with 53 additions and 143 deletions
|
|
@ -55,81 +55,3 @@ void DocumentEditorComponent::documentAboutToClose (OpenDocumentManager::Documen
|
|||
jassertfalse
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationCommandTarget* DocumentEditorComponent::getNextCommandTarget()
|
||||
{
|
||||
return findFirstTargetParentComponent();
|
||||
}
|
||||
|
||||
void DocumentEditorComponent::getAllCommands (Array <CommandID>& commands)
|
||||
{
|
||||
const CommandID ids[] = { CommandIDs::saveDocument,
|
||||
CommandIDs::saveDocumentAs,
|
||||
CommandIDs::closeDocument };
|
||||
|
||||
commands.addArray (ids, numElementsInArray (ids));
|
||||
}
|
||||
|
||||
void DocumentEditorComponent::getCommandInfo (const CommandID commandID, ApplicationCommandInfo& result)
|
||||
{
|
||||
result.setActive (document != nullptr);
|
||||
String name;
|
||||
|
||||
if (document != nullptr)
|
||||
name = " '" + document->getName().substring (0, 32) + "'";
|
||||
|
||||
switch (commandID)
|
||||
{
|
||||
case CommandIDs::saveDocument:
|
||||
result.setInfo ("Save" + name,
|
||||
"Saves the current document",
|
||||
CommandCategories::general, 0);
|
||||
result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier, 0));
|
||||
break;
|
||||
|
||||
case CommandIDs::saveDocumentAs:
|
||||
result.setInfo ("Save" + name + " As...",
|
||||
"Saves the current document to a different filename",
|
||||
CommandCategories::general, 0);
|
||||
result.setActive (document != nullptr && document->canSaveAs());
|
||||
result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier | ModifierKeys::shiftModifier, 0));
|
||||
break;
|
||||
|
||||
case CommandIDs::closeDocument:
|
||||
result.setInfo ("Close" + name,
|
||||
"Closes the current document",
|
||||
CommandCategories::general, 0);
|
||||
#if JUCE_MAC
|
||||
result.defaultKeypresses.add (KeyPress ('w', ModifierKeys::commandModifier | ModifierKeys::ctrlModifier, 0));
|
||||
#else
|
||||
result.defaultKeypresses.add (KeyPress ('w', ModifierKeys::commandModifier | ModifierKeys::shiftModifier, 0));
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool DocumentEditorComponent::perform (const InvocationInfo& info)
|
||||
{
|
||||
switch (info.commandID)
|
||||
{
|
||||
case CommandIDs::saveDocument:
|
||||
document->save();
|
||||
return true;
|
||||
|
||||
case CommandIDs::saveDocumentAs:
|
||||
document->saveAs();
|
||||
return true;
|
||||
|
||||
case CommandIDs::closeDocument:
|
||||
OpenDocumentManager::getInstance()->closeDocument (document, true);
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue