Skip to content

Commit bf1d4d1

Browse files
committed
Allow loading signal chain from command line
1 parent e31f6f5 commit bf1d4d1

3 files changed

Lines changed: 21 additions & 8 deletions

File tree

Source/Main.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ class OpenEphysApplication : public JUCEApplication
6161

6262
StringArray parameters;
6363
parameters.addTokens(commandLine," ","\"");
64+
parameters.removeEmptyStrings();
6465

6566
#ifdef WIN32
6667
//glWinInit();
6768

68-
if (parameters.contains("--console",true))
69+
int consoleArg = parameters.indexOf("--console", true);
70+
if (consoleArg != -1)
6971
{
72+
parameters.remove(consoleArg);
7073
if (AllocConsole())
7174
{
7275
freopen("CONOUT$","w",stdout);
@@ -81,14 +84,20 @@ class OpenEphysApplication : public JUCEApplication
8184

8285
#endif
8386

84-
8587
customLookAndFeel = new CustomLookAndFeel();
8688
LookAndFeel::setDefaultLookAndFeel(customLookAndFeel);
8789

88-
mainWindow = new MainWindow();
89-
90-
9190

91+
// signal chain to load
92+
if (!parameters.isEmpty())
93+
{
94+
File fileToLoad(File::getCurrentWorkingDirectory().getChildFile(parameters[0]));
95+
mainWindow = new MainWindow(fileToLoad);
96+
}
97+
else
98+
{
99+
mainWindow = new MainWindow();
100+
}
92101
}
93102

94103
void shutdown() { }

Source/MainWindow.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static inline File getSavedStateDirectory() {
3939
#endif
4040
}
4141

42-
MainWindow::MainWindow()
42+
MainWindow::MainWindow(const File& fileToLoad)
4343
: DocumentWindow(JUCEApplication::getInstance()->getApplicationName(),
4444
Colour(Colours::black),
4545
DocumentWindow::allButtons)
@@ -83,7 +83,11 @@ static inline File getSavedStateDirectory() {
8383
// Constraining the window's size doesn't seem to work:
8484
setResizeLimits(500, 500, 10000, 10000);
8585

86-
if (shouldReloadOnStartup)
86+
if (!fileToLoad.getFullPathName().isEmpty())
87+
{
88+
ui->getEditorViewport()->loadState(fileToLoad);
89+
}
90+
else if (shouldReloadOnStartup)
8791
{
8892
File file = getSavedStateDirectory().getChildFile("lastConfig.xml");
8993
ui->getEditorViewport()->loadState(file);

Source/MainWindow.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class MainWindow : public DocumentWindow
4646

4747
/** Initializes the MainWindow, creates the AudioComponent, ProcessorGraph,
4848
and UIComponent, and sets the window boundaries. */
49-
MainWindow();
49+
MainWindow(const File& fileToLoad = File());
5050

5151
/** Destroys the AudioComponent, ProcessorGraph, and UIComponent, and saves the window boundaries. */
5252
~MainWindow();

0 commit comments

Comments
 (0)