Skip to content
Snippets Groups Projects
Commit 642a6066 authored by Christopher Stawarz's avatar Christopher Stawarz
Browse files

On OS X, store lastConfig.xml and windowState.xml in ~/Library/Application Support/open-ephys

parent 839226a3
Branches
Tags
No related merge requests found
......@@ -25,6 +25,18 @@
#include <stdio.h>
//-----------------------------------------------------------------------
static inline File getSavedStateDirectory() {
#if defined(__APPLE__)
File dir = File::getSpecialLocation(File::userApplicationDataDirectory).getChildFile("Application Support/open-ephys");
if (!dir.isDirectory()) {
dir.createDirectory();
}
return std::move(dir);
#else
return File::getSpecialLocation(File::currentExecutableFile).getParentDirectory();
#endif
}
MainWindow::MainWindow()
: DocumentWindow(JUCEApplication::getInstance()->getApplicationName(),
Colour(Colours::black),
......@@ -71,10 +83,7 @@
if (shouldReloadOnStartup)
{
File executable = File::getSpecialLocation(File::currentExecutableFile);
File executableDirectory = executable.getParentDirectory();
File file = executableDirectory.getChildFile("lastConfig.xml");
File file = getSavedStateDirectory().getChildFile("lastConfig.xml");
ui->getEditorViewport()->loadState(file);
}
......@@ -97,10 +106,7 @@ MainWindow::~MainWindow()
UIComponent* ui = (UIComponent*) getContentComponent();
ui->disableDataViewport();
File executable = File::getSpecialLocation(File::currentExecutableFile);
File executableDirectory = executable.getParentDirectory();
File file = executableDirectory.getChildFile("lastConfig.xml");
File file = getSavedStateDirectory().getChildFile("lastConfig.xml");
ui->getEditorViewport()->saveState(file);
setMenuBar(0);
......@@ -130,9 +136,7 @@ void MainWindow::saveWindowBounds()
std::cout << "Saving window bounds." << std::endl;
std::cout << std::endl;
File executable = File::getSpecialLocation(File::currentExecutableFile);
File executableDirectory = executable.getParentDirectory();
File file = executableDirectory.getChildFile("windowState.xml");
File file = getSavedStateDirectory().getChildFile("windowState.xml");
XmlElement* xml = new XmlElement("MAINWINDOW");
......@@ -180,9 +184,7 @@ void MainWindow::loadWindowBounds()
//File file = File::getCurrentWorkingDirectory().getChildFile("windowState.xml");
File executable = File::getSpecialLocation(File::currentExecutableFile);
File executableDirectory = executable.getParentDirectory();
File file = executableDirectory.getChildFile("windowState.xml");
File file = getSavedStateDirectory().getChildFile("windowState.xml");
XmlDocument doc(file);
XmlElement* xml = doc.getDocumentElement();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment