diff --git a/extras/Introjucer/Source/Project/jucer_ConfigTree_Modules.h b/extras/Introjucer/Source/Project/jucer_ConfigTree_Modules.h index b795e13e0f..6140acb401 100644 --- a/extras/Introjucer/Source/Project/jucer_ConfigTree_Modules.h +++ b/extras/Introjucer/Source/Project/jucer_ConfigTree_Modules.h @@ -40,7 +40,12 @@ public: bool isMissing() override { return hasMissingDependencies(); } Icon getIcon() const override { return Icon (getIcons().jigsaw, getContrastingColour (Colours::red, 0.5f)); } void showDocument() override { showSettingsPage (new ModuleSettingsPanel (project, moduleID)); } - void deleteItem() override { project.getModules().removeModule (moduleID); } + + void deleteItem() override + { + // NB: this local string copy essential, as this object will be deleted during the call + project.getModules().removeModule (String (moduleID)); + } void showPopupMenu() override { diff --git a/extras/Introjucer/Source/Project/jucer_Module.cpp b/extras/Introjucer/Source/Project/jucer_Module.cpp index b72d780d25..45820053ea 100644 --- a/extras/Introjucer/Source/Project/jucer_Module.cpp +++ b/extras/Introjucer/Source/Project/jucer_Module.cpp @@ -699,7 +699,7 @@ void EnabledModuleList::sortAlphabetically() state.sort (sorter, getUndoManager(), false); } -Value EnabledModuleList::shouldCopyModuleFilesLocally (const String& moduleID) +Value EnabledModuleList::shouldCopyModuleFilesLocally (const String& moduleID) const { return state.getChildWithProperty (Ids::ID, moduleID) .getPropertyAsValue (Ids::useLocalCopy, getUndoManager()); @@ -735,7 +735,7 @@ void EnabledModuleList::addModule (const File& moduleManifestFile, bool copyLoca void EnabledModuleList::removeModule (const String& moduleID) { - for (int i = 0; i < state.getNumChildren(); ++i) + for (int i = state.getNumChildren(); --i >= 0;) if (state.getChild(i) [Ids::ID] == moduleID) state.removeChild (i, getUndoManager()); @@ -797,7 +797,7 @@ StringArray EnabledModuleList::getExtraDependenciesNeeded (const String& moduleI getDependencies (project, moduleID, dependencies); for (int i = 0; i < dependencies.size(); ++i) - if ((! project.getModules().isModuleEnabled (dependencies[i])) && dependencies[i] != moduleID) + if ((! isModuleEnabled (dependencies[i])) && dependencies[i] != moduleID) extraDepsNeeded.add (dependencies[i]); return extraDepsNeeded; @@ -807,9 +807,9 @@ bool EnabledModuleList::areMostModulesCopiedLocally() const { int numYes = 0, numNo = 0; - for (int i = project.getModules().getNumModules(); --i >= 0;) + for (int i = getNumModules(); --i >= 0;) { - if (project.getModules().shouldCopyModuleFilesLocally (project.getModules().getModuleID (i)).getValue()) + if (shouldCopyModuleFilesLocally (getModuleID (i)).getValue()) ++numYes; else ++numNo; @@ -818,6 +818,12 @@ bool EnabledModuleList::areMostModulesCopiedLocally() const return numYes > numNo; } +void EnabledModuleList::setLocalCopyModeForAllModules (bool copyLocally) +{ + for (int i = getNumModules(); --i >= 0;) + shouldCopyModuleFilesLocally (project.getModules().getModuleID (i)) = copyLocally; +} + File EnabledModuleList::findDefaultModulesFolder (Project& project) { ModuleList available; diff --git a/extras/Introjucer/Source/Project/jucer_Module.h b/extras/Introjucer/Source/Project/jucer_Module.h index 452f752ef2..b49efd9be3 100644 --- a/extras/Introjucer/Source/Project/jucer_Module.h +++ b/extras/Introjucer/Source/Project/jucer_Module.h @@ -123,7 +123,7 @@ public: bool isModuleEnabled (const String& moduleID) const; Value shouldShowAllModuleFilesInProject (const String& moduleID); - Value shouldCopyModuleFilesLocally (const String& moduleID); + Value shouldCopyModuleFilesLocally (const String& moduleID) const; void removeModule (const String& moduleID); bool isAudioPluginModuleMissing() const; @@ -145,6 +145,7 @@ public: String getModuleID (int index) const { return state.getChild (index) [Ids::ID].toString(); } bool areMostModulesCopiedLocally() const; + void setLocalCopyModeForAllModules (bool copyLocally); void sortAlphabetically(); static File findDefaultModulesFolder (Project&); diff --git a/extras/Introjucer/Source/Project/jucer_ModulesPanel.h b/extras/Introjucer/Source/Project/jucer_ModulesPanel.h index 13775dfbd1..14051214c3 100644 --- a/extras/Introjucer/Source/Project/jucer_ModulesPanel.h +++ b/extras/Introjucer/Source/Project/jucer_ModulesPanel.h @@ -33,7 +33,8 @@ public: : project (p), modulesValueTree (p.getModules().state), addWebModuleButton ("Download and add a module..."), - updateModuleButton ("Install updates to modules...") + updateModuleButton ("Install updates to modules..."), + setCopyModeButton ("Set copy-mode for all modules...") { table.getHeader().addColumn ("Module", nameCol, 180, 100, 400, TableHeaderComponent::notSortable); table.getHeader().addColumn ("Installed Version", versionCol, 100, 100, 100, TableHeaderComponent::notSortable); @@ -49,9 +50,12 @@ public: addAndMakeVisible (&addWebModuleButton); addAndMakeVisible (&updateModuleButton); + addAndMakeVisible (&setCopyModeButton); addWebModuleButton.addListener (this); updateModuleButton.addListener (this); updateModuleButton.setEnabled (false); + setCopyModeButton.addListener (this); + setCopyModeButton.setTriggeredOnMouseDown (true); modulesValueTree.addListener (this); lookAndFeelChanged(); @@ -72,9 +76,11 @@ public: table.setBounds (r.removeFromTop (table.getRowPosition (getNumRows() - 1, true).getBottom() + 20)); Rectangle buttonRow (r.removeFromTop (32).removeFromBottom (28)); - addWebModuleButton.setBounds (buttonRow.removeFromLeft (jmin (260, r.getWidth() / 2))); + addWebModuleButton.setBounds (buttonRow.removeFromLeft (jmin (260, r.getWidth() / 3))); buttonRow.removeFromLeft (8); - updateModuleButton.setBounds (buttonRow.removeFromLeft (jmin (260, r.getWidth() / 2))); + updateModuleButton.setBounds (buttonRow.removeFromLeft (jmin (260, r.getWidth() / 3))); + buttonRow.removeFromLeft (8); + setCopyModeButton.setBounds (buttonRow.removeFromLeft (jmin (260, r.getWidth() / 3))); } int getNumRows() override @@ -170,10 +176,9 @@ public: void buttonClicked (Button* b) { - if (b == &addWebModuleButton) - showAddModuleMenu(); - else if (b == &updateModuleButton) - showUpdateModulesMenu(); + if (b == &addWebModuleButton) showAddModuleMenu(); + else if (b == &updateModuleButton) showUpdateModulesMenu(); + else if (b == &setCopyModeButton) showCopyModeMenu(); } private: @@ -189,7 +194,7 @@ private: Project& project; ValueTree modulesValueTree; TableListBox table; - TextButton addWebModuleButton, updateModuleButton; + TextButton addWebModuleButton, updateModuleButton, setCopyModeButton; ScopedPointer listFromWebsite; void valueTreePropertyChanged (ValueTree&, const Identifier&) override { itemChanged(); } @@ -310,6 +315,18 @@ private: DownloadAndInstallThread::addModuleFromWebsite (project, *md); } + void showCopyModeMenu() + { + PopupMenu m; + m.addItem (1, "Set all modules to copy locally"); + m.addItem (2, "Set all modules to not copy locally"); + + int res = m.showAt (&setCopyModeButton); + + if (res != 0) + project.getModules().setLocalCopyModeForAllModules (res == 1); + } + struct WebsiteUpdateFetchThread : private Thread, private AsyncUpdater {