mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Introjucer: added "save as"
This commit is contained in:
parent
1bf9f441e6
commit
12c28fd882
9 changed files with 67 additions and 30 deletions
|
|
@ -419,15 +419,20 @@ void ProjectContentComponent::closeDocument()
|
|||
hideEditor();
|
||||
}
|
||||
|
||||
static void showSaveWarning (OpenDocumentManager::Document* currentDocument)
|
||||
{
|
||||
AlertWindow::showMessageBox (AlertWindow::WarningIcon,
|
||||
TRANS("Save failed!"),
|
||||
TRANS("Couldn't save the file:")
|
||||
+ "\n" + currentDocument->getFile().getFullPathName());
|
||||
}
|
||||
|
||||
void ProjectContentComponent::saveDocument()
|
||||
{
|
||||
if (currentDocument != nullptr)
|
||||
{
|
||||
if (! currentDocument->save())
|
||||
AlertWindow::showMessageBox (AlertWindow::WarningIcon,
|
||||
TRANS("Save failed!"),
|
||||
TRANS("Couldn't save the file:")
|
||||
+ "\n" + currentDocument->getFile().getFullPathName());
|
||||
showSaveWarning (currentDocument);
|
||||
}
|
||||
else
|
||||
saveProject();
|
||||
|
|
@ -435,6 +440,12 @@ void ProjectContentComponent::saveDocument()
|
|||
updateMainWindowTitle();
|
||||
}
|
||||
|
||||
void ProjectContentComponent::saveAs()
|
||||
{
|
||||
if (currentDocument != nullptr && ! currentDocument->saveAs())
|
||||
showSaveWarning (currentDocument);
|
||||
}
|
||||
|
||||
bool ProjectContentComponent::goToPreviousFile()
|
||||
{
|
||||
OpenDocumentManager::Document* doc = recentDocumentList.getCurrentDocument();
|
||||
|
|
@ -544,6 +555,7 @@ ApplicationCommandTarget* ProjectContentComponent::getNextCommandTarget()
|
|||
void ProjectContentComponent::getAllCommands (Array <CommandID>& commands)
|
||||
{
|
||||
const CommandID ids[] = { CommandIDs::saveDocument,
|
||||
CommandIDs::saveDocumentAs,
|
||||
CommandIDs::closeDocument,
|
||||
CommandIDs::saveProject,
|
||||
CommandIDs::closeProject,
|
||||
|
|
@ -595,6 +607,14 @@ void ProjectContentComponent::getCommandInfo (const CommandID commandID, Applica
|
|||
result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier, 0));
|
||||
break;
|
||||
|
||||
case CommandIDs::saveDocumentAs:
|
||||
result.setInfo ("Save As...",
|
||||
"Saves the current document to a new location",
|
||||
CommandCategories::general, 0);
|
||||
result.setActive (currentDocument != nullptr || project != nullptr);
|
||||
result.defaultKeypresses.add (KeyPress ('s', ModifierKeys::commandModifier | ModifierKeys::shiftModifier, 0));
|
||||
break;
|
||||
|
||||
case CommandIDs::closeDocument:
|
||||
result.setInfo ("Close" + documentName,
|
||||
"Closes the current document",
|
||||
|
|
@ -688,6 +708,7 @@ bool ProjectContentComponent::perform (const InvocationInfo& info)
|
|||
case CommandIDs::saveProject:
|
||||
case CommandIDs::closeProject:
|
||||
case CommandIDs::saveDocument:
|
||||
case CommandIDs::saveDocumentAs:
|
||||
case CommandIDs::closeDocument:
|
||||
case CommandIDs::goToPreviousDoc:
|
||||
case CommandIDs::goToNextDoc:
|
||||
|
|
@ -710,6 +731,7 @@ bool ProjectContentComponent::perform (const InvocationInfo& info)
|
|||
case CommandIDs::saveProject: saveProject(); break;
|
||||
case CommandIDs::closeProject: closeProject(); break;
|
||||
case CommandIDs::saveDocument: saveDocument(); break;
|
||||
case CommandIDs::saveDocumentAs: saveAs(); break;
|
||||
|
||||
case CommandIDs::closeDocument: closeDocument(); break;
|
||||
case CommandIDs::goToPreviousDoc: goToPreviousFile(); break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue