1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Set the default value of JUCE_MODAL_LOOPS_PERMITTED to 0

See BREAKING-CHANGES.txt for more details.
This commit is contained in:
Tom Poole 2021-06-30 13:00:21 +01:00
parent f1768843fb
commit fe4ba9071b
79 changed files with 3423 additions and 1332 deletions

File diff suppressed because it is too large Load diff

View file

@ -72,7 +72,7 @@ public:
@see setChangedFlag, changed
*/
bool hasChangedSinceSaved() const { return changedSinceSave; }
bool hasChangedSinceSaved() const;
/** Called to indicate that the document has changed and needs saving.
@ -98,7 +98,7 @@ public:
//==============================================================================
/** Tries to open a file.
If the file opens correctly, the document's file (see the getFile() method) is set
If the file opens correctly the document's file (see the getFile() method) is set
to this new one; if it fails, the document's file is left unchanged, and optionally
a message box is shown telling the user there was an error.
@ -110,6 +110,22 @@ public:
bool showMessageOnFailure,
bool showWaitCursor = true);
/** Tries to open a file.
The callback is called with the result indicating whether the new file loaded
successfully, or the error message if it failed.
If the file opens correctly the document's file (see the getFile() method) is set
to this new one; if it fails, the document's file is left unchanged, and optionally
a message box is shown telling the user there was an error.
@see loadDocumentAsync, loadFromUserSpecifiedFileAsync
*/
void loadFromAsync (const File& fileToLoadFrom,
bool showMessageOnFailure,
std::function<void (Result)> callback);
#if JUCE_MODAL_LOOPS_PERMITTED
/** Asks the user for a file and tries to load it.
This will pop up a dialog box using the title, file extension and
@ -122,6 +138,19 @@ public:
@see loadFrom
*/
Result loadFromUserSpecifiedFile (bool showMessageOnFailure);
#endif
/** Asks the user for a file and tries to load it.
This will pop up a dialog box using the title, file extension and
wildcard specified in the document's constructor, and asks the user
for a file. If they pick one, the loadFrom() method is used to
try to load it, optionally showing a message if it fails. The result
of the operation is provided in the callback function.
@see loadFrom
*/
void loadFromUserSpecifiedFileAsync (bool showMessageOnFailure, std::function<void (Result)> callback);
//==============================================================================
/** A set of possible outcomes of one of the save() methods
@ -133,6 +162,7 @@ public:
failedToWriteToFile /**< indicates that it tried to write to a file but this failed. */
};
#if JUCE_MODAL_LOOPS_PERMITTED
/** Tries to save the document to the last file it was saved or loaded from.
This will always try to write to the file, even if the document isn't flagged as
@ -147,7 +177,26 @@ public:
*/
SaveResult save (bool askUserForFileIfNotSpecified,
bool showMessageOnFailure);
#endif
/** Tries to save the document to the last file it was saved or loaded from.
This will always try to write to the file, even if the document isn't flagged as
having changed.
@param askUserForFileIfNotSpecified if there's no file currently specified and this is
true, it will prompt the user to pick a file, as if
saveAsInteractive() was called.
@param showMessageOnFailure if true it will show a warning message when if the
save operation fails
@param callback called after the save operation with the result
@see saveIfNeededAndUserAgrees, saveAs, saveAsInteractive
*/
void saveAsync (bool askUserForFileIfNotSpecified,
bool showMessageOnFailure,
std::function<void (SaveResult)> callback);
#if JUCE_MODAL_LOOPS_PERMITTED
/** If the file needs saving, it'll ask the user if that's what they want to do, and save
it if they say yes.
@ -169,7 +218,31 @@ public:
@see save, saveAs, saveAsInteractive
*/
SaveResult saveIfNeededAndUserAgrees();
#endif
/** If the file needs saving, it'll ask the user if that's what they want to do, and save
it if they say yes.
If you've got a document open and want to close it (e.g. to quit the app), this is the
method to call.
If the document doesn't need saving the callback will be called with the value savedOk
so you can go ahead and delete the document.
If it does need saving it'll prompt the user, and if they say "discard changes" the
callback will be called with savedOk, so again, you can safely delete the document.
If the user clicks "cancel", the callback will be aclled with userCancelledSave, so
you can abort the close-document operation.
And if they click "save changes", it'll try to save and the callback will be called
with either savedOk, or failedToWriteToFile if there was a problem.
@see saveAsync, saveAsAsync, saveAsInteractiveAsync
*/
void saveIfNeededAndUserAgreesAsync (std::function<void (SaveResult)> callback);
#if JUCE_MODAL_LOOPS_PERMITTED
/** Tries to save the document to a specified file.
If this succeeds, it'll also change the document's internal file (as returned by
@ -192,6 +265,45 @@ public:
bool askUserForFileIfNotSpecified,
bool showMessageOnFailure,
bool showWaitCursor = true);
#endif
/** Tries to save the document to a specified file.
If this succeeds, it'll also change the document's internal file (as returned by
the getFile() method). If it fails, the file will be left unchanged.
@param newFile the file to try to write to
@param warnAboutOverwritingExistingFiles if true and the file exists, it'll ask the user
first if they want to overwrite it
@param askUserForFileIfNotSpecified if the file is non-existent and this is true, it'll
use the saveAsInteractive() method to ask the user
for a filename
@param showMessageOnFailure if true and the write operation fails, it'll show
a message box to warn the user
@param callback called with the result of the save operation
@see saveIfNeededAndUserAgreesAsync, saveAsync, saveAsInteractiveAsync
*/
void saveAsAsync (const File& newFile,
bool warnAboutOverwritingExistingFiles,
bool askUserForFileIfNotSpecified,
bool showMessageOnFailure,
std::function<void (SaveResult)> callback);
#if JUCE_MODAL_LOOPS_PERMITTED
/** Prompts the user for a filename and tries to save to it.
This will pop up a dialog box using the title, file extension and
wildcard specified in the document's constructor, and asks the user
for a file. If they pick one, the saveAs() method is used to try to save
to this file.
@param warnAboutOverwritingExistingFiles if true and the file exists, it'll ask
the user first if they want to overwrite it
@see saveIfNeededAndUserAgrees, save, saveAs
*/
SaveResult saveAsInteractive (bool warnAboutOverwritingExistingFiles);
#endif
/** Prompts the user for a filename and tries to save to it.
@ -201,10 +313,12 @@ public:
to this file.
@param warnAboutOverwritingExistingFiles if true and the file exists, it'll ask
the user first if they want to overwrite it
@see saveIfNeededAndUserAgrees, save, saveAs
the user first if they want to overwrite it
@param callback called with the result of the save operation
@see saveIfNeededAndUserAgreesAsync, saveAsync, saveAsAsync
*/
SaveResult saveAsInteractive (bool warnAboutOverwritingExistingFiles);
void saveAsInteractiveAsync (bool warnAboutOverwritingExistingFiles,
std::function<void (SaveResult)> callback);
//==============================================================================
/** Returns the file that this document was last successfully saved or loaded from.
@ -214,7 +328,7 @@ public:
It is changed when one of the load or save methods is used, or when setFile()
is used to explicitly set it.
*/
const File& getFile() const { return documentFile; }
const File& getFile() const;
/** Sets the file that this document thinks it was loaded from.
@ -224,7 +338,6 @@ public:
*/
void setFile (const File& newFile);
protected:
//==============================================================================
/** Overload this to return the title of the document.
@ -239,11 +352,33 @@ protected:
*/
virtual Result loadDocument (const File& file) = 0;
/** This method should try to load your document from the given file, then
call the provided callback on the message thread, passing the result of the load.
By default, this will synchronously call through to loadDocument.
For longer-running load operations, you may wish to override this function to
run the load on a background thread, and then to call the callback later on the
message thread to signal that the load has completed.
*/
virtual void loadDocumentAsync (const File& file, std::function<void (Result)> callback);
/** This method should try to write your document to the given file.
@returns a Result object to indicate the whether there was an error.
*/
virtual Result saveDocument (const File& file) = 0;
/** This method should try to write your document to the given file, then
call the provided callback on the message thread, passing the result of the write.
By default, this will synchronously call through to saveDocument.
For longer-running save operations, you may wish to override this function to
run the save on a background thread, and then to call the callback later on the
message thread to signal that the save has completed.
*/
virtual void saveDocumentAsync (const File& file, std::function<void (Result)> callback);
/** This is used for dialog boxes to make them open at the last folder you
were using.
@ -277,21 +412,18 @@ protected:
*/
virtual void setLastDocumentOpened (const File& file) = 0;
#if JUCE_MODAL_LOOPS_PERMITTED || DOXYGEN
/** This is called by saveAsInteractive() to allow you to optionally customise the
/** This is called by saveAsInteractiveAsync() to allow you to optionally customise the
filename that the user is presented with in the save dialog.
The defaultFile parameter is an initial suggestion based on what the class knows
about the current document - you can return a variation on this file with a different
extension, etc, or just return something completely different.
*/
virtual File getSuggestedSaveAsFile (const File& defaultFile);
#endif
private:
//==============================================================================
File documentFile;
bool changedSinceSave = false;
String fileExtension, fileWildcard, openFileDialogTitle, saveFileDialogTitle;
class Pimpl;
std::unique_ptr<Pimpl> pimpl;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileBasedDocument)
};