reMesh* reFBXAsset::importMesh(FbxNode* fbxNode) { qDebug() << "import mesh for" << fbxNode->GetName(); reMesh* mesh = new reMesh; FbxMesh* fmesh = (FbxMesh*) fbxNode->GetNodeAttribute(); FbxVector4* controlPoints = fmesh->GetControlPoints(); for (int i=0; i<fmesh->GetPolygonCount(); i++) { reFace* face = new reFace; for (int j=0; j<fmesh->GetPolygonSize(i); j++) { int vi = fmesh->GetPolygonVertex(i, j); reVertex vertex; vertex.pos = reVec3(controlPoints[vi][0], controlPoints[vi][1], controlPoints[vi][2]); FbxVector4 fNormal; fmesh->GetPolygonVertexNormal(i, j, fNormal); vertex.uv = getUV(fmesh, vi, i, j); vertex.normal = reVec3(fNormal[0], fNormal[1], fNormal[2]); face->vertices.push_back(vertex); } reMaterial* mat = getMaterial(fmesh, i, mesh->materialSet); mesh->addFace(face,mat ? mat->id: -1); } reMeshAsset* meshAsset = new reMeshAsset(meshes); meshAsset->mesh = mesh; meshes->children.push_back(meshAsset); meshAsset->setPath((dataDir().toStdString() + "/" + fbxNode->GetName() + ".mesh").c_str()); mesh->save(dataDir().toStdString() + "/" + fbxNode->GetName() + ".mesh"); return mesh; }
QQGlobal::QQGlobal() { QFile file(dataDir()+"/res.xml"); file.open(QIODevice::ReadOnly); QDomDocument global_xml("xml"); global_xml.setContent(&file); file.close(); appicon_path_ = dataDir()+ "/" + global_xml.documentElement().attribute("app_icon"); }
bool CamuleDlg::Check_and_Init_Skin() { bool ret = true; wxString skinFileName(thePrefs::GetSkin()); if (skinFileName.IsEmpty() || skinFileName.IsSameAs(_("- default -"))) { return false; } wxString userDir(JoinPaths(GetConfigDir(), wxT("skins")) + wxFileName::GetPathSeparator()); wxStandardPathsBase &spb(wxStandardPaths::Get()); #ifdef __WINDOWS__ wxString dataDir(spb.GetPluginsDir()); #elif defined(__WXMAC__) wxString dataDir(spb.GetDataDir()); #else wxString dataDir(spb.GetDataDir().BeforeLast(wxT('/')) + wxT("/amule")); #endif wxString systemDir(JoinPaths(dataDir,wxT("skins")) + wxFileName::GetPathSeparator()); skinFileName.Replace(wxT("User:"******"System:"), systemDir ); m_skinFileName.Assign(skinFileName); if (!m_skinFileName.FileExists()) { AddLogLineC(CFormat( _("Skin directory '%s' does not exist")) % skinFileName ); ret = false; } else if (!m_skinFileName.IsFileReadable()) { AddLogLineC(CFormat( _("WARNING: Unable to open skin file '%s' for read")) % skinFileName); ret = false; } wxFFileInputStream in(m_skinFileName.GetFullPath()); wxZipInputStream zip(in); wxZipEntry *entry; while ((entry = zip.GetNextEntry()) != NULL) { wxZipEntry*& current = cat[entry->GetInternalName()]; delete current; current = entry; } return ret; }
void TestQgsProject::testLayerFlags() { QString dataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt QString layerPath = dataDir + "/points.shp"; QgsVectorLayer *layer1 = new QgsVectorLayer( layerPath, QStringLiteral( "points 1" ), QStringLiteral( "ogr" ) ); QgsVectorLayer *layer2 = new QgsVectorLayer( layerPath, QStringLiteral( "points 2" ), QStringLiteral( "ogr" ) ); QgsProject prj; prj.addMapLayer( layer1 ); prj.addMapLayer( layer2 ); layer2->setFlags( layer2->flags() & ~QgsMapLayer::Removable ); QString layer2id = layer2->id(); QTemporaryFile f; QVERIFY( f.open() ); f.close(); prj.setFileName( f.fileName() ); prj.write(); // test reading required layers back QgsProject prj2; prj2.setFileName( f.fileName() ); QVERIFY( prj2.read() ); QgsMapLayer *layer = prj.mapLayer( layer2id ); QVERIFY( layer ); QVERIFY( !layer->flags().testFlag( QgsMapLayer::Removable ) ); }
HstesterServer::HstesterServer(QObject *parent): QObject(parent) { testManager = new TestManager(this); QDir appDir(QCoreApplication::applicationDirPath()); QString dataDirPath; #ifdef Q_OS_LINUX appDir.cdUp(); appDir.cdUp(); dataDirPath = appDir.absolutePath() + "/var/lib/hstest"; #endif #ifdef Q_OS_WIN32 dataDirPath = appDir.absolutePath() + "/data"; #endif QDir dataDir(dataDirPath); if(!dataDir.exists()) dataDir.mkpath(dataDirPath); testManager->setTestDir(dataDirPath); testManager->readTestDbFromFile(); testManager->readStudentDbFromFile(); testServer = new TestServer(testManager, this); if(!testServer->listen(QHostAddress::Any, 1605)) { qDebug() << trUtf8("Unable to start the server: ") << testServer->errorString(); return; } }
void MediaCenter::createMediaFolders() { QDir dataDirectory = dataDir(); if (!dataDirectory.exists() && !dataDirectory.mkpath(dataDirectory.absolutePath())) { qWarning() << "Falha ao criar diretorio:" << dataDirectory.absolutePath(); } }
// Slot run in this thread (DB thread) void tDatabase::DbMountData( QString dataSetDir ) { //assert( currentThread() == this ); QString errorMsg; bool hadErrors; // Create QDir object given path QDir dataDir( dataSetDir ); // Check for existance if ( dataDir.exists() ) { hadErrors = ! _MountData( dataDir, errorMsg ); } else { hadErrors = true; errorMsg = QString( "Map data directory does not exist! dir=%1" ).arg( dataDir.absolutePath() ); } if ( ! hadErrors ) { m_Lock.lock(); m_DataMounted = true; m_Lock.unlock(); } else { emit Error( (int)DB_MOUNT_ERROR, errorMsg ); } emit MountDataComplete( dataSetDir, hadErrors ); }
bts::application_config load_config( const std::string& profile_name ) { try { auto strDataDir = QStandardPaths::writableLocation(QStandardPaths::DataLocation).toStdWString(); boost::filesystem::path dataDir(strDataDir); boost::filesystem::path profileDataDir(dataDir/profile_name); fc::path profileDir(profileDataDir); fc::create_directories(profileDir); auto config_file = profileDir / "config.json"; ilog( "config_file: ${file}", ("file",config_file) ); if(fc::exists(config_file) == false) { bts::application_config default_cfg; default_cfg.data_dir = profileDir / "data"; fc::ofstream out( config_file ); out << fc::json::to_pretty_string( default_cfg ); } auto app_config = fc::json::from_file( config_file ).as<bts::application_config>(); fc::ofstream out( config_file ); out << fc::json::to_pretty_string( app_config ); return app_config; } FC_RETHROW_EXCEPTIONS( warn, "") }
QString logsDirPath() { QString path = dataDirPath(); QDir dataDir(path); if (!dataDir.exists(kLogsDirName)) dataDir.mkdir(kLogsDirName); return QString("%1/%2/").arg(path, kLogsDirName); }
bool TupProject::removeScene(int pos) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[TupProject::removeScene()]"; #else T_FUNCINFO; #endif #endif TupScene *toRemove = sceneAt(pos); if (toRemove) { QString path = dataDir() + "/scene" + QString::number(pos) + ".tps"; if (QFile::exists(path)) { if (!QFile::remove(path)) { #ifdef K_DEBUG QString msg = "TupProject::removeScene() - Error removing file " + path; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif return false; } } int total = k->sceneCounter - 1; if (pos < total) { for (int i=pos + 1; i<=total; i++) { QString oldName = dataDir() + "/scene" + QString::number(i) + ".tps"; QString newName = dataDir() + "/scene" + QString::number(i-1) + ".tps"; QFile::rename(oldName, newName); } } k->undoScenes << k->scenes.takeAt(pos); k->sceneCounter--; return true; } return false; }
QString JSKitLocalStorage::getStorageFileFor(const QUuid &uuid) { QDir dataDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation)); dataDir.mkpath("js-storage"); QString fileName = uuid.toString(); fileName.remove('{'); fileName.remove('}'); return dataDir.absoluteFilePath("js-storage/" + fileName + ".ini"); }
void MainWindow::UpdateTracker() { QSettings settings(ORGANIZATION_NAME, APPLICATION_NAME); QString dataDir(settings.value("Main/DataDir", DATA_DIR_ROOT).toString()); TrackerCfg tracker(this, dataDir, dataDir); tracker.Update(); }
void CCDBManager::parseXMLByDir(const String& path, String &skeletonXMLFile, String &textureXMLFile) { String dataDir(path); size_t pos; while ((pos = dataDir.find_first_of("\\")) != String::npos) { dataDir.replace(pos, 1, "/"); } size_t slash = dataDir.find_last_of("/"); if(slash == String::npos || slash != dataDir.size()-1) { dataDir.append("/"); } skeletonXMLFile.append(dataDir + "skeleton.xml"); textureXMLFile.append(dataDir + "texture.xml"); }
QString Paths::soundsPath(const QString& sound) { // check local filesystem first auto localSound = dataDir("sounds/" + sound); QFileInfo f(localSound); if (f.exists()) return f.absoluteFilePath(); f = QFileInfo(":/sounds/" + sound); if (!f.exists()) { QLOG_WARN() << "Can't find sound:" << sound; return QString(); } return f.absoluteFilePath(); }
void ZealDocsetsRegistry::initialiseDocsets() { clear(); QDir dataDir( docsetsDir() ); for(auto subdir : dataDir.entryInfoList()) { if(subdir.isDir() && subdir.fileName() != "." && subdir.fileName() != "..") { QMetaObject::invokeMethod(docsets, "addDocset", Qt::BlockingQueuedConnection, Q_ARG(QString, subdir.absoluteFilePath())); } } QDir appDir( QCoreApplication::applicationDirPath() ); if(appDir.cd("docsets")){ for(auto subdir : appDir.entryInfoList()) { if(subdir.isDir() && subdir.fileName() != "." && subdir.fileName() != "..") { QMetaObject::invokeMethod(docsets, "addDocset", Qt::BlockingQueuedConnection, Q_ARG(QString, subdir.absoluteFilePath())); } } } }
/** * \return List of all plugin paths for application plugins and add on * plugins in the application data location (for user specific plugins). */ QStringList RSettings::getPluginPaths() { QStringList ret; ret << RSettings::getPluginPath(); QDir dataDir(RSettings::getDataLocation()); QStringList addOns = dataDir.entryList(QDir::NoDotAndDotDot|QDir::Readable|QDir::Dirs|QDir::Executable, QDir::Name); for (int i=0; i<addOns.length(); i++) { if (addOns[i]=="scripts") { continue; } QFileInfo fi(dataDir.absolutePath() + QDir::separator() + addOns[i] + QDir::separator() + "plugins"); if (fi.exists()) { ret.append(fi.absolutePath()); } } return ret; }
// // Step 3 // Check if directories are exists and // create root directories if needed // bool InstallWindow::Step3PrepareDirs() { PrintStep(tr("Prepare directories")); QSettings settings(ORGANIZATION_NAME, APPLICATION_NAME); QString mainName(_game->JsonTitle()); if (mainName.isEmpty()) return Failed(tr("Main property not found in Json: ") + mainName); _game->SetBinPath(settings.value("Main/BinDir", BIN_DIR_ROOT).toString() + QString("/") + mainName); _game->SetDataPath(settings.value("Main/DataDir", DATA_DIR_ROOT).toString() + QString("/") + mainName); QDir dataDir(_game->DataPath()); QDir binDir(_game->BinPath()); if (dataDir.exists()) if (!ConfirmRemoveDir(dataDir.path())) return false; if (binDir.exists()) if (!ConfirmRemoveDir(binDir.path())) return false; if (!dataDir.mkpath(dataDir.path())) return Failed(QString(tr("Can't create directory %1")) .arg(dataDir.path())); if (!binDir.mkpath(binDir.path())) return Failed(QString(tr("Can't create directory %1")) .arg(binDir.path())); PrintOK(); return Step4Unpack(); }
void MainWgt::saveResults() { QDir dataDir(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); if (!dataDir.exists()){ dataDir.mkpath(QDesktopServices::storageLocation(QDesktopServices::DataLocation)); } QFile resultsFile(QDesktopServices::storageLocation(QDesktopServices::DataLocation)+"/semko.txt"); if (!resultsFile.open(QIODevice::WriteOnly | QIODevice::Text)){ return; } QTextStream out(&resultsFile); QMapIterator<int, QString> i(results); while (i.hasNext()) { i.next(); out << i.key() << ": " << i.value() << "\n"; } out.flush(); resultsFile.close(); }
void FileSettings::constrainCacheToMaxSize(int size) { const QString dataPath = dataFilePath(); QDir dataDir(dataPath); // get size of cache QFileInfoList dataFileInfoList = dataDir.entryInfoList(QDir::Files | QDir::NoDotDot, QDir::Time); int cacheSize = QFileInfo(dataPath).size(); for (int i = 0; i < dataFileInfoList.size(); ++i) cacheSize += dataFileInfoList.at(i).size(); while (cacheSize > size) // remove oldest file settings from cache { if (dataFileInfoList.isEmpty()) break; const QString fileName = dataFileInfoList.last().fileName(); int fileSize = dataFileInfoList.takeLast().size(); if (dataDir.remove(fileName)) cacheSize -= fileSize; } }
ZooKeeperTestServer::ZooKeeperTestServer() : zooKeeperServer(NULL), connectionFactory(NULL), port(0), started(false) { // Create temporary directories for the FileTxnSnapLog. Try<std::string> directory = os::mkdtemp(); CHECK_SOME(directory); java::io::File dataDir(directory.get()); dataDir.deleteOnExit(); directory = os::mkdtemp(); CHECK_SOME(directory); java::io::File snapDir(directory.get()); snapDir.deleteOnExit(); zooKeeperServer = new ZooKeeperServer( FileTxnSnapLog(dataDir, snapDir), ZooKeeperServer::BasicDataTreeBuilder()); }
AppManager::AppManager(Pebble *pebble, WatchConnection *connection) : QObject(pebble), m_pebble(pebble), m_connection(connection) { QDir dataDir(m_pebble->storagePath() + "/apps/"); if (!dataDir.exists() && !dataDir.mkpath(dataDir.absolutePath())) { qWarning() << "could not create apps dir" << dataDir.absolutePath(); } qDebug() << "install apps in" << dataDir.absolutePath(); m_blobDBStoragePath = m_pebble->storagePath() + "/blobdb/"; QDir dir(m_blobDBStoragePath); if (!dir.exists() && !dir.mkpath(m_blobDBStoragePath)) { qWarning() << "Error creating blobdb storage dir."; return; } m_connection->registerEndpointHandler(WatchConnection::EndpointAppFetch,this, "handleAppFetchMessage"); m_connection->registerEndpointHandler(WatchConnection::EndpointSorting, this, "sortingReply"); connect(pebble->blobdb(), &BlobDB::blobCommandResult, this, &AppManager::blobdbAckHandler); }
void CUnitSync::init() { if(!IsLoaded) return; int ModCount = m_GetPrimaryModCount(); for(int i = 0; i < ModCount; i++) Mods.append(m_GetPrimaryModName(i)); QDir Dir; QString DataDir = dataDir(); if(!Dir.exists(DataDir + "/maps/")) Dir.mkpath(DataDir + "/maps/"); if(!Dir.exists(DataDir + "/mods/")) Dir.mkpath(DataDir + "/mods/"); if(!Dir.exists(DataDir + "/lua/")) Dir.mkpath(DataDir + "/lua/"); emit(loaded()); }
void reFBXAsset::import() { FbxImporter* importer = FbxImporter::Create(sdk,""); meshes = new reFileAsset(this); meshes->setPath("meshes"); children.push_back(meshes); if(!importer->Initialize(path().toUtf8().constData(), -1, sdk->GetIOSettings())) { printf("Call to FbxImporter::Initialize() failed.\n"); printf("Error returned: %s\n\n", importer->GetLastErrorString()); return; } FbxScene* lScene = FbxScene::Create(sdk, "myScene"); FbxAxisSystem ga(FbxAxisSystem::OpenGL); ga.ConvertScene(lScene); importer->Import(lScene); FbxNode* lRootNode = lScene->GetRootNode(); if(lRootNode) { reNode* node = importNode(lRootNode, NULL); node->name(info.baseName().toStdString()); QString path = dataDir() + QDir::separator() + node->name().c_str() + ".json"; node->save(path.toStdString()); } importer->Destroy(); }
void reFBXAsset::loadNodeAssets () { QDirIterator it(dataDir(), QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); while (it.hasNext()) { QFileInfo info(it.next()); if (info.completeSuffix() == "json") { reFileAsset* asset = new reFileAsset(this); asset->setPath(info.filePath()); //reNodeAsset* nodeAsset = new reNodeAsset(this); //nodeAsset->nodeFilePath(info.filePath().toStdString()); //nodeAsset->node(node, true); children.push_back(asset); } if (info.completeSuffix() == "mesh") { reFileAsset* asset = new reMeshAsset(this); asset->setPath(info.filePath()); children.push_back(asset); } } }
/// /// Load the preferences file /// void Preferences::loadPreferences( bool bGlobal ) { bool recreate = false; // configuration file must be recreated? QString sPreferencesDirectory; QString sPreferencesFilename; QString sDataDirectory; if ( bGlobal ) { sPreferencesDirectory = DataPath::get_data_path(); sPreferencesFilename = sPreferencesDirectory + "/composite.default.conf"; DEBUGLOG( "Loading preferences file (GLOBAL) [" + sPreferencesFilename + "]" ); } else { sPreferencesFilename = m_sPreferencesFilename; sPreferencesDirectory = m_sPreferencesDirectory; sDataDirectory = QDir::homePath().append( "/.composite/data" ); DEBUGLOG( "Loading preferences file (USER) [" + sPreferencesFilename + "]" ); } // preferences directory exists? QDir prefDir( sPreferencesDirectory ); if ( !prefDir.exists() ) { if ( bGlobal ) { WARNINGLOG( "System configuration directory '" + sPreferencesDirectory + "' not found." ); } else { ERRORLOG( "Configuration directory '" + sPreferencesDirectory + "' not found." ); createPreferencesDirectory(); } } // data directory exists? QDir dataDir( sDataDirectory ); if ( !dataDir.exists() ) { WARNINGLOG( "Data directory not found." ); createDataDirectory(); } // soundLibrary directory exists? QString sDir = sDataDirectory; QString sDrumkitDir; QString sSongDir; QString sPatternDir; DEBUGLOG( "Creating soundLibrary directories in " + sDir ); sDrumkitDir = sDir + "/drumkits"; sSongDir = sDir + "/songs"; sPatternDir = sDir + "/patterns"; QDir drumkitDir( sDrumkitDir ); QDir songDir( sSongDir ); QDir patternDir( sPatternDir ); if ( ! drumkitDir.exists() || ! songDir.exists() || ! patternDir.exists() ) { createSoundLibraryDirectories(); } // pref file exists? std::ifstream input( sPreferencesFilename.toLocal8Bit() , std::ios::in | std::ios::binary ); if ( input ) { // read preferences file QDomDocument doc = LocalFileMng::openXmlDocument( sPreferencesFilename ); QDomNode rootNode = doc.firstChildElement( "hydrogen_preferences" ); if ( !rootNode.isNull() ) { // version QString version = LocalFileMng::readXmlString( rootNode, "version", "" ); if ( version.isEmpty() ) { recreate = true; } //////// GENERAL /////////// //m_sLadspaPath = LocalFileMng::readXmlString( this, rootNode, "ladspaPath", m_sLadspaPath ); m_bShowDevelWarning = LocalFileMng::readXmlBool( rootNode, "showDevelWarning", m_bShowDevelWarning ); restoreLastSong = LocalFileMng::readXmlBool( rootNode, "restoreLastSong", restoreLastSong ); m_bPatternModePlaysSelected = LocalFileMng::readXmlBool( rootNode, "patternModePlaysSelected", TRUE ); hearNewNotes = LocalFileMng::readXmlBool( rootNode, "hearNewNotes", hearNewNotes ); recordEvents = LocalFileMng::readXmlBool( rootNode, "recordEvents", recordEvents ); quantizeEvents = LocalFileMng::readXmlBool( rootNode, "quantizeEvents", quantizeEvents ); QDomNode pRecentUsedSongsNode = rootNode.firstChildElement( "recentUsedSongs" ); if ( !pRecentUsedSongsNode.isNull() ) { QDomElement pSongElement = pRecentUsedSongsNode.firstChildElement( "song" ); while( !pSongElement.isNull() && !pSongElement.text().isEmpty() ){ m_recentFiles.push_back( pSongElement.text() ); pSongElement = pSongElement.nextSiblingElement( "song" ); } } else { DEBUGLOG( "recentUsedSongs node not found" ); } QDomNode pRecentFXNode = rootNode.firstChildElement( "recentlyUsedEffects" ); if ( ! pRecentFXNode.isNull() ) { QDomElement pFXElement = pRecentFXNode.firstChildElement( "FX" ); while ( !pFXElement.isNull() && ! pFXElement.text().isEmpty()) { m_recentFX.push_back( pFXElement.text() ); pFXElement = pFXElement.nextSiblingElement( "FX" ); } } else { DEBUGLOG( "recentlyUsedEffects node not found" ); } sServerList.clear(); QDomNode pServerListNode = rootNode.firstChildElement( "serverList" ); if ( !pServerListNode.isNull() ) { QDomElement pServerElement = pServerListNode.firstChildElement( "server" ); while ( !pServerElement.isNull() && !pServerElement.text().isEmpty() ) { sServerList.push_back( pServerElement.text() ); pServerElement = pServerElement.nextSiblingElement( "server" ); } } else { DEBUGLOG( "serverList node not found" ); } m_patternCategories.clear(); QDomNode pPatternCategoriesNode = rootNode.firstChildElement( "patternCategories" ); if ( !pPatternCategoriesNode.isNull() ) { QDomElement pPatternCategoriesElement = pPatternCategoriesNode.firstChildElement( "categories" ); while ( !pPatternCategoriesElement.isNull() && !pPatternCategoriesElement.text().isEmpty() ) { m_patternCategories.push_back( pPatternCategoriesElement.text() ); pPatternCategoriesElement = pPatternCategoriesElement.nextSiblingElement( "categories" ); } } else { DEBUGLOG( "patternCategories node not found" ); } m_sLastNews = LocalFileMng::readXmlString( rootNode, "lastNews", "-", true ); /////////////// AUDIO ENGINE ////////////// QDomNode audioEngineNode = rootNode.firstChildElement( "audio_engine" ); if ( audioEngineNode.isNull() ) { DEBUGLOG( "audio_engine node not found" ); recreate = true; } else { m_sAudioDriver = LocalFileMng::readXmlString( audioEngineNode, "audio_driver", m_sAudioDriver ); m_bUseMetronome = LocalFileMng::readXmlBool( audioEngineNode, "use_metronome", m_bUseMetronome ); m_fMetronomeVolume = LocalFileMng::readXmlFloat( audioEngineNode, "metronome_volume", 0.5f ); m_nMaxNotes = LocalFileMng::readXmlInt( audioEngineNode, "maxNotes", m_nMaxNotes ); m_nBufferSize = LocalFileMng::readXmlInt( audioEngineNode, "buffer_size", m_nBufferSize ); m_nSampleRate = LocalFileMng::readXmlInt( audioEngineNode, "samplerate", m_nSampleRate ); //// JACK DRIVER //// QDomNode jackDriverNode = audioEngineNode.firstChildElement( "jack_driver" ); if ( jackDriverNode.isNull() ) { DEBUGLOG( "jack_driver node not found" ); recreate = true; } else { m_sJackPortName1 = LocalFileMng::readXmlString( jackDriverNode, "jack_port_name_1", m_sJackPortName1 ); m_sJackPortName2 = LocalFileMng::readXmlString( jackDriverNode, "jack_port_name_2", m_sJackPortName2 ); QString sMode = LocalFileMng::readXmlString( jackDriverNode, "jack_transport_mode", "NO_JACK_TRANSPORT" ); if ( sMode == "NO_JACK_TRANSPORT" ) { m_bJackTransportMode = NO_JACK_TRANSPORT; } else if ( sMode == "USE_JACK_TRANSPORT" ) { m_bJackTransportMode = USE_JACK_TRANSPORT; } //jack time master QString tmMode = LocalFileMng::readXmlString( jackDriverNode, "jack_transport_mode_master", "NO_JACK_TIME_MASTER" ); if ( tmMode == "NO_JACK_TIME_MASTER" ) { m_bJackMasterMode = NO_JACK_TIME_MASTER; } else if ( tmMode == "USE_JACK_TIME_MASTER" ) { m_bJackMasterMode = USE_JACK_TIME_MASTER; } //~ jack time master m_bJackTrackOuts = LocalFileMng::readXmlBool( jackDriverNode, "jack_track_outs", m_bJackTrackOuts ); m_bJackConnectDefaults = LocalFileMng::readXmlBool( jackDriverNode, "jack_connect_defaults", m_bJackConnectDefaults ); m_nJackTrackOutputMode = LocalFileMng::readXmlInt( jackDriverNode, "jack_track_output_mode", m_nJackTrackOutputMode ); } /// MIDI DRIVER /// QDomNode midiDriverNode = audioEngineNode.firstChildElement( "midi_driver" ); if ( midiDriverNode.isNull() ) { DEBUGLOG( "midi_driver node not found" ); recreate = true; } else { m_sMidiDriver = LocalFileMng::readXmlString( midiDriverNode, "driverName", "JackMidi" ); m_sMidiPortName = LocalFileMng::readXmlString( midiDriverNode, "port_name", "None" ); m_nMidiChannelFilter = LocalFileMng::readXmlInt( midiDriverNode, "channel_filter", -1 ); m_bMidiNoteOffIgnore = LocalFileMng::readXmlBool( midiDriverNode, "ignore_note_off", true ); } } /////////////// GUI ////////////// QDomNode guiNode = rootNode.firstChildElement( "gui" ); if ( guiNode.isNull() ) { DEBUGLOG( "gui node not found" ); recreate = true; } else { // QT Style m_sQTStyle = LocalFileMng::readXmlString( guiNode, "QTStyle", m_sQTStyle, true ); // Application font family applicationFontFamily = LocalFileMng::readXmlString( guiNode, "application_font_family", applicationFontFamily ); // Application font pointSize applicationFontPointSize = LocalFileMng::readXmlInt( guiNode, "application_font_pointsize", applicationFontPointSize ); // mixer font family mixerFontFamily = LocalFileMng::readXmlString( guiNode, "mixer_font_family", mixerFontFamily ); // mixer font pointSize mixerFontPointSize = LocalFileMng::readXmlInt( guiNode, "mixer_font_pointsize", mixerFontPointSize ); // Mixer falloff speed mixerFalloffSpeed = LocalFileMng::readXmlFloat( guiNode, "mixer_falloff_speed", 1.1f ); // pattern editor grid resolution m_nPatternEditorGridResolution = LocalFileMng::readXmlInt( guiNode, "patternEditorGridResolution", m_nPatternEditorGridResolution ); m_bPatternEditorUsingTriplets = LocalFileMng::readXmlBool( guiNode, "patternEditorUsingTriplets", m_bPatternEditorUsingTriplets ); m_bShowInstrumentPeaks = LocalFileMng::readXmlBool( guiNode, "showInstrumentPeaks", m_bShowInstrumentPeaks ); m_bIsFXTabVisible = LocalFileMng::readXmlBool( guiNode, "isFXTabVisible", m_bIsFXTabVisible ); // pattern editor grid height m_nPatternEditorGridHeight = LocalFileMng::readXmlInt( guiNode, "patternEditorGridHeight", m_nPatternEditorGridHeight ); // pattern editor grid width m_nPatternEditorGridWidth = LocalFileMng::readXmlInt( guiNode, "patternEditorGridWidth", m_nPatternEditorGridWidth ); // mainForm window properties setMainFormProperties( readWindowProperties( guiNode, "mainForm_properties", mainFormProperties ) ); setMixerProperties( readWindowProperties( guiNode, "mixer_properties", mixerProperties ) ); setPatternEditorProperties( readWindowProperties( guiNode, "patternEditor_properties", patternEditorProperties ) ); setSongEditorProperties( readWindowProperties( guiNode, "songEditor_properties", songEditorProperties ) ); setAudioEngineInfoProperties( readWindowProperties( guiNode, "audioEngineInfo_properties", audioEngineInfoProperties ) ); m_bFollowPlayhead = LocalFileMng::readXmlBool( guiNode, "followPlayhead", true ); //beatcounter QString bcMode = LocalFileMng::readXmlString( guiNode, "bc", "BC_OFF" ); if ( bcMode == "BC_OFF" ) { m_bbc = BC_OFF; } else if ( bcMode == "BC_ON" ) { m_bbc = BC_ON; } QString setPlay = LocalFileMng::readXmlString( guiNode, "setplay", "SET_PLAY_OFF" ); if ( setPlay == "SET_PLAY_OFF" ) { m_mmcsetplay = SET_PLAY_OFF; } else if ( setPlay == "SET_PLAY_ON" ) { m_mmcsetplay = SET_PLAY_ON; } m_countOffset = LocalFileMng::readXmlInt( guiNode, "countoffset", 0 ); m_startOffset = LocalFileMng::readXmlInt( guiNode, "playoffset", 0 ); //~ beatcounter //SoundLibraryPanel expand items __expandSongItem = LocalFileMng::readXmlBool( guiNode, "expandSongItem", __expandSongItem ); __expandPatternItem = LocalFileMng::readXmlBool( guiNode, "expandPatternItem", __expandPatternItem ); for ( unsigned nFX = 0; nFX < MAX_FX; nFX++ ) { QString sNodeName = QString("ladspaFX_properties%1").arg( nFX ); setLadspaProperties( nFX, readWindowProperties( guiNode, sNodeName, m_ladspaProperties[nFX] ) ); } QDomNode pUIStyle = guiNode.firstChildElement( "UI_Style" ); if ( !pUIStyle.isNull() ) { readUIStyle( pUIStyle ); } else { DEBUGLOG( "UI_Style node not found" ); recreate = true; } } /////////////// FILES ////////////// QDomNode filesNode = rootNode.firstChildElement( "files" ); if ( filesNode.isNull() ) { DEBUGLOG( "files node not found" ); recreate = true; } else { // last used song lastSongFilename = LocalFileMng::readXmlString( filesNode, "lastSongFilename", lastSongFilename, true ); m_sDefaultEditor = LocalFileMng::readXmlString( filesNode, "defaulteditor", m_sDefaultEditor, true ); } MidiMap* mM = get_midi_map(); mM->reset(); QDomNode pMidiEventMapNode = rootNode.firstChildElement( "midiEventMap" ); if ( !pMidiEventMapNode.isNull() ) { QDomNode pMidiEventNode = pMidiEventMapNode.firstChildElement( "midiEvent" ); while ( !pMidiEventNode.isNull() ) { if( pMidiEventNode.firstChildElement().nodeValue() == QString("mmcEvent")){ QString event = pMidiEventNode.firstChildElement("mmcEvent").firstChildElement().nodeValue(); QString s_action = pMidiEventNode.firstChildElement("action").firstChildElement().nodeValue(); QString s_param = pMidiEventNode.firstChildElement("parameter").firstChildElement().nodeValue(); Action* pAction = new Action( s_action ); pAction->setParameter1( s_param ); mM->registerMMCEvent(event, pAction); } if( pMidiEventNode.firstChildElement().nodeValue() == QString("noteEvent")){ QString event = pMidiEventNode.firstChildElement("noteEvent").firstChildElement().nodeValue(); QString s_action = pMidiEventNode.firstChildElement("action").firstChildElement().nodeValue(); QString s_param = pMidiEventNode.firstChildElement("parameter").firstChildElement().nodeValue(); QString s_eventParameter = pMidiEventNode.firstChildElement("eventParameter").firstChildElement().nodeValue(); Action* pAction = new Action( s_action ); pAction->setParameter1( s_param ); mM->registerNoteEvent(s_eventParameter.toInt(), pAction); } if( pMidiEventNode.firstChildElement().nodeValue() == QString("ccEvent") ){ QString event = pMidiEventNode.firstChildElement("ccEvent").firstChildElement().nodeValue(); QString s_action = pMidiEventNode.firstChildElement("action").firstChildElement().nodeValue(); QString s_param = pMidiEventNode.firstChildElement("parameter").firstChildElement().nodeValue(); QString s_eventParameter = pMidiEventNode.firstChildElement("eventParameter").firstChildElement().nodeValue(); Action * pAction = new Action( s_action ); pAction->setParameter1( s_param ); mM->registerCCEvent( s_eventParameter.toInt(), pAction ); } pMidiEventNode = pMidiEventNode.nextSiblingElement( "midiEvent" ); } } else { DEBUGLOG( "midiMap node not found" ); } } // rootNode else { DEBUGLOG( "hydrogen_preferences node not found" ); recreate = true; } } else { if ( bGlobal ) { WARNINGLOG( "System configuration file not found." ); } else { WARNINGLOG( "Configuration file not found." ); recreate = true; } } // The preferences file should be recreated? if ( recreate == true ) { WARNINGLOG( "Recreating configuration file." ); savePreferences(); } }
/** \brief return psi's private read write data directory * unix+mac: $HOME/.psi * environment variable "PSIDATADIR" overrides */ QString ApplicationInfo::homeDir(ApplicationInfo::HomedirType type) { static QString configDir_; static QString dataDir_; static QString cacheDir_; if (configDir_.isEmpty()) { // Try the environment override first configDir_ = QString::fromLocal8Bit(getenv("PSIDATADIR")); if (configDir_.isEmpty()) { #if defined Q_OS_WIN QString base = QFileInfo(QCoreApplication::applicationFilePath()).fileName() .toLower().indexOf("portable") == -1? "" : QCoreApplication::applicationDirPath(); if (base.isEmpty()) { wchar_t path[MAX_PATH]; if (SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, 0, path) == S_OK) { configDir_ = QString::fromWCharArray(path) + "\\" + name(); } else { configDir_ = QDir::homePath() + "/" + name(); } dataDir_ = configDir_; // prefer non-roaming data location for cache which is default for qds:DataLocation cacheDir_ = QDesktopServices::storageLocation(QDesktopServices::DataLocation); } else { configDir_ = dataDir_ = cacheDir_ = base + "/" + name(); } // temporary store for later processing QDir configDir(configDir_); QDir cacheDir(cacheDir_); QDir dataDir(dataDir_); #elif defined Q_OS_MAC QDir configDir(QDir::homePath() + "/Library/Application Support/" + name()); QDir cacheDir(QDir::homePath() + "/Library/Caches/" + name()); QDir dataDir(configDir); #elif defined HAVE_X11 QString XdgConfigHome = QString::fromLocal8Bit(getenv("XDG_CONFIG_HOME")); QString XdgDataHome = QString::fromLocal8Bit(getenv("XDG_DATA_HOME")); QString XdgCacheHome = QString::fromLocal8Bit(getenv("XDG_CACHE_HOME")); if (XdgConfigHome.isEmpty()) { XdgConfigHome = QDir::homePath() + "/.config"; } if (XdgDataHome.isEmpty()) { XdgDataHome = QDir::homePath() + "/.local/share"; } if (XdgCacheHome.isEmpty()) { XdgCacheHome = QDir::homePath() + "/.cache"; } QDir configDir(XdgConfigHome + "/" + sname()); QDir dataDir(XdgDataHome + "/" + sname()); QDir cacheDir(XdgCacheHome + "/" + sname()); // migrate mix-cased to lowercase, if needed QDir configDirOld(XdgConfigHome + "/" + name()); QDir dataDirOld(XdgDataHome + "/" + name()); QDir cacheDirOld(XdgCacheHome + "/" + name()); bool ok = true; if (ok && !configDir.exists() && configDirOld.exists()) { configDirOld = QDir(XdgConfigHome); ok = configDirOld.rename(name(), sname()); } if (ok && !dataDir.exists() && dataDirOld.exists()) { dataDirOld = QDir(XdgDataHome); ok = dataDirOld.rename(name(), sname()); } if (ok && !cacheDir.exists() && cacheDirOld.exists()) { cacheDirOld = QDir(XdgCacheHome); ok = cacheDirOld.rename(name(), sname()); } if(!ok) { QMessageBox::information(0, QObject::tr("Conversion Error"), QObject::tr("Configuration data for a previous version of Psi was found, but it was not possible to convert it to work with the current version. Ensure you have appropriate permission and that another copy of Psi is not running, and try again.")); exit(0); } #endif configDir_ = configDir.path(); cacheDir_ = cacheDir.path(); dataDir_ = dataDir.path(); // To prevent from multiple startup of import wizard if (ActiveProfiles::instance()->isActive("import_wizard")) { exit(0); } if (!configDir.exists() && !dataDir.exists() && !cacheDir.exists()) { HomeDirMigration dlg; if (dlg.checkOldHomeDir()) { ActiveProfiles::instance()->setThisProfile("import_wizard"); QSettings s(dlg.oldHomeDir() + "/psirc", QSettings::IniFormat); QString lastLang = s.value("last_lang", QString()).toString(); if(lastLang.isEmpty()) { lastLang = QLocale().name().section('_', 0, 0); } TranslationManager::instance()->loadTranslation(lastLang); dlg.exec(); ActiveProfiles::instance()->unsetThisProfile(); } } if (!dataDir.exists()) { dataDir.mkpath("."); } if (!cacheDir.exists()) { cacheDir.mkpath("."); } } else { cacheDir_ = configDir_; dataDir_ = configDir_; } } QString ret; switch(type) { case ApplicationInfo::ConfigLocation: ret = configDir_; break; case ApplicationInfo::DataLocation: ret = dataDir_; break; case ApplicationInfo::CacheLocation: ret = cacheDir_; break; } return ret; }
void TestQgsProject::testPathResolverSvg() { QString dataDir( TEST_DATA_DIR ); //defined in CmakeLists.txt QString layerPath = dataDir + "/points.shp"; QVERIFY( QgsSymbolLayerUtils::svgSymbolNameToPath( QString(), QgsPathResolver() ).isEmpty() ); QVERIFY( QgsSymbolLayerUtils::svgSymbolPathToName( QString(), QgsPathResolver() ).isEmpty() ); // build a project with 3 layers, each having a simple renderer with SVG marker // - existing SVG file in project dir // - existing SVG file in QGIS dir // - non-exsiting SVG file QTemporaryDir dir; QVERIFY( dir.isValid() ); // on mac the returned path was not canonical and the resolver failed to convert paths properly QString dirPath = QFileInfo( dir.path() ).canonicalFilePath(); QString projectFilename = dirPath + "/project.qgs"; QString ourSvgPath = dirPath + "/valid.svg"; QString invalidSvgPath = dirPath + "/invalid.svg"; QFile svgFile( ourSvgPath ); QVERIFY( svgFile.open( QIODevice::WriteOnly ) ); svgFile.write( "<svg/>" ); // not a proper SVG, but good enough for this case svgFile.close(); QVERIFY( QFileInfo::exists( ourSvgPath ) ); // should exist now QString librarySvgPath = QgsSymbolLayerUtils::svgSymbolNameToPath( QStringLiteral( "transport/transport_airport.svg" ), QgsPathResolver() ); QCOMPARE( QgsSymbolLayerUtils::svgSymbolPathToName( librarySvgPath, QgsPathResolver() ), QStringLiteral( "transport/transport_airport.svg" ) ); QgsVectorLayer *layer1 = new QgsVectorLayer( layerPath, QStringLiteral( "points 1" ), QStringLiteral( "ogr" ) ); _useRendererWithSvgSymbol( layer1, ourSvgPath ); QgsVectorLayer *layer2 = new QgsVectorLayer( layerPath, QStringLiteral( "points 2" ), QStringLiteral( "ogr" ) ); _useRendererWithSvgSymbol( layer2, invalidSvgPath ); QgsVectorLayer *layer3 = new QgsVectorLayer( layerPath, QStringLiteral( "points 3" ), QStringLiteral( "ogr" ) ); _useRendererWithSvgSymbol( layer3, librarySvgPath ); QVERIFY( layer1->isValid() ); QgsProject project; project.addMapLayers( QList<QgsMapLayer *>() << layer1 << layer2 << layer3 ); project.write( projectFilename ); // make sure the path resolver works with relative paths (enabled by default) QCOMPARE( project.pathResolver().readPath( "./a.txt" ), dirPath + "/a.txt" ); QCOMPARE( project.pathResolver().writePath( dirPath + "/a.txt" ), QString( "./a.txt" ) ); // check that the saved paths are relative // key = layer name, value = svg path QHash<QString, QString> projectFileSvgPaths = _parseSvgPathsForLayers( projectFilename ); QCOMPARE( projectFileSvgPaths.count(), 3 ); QCOMPARE( projectFileSvgPaths["points 1"], QString( "./valid.svg" ) ); // relative path to project QCOMPARE( projectFileSvgPaths["points 2"], invalidSvgPath ); // full path to non-existent file (not sure why - but that's how it works now) QCOMPARE( projectFileSvgPaths["points 3"], QString( "transport/transport_airport.svg" ) ); // relative path to library // load project again, check that the paths are absolute QgsProject projectLoaded; projectLoaded.read( projectFilename ); QString svg1 = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 1" ) ); QString svg2 = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 2" ) ); QString svg3 = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 3" ) ); QCOMPARE( svg1, ourSvgPath ); QCOMPARE( svg2, invalidSvgPath ); QCOMPARE( svg3, librarySvgPath ); // // now let's use these layers in embedded in another project... // QList<QDomNode> brokenNodes; QgsProject projectMaster; QVERIFY( projectMaster.createEmbeddedLayer( layer1->id(), projectFilename, brokenNodes ) ); QVERIFY( projectMaster.createEmbeddedLayer( layer2->id(), projectFilename, brokenNodes ) ); QVERIFY( projectMaster.createEmbeddedLayer( layer3->id(), projectFilename, brokenNodes ) ); QString svg1x = _getLayerSvgMarkerPath( projectMaster, QStringLiteral( "points 1" ) ); QString svg2x = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 2" ) ); QString svg3x = _getLayerSvgMarkerPath( projectLoaded, QStringLiteral( "points 3" ) ); QCOMPARE( svg1x, ourSvgPath ); QCOMPARE( svg2x, invalidSvgPath ); QCOMPARE( svg3x, librarySvgPath ); }
QString CommHistoryDatabasePath::dataDir(int id) { return dataDir() + QStringLiteral("%1/").arg(id); }
QString DiskUtil::gameObjectPath(const QString &objectType, uint id) { return dataDir() + QString("/%1.%2").arg(objectType.toLower()).arg(id, 9, 10, QChar('0')); }
int main( int argc, char* argv[] ) { if( argc > 1 ) { energy = atoi(argv[1]); } setStyle(); std::string dataDir(Form("../data_%dGeV", energy)); if( cef3_thickness==3. ) dataDir = std::string(Form("../data_3mm_%dGeV", energy)); std::vector<DataFile> dataFiles; dataFiles.push_back(DataFile("EEShash_LYSO_tung25_nLayers28.root", dataDir) ); if( cef3_thickness==5. ) { dataFiles.push_back(DataFile("EEShash_CeF3_tung15_nLayers34.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung20_nLayers28.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung25_nLayers24.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung30_nLayers21.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung35_nLayers19.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung40_nLayers17.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung45_nLayers16.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung50_nLayers14.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung55_nLayers13.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung60_nLayers12.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung65_nLayers12.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung70_nLayers11.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung75_nLayers10.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung80_nLayers10.root", dataDir) ); } else if( cef3_thickness==3. ) { dataFiles.push_back(DataFile("EEShash_CeF3_tung30_nLayers24.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung35_nLayers21.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung40_nLayers19.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung45_nLayers17.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung50_nLayers15.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung55_nLayers14.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung60_nLayers13.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung65_nLayers12.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung70_nLayers12.root", dataDir) ); dataFiles.push_back(DataFile("EEShash_CeF3_tung75_nLayers11.root", dataDir) ); //dataFiles.push_back(DataFile("EEShash_CeF3_tung80_nLayers10.root", dataDir) ); } std::string outputdir(Form("Plots_CeF3_vs_LYSO_%dGeV", energy)); if( cef3_thickness!=5. ) outputdir = std::string(Form("Plots_CeF3_vs_LYSO_%dGeV_%.0fmm", energy, cef3_thickness)); system( Form("mkdir -p %s", outputdir.c_str()) ); TGraphErrors* gr_mol = getMoliereGraph( dataFiles ); TGraphErrors* gr_vol = getVolumeGraph( dataFiles ); std::pair<TGraphErrors*, TGraphErrors*> gr_resp_reso = getResponseGraphs( outputdir, dataFiles ); std::vector< TGraphErrors* > graphs; graphs.push_back( gr_mol ); graphs.push_back( gr_vol ); graphs.push_back( gr_resp_reso.first ); graphs.push_back( gr_resp_reso.second ); for( unsigned i=0; i<graphs.size(); ++i ) drawSingleGraph( outputdir, graphs[i] ); drawCompareAll( outputdir, graphs ); return 0; }