void VstPluginWindow::savePreset () { File lastPresetDirectory = File (plugin->getValue (PROP_PLUGPRESETDIR, String::empty)); if (! lastPresetDirectory.exists()) lastPresetDirectory = Config::getInstance ()->lastPresetDirectory; FileChooser myChooser (T("Save a preset file..."), lastPresetDirectory, JOST_PRESET_WILDCARD, JOST_USE_NATIVE_FILE_CHOOSER); if (myChooser.browseForFileToSave (true)) { File fileToSave = myChooser.getResult().withFileExtension (JOST_PRESET_EXTENSION); XmlElement xml (JOST_PRESET_PRESETTAG); plugin->savePresetToXml (&xml); if (fileToSave.replaceWithText (xml.createDocument (String::empty))) { Config::getInstance()->addRecentPreset (fileToSave); plugin->setValue (PROP_PLUGPRESETDIR, fileToSave.getParentDirectory().getFullPathName()); } } }
void CabbageProjectWindow::createNewFile (String type) { FileChooser fc ("Select file name and location", File::getSpecialLocation (File::SpecialLocationType::userHomeDirectory), "", CabbageUtilities::shouldUseNativeBrowser()); if (fc.browseForFileToSave (false)) { String csdText; if (type == "newCsound") csdText = CabbageStrings::getNewCsoundFileText(); else if (type == "newEffect") csdText = CabbageStrings::getNewCabbageEffectFileText(); else csdText = CabbageStrings::getNewCabbageInstrumentFileText(); if (fc.getResult().existsAsFile()) { CabbageIDELookAndFeel lookAndFeel; const int result = CabbageUtilities::showYesNoMessage ("Do you wish to overwrite\nexiting file?", &lookAndFeel); if (result == 1) { writeNewFile (fc.getResult().withFileExtension (".csd"), csdText); } } else { writeNewFile (fc.getResult().withFileExtension (".csd"), csdText); } } }
void HostFilterComponent::handleSaveCommand(bool saveToExistingFileAndDontPrompt) { File tmp = currentSessionFile; bool userConfirmed = true; if (!saveToExistingFileAndDontPrompt || !tmp.exists()) { FileChooser myChooser (T("Save Session..."), currentSessionFile.exists() ? tmp : Config::getInstance ()->lastSessionDirectory, JOST_SESSION_WILDCARD, JOST_USE_NATIVE_FILE_CHOOSER); if (myChooser.browseForFileToSave (true)) tmp = myChooser.getResult().withFileExtension (JOST_SESSION_EXTENSION); else userConfirmed = false; } if (userConfirmed && (tmp != File::nonexistent)) { MemoryBlock fileData; getFilter ()->getStateInformation (fileData); if (tmp.replaceWithData (fileData.getData (), fileData.getSize())) { Config::getInstance()->addRecentSession (tmp); setCurrentSessionFile(tmp); Config::getInstance()->lastSessionFile = tmp; } } }
void ProjucerApplication::askUserToOpenFile() { FileChooser fc ("Open File"); if (fc.browseForFileToOpen()) openFile (fc.getResult()); }
String BinaryResources::browseForResource (const String& title, const String& wildcard, const File& fileToStartFrom, const String& resourceToReplace) { FileChooser fc (title, fileToStartFrom, wildcard); if (fc.browseForFileToOpen()) { String name (resourceToReplace); if (name.isEmpty()) name = findUniqueName (fc.getResult().getFileName()); if (! add (name, fc.getResult())) { AlertWindow::showMessageBox (AlertWindow::WarningIcon, TRANS("Adding Resource"), TRANS("Failed to load the file!")); name.clear(); } return name; } return String::empty; }
void Ambix_binauralAudioProcessorEditor::menuItemChosenCallback (int result, Ambix_binauralAudioProcessorEditor* demoComponent) { // std::cout << "result: " << result << std::endl; Ambix_binauralAudioProcessor* ourProcessor = demoComponent->getProcessor(); // file chooser.... if (result == 0) { // do nothing } else if (result == -1) { FileChooser myChooser ("Please select the preset file to load...", ourProcessor->lastDir, "*.config"); if (myChooser.browseForFileToOpen()) { File mooseFile (myChooser.getResult()); //ourProcessor->ScheduleConfiguration(mooseFile); ourProcessor->LoadConfiguration(mooseFile); ourProcessor->lastDir = mooseFile.getParentDirectory(); } } else // load preset { demoComponent->stopTimer(); ourProcessor->LoadPreset(result - 1); } }
void FileChooserImpl::accept_browser() { int i = int(fbrowser_->selected()); if (i == -1) { accept_editor(editor_); return; } i = filter_map_[i]; const String& path = *dir_->path(); const String& name = *dir_->name(i); int length = path.length() + name.length(); char* tmp = new char[length + 1]; sprintf( tmp, "%.*s%.*s", path.length(), path.string(), name.length(), name.string() ); editor_->field(tmp); selected_ = editor_->text(); if (dir_->is_directory(i)) { if (chdir(String(tmp, length))) { editor_->field(*dir_->path()); fchooser_->focus(editor_); } else { /* should generate an error message */ } } else { fchooser_->dismiss(true); } delete tmp; }
void MainComponent::buttonClicked(Button* buttonthatWasClicked) { if (buttonthatWasClicked == quitButton) { JUCEApplication::quit(); } if (buttonthatWasClicked == loadButton) { FileChooser chooser (("Choose .map file to open"),File::nonexistent,"*",true); chooser.browseForFileToOpen(); // if (chooser.getResult().exists()) currentFile = File(chooser.getResult()); if (currentFile.exists()) { // UI addAndMakeVisible(visualPlanner = new MapComponent(currentFile)); int a = (visualPlanner->height)*BLOCKSIZE; int b = (visualPlanner->width)*BLOCKSIZE; visualPlanner->setBounds(getWidth()/2-b/2, getHeight()/2-a/2,b,a); //planner planner = new MapParser(currentMap.toStdString()); currentMap = currentFile.loadFileAsString(); sokoban = new Sokoban(currentMap.toStdString()); } else { printf("no such file!"); } } if (buttonthatWasClicked == solveButton) { console->setText("planning... ", dontSendNotification); sokoban->solve(); if (sokoban->numSteps>0){ String temp = "solved!\n" + String(sokoban->numSteps) + " steps total.\nRunning time: "+String(sokoban->time)+ " seconds. \n "; console->setText(temp, dontSendNotification); cout<<endl<<endl<< "number of steps : " << sokoban->numSteps <<endl; cout<<endl<<"time : "<<sokoban->time<<" sec"<<endl; cout<<endl<<sokoban->reverseplan<<endl<<endl<<"start plan :"<<endl<<endl; for(int i=0; i<sokoban->actions.size(); i++){ cout<< sokoban->actions[i]<<endl; } cout<<endl<<"end plan"<<endl; } else { console->setText("no solution found", dontSendNotification); cout<<"no solution found"<<endl; } if (visualPlanner) { visualPlanner->getSolution(sokoban->reverseplan); visualPlanner->autoStart = 1; } } }
void CtrlrManager::openPanelFromFile(Component *componentToAttachMenu) { FileChooser fc ("Open panel", File(getProperty(Ids::ctrlrLastBrowsedFileDirectory)), "*.panel;*.panelz;*.bpanel;*.bpanelz;*.*", true); if (fc.browseForFileToOpen()) { openPanelInternal(fc.getResult()); panelFileOpened (fc.getResult()); } }
void loadScheme() { FileChooser fc ("Please select a colour-scheme file to load...", getAppSettings().appearance.getSchemesFolder(), AppearanceSettings::getSchemeFileWildCard()); if (fc.browseForFileToOpen()) if (getAppSettings().appearance.readFromFile (fc.getResult())) rebuildProperties(); }
void FEDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { if (index.column() == COL_FILE) { FileChooser * fch = static_cast<FileChooser*>(editor); model->setData(index, fch->text() ); } else if (index.column() == COL_NAME) { QLineEdit * e = static_cast<QLineEdit*>(editor); model->setData(index, e->text() ); } }
Result FileBasedDocument::loadFromUserSpecifiedFile (const bool showMessageOnFailure) { FileChooser fc (openFileDialogTitle, getLastDocumentOpened(), fileWildcard); if (fc.browseForFileToOpen()) return loadFrom (fc.getResult(), showMessageOnFailure); return Result::fail (TRANS("User cancelled")); }
void FileSearchPathListComponent::buttonClicked (Button* button) { const int currentRow = listBox.getSelectedRow(); if (button == &removeButton) { deleteKeyPressed (currentRow); } else if (button == &addButton) { File start (defaultBrowseTarget); if (start == File::nonexistent) start = path [0]; if (start == File::nonexistent) start = File::getCurrentWorkingDirectory(); #if JUCE_MODAL_LOOPS_PERMITTED FileChooser chooser (TRANS("Add a folder..."), start, "*"); if (chooser.browseForDirectory()) path.add (chooser.getResult(), currentRow); #else jassertfalse; // needs rewriting to deal with non-modal environments #endif } else if (button == &changeButton) { returnKeyPressed (currentRow); } else if (button == &upButton) { if (currentRow > 0 && currentRow < path.getNumPaths()) { const File f (path[currentRow]); path.remove (currentRow); path.add (f, currentRow - 1); listBox.selectRow (currentRow - 1); } } else if (button == &downButton) { if (currentRow >= 0 && currentRow < path.getNumPaths() - 1) { const File f (path[currentRow]); path.remove (currentRow); path.add (f, currentRow + 1); listBox.selectRow (currentRow + 1); } } changed(); }
void Ambix_binauralAudioProcessorEditor::buttonClicked (Button* buttonThatWasClicked) { Ambix_binauralAudioProcessor* ourProcessor = getProcessor(); /* if (buttonThatWasClicked == btn_open) { FileChooser myChooser ("Please select the preset file to load...", ourProcessor->lastDir, "*.config"); if (myChooser.browseForFileToOpen()) { File mooseFile (myChooser.getResult()); ourProcessor->LoadConfiguration(mooseFile); UpdateText(); ourProcessor->lastDir = mooseFile.getParentDirectory(); } } */ if (buttonThatWasClicked == btn_open) { popup_presets.showMenuAsync(PopupMenu::Options().withTargetComponent (btn_open), ModalCallbackFunction::forComponent (menuItemChosenCallback, this)); } else if (buttonThatWasClicked == btn_preset_folder) { FileChooser myChooser ("Please select the new preset folder...", ourProcessor->presetDir, "*.config"); if (myChooser.browseForDirectory()) { File mooseFile (myChooser.getResult()); ourProcessor->presetDir = mooseFile; ourProcessor->SearchPresets(mooseFile); ourProcessor->lastDir = mooseFile.getParentDirectory(); UpdatePresets(); } } #if BINAURAL_DECODER if (buttonThatWasClicked == tgl_load_irs) { ourProcessor->_load_ir = tgl_load_irs->getToggleState(); } #endif }
void EnabledModuleList::addModuleFromUserSelectedFile() { static File lastLocation (findDefaultModulesFolder (project)); FileChooser fc ("Select a module to add...", lastLocation, String::empty, false); if (fc.browseForDirectory()) { lastLocation = fc.getResult(); addModuleOfferingToCopy (lastLocation); } }
void DexedAudioProcessorEditor::saveCart() { File startFileName = processor->activeFileCartridge.exists() ? processor->activeFileCartridge : processor->dexedCartDir; FileChooser fc ("Export DX sysex...", processor->dexedCartDir, "*.syx", 1); if ( fc.browseForFileToSave(true) ) { if ( ! processor->currentCart.saveVoice(fc.getResults().getReference(0)) ) { AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Error", "Unable to write: " + fc.getResults().getReference(0).getFullPathName()); } } }
void MainContentComponent::load_button() { FileChooser myChooser ("I pitty the file who doesn't choose a fool!", File::getSpecialLocation(File::userHomeDirectory), "*.wav"); if(myChooser.browseForFileToOpen()) { File wavFile (myChooser.getResult()); long length_of_file; int channels, f_fs; float* data = load_file(wavFile.getFullPathName(), &length_of_file, &channels, &f_fs); file_buf = data; file_fs = f_fs; file_len = length_of_file; file_chn = channels; } }
void FileSearchPathListComponent::returnKeyPressed (int row) { #if JUCE_MODAL_LOOPS_PERMITTED FileChooser chooser (TRANS("Change folder..."), path [row], "*"); if (chooser.browseForDirectory()) { path.remove (row); path.add (chooser.getResult(), row); changed(); } #endif }
FileBasedDocument::SaveResult FileBasedDocument::saveAsInteractive (const bool warnAboutOverwritingExistingFiles) { File f; if (documentFile.existsAsFile()) f = documentFile; else f = getLastDocumentOpened(); String legalFilename (File::createLegalFileName (getDocumentTitle())); if (legalFilename.isEmpty()) legalFilename = "unnamed"; if (f.existsAsFile() || f.getParentDirectory().isDirectory()) f = f.getSiblingFile (legalFilename); else f = File::getSpecialLocation (File::userDocumentsDirectory).getChildFile (legalFilename); f = getSuggestedSaveAsFile (f); FileChooser fc (saveFileDialogTitle, f, fileWildcard); if (fc.browseForFileToSave (warnAboutOverwritingExistingFiles)) { File chosen (fc.getResult()); if (chosen.getFileExtension().isEmpty()) { chosen = chosen.withFileExtension (fileExtension); if (chosen.exists()) { if (! AlertWindow::showOkCancelBox (AlertWindow::WarningIcon, TRANS("File already exists"), TRANS("There's already a file called:") + "\n\n" + chosen.getFullPathName() + "\n\n" + TRANS("Are you sure you want to overwrite it?"), TRANS("overwrite"), TRANS("cancel"))) { return userCancelledSave; } } } setLastDocumentOpened (chosen); return saveAs (chosen, false, false, true); } return userCancelledSave; }
void saveScheme() { FileChooser fc ("Select a file in which to save this colour-scheme...", getAppSettings().appearance.getSchemesFolder() .getNonexistentChildFile ("Scheme", AppearanceSettings::getSchemeFileSuffix()), AppearanceSettings::getSchemeFileWildCard()); if (fc.browseForFileToSave (true)) { File file (fc.getResult().withFileExtension (AppearanceSettings::getSchemeFileSuffix())); getAppSettings().appearance.writeToFile (file); getAppSettings().appearance.refreshPresetSchemeList(); } }
File NewFileWizard::Type::askUserToChooseNewFile (const String& suggestedFilename, const String& wildcard, const Project::Item& projectGroupToAddTo) { FileChooser fc ("Select File to Create", projectGroupToAddTo.determineGroupFolder() .getChildFile (suggestedFilename) .getNonexistentSibling(), wildcard); if (fc.browseForFileToSave (true)) return fc.getResult(); return File::nonexistent; }
JucerDocument* loadDocumentFromFile (const File& f, const bool showErrorMessage) { File file (f); if (file == File::nonexistent && showErrorMessage) { FileChooser fc ("Open a Jucer C++ file...", StoredSettings::getInstance()->recentFiles.getFile (0), "*.cpp"); if (! fc.browseForFileToOpen()) return 0; file = fc.getResult(); } XmlElement* xml = JucerDocument::pullMetaDataFromCppFile (file.loadFileAsString()); if (xml == 0 || ! xml->hasTagName (JucerDocument::jucerCompXmlTag)) { if (file != File::nonexistent && showErrorMessage) AlertWindow::showMessageBox (AlertWindow::WarningIcon, TRANS("Failed to open file..."), TRANS("This wasn't a valid Jucer .cpp file...")); delete xml; return 0; } const String docType (xml->getStringAttribute ("documentType")); delete xml; // (reverse order so ComponentDocument is default last-case) for (int i = numDocumentTypes; --i >= 0;) { if (docType.equalsIgnoreCase (documentTypeNames[i]) || i == 0) { JucerDocument* doc = createNewDocument (i); if (doc->loadFrom (file, showErrorMessage)) return doc; delete doc; break; } } return 0; }
void ProjectTreeViewBase::browseToAddExistingFiles() { const File location (item.isGroup() ? item.determineGroupFolder() : getFile()); FileChooser fc ("Add Files to Jucer Project", location, String::empty, false); if (fc.browseForMultipleFilesOrDirectories()) { StringArray files; for (int i = 0; i < fc.getResults().size(); ++i) files.add (fc.getResults().getReference(i).getFullPathName()); addFiles (files, 0); } }
bool GraphComponent::loadAndAppendPlugin () { DBG ("GraphComponent::loadAndAppendPlugin (with chooser)"); FileChooser myChooser (T("Load a plugin..."), Config::getInstance ()->lastPluginDirectory, JOST_PLUGIN_WILDCARD, JOST_USE_NATIVE_FILE_CHOOSER); if (myChooser.browseForFileToOpen()) { File fileToLoad = myChooser.getResult(); if (fileToLoad.existsAsFile()) return loadAndAppendPlugin (fileToLoad, 100, 100); } return false; }
QWidget *FEDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { //qDebug("FEDelegate::createEditor"); if (index.column() == COL_FILE) { FileChooser *fch = new FileChooser(parent); fch->setText(index.model()->data(index, Qt::DisplayRole).toString()); return fch; } else if (index.column() == COL_NAME) { QLineEdit *e = new QLineEdit(parent); e->setText(index.model()->data(index, Qt::DisplayRole).toString()); return e; } else { return QItemDelegate::createEditor(parent, option, index); } }
void CtrlrLuaMethodEditor::addMethodFromFile(ValueTree parentGroup) { FileChooser fc ("Select LUA files", lastBrowsedSourceDir, "*.lua;*.txt"); if (fc.browseForMultipleFilesToOpen ()) { Array <File> results = fc.getResults(); for (int i=0; i<results.size(); i++) { getMethodManager().addMethodFromFile (parentGroup, results[i]); } } updateRootItem(); saveSettings(); // save settings }
void FilenameComponent::buttonClicked (Button*) { #if JUCE_MODAL_LOOPS_PERMITTED FileChooser fc (isDir ? TRANS ("Choose a new directory") : TRANS ("Choose a new file"), getLocationToBrowse(), wildcard); if (isDir ? fc.browseForDirectory() : (isSaving ? fc.browseForFileToSave (false) : fc.browseForFileToOpen())) { setCurrentFile (fc.getResult(), true); } #else jassertfalse; // needs rewriting to deal with non-modal environments #endif }
QWidget * FEDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem & option, const QModelIndex & index) const { //qDebug("FEDelegate::createEditor"); if (index.column() == COL_FILE) { FileChooser * fch = new FileChooser(parent); fch->setOptions(QFileDialog::DontUseNativeDialog | QFileDialog::DontResolveSymlinks); // Crashes if use the KDE dialog fch->setText( index.model()->data(index, Qt::DisplayRole).toString() ); return fch; } else if (index.column() == COL_NAME) { QLineEdit * e = new QLineEdit(parent); e->setText( index.model()->data(index, Qt::DisplayRole).toString() ); return e; } else { return QItemDelegate::createEditor(parent, option, index); } }
void TargetFileComponent::buttonClicked (Button* buttonThatWasClicked) { //[UserbuttonClicked_Pre] //[/UserbuttonClicked_Pre] if (buttonThatWasClicked == playButton) { //[UserButtonCode_playButton] -- add your button handler code here.. playAudio(); //[/UserButtonCode_playButton] } else if (buttonThatWasClicked == stopButton) { //[UserButtonCode_stopButton] -- add your button handler code here.. stopAudio(); //[/UserButtonCode_stopButton] } else if (buttonThatWasClicked == loadFileButton) { //[UserButtonCode_loadFileButton] -- add your button handler code here.. FileChooser myChooser ("Please select the file you want to load..."); if (myChooser.browseForFileToOpen()) { audioTransport.setSource(nullptr); // this fixes memory issue with loading new file File selectedFile = myChooser.getResult(); currentFile->setFile(selectedFile); container->setFile(selectedFile); audioTransport.setSource(currentFile->getSource()); isPlayable = true; setPlayable(true); sendActionMessage("setTargetFile"); } //[/UserButtonCode_loadFileButton] } //[UserbuttonClicked_Post] //[/UserbuttonClicked_Post] }
void CtrlrEditor::performKeyGenerator() { CtrlrKeyGenerator generator; generator.runThread (); if (generator.waitForThreadToExit (60 * 1000)) { FileChooser fc ("RSA Key file name", File::getSpecialLocation (File::userHomeDirectory), "*.*", true); if (fc.browseForFileToSave(true)) { File privateKeyFile = fc.getResult().withFileExtension("private"); File publicKeyFile = fc.getResult().withFileExtension("public"); if (privateKeyFile.hasWriteAccess() && publicKeyFile.hasWriteAccess()) { privateKeyFile.replaceWithText (generator.privateKey.toString()); publicKeyFile.replaceWithText (generator.publicKey.toString()); } } } }