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

Add MessageBoxOptions class for specifying a set of AlertWindow and NativeMessageBox options

- Add AlertWindow::show() and showAsync() methods that take a MessageBoxOptions argument
  - Add NativeMessageBox::show() and showAsync() methods that take a MessageBoxOptions argument
  - Update the DialogsDemo to demonstrate the new methods
  - Deprecate AlertWindow::showNativeDialogBox() in favour of the NativeMessageBox methods
  - Pass button strings specified in MesssageBoxOptions to native dialog boxes correctly
  - Use modern TaskDialog on Windows for the native dialog box where available
This commit is contained in:
ed 2021-07-21 16:34:12 +01:00
parent 89ca17cf34
commit 551d7b9c5b
54 changed files with 1357 additions and 595 deletions

View file

@ -98,7 +98,7 @@ void PluginGraph::addPluginCallback (std::unique_ptr<AudioPluginInstance> instan
{
if (instance == nullptr)
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
TRANS("Couldn't create plugin"),
error);
}

View file

@ -222,7 +222,7 @@ File NewProjectWizard::getLastWizardFolder()
static void displayFailedFilesMessage (const StringArray& failedFiles)
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
TRANS("Errors in Creating Project!"),
TRANS("The following files couldn't be written:")
+ "\n\n"
@ -244,7 +244,7 @@ static void prepareDirectory (const File& targetFolder, Callback&& callback)
}
else if (FileHelpers::containsAnyNonHiddenFiles (targetFolder))
{
AlertWindow::showOkCancelBox (AlertWindow::InfoIcon,
AlertWindow::showOkCancelBox (MessageBoxIconType::InfoIcon,
TRANS("New JUCE Project"),
TRANS("You chose the folder:\n\nXFLDRX\n\n").replace ("XFLDRX", targetFolder.getFullPathName())
+ TRANS("This folder isn't empty - are you sure you want to create the project there?")

View file

@ -122,7 +122,7 @@ private:
if (postStrings.size() != preStrings.size())
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
TRANS("Error"),
TRANS("The pre- and post-translation text doesn't match!\n\n"
"Perhaps it got mangled by the translator?"));
@ -138,7 +138,7 @@ private:
if (Project* project = ProjucerApplication::getApp().mainWindowList.getFrontmostProject())
setPreTranslationText (TranslationHelpers::getPreTranslationText (*project));
else
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Translation Tool",
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon, "Translation Tool",
"This will only work when you have a project open!");
}

View file

