mirror of
https://codeberg.org/armin/chromaflock.git
synced 2026-09-01 04:10:47 +02:00
Fix preset dialog default dir resolving to / on Linux
This commit is contained in:
parent
9b1d34b24c
commit
54c99d90ee
1 changed files with 26 additions and 2 deletions
|
|
@ -1,6 +1,30 @@
|
||||||
#include "PluginEditor.h"
|
#include "PluginEditor.h"
|
||||||
#include <BinaryData.h>
|
#include <BinaryData.h>
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
// Returns a sensible default directory for preset files. On Linux,
|
||||||
|
// File::getSpecialLocation (userHomeDirectory) can resolve to "/" when the
|
||||||
|
// home directory can't be determined, so fall back through $HOME, the user
|
||||||
|
// documents directory, and finally the current working directory.
|
||||||
|
juce::File getDefaultPresetDirectory()
|
||||||
|
{
|
||||||
|
auto test = [] (const juce::File& f) { return f.isDirectory() && f.createDirectory().wasOk(); };
|
||||||
|
|
||||||
|
if (auto* homeEnv = std::getenv ("HOME"))
|
||||||
|
if (test (juce::File (homeEnv)))
|
||||||
|
return juce::File (homeEnv);
|
||||||
|
|
||||||
|
if (test (juce::File::getSpecialLocation (juce::File::userHomeDirectory)))
|
||||||
|
return juce::File::getSpecialLocation (juce::File::userHomeDirectory);
|
||||||
|
|
||||||
|
if (test (juce::File::getSpecialLocation (juce::File::userDocumentsDirectory)))
|
||||||
|
return juce::File::getSpecialLocation (juce::File::userDocumentsDirectory);
|
||||||
|
|
||||||
|
return juce::File::getCurrentWorkingDirectory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
KnobLookAndFeel::KnobLookAndFeel() {
|
KnobLookAndFeel::KnobLookAndFeel() {
|
||||||
knobOverlay = juce::ImageCache::getFromMemory(BinaryData::metalknob_png,
|
knobOverlay = juce::ImageCache::getFromMemory(BinaryData::metalknob_png,
|
||||||
BinaryData::metalknob_pngSize);
|
BinaryData::metalknob_pngSize);
|
||||||
|
|
@ -907,7 +931,7 @@ juce::String MainContentComponent::currentPresetName() const {
|
||||||
|
|
||||||
void MainContentComponent::savePresetFile() {
|
void MainContentComponent::savePresetFile() {
|
||||||
auto* chooser = new juce::FileChooser("Save ChromaFlock Preset",
|
auto* chooser = new juce::FileChooser("Save ChromaFlock Preset",
|
||||||
juce::File::getSpecialLocation(juce::File::userHomeDirectory)
|
getDefaultPresetDirectory()
|
||||||
.getChildFile("chromaflock-" + currentPresetName().replaceCharacter(' ', '-') + ".cfl"),
|
.getChildFile("chromaflock-" + currentPresetName().replaceCharacter(' ', '-') + ".cfl"),
|
||||||
"*.cfl");
|
"*.cfl");
|
||||||
|
|
||||||
|
|
@ -945,7 +969,7 @@ void MainContentComponent::savePresetFile() {
|
||||||
|
|
||||||
void MainContentComponent::loadPresetFile() {
|
void MainContentComponent::loadPresetFile() {
|
||||||
auto* chooser = new juce::FileChooser("Load ChromaFlock Preset",
|
auto* chooser = new juce::FileChooser("Load ChromaFlock Preset",
|
||||||
juce::File::getSpecialLocation(juce::File::userHomeDirectory),
|
getDefaultPresetDirectory(),
|
||||||
"*.cfl");
|
"*.cfl");
|
||||||
|
|
||||||
chooser->launchAsync(juce::FileBrowserComponent::openMode
|
chooser->launchAsync(juce::FileBrowserComponent::openMode
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue