Updated JUCE modules to version 3, which also updated the license headers to reflect AGPLv3 compatibility.

This commit is contained in:
Jonathan Thomas
2014-07-10 14:24:30 -05:00
parent 417648fb9e
commit 3879498af3
891 changed files with 103385 additions and 70181 deletions

View File

@@ -1,24 +1,23 @@
/*
==============================================================================
This file is part of the JUCE library - "Jules' Utility Class Extensions"
Copyright 2004-11 by Raw Material Software Ltd.
This file is part of the JUCE library.
Copyright (c) 2013 - Raw Material Software Ltd.
------------------------------------------------------------------------------
Permission is granted to use this software under the terms of either:
a) the GPL v2 (or any later version)
b) the Affero GPL v3
JUCE can be redistributed and/or modified under the terms of the GNU General
Public License (Version 2), as published by the Free Software Foundation.
A copy of the license is included in the JUCE distribution, or can be found
online at www.gnu.org/licenses.
Details of these licenses can be found at: www.gnu.org/licenses
JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
------------------------------------------------------------------------------
To release a closed-source product which uses JUCE, commercial licenses are
available: visit www.rawmaterialsoftware.com/juce for more information.
available: visit www.juce.com for more information.
==============================================================================
*/
@@ -66,52 +65,45 @@ void FileBasedDocument::setFile (const File& newFile)
}
//==============================================================================
#if JUCE_MODAL_LOOPS_PERMITTED
bool FileBasedDocument::loadFrom (const File& newFile,
const bool showMessageOnFailure)
Result FileBasedDocument::loadFrom (const File& newFile, const bool showMessageOnFailure)
{
MouseCursor::showWaitCursor();
const File oldFile (documentFile);
documentFile = newFile;
String error;
Result result (Result::fail (TRANS("The file doesn't exist")));
if (newFile.existsAsFile())
{
error = loadDocument (newFile);
result = loadDocument (newFile);
if (error.isEmpty())
if (result.wasOk())
{
setChangedFlag (false);
MouseCursor::hideWaitCursor();
setLastDocumentOpened (newFile);
return true;
return result;
}
}
else
{
error = "The file doesn't exist";
}
documentFile = oldFile;
MouseCursor::hideWaitCursor();
if (showMessageOnFailure)
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon,
TRANS("Failed to open file..."),
TRANS("There was an error while trying to load the file:\n\n")
+ newFile.getFullPathName()
+ "\n\n"
+ error);
}
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
TRANS("Failed to open file..."),
TRANS("There was an error while trying to load the file: FLNM")
.replace ("FLNM", "\n" + newFile.getFullPathName())
+ "\n\n"
+ result.getErrorMessage());
return false;
return result;
}
bool FileBasedDocument::loadFromUserSpecifiedFile (const bool showMessageOnFailure)
#if JUCE_MODAL_LOOPS_PERMITTED
Result FileBasedDocument::loadFromUserSpecifiedFile (const bool showMessageOnFailure)
{
FileChooser fc (openFileDialogTitle,
getLastDocumentOpened(),
@@ -120,7 +112,19 @@ bool FileBasedDocument::loadFromUserSpecifiedFile (const bool showMessageOnFailu
if (fc.browseForFileToOpen())
return loadFrom (fc.getResult(), showMessageOnFailure);
return false;
return Result::fail (TRANS("User cancelled"));
}
static bool askToOverwriteFile (const File& newFile)
{
return AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
TRANS("File already exists"),
TRANS("There's already a file called: FLNM")
.replace ("FLNM", newFile.getFullPathName())
+ "\n\n"
+ TRANS("Are you sure you want to overwrite it?"),
TRANS("Overwrite"),
TRANS("Cancel"));
}
//==============================================================================
@@ -141,39 +145,26 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAs (const File& newFile,
if (newFile == File::nonexistent)
{
if (askUserForFileIfNotSpecified)
{
return saveAsInteractive (true);
}
else
{
// can't save to an unspecified file
jassertfalse;
return failedToWriteToFile;
}
// can't save to an unspecified file
jassertfalse;
return failedToWriteToFile;
}
if (warnAboutOverwritingExistingFiles && newFile.exists())
{
if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
TRANS("File already exists"),
TRANS("There's already a file called:\n\n")
+ newFile.getFullPathName()
+ TRANS("\n\nAre you sure you want to overwrite it?"),
TRANS("overwrite"),
TRANS("cancel")))
{
return userCancelledSave;
}
}
if (warnAboutOverwritingExistingFiles
&& newFile.exists()
&& ! askToOverwriteFile (newFile))
return userCancelledSave;
MouseCursor::showWaitCursor();
const File oldFile (documentFile);
documentFile = newFile;
String error (saveDocument (newFile));
const Result result (saveDocument (newFile));
if (error.isEmpty())
if (result.wasOk())
{
setChangedFlag (false);
MouseCursor::hideWaitCursor();
@@ -185,16 +176,13 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAs (const File& newFile,
MouseCursor::hideWaitCursor();
if (showMessageOnFailure)
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon,
TRANS("Error writing to file..."),
TRANS("An error occurred while trying to save \"")
+ getDocumentTitle()
+ TRANS("\" to the file:\n\n")
+ newFile.getFullPathName()
+ "\n\n"
+ error);
}
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
TRANS("Error writing to file..."),
TRANS("An error occurred while trying to save \"DCNM\" to the file: FLNM")
.replace ("DCNM", getDocumentTitle())
.replace ("FLNM", "\n" + newFile.getFullPathName())
+ "\n\n"
+ result.getErrorMessage());
return failedToWriteToFile;
}
@@ -206,22 +194,17 @@ FileBasedDocument::SaveResult FileBasedDocument::saveIfNeededAndUserAgrees()
const int r = AlertWindow::showYesNoCancelBox (AlertWindow::QuestionIcon,
TRANS("Closing document..."),
TRANS("Do you want to save the changes to \"")
+ getDocumentTitle() + "\"?",
TRANS("save"),
TRANS("discard changes"),
TRANS("cancel"));
TRANS("Do you want to save the changes to \"DCNM\"?")
.replace ("DCNM", getDocumentTitle()),
TRANS("Save"),
TRANS("Discard changes"),
TRANS("Cancel"));
if (r == 1)
{
// save changes
if (r == 1) // save changes
return save (true, true);
}
else if (r == 2)
{
// discard changes
if (r == 2) // discard changes
return savedOk;
}
return userCancelledSave;
}
@@ -261,19 +244,8 @@ FileBasedDocument::SaveResult FileBasedDocument::saveAsInteractive (const bool w
{
chosen = chosen.withFileExtension (fileExtension);
if (chosen.exists())
{
if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
TRANS("File already exists"),
TRANS("There's already a file called:")
+ "\n\n" + chosen.getFullPathName()
+ "\n\n" + TRANS("Are you sure you want to overwrite it?"),
TRANS("overwrite"),
TRANS("cancel")))
{
return userCancelledSave;
}
}
if (chosen.exists() && ! askToOverwriteFile (chosen))
return userCancelledSave;
}
setLastDocumentOpened (chosen);