Skip to content

Commit

Permalink
- multipage creator: fix file selector throwing an error when setting…
Browse files Browse the repository at this point in the history
… a file programatically

- multipage creator: switched plugin directories constant to local UseGlobalAppData property
  • Loading branch information
Christoph Hart committed Aug 17, 2024
1 parent 9947e60 commit 2c28220
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 21 deletions.
42 changes: 34 additions & 8 deletions hi_tools/hi_multipage/ActionComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,22 @@ Result JavascriptFunction::onAction()
{
auto fn = code.fromFirstOccurrenceOf("{BIND::", false, false).upToLastOccurrenceOf("}", false, false);

var thisObj(new DynamicObject());
var args[2];
args[0] = infoObject[mpid::ID];
args[1] = rootDialog.getState().globalState;
var::NativeFunctionArgs a(thisObj, args, 2);
try
{
var thisObj(new DynamicObject());
var args[2];
args[0] = infoObject[mpid::ID];
args[1] = rootDialog.getState().globalState;
var::NativeFunctionArgs a(thisObj, args, 2);

rootDialog.getState().callNativeFunction(fn, a, nullptr);
return Result::ok();
rootDialog.getState().callNativeFunction(fn, a, nullptr);

return Result::ok();
}
catch(Result& e)
{
return e;
}
}

if(code.startsWith("${"))
Expand Down Expand Up @@ -2411,7 +2419,7 @@ void PluginDirectories::loadConstants()
{
#if JUCE_MAC

auto useGlobal = rootDialog.useGlobalAppDataDirectory();
auto useGlobal = (bool)infoObject[mpid::UseGlobalAppData];

String prefix = useGlobal ? "" : "~";

Expand Down Expand Up @@ -2440,6 +2448,24 @@ void PluginDirectories::loadConstants()
#endif
}

#if HISE_MULTIPAGE_INCLUDE_EDIT
void PluginDirectories::createEditor(Dialog::PageInfo& rootList)
{
rootList.addChild<Type>({
{ mpid::ID, "Type"},
{ mpid::Type, PluginDirectories::getStaticId().toString() },
{ mpid::Help, "Adding this will load the plugin directories as constant" }
});

rootList.addChild<Button>({
{ mpid::ID, mpid::UseGlobalAppData.toString() },
{ mpid::Text, mpid::UseGlobalAppData.toString() },
{ mpid::Value, infoObject[mpid::UseGlobalAppData] },
{ mpid::Help, "Whether to use the global or user plugin folder." }
});
}
#endif

void OperatingSystem::loadConstants()
{

Expand Down
2 changes: 1 addition & 1 deletion hi_tools/hi_multipage/ActionComponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ struct PluginDirectories: public Constants

String getDescription() const override { return "Plugin Directories";}


CREATE_EDITOR_OVERRIDE;

void loadConstants() override;
};
Expand Down
20 changes: 8 additions & 12 deletions hi_tools/hi_multipage/InputComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1549,21 +1549,17 @@ Result FileSelector::checkGlobalState(var globalState)
{
auto& fileSelector = getComponent<BetterFileSelector>();
auto f = fileSelector.getCurrentFile();

if(f == File() && !fileSelector.fileLabel.isEmpty())
{
f = File(fileSelector.fileLabel.getText());

if(isDirectory && !f.isDirectory())
{
auto i = rootDialog.createModalPopup<MarkdownText>({
{ mpid::Text, "Do you want to create the directory \n> " + String(f.getFullPathName()) }
});

rootDialog.showModalPopup(true, i);
}
f = File(fileSelector.fileLabel.getText());
}


if(isDirectory && !f.isDirectory() && f != File())
{
f.createDirectory();
}

if(f != File() && !f.isRoot() && (f.isDirectory() || f.existsAsFile()))
{
writeState(f.getFullPathName());
Expand Down

0 comments on commit 2c28220

Please sign in to comment.