void MusE::importMidi(const QString &file) { QString fn; if (file.isEmpty()) { fn = MusEGui::getOpenFileName(MusEGlobal::lastMidiPath, MusEGlobal::midi_file_pattern, this, tr("MusE: Import Midi"), 0); if (fn.isEmpty()) return; MusEGlobal::lastMidiPath = fn; } else fn = file; int n = QMessageBox::question(this, appName, tr("Add midi file to current project?\n"), tr("&Add to Project"), tr("&Replace"), tr("&Abort"), 0, 2); switch (n) { case 0: importMidi(fn, true); MusEGlobal::song->update(); break; case 1: loadProjectFile(fn, false, false); // replace break; default: return; } }
void MainWindow::openProject() { QStringList filters; filters << "Prototyping Toolkit Project files (*.ptp)" << "Any files (*)"; const QStringList documentsLocations = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); QFileDialog dialog(this, tr("Open Project"), documentsLocations.isEmpty() ? QDir::currentPath() : documentsLocations.first()); dialog.setAcceptMode(QFileDialog::AcceptOpen); dialog.setNameFilters(filters); while (dialog.exec() == QDialog::Accepted && !loadProjectFile(dialog.selectedFiles().first())) { } }
void LOS::importMidi(const QString &file) { QString fn; if (file.isEmpty()) { fn = getOpenFileName(lastMidiPath, midi_file_pattern, this, tr("LOS: Import Midi"), 0); if (fn.isEmpty()) return; lastMidiPath = fn; } else fn = file; int n = QMessageBox::question(this, appName, tr("Add midi file to current project?\n"), tr("&Add to Project"), tr("&Replace"), tr("&Cancel"), 0, 2); switch (n) { case 0: song->invalid = true; importMidi(fn, true); song->invalid = false; song->update(); break; case 1: song->invalid = true; loadProjectFile(fn, false, false); // replace song->invalid = false; break; default: return; } }
bool baseProject::create(string path){ addons.clear(); projectDir = ofFilePath::addTrailingSlash(path); projectName = ofFilePath::getFileName(path); bool bDoesDirExist = false; ofDirectory project(ofFilePath::join(projectDir,"src")); // this is a directory, really? if(project.exists()){ bDoesDirExist = true; }else{ ofDirectory project(projectDir); ofFile::copyFromTo(ofFilePath::join(templatePath,"src"),ofFilePath::join(projectDir,"src")); ofFile::copyFromTo(ofFilePath::join(templatePath,"bin"),ofFilePath::join(projectDir,"bin")); } // if overwrite then ask for permission... bool ret = createProjectFile(); if(!ret) return false; ret = loadProjectFile(); if(!ret) return false; if (bDoesDirExist){ vector < string > fileNames; getFilesRecursively(ofFilePath::join(projectDir , "src"), fileNames); for (int i = 0; i < (int)fileNames.size(); i++){ fileNames[i].erase(fileNames[i].begin(), fileNames[i].begin() + projectDir.length()); string first, last; #ifdef TARGET_WIN32 splitFromLast(fileNames[i], "\\", first, last); #else splitFromLast(fileNames[i], "/", first, last); #endif if (fileNames[i] != "src/ofApp.cpp" && fileNames[i] != "src/ofApp.h" && fileNames[i] != "src/main.cpp" && fileNames[i] != "src/ofApp.mm" && fileNames[i] != "src/main.mm"){ addSrc(fileNames[i], first); } } // if( target == "ios" ){ // getFilesRecursively(ofFilePath::join(projectDir , "bin/data"), fileNames); // // for (int i = 0; i < (int)fileNames.size(); i++){ // fileNames[i].erase(fileNames[i].begin(), fileNames[i].begin() + projectDir.length()); // // string first, last; // splitFromLast(fileNames[i], "/", first, last); // if (fileNames[i] != "Default.png" && // fileNames[i] != "src/ofApp.h" && // fileNames[i] != "src/main.cpp" && // fileNames[i] != "src/ofApp.mm" && // fileNames[i] != "src/main.mm"){ // addSrc(fileNames[i], first); // } // } // } #if defined(TARGET_LINUX) || defined(TARGET_OSX) parseAddons(); #endif // get a unique list of the paths that are needed for the includes. list < string > paths; vector < string > includePaths; for (int i = 0; i < (int)fileNames.size(); i++){ size_t found; #ifdef TARGET_WIN32 found = fileNames[i].find_last_of("\\"); #else found = fileNames[i].find_last_of("/"); #endif paths.push_back(fileNames[i].substr(0,found)); } paths.sort(); paths.unique(); for (list<string>::iterator it=paths.begin(); it!=paths.end(); ++it){ includePaths.push_back(*it); } for (int i = 0; i < includePaths.size(); i++){ addInclude(includePaths[i]); } } return true; }