From 7a263209fc541bdd87b2e6f1dc5f9a05d76fa043 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Tue, 28 Jan 2014 18:16:39 -0500 Subject: [PATCH] Add reloadOnStartup flag --- Source/MainWindow.cpp | 22 +++++++++++++++++++++- Source/MainWindow.h | 5 +++++ Source/UI/UIComponent.cpp | 16 ++++++++++++++++ Source/UI/UIComponent.h | 3 ++- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/Source/MainWindow.cpp b/Source/MainWindow.cpp index c7e516550..ee6faa7a3 100644 --- a/Source/MainWindow.cpp +++ b/Source/MainWindow.cpp @@ -35,7 +35,7 @@ MainWindow::MainWindow() setResizable(true, // isResizable false); // useBottomCornerRisizer -- doesn't work very well - + shouldReloadOnStartup = false; // Create ProcessorGraph and AudioComponent, and connect them. // Callbacks will be set by the play button in the control panel @@ -70,6 +70,17 @@ MainWindow::MainWindow() // Constraining the window's size doesn't seem to work: setResizeLimits(300, 200, 10000, 10000); + if (shouldReloadOnStartup) + { + File executable = File::getSpecialLocation(File::currentExecutableFile); + File executableDirectory = executable.getParentDirectory(); + File file = executableDirectory.getChildFile("lastConfig.xml"); + + ui->getEditorViewport()->loadState(file); + } + + + } MainWindow::~MainWindow() @@ -87,6 +98,12 @@ MainWindow::~MainWindow() UIComponent* ui = (UIComponent*) getContentComponent(); ui->disableDataViewport(); + File executable = File::getSpecialLocation(File::currentExecutableFile); + File executableDirectory = executable.getParentDirectory(); + File file = executableDirectory.getChildFile("lastConfig.xml"); + + ui->getEditorViewport()->saveState(file); + setMenuBar(0); #if JUCE_MAC @@ -121,6 +138,7 @@ void MainWindow::saveWindowBounds() XmlElement* xml = new XmlElement("MAINWINDOW"); xml->setAttribute("version", JUCEApplication::getInstance()->getApplicationVersion()); + xml->setAttribute("shouldReloadOnStartup", shouldReloadOnStartup); XmlElement* bounds = new XmlElement("BOUNDS"); bounds->setAttribute("x",getScreenX()); @@ -183,6 +201,8 @@ void MainWindow::loadWindowBounds() String description; + shouldReloadOnStartup = xml->getBoolAttribute("shouldReloadOnStartup", false); + forEachXmlChildElement(*xml, e) { diff --git a/Source/MainWindow.h b/Source/MainWindow.h index 7592b0432..82b4af6be 100644 --- a/Source/MainWindow.h +++ b/Source/MainWindow.h @@ -59,6 +59,9 @@ public: commands. */ ApplicationCommandManager commandManager; + /** Determines whether the last used configuration reloads upon startup. */ + bool shouldReloadOnStartup; + private: /** Saves the MainWindow's boundaries into the file "windowState.xml", located in the directory @@ -75,6 +78,8 @@ private: /** A pointer to the application's ProcessorGraph (owned by the MainWindow). */ ScopedPointer<ProcessorGraph> processorGraph; + + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainWindow) }; diff --git a/Source/UI/UIComponent.cpp b/Source/UI/UIComponent.cpp index bb8d55487..837bfc5f7 100755 --- a/Source/UI/UIComponent.cpp +++ b/Source/UI/UIComponent.cpp @@ -300,6 +300,8 @@ PopupMenu UIComponent::getMenuForIndex(int menuIndex, const String& menuName) { menu.addCommandItem(commandManager, openConfiguration); menu.addCommandItem(commandManager, saveConfiguration); + menu.addSeparator(); + menu.addCommandItem(commandManager, reloadOnStartup); #if !JUCE_MAC menu.addSeparator(); @@ -356,6 +358,7 @@ void UIComponent::getAllCommands(Array <CommandID>& commands) { const CommandID ids[] = {openConfiguration, saveConfiguration, + reloadOnStartup, undo, redo, copySignalChain, @@ -388,7 +391,12 @@ void UIComponent::getCommandInfo(CommandID commandID, ApplicationCommandInfo& re case saveConfiguration: result.setInfo("Save configuration", "Save the current processor graph.", "General", 0); result.addDefaultKeypress('S', ModifierKeys::commandModifier); + break; + + case reloadOnStartup: + result.setInfo("Reload on startup", "Load the last used configuration on startup.", "General", 0); result.setActive(!acquisitionStarted); + result.setTicked(mainWindow->shouldReloadOnStartup); break; case undo: @@ -499,6 +507,14 @@ bool UIComponent::perform(const InvocationInfo& info) break; } + + case reloadOnStartup: + { + mainWindow->shouldReloadOnStartup = !mainWindow->shouldReloadOnStartup; + + } + break; + case clearSignalChain: { getEditorViewport()->clearSignalChain(); diff --git a/Source/UI/UIComponent.h b/Source/UI/UIComponent.h index a8e5e5637..8b7cd0605 100755 --- a/Source/UI/UIComponent.h +++ b/Source/UI/UIComponent.h @@ -206,7 +206,8 @@ private: toggleSignalChain = 0x2009, toggleFileInfo = 0x2010, showHelp = 0x2011, - resizeWindow = 0x2012 + resizeWindow = 0x2012, + reloadOnStartup = 0x2013 }; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(UIComponent); -- GitLab