@ -835,7 +835,7 @@ void ProjucerApplication::launchDemoRunner()
"Couldn't find a compiled version of the Demo Runner."
" Please compile the Demo Runner project in the JUCE examples directory.",
"OK", {}, {},
AlertWindow::WarningIcon, 1,
MessageBoxIconType::WarningIcon, 1,
mainWindowList.getFrontmostWindow (false)));
demoRunnerAlert->enterModalState (true, ModalCallbackFunction::create ([this] (int)
{
@ -847,7 +847,7 @@ void ProjucerApplication::launchDemoRunner()
"Couldn't find a compiled version of the Demo Runner."
" Do you want to open the project?",
"Open project", "Cancel", {},
AlertWindow::QuestionIcon, 2,
MessageBoxIconType::QuestionIcon, 2,
mainWindowList.getFrontmostWindow (false)));
demoRunnerAlert->enterModalState (true, ModalCallbackFunction::create ([this, demoRunnerFile] (int retVal)
{
@ -1102,7 +1102,7 @@ void ProjucerApplication::createNewProjectFromClipboard()
{
if (errorString.isNotEmpty())
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Error", errorString);
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon, "Error", errorString);
tempFile.deleteFile();
}
};

View file

@ -56,7 +56,7 @@ void LatestVersionCheckerAndUpdater::run()
if (info == nullptr)
{
if (! backgroundCheck)
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"Update Server Communication Error",
"Failed to communicate with the JUCE update server.\n"
"Please try again in a few minutes.\n\n"
@ -68,7 +68,7 @@ void LatestVersionCheckerAndUpdater::run()
if (! info->isNewerVersionThanCurrent())
{
if (! backgroundCheck)
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::InfoIcon,
"No New Version Available",
"Your JUCE version is up to date.");
return;
@ -109,7 +109,7 @@ void LatestVersionCheckerAndUpdater::run()
}
if (! backgroundCheck)
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"Failed to find any new downloads",
"Please try again in a few minutes.");
}
@ -275,13 +275,13 @@ void LatestVersionCheckerAndUpdater::askUserForLocationToDownload (const Version
{
if (targetFolder.getChildFile (".git").isDirectory())
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Downloading New JUCE Version",
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon, "Downloading New JUCE Version",
targetFolderPath + "\n\nis a GIT repository!\n\nYou should use a \"git pull\" to update it to the latest version.");
return;
}
AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
AlertWindow::showOkCancelBox (MessageBoxIconType::WarningIcon,
"Overwrite Existing JUCE Folder?",
"Do you want to replace the folder\n\n" + targetFolderPath + "\n\nwith the latest version from juce.com?\n\n"
"This will move the existing folder to " + targetFolderPath + "_old.\n\n"
@ -295,7 +295,7 @@ void LatestVersionCheckerAndUpdater::askUserForLocationToDownload (const Version
if (targetFolder.exists())
{
AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
AlertWindow::showOkCancelBox (MessageBoxIconType::WarningIcon,
"Existing File Or Directory",
"Do you want to move\n\n" + targetFolderPath + "\n\nto\n\n" + targetFolderPath + "_old?",
{},
@ -388,7 +388,7 @@ private:
result = install (zipData);
if (result.failed())
MessageManager::callAsync ([result] { AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
MessageManager::callAsync ([result] { AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"Installation Failed",
result.getErrorMessage()); });
else

View file

@ -452,7 +452,7 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
if (generatorResult != Result::ok())
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"PIP Error.",
generatorResult.getErrorMessage());
@ -464,7 +464,7 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
if (! generator->createMainCpp())
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"PIP Error.",
"Failed to create Main.cpp.");
@ -481,7 +481,7 @@ void MainWindow::openPIP (const File& pipFile, std::function<void (bool)> callba
if (! openedSuccessfully)
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"PIP Error.",
"Failed to open .jucer file.");

View file

@ -176,7 +176,7 @@ void OpenDocumentManager::saveIfNeededAndUserAgrees (OpenDocumentManager::Docume
return;
}
AlertWindow::showYesNoCancelBox (AlertWindow::QuestionIcon,
AlertWindow::showYesNoCancelBox (MessageBoxIconType::QuestionIcon,
TRANS("Closing document..."),
TRANS("Do you want to save the changes to \"")
+ doc->getName() + "\"?",

View file

@ -658,7 +658,7 @@ void CppCodeEditorComponent::insertComponentClass()
{
asyncAlertWindow = std::make_unique<AlertWindow> (TRANS ("Insert a new Component class"),
TRANS ("Please enter a name for the new class"),
AlertWindow::NoIcon,
MessageBoxIconType::NoIcon,
nullptr);
const String classNameField { "Class Name" };

View file

@ -265,7 +265,7 @@ void ResourceEditorPanel::reloadAll()
failed.add (document.getResources().getResourceNames() [i]);
if (failed.size() > 0)
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
TRANS("Reloading resources"),
TRANS("The following resources couldn't be reloaded from their original files:\n\n")
+ failed.joinIntoString (", "));

View file

@ -143,7 +143,7 @@ void BinaryResources::browseForResource (const String& title,
if (! add (name, fc.getResult()))
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
TRANS("Adding Resource"),
TRANS("Failed to load the file!"));

View file

@ -682,14 +682,14 @@ void EnabledModulesList::addModuleOfferingToCopy (const File& f, bool isFromUser
if (! m.isValid())
{
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::InfoIcon,
"Add Module", "This wasn't a valid module folder!");
return;
}
if (isModuleEnabled (m.getID()))
{
AlertWindow::showMessageBoxAsync (AlertWindow::InfoIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::InfoIcon,
"Add Module", "The project already contains this module!");
return;
}

View file

@ -90,7 +90,7 @@ public:
safeThis->project.getUndoManagerFor (parent));
};
AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
AlertWindow::showOkCancelBox (MessageBoxIconType::WarningIcon,
"Delete Exporter",
"Are you sure you want to delete this export target?",
"",
@ -244,7 +244,7 @@ public:
void deleteItem() override
{
AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
AlertWindow::showOkCancelBox (MessageBoxIconType::WarningIcon,
"Delete Configuration",
"Are you sure you want to delete this configuration?",
"",

View file

@ -138,7 +138,7 @@ public:
if (filesToTrash.size() > maxFilesToList)
fileList << "\n...plus " << (filesToTrash.size() - maxFilesToList) << " more files...";
AlertWindow::showYesNoCancelBox (AlertWindow::NoIcon,
AlertWindow::showYesNoCancelBox (MessageBoxIconType::NoIcon,
"Delete Project Items",
"As well as removing the selected item(s) from the project, do you also want to move their files to the trash:\n\n"
+ fileList,
@ -521,7 +521,7 @@ public:
{
if (newName != File::createLegalFileName (newName))
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"File Rename",
"That filename contained some illegal characters!");
triggerAsyncRename (item);
@ -538,7 +538,7 @@ public:
if (correspondingItem.isValid())
{
AlertWindow::showOkCancelBox (AlertWindow::NoIcon,
AlertWindow::showOkCancelBox (MessageBoxIconType::NoIcon,
"File Rename",
"Do you also want to rename the corresponding file \"" + correspondingFile.getFileName() + "\" to match?",
{},
@ -552,7 +552,7 @@ public:
if (! parent->item.renameFile (newFile))
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"File Rename",
"Failed to rename \"" + oldFile.getFullPathName() + "\"!\n\nCheck your file permissions!");
return;
@ -560,7 +560,7 @@ public:
if (! correspondingItem.renameFile (newFile.withFileExtension (correspondingFile.getFileExtension())))
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"File Rename",
"Failed to rename \"" + correspondingFile.getFullPathName() + "\"!\n\nCheck your file permissions!");
}
@ -571,7 +571,7 @@ public:
if (! item.renameFile (newFile))
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"File Rename",
"Failed to rename the file!\n\nCheck your file permissions!");
}

View file

@ -378,7 +378,7 @@ private:
{
missingDependencies = enabledModules.getExtraDependenciesNeeded (moduleID);
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"Adding Missing Dependencies",
"Couldn't locate some of these modules - you'll need to find their "
"folders manually and add them to the list.");

View file

@ -320,7 +320,7 @@ void ProjectContentComponent::closeDocument()
static void showSaveWarning (OpenDocumentManager::Document* currentDocument)
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
TRANS("Save failed!"),
TRANS("Couldn't save the file:")
+ "\n" + currentDocument->getFile().getFullPathName());

View file

@ -407,7 +407,7 @@ void Project::removeDefunctExporters()
if (ProjucerApplication::getApp().isRunningCommandLine)
std::cout << "WARNING! The " + oldExporters[key] + " Exporter is deprecated. The exporter will be removed from this project." << std::endl;
else
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
TRANS (oldExporters[key]),
TRANS ("The " + oldExporters[key] + " Exporter is deprecated. The exporter will be removed from this project."));

View file

@ -723,7 +723,7 @@ public:
"Since JUCE 4.2, this is instead done using \"AU/VST/VST2/AAX/RTAS Binary Location\" in the Xcode (OS X) configuration settings.\n\n"
"Click 'Update' to remove the script (otherwise your plug-in may not compile correctly).";
if (AlertWindow::showOkCancelBox (AlertWindow::WarningIcon,
if (AlertWindow::showOkCancelBox (MessageBoxIconType::WarningIcon,
"Project settings: " + project.getDocumentTitle(),
alertWindowText, "Update", "Cancel", nullptr, nullptr))
postbuildCommandValue.resetToDefault();

View file

@ -171,7 +171,7 @@ private:
{
asyncAlertWindow = std::make_unique<AlertWindow> (TRANS ("Create new Component class"),
TRANS ("Please enter the name for the new class"),
AlertWindow::NoIcon, nullptr);
MessageBoxIconType::NoIcon, nullptr);
asyncAlertWindow->addTextEditor (getClassNameFieldName(), String(), String(), false);
asyncAlertWindow->addButton (TRANS ("Create Files"), 1, KeyPress (KeyPress::returnKey));
@ -235,7 +235,7 @@ public:
//==============================================================================
void NewFileWizard::Type::showFailedToWriteMessage (const File& file)
{
AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
AlertWindow::showMessageBoxAsync (MessageBoxIconType::WarningIcon,
"Failed to Create File!",
"Couldn't write to the file: " + file.getFullPathName());
}