//---------------------------------------------------------------------------------------------------------------------- void SettingsDialog::setCalibrationData(const CalibrationData& calibrationData) { #ifdef TEST_ONLY QSettings settingsFile("tokenTest_Settings.ini", QSettings::IniFormat); #else QSettings settingsFile("tokenGraver_Settings.ini", QSettings::IniFormat); #endif for (int i = 0; i < calibrationData.size(); ++i) { settingsFile.setValue(QString("calibrationData") + QString::number(i), calibrationData[i]); } }
bool AppPathManager::isPortable() { if(_settingsPath.isNull()) _settingsPath = ApplicationPath; if(!QFile(settingsFile()).exists()) return false; bool forcePortable=false; QSettings checkForPort(settingsFile(), QSettings::IniFormat); checkForPort.beginGroup("Main"); forcePortable= checkForPort.value("force-portable", false).toBool(); checkForPort.endGroup(); return forcePortable; }
//------------------------------------------------------------------------------------------------- bool ExportFile( const QString& filepath, quint32 serialNumber ) { //TODO: should probably recombine this with the original code tFile file( filepath ); if ( !file.open( QIODevice::WriteOnly ) ) { //DbgPrintf( QString("Failed to open output file %1").arg( filepath ) ); return false; } QDataStream out( &file ); // we must set the version to 4.4 so newer builds with greater versions can build export files for older products. // even if we are sending in the 4.8 version a 4.4 build doesn't know what to do with it. out.setVersion( QDataStream::Qt_4_4 ); out.setByteOrder( QDataStream::LittleEndian ); // To match the user data file out << (qint32)SettingsFileVersion; out << (qint32)out.version(); // Qt QDataStream version QString titleString("Mercury exported settings file"); qint32 titleStringLength = titleString.length(); out << titleStringLength; out.writeRawData( titleString.toAscii(), titleStringLength ); QDateTime currentDateTime = QDateTime::currentDateTime(); QString dateString = currentDateTime.toString( tSystemSettings::Instance()->DateFormatString() ); qint32 dateStringLength = dateString.length(); out << dateStringLength; out.writeRawData( dateString.toAscii(), dateStringLength ); out << currentDateTime; out << serialNumber; tFile settingsFile( tPath::SettingsIniFile() ); if (settingsFile.open( QIODevice::ReadOnly | QIODevice::Text ) == false) { //DbgPrintf( "Failed to open Settings.ini file" ); return false; } QTextStream settingsFileStream( &settingsFile ); QString line; int length; while ( !settingsFileStream.atEnd() ) { line = settingsFileStream.readLine(); line.append("\n"); length = line.length(); out.writeRawData( line.toAscii(), length ); } settingsFile.close(); file.close(); QFileInfo fileInfo( filepath ); tFile::syncdir( fileInfo.absolutePath() ); return true; }
status_t TouchpadPref::SaveSettings() { BPath path; status_t status = GetSettingsPath(path); if (status != B_OK) return status; BFile settingsFile(path.Path(), B_READ_WRITE | B_CREATE_FILE); status = settingsFile.InitCheck(); if (status != B_OK) return status; if (settingsFile.Write(&fSettings, sizeof(touchpad_settings)) != sizeof(touchpad_settings)) { LOG("can't save settings\n"); return B_ERROR; } if (settingsFile.Write(&fWindowPosition, sizeof(BPoint)) != sizeof(BPoint)) { LOG("can't save window position\n"); return B_ERROR; } return B_OK; }
void DrishtiImport::saveSettings() { QString str; QDomDocument doc("Drishti_Import_v1.0"); QDomElement topElement = doc.createElement("DrishtiImportSettings"); doc.appendChild(topElement); { QDomElement de0 = doc.createElement("previousdirectory"); QDomText tn0; tn0 = doc.createTextNode(Global::previousDirectory()); de0.appendChild(tn0); topElement.appendChild(de0); } QString homePath = QDir::homePath(); QFileInfo settingsFile(homePath, ".drishti.import"); QString flnm = settingsFile.absoluteFilePath(); QFile f(flnm.toAscii().data()); if (f.open(QIODevice::WriteOnly)) { QTextStream out(&f); doc.save(out, 2); f.close(); } else QMessageBox::information(0, "Cannot save ", flnm.toAscii().data()); }
void DrishtiImport::loadSettings() { QString homePath = QDir::homePath(); QFileInfo settingsFile(homePath, ".drishti.import"); QString flnm = settingsFile.absoluteFilePath(); if (! settingsFile.exists()) return; QDomDocument document; QFile f(flnm.toAscii().data()); if (f.open(QIODevice::ReadOnly)) { document.setContent(&f); f.close(); } QDomElement main = document.documentElement(); QDomNodeList dlist = main.childNodes(); for(uint i=0; i<dlist.count(); i++) { if (dlist.at(i).nodeName() == "previousdirectory") { QString str = dlist.at(i).toElement().text(); Global::setPreviousDirectory(str); } } }
status_t TouchpadPref::LoadSettings() { BPath path; status_t status = GetSettingsPath(path); if (status != B_OK) return status; BFile settingsFile(path.Path(), B_READ_ONLY); status = settingsFile.InitCheck(); if (status != B_OK) return status; if (settingsFile.Read(&fSettings, sizeof(touchpad_settings)) != sizeof(touchpad_settings)) { LOG("failed to load settings\n"); return B_ERROR; } if (settingsFile.Read(&fWindowPosition, sizeof(BPoint)) != sizeof(BPoint)) { LOG("failed to load settings\n"); return B_ERROR; } return B_OK; }
bool OSMRendererClient::load() { if ( m_advancedSettings == NULL ) m_advancedSettings = new OSMRSettingsDialog(); advancedSettingsChanged(); network = new QNetworkAccessManager( this ); diskCache = new QNetworkDiskCache( this ); QString cacheDir = QDesktopServices::storageLocation( QDesktopServices::CacheLocation ); if ( cacheDir == "" ) { cacheDir = QDesktopServices::storageLocation( QDesktopServices::TempLocation ); QDir dir( cacheDir ); dir.mkdir( "osmrenderer" ); dir.cd( "osmrenderer" ); cacheDir = dir.path(); } qDebug() << "set disk cache to: " << cacheDir; diskCache->setCacheDirectory( cacheDir ); network->setCache( diskCache ); connect( network, SIGNAL(finished(QNetworkReply*)), this, SLOT(finished(QNetworkReply*)) ); tileSize = 256; QFile settingsFile( fileInDirectory( m_directory, "OSM Renderer" ) + "_settings" ); if ( !openQFile( &settingsFile, QIODevice::ReadOnly ) ) return false; while ( true ) { int zoomLevel; if ( settingsFile.read( ( char* ) &zoomLevel, sizeof( zoomLevel ) ) != sizeof( zoomLevel ) ) break; m_zoomLevels.push_back( zoomLevel ); } return true; }
void UPnPServerSettings::loadFromFile() { ifstream settingsFile(m_SettingsFile.c_str()); if (!settingsFile.is_open()) { log::info("No config file present, relying on default values"); return; } string line; while (getline(settingsFile, line)) { if (line.empty()) { continue; } std::vector<std::string> items = stringops::tokenize(line, "="); if (items.size() != 4) { log::warn("Warning: ignoring malformed line in config file: %s", line); continue; } upnp::Service service; service.m_ControlURL = stringops::trim(items[3].c_str()); auto server = std::make_shared<upnp::Device>(); server->m_UserDefinedName = stringops::trim(items[0].c_str()); server->m_UDN = stringops::trim(items[1].c_str()); server->m_ContainerId = stringops::trim(items[2].c_str()); server->m_Services[upnp::ServiceType::ContentDirectory] = service; m_Servers.push_back(server); } }
void MainTray::readSettings() { QDir configDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)); if (!configDir.exists()) { if (!configDir.mkpath(configDir.absolutePath())) return; } QFile settingsFile(configDir.absolutePath() + '/' + ConfigFileName); if (settingsFile.open(QIODevice::ReadOnly)) { QDataStream settingsReader(&settingsFile); settingsReader.setVersion(QDataStream::Qt_5_4); QTime tempTime; settingsReader >> tempTime; updateInterval(tempTime); quint64 currentID; qint32 sizeSkip; while(!settingsReader.atEnd()){ settingsReader >> currentID; for (auto i = m_taskList.begin(); i != m_taskList.end(); ++i) { if((*i)->getTaskID()==currentID){ settingsReader.device()->seek(settingsReader.device()->pos() - sizeof(quint64)); (*i)->readSettings(settingsReader); break; } if (i == m_taskList.end()-1){ // task not found, skip it settingsReader >> sizeSkip; settingsReader.skipRawData(sizeSkip); } } }
void DomainServerSettingsManager::persistToFile() { QFile settingsFile(QCoreApplication::applicationDirPath() + SETTINGS_CONFIG_FILE_RELATIVE_PATH); if (settingsFile.open(QIODevice::WriteOnly)) { settingsFile.write(getJSONSettingsMap()); } else { qCritical("Could not write to JSON settings file. Unable to persist settings."); } }
Result InitComponent::saveConfig() { AudioDeviceManager::AudioDeviceSetup audioDeviceSetup; deviceManager.getAudioDeviceSetup(audioDeviceSetup); ScopedPointer<XmlElement> audioDeviceState ( deviceManager.createStateXml() ); /* create audioDeviceState when no changes were applied to the device settings */ if (audioDeviceState == NULL) { audioDeviceState = createXmlSettings(deviceManager); } /* Check if audioDeviceState is complete */ String attrString; attrString = "audioDeviceRate"; if ( !audioDeviceState->hasAttribute( attrString ) ) audioDeviceState->setAttribute(attrString, audioDeviceSetup.sampleRate ); attrString = "audioDeviceBufferSize"; if ( !audioDeviceState->hasAttribute(attrString ) ) audioDeviceState->setAttribute( attrString, audioDeviceSetup.bufferSize ); attrString = "audioDeviceInChans"; if ( !audioDeviceState->hasAttribute( attrString ) ) audioDeviceState->setAttribute( attrString, audioDeviceSetup.inputChannels.toString(2, 1) ); attrString = "audioDeviceOutChans"; if ( !audioDeviceState->hasAttribute( attrString ) ) audioDeviceState->setAttribute( attrString, audioDeviceSetup.outputChannels.toString(2, 1) ); /* add more attributes to audioDeviceState */ XmlElement* mchaSettings = new XmlElement( "MCHASETTINGS" ); // this will be deleted automatically by the parent mchaSettings->setAttribute( "loggingLevel", mchaSettingsComponent->getLogLevel() ); mchaSettings->setAttribute( "memoryMode", mchaSettingsComponent->getMemoryMode() ); audioDeviceState->addChildElement(mchaSettings); File settingsFile( settingsFileName ); if (settingsFile == File::nonexistent) { return Result::fail( L"Settings file is absent" );; } DBG( L"mchaInit:\n Settings file created:\t" + settingsFile.getFileName() ); if ( !audioDeviceState->writeToFile ( settingsFile, String::empty ) ) { return Result::fail( L"Unable to save settings" ); } deviceManager.closeAudioDevice(); return Result::ok(); }
void QgsUserProfileManager::setRootLocation( const QString &rootProfileLocation ) { mRootProfilePath = rootProfileLocation; //updates (or removes) profile file watcher for new root location setNewProfileNotificationEnabled( mWatchProfiles ); mSettings.reset( new QSettings( settingsFile(), QSettings::IniFormat ) ); }
EditorConfig::EditorConfig() : _file_watcher(new QFileSystemWatcher()) { //Make sure the file exists so that mupuf's horrible file watcher doesn't bug QFile settingsFile(QSettings().fileName()); settingsFile.open(QFile::Append); settingsFile.close(); //Watch for settings updates from other instances // _file_watcher->addPath(QSettings().fileName()); // connect(_file_watcher, SIGNAL(fileChanged(QString)), this, SIGNAL(updated())); }
// Parse contents of specified file as JSON and set any settings contained in // the JSON to their specified values bool Settings::SetFromFile(const std::string& filename) { std::stringstream buffer; std::ifstream settingsFile(filename.c_str()); // check if file exists if (!settingsFile.is_open()) return false; buffer << settingsFile.rdbuf(); return SetFromJSONString(buffer.str()); }
// If the print data contains the specified file, read contents into specified // string and return true. Otherwise, return false. bool PrintDataDirectory::GetFileContents(const std::string& fileName, std::string& contents) { std::string path = _directoryPath + "/" + fileName; std::ifstream settingsFile(path.c_str()); if (settingsFile.good()) { std::stringstream buffer; buffer << settingsFile.rdbuf(); contents = buffer.str(); return true; } else return false; }
bool eraseSettings() { QString homePath = QDir::homePath(); QString settingsFilePath = QDir(homePath).filePath(".config/MapMap/MapMap.conf"); QFile settingsFile(settingsFilePath); if (! settingsFile.exists()) { return false; } else { qDebug() << "Erase MapMap settings."; settingsFile.close(); return settingsFile.remove(); } }
JobManager::JobManager(QObject *parent) : QObject(parent) { QDir temp = QDir(QDir::tempPath()); m_monavSettings = QFileInfo(temp, "monav_settings.ini"); QFile settingsFile(m_monavSettings.absoluteFilePath()); settingsFile.open(QFile::WriteOnly | QFile::Truncate); QTextStream settingsStream(&settingsFile); settingsStream << "[General]\npackaging=false\ndictionarySize=16384\nblockSize=16384\n"; settingsStream << "importer=OpenStreetMap Importer\nrouter=Contraction Hierarchies"; settingsStream << "renderer=Mapnik Renderer\ngpsLookup=GPS Grid\naddressLookup=Unicode Tournament Trie\n\n"; settingsStream << "[OSM%20Importer]\nlanguages=name\nspeedProfile=:/speed profiles/motorcar.spp\n\n"; settingsStream << "[ContractionHierarchies]\nblockSize=12\n"; settingsFile.close(); }
Dispatcher::Dispatcher(char *port, char *settings_file) { this->port = port; cluster_nodes = new std::vector<struct Host*>; std::ifstream settingsFile(settings_file); if (!settingsFile.is_open()) { log_err("Could not find settings file."); throw "Could not find settings file."; } Json::Reader r = Json::Reader(); Json::Value v; debug("Parse settings"); if (!r.parse(settingsFile, v, false)) { log_err("Could not parse settings file! No valid JSON."); throw "Could not parse settings file! No valid JSON."; } Json::Value jsonHosts = v.get("hosts", ""); for (auto host: jsonHosts) { std::string url = host.get("url", "").asString(); int port = host.get("port", "0").asInt(); if (url != "" and port != 0) { const char *url_c = url.c_str(); add_host(url_c, port); } } if (cluster_nodes->size() == 0) { debug("Settings file does not contain any valid hosts."); } thread_pool_size = v.get("threads", 1).asInt(); std::string dispatch_algorithm = v.get("algorithm", "RoundRobin").asString(); if (dispatch_algorithm == "Stream") { distributor = new StreamDistributor(cluster_nodes); debug("Used dispatching algorithm: Stream"); } else { //SimpleRoundRobinDipatcher is the standard algorithm distributor = new RoundRobinDistributor(cluster_nodes); debug("Used dispatching algorithm: RoundRobin"); } }
bool Settings::read(QString fname) { QFile settingsFile(fname); if (!settingsFile.open(QIODevice::ReadOnly)) return false; QJsonParseError errors; QJsonDocument json = QJsonDocument::fromJson(settingsFile.readAll(), &errors); if (errors.error != QJsonParseError::NoError) return false; if (!json.isObject()) return false; auto rootObj = json.object(); auto workingDir = Files::absPath(rootObj["workingDir"].toString(this->workingDir().path)); auto downloadsDir = Files::absPath(rootObj["downloadsDir"].toString(this->downloadsDir().path)); vcVersion = rootObj["vcVersion"].toString(); if (vcVersion != MSVC_VERSION) { vcVarsPath = extractVCVarsPath(); vcVersion = MSVC_VERSION; } else { vcVarsPath = rootObj["vcVarsPath"].toString(extractVCVarsPath()); } outputPath = Files::absPath(rootObj["outputPath"].toString(outputPath)); isFirstUsage = rootObj["isFirstUsage"].toBool(false); selfUpdateSourceUrl = rootObj["selfUpdateSourceUrl"].toString(selfUpdateSourceUrl); auto librarySourcesArray = rootObj["librarySources"].toArray(); librarySources.clear(); librarySources.append(LibrarySource{ LibrarySource::WorkingDirectory, workingDir, SourceStatus::Unknown }); librarySources.append(LibrarySource{ LibrarySource::DownloadsDirectory, downloadsDir, SourceStatus::Unknown }); foreach (auto sourceValue, librarySourcesArray) { auto sourceObj = sourceValue.toObject(); LibrarySource::Type type = LibrarySource::Directory; auto typeStr = sourceObj["type"].toString("directory"); if (typeStr == "server") type = LibrarySource::Server; auto path = sourceObj["path"].toString(); if (path.isEmpty()) continue; if (type != LibrarySource::Server) path = Files::absPath(path); librarySources.append(LibrarySource{ type, path, SourceStatus::Unknown }); }
/** * Clumsily define the defaults application-wide in this constructor. * Is there a way to do this in bulk using C++11 uniform initialisation? */ ConfigManager::ConfigManager() { configRoot[ "fps_overview" ] = 30; configRoot[ "vsync_limiter_overview" ] = false; configRoot[ "min_log_level" ] = 0; configRoot[ "logfile_path" ] = "bluebear.log"; configRoot[ "logger_mode" ] = 0; configRoot[ "viewport_x" ] = 1024; configRoot[ "viewport_y" ] = 768; configRoot[ "current_locale" ] = "en_US"; configRoot[ "key_switch_perspective" ] = sf::Keyboard::P; configRoot[ "key_move_up" ] = sf::Keyboard::Up; configRoot[ "key_move_down" ] = sf::Keyboard::Down; configRoot[ "key_move_left" ] = sf::Keyboard::Left; configRoot[ "key_move_right" ] = sf::Keyboard::Right; configRoot[ "key_terminal" ] = sf::Keyboard::Tilde; configRoot[ "key_pause" ] = sf::Keyboard::Num1; configRoot[ "key_play" ] = sf::Keyboard::Num2; configRoot[ "key_play_fast" ] = sf::Keyboard::Num3; configRoot[ "key_rotate_right" ] = sf::Keyboard::E; configRoot[ "key_rotate_left" ] = sf::Keyboard::Q; configRoot[ "key_zoom_in" ] = sf::Keyboard::Add; configRoot[ "key_zoom_out" ] = sf::Keyboard::Subtract; configRoot[ "disable_image_cache" ] = false; configRoot[ "disable_texture_cache" ] = false; configRoot[ "ui_theme" ] = "system/ui/default.theme"; configRoot[ "max_ingame_terminal_scrollback" ] = 100; // Load settings.json from file std::ifstream settingsFile( SETTINGS_PATH ); Json::Value settingsJSON; Json::Reader reader; if( reader.parse( settingsFile, settingsJSON ) ) { // Override defaults // iterators - barf for( Json::Value::iterator jsonIterator = settingsJSON.begin(); jsonIterator != settingsJSON.end(); ++jsonIterator ) { // BARF Json::Value key = jsonIterator.key(); Json::Value value = *jsonIterator; // Store every value as a string because strong typing is a PITA configRoot[ key.asString() ] = value; } } }
void Conf::init(std::string filename) { std::ifstream settingsFile(filename.c_str()); std::string key; while (settingsFile >> key) { if (key.compare("#")) { std::getline (std::cin,key); continue; } if (key.compare("GyroAcceleration")) { settingsFile >> GyroAcceleration; continue; } if (key.compare("GyroForce")) { settingsFile >> GyroForce; continue; }
bool JSONStorage::loadSettings() { //open the json settings file QString fullPath = buildFullPath(Settings); QFile settingsFile(fullPath); if (!settingsFile.open(QIODevice::ReadOnly)) { qWarning("Couldn't open save file."); return false; } //read the contents into a bytearray QByteArray settingsData = settingsFile.readAll(); settingsFile.close(); //store content as a local json structure _settingsJson.fromJson(settingsData); return true; }
void ProtocolHandler::LoadPasswords() { //find settings dir BPath passwordPath; find_directory(B_USER_SETTINGS_DIRECTORY, &passwordPath); //append Bme path and Cache path passwordPath.Append(K_BME_SETTINGS_PATH); passwordPath.Append(K_CACHE_PATH); //loop through Bme Cache path and find all login names with saved passwords BDirectory cacheDir(passwordPath.Path()); int32 entryNum = cacheDir.CountEntries(); //compose list of loginNames with passwords for (int32 i = 0; i < entryNum;i++) { BEntry entry; cacheDir.GetNextEntry(&entry); //only open if it is a file!!! if (entry.IsFile()) { BFile settingsFile(&entry, B_READ_ONLY); //data is stored as BMessages BMessage message; message.Unflatten(&settingsFile); //see if password is stored in message BString password; BMessage userMessage; if (message.FindMessage("user",&userMessage) == B_OK) { if (userMessage.FindString("User::password",&password) == B_OK) { BString loginName; if (userMessage.FindString("Contact::passport" ,&loginName) == B_OK) { Login login = {loginName,password}; m_passwords.push_back(login); } } } } } }
bool JurisdictionMap::readFromFile(const char* filename) { QString settingsFile(filename); QSettings settings(settingsFile, QSettings::IniFormat); QString rootCode = settings.value("root","00").toString(); qDebug() << "rootCode=" << rootCode << "\n"; _rootOctalCode = hexStringToOctalCode(rootCode); printOctalCode(_rootOctalCode); settings.beginGroup("endNodes"); const QStringList childKeys = settings.childKeys(); QHash<QString, QString> values; foreach (const QString &childKey, childKeys) { QString childValue = settings.value(childKey).toString(); values.insert(childKey, childValue); qDebug() << childKey << "=" << childValue << "\n"; unsigned char* octcode = hexStringToOctalCode(childValue); printOctalCode(octcode); _endNodes.push_back(octcode); }
void SettingsDialog::accept() { m_saveSignalCount = 0; Q_FOREACH(ConfigurationWidgetInterface *page, pages) { if (!page->checkValidity()) { stack->setCurrentWidget(page->asWidget()); return; } connect(page->asWidget(), SIGNAL(saved()), this, SLOT(slotAccept())); ++m_saveSignalCount; } #ifndef Q_OS_WIN // Try to wour around QSettings' inability to set umask for its file access. We don't want to set umask globally. QFile settingsFile(m_settings->fileName()); settingsFile.setPermissions(QFile::ReadUser | QFile::WriteUser); #endif buttons->setEnabled(false); Q_FOREACH(ConfigurationWidgetInterface *page, pages) { page->asWidget()->setEnabled(false); }
PadBlocker::PadBlocker() { _lastKeyUp = 0; _threshold = 300; //~one third of a second? #if Z_DEBUG BeDC dc("PadBlocker"); #endif //load settings file BPath settingsPath; if (find_directory(B_USER_SETTINGS_DIRECTORY, &settingsPath) == B_OK) { settingsPath.Append("PadBlocker_settings"); BEntry settingsEntry(settingsPath.Path()); //does the settings file exist? if (!settingsEntry.Exists()) { #if Z_DEBUG dc.SendMessage("Settings file does not exist. Creating new one."); #endif BFile defaultSettingsFile(&settingsEntry, B_CREATE_FILE | B_READ_WRITE); if (defaultSettingsFile.IsWritable()) { //write in default settings char buf[64]; sprintf(buf, "%ld #delay in 1/1000 secs", (int32)_threshold); defaultSettingsFile.WriteAt(0, (void *)buf, strlen(buf)); defaultSettingsFile.Unset(); } } else { #if Z_DEBUG dc.SendMessage("Settings file Exists"); #endif BFile settingsFile(&settingsEntry, B_READ_WRITE); if (settingsFile.IsReadable()) { char buf[256]; uint32 amt_read = settingsFile.ReadAt(0, (void *)buf, 256); buf[amt_read] = '\0'; _threshold = atoi(buf); } } } _threshold *= 1000; //I'd rather keep the number in the file in thousandths #ifdef Z_DEBUG dc.SendInt(_threshold, "Touchpad threshold."); #endif }
void Gdc2005Demo::optionUpdate() { const hkVector4 UP(0,1,0); // Handle load save //Set capsule size. { const hkReal totalHeight = m_options.m_Proxy.m_height; const hkReal radius = m_options.m_Proxy.m_radius; const hkReal capsulePoint = totalHeight*0.5f - radius; updateProxyDisplay(m_options.m_Proxy.m_radius, m_options.m_Proxy.m_height); hkVector4 vertexA(0, capsulePoint * 2 + radius, 0); hkVector4 vertexB(0, radius, 0); hkpCapsuleShape* capsule = static_cast<hkpCapsuleShape*>( const_cast<hkpShape*>(m_characterProxy->getShapePhantom()->getCollidable()->getShape() )); capsule->setRadius( radius ); capsule->setVertex(0, vertexA); capsule->setVertex(1, vertexB); } // Set gravity hkVector4 gravity; gravity.setMul4( -m_options.m_Physics.m_gravity, UP); m_world->setGravity( gravity ); // Ragdoll bodies (green) if (m_options.m_Display.m_ragdoll != m_ragdollDisplayBodiesVisible ) { toggleRagdollVisibility(); } if (m_options.m_Display.m_proxy != m_proxyVisible) { toggleProxyVisibility(); } // Graphics hkDefaultDemo::forceShadowState( m_options.m_Display.m_shadows ); if (m_lightmapDisplay) { if (m_options.m_Display.m_lightmaps) { int vertsIn = m_env->m_displayWorld->findDisplayObject( m_vertexColorDisplay ); if (vertsIn >= 0 ) { m_env->m_displayWorld->removeDisplayObject( vertsIn ); m_vertexColorDisplay->release(); // already have a ref anyway m_env->m_displayWorld->addDisplayObject( m_lightmapDisplay ); } } else { int lmIn = m_env->m_displayWorld->findDisplayObject( m_lightmapDisplay ); if (lmIn >= 0 ) { m_env->m_displayWorld->removeDisplayObject( lmIn ); m_lightmapDisplay->release(); // already have a ref anyway m_env->m_displayWorld->addDisplayObject( m_vertexColorDisplay ); } } } hkReal w = hkMath::max2( m_animatedSkeleton->getAnimationControl(GDC_DEATH_CONTROL)->getWeight(), m_animatedSkeleton->getAnimationControl(GDC_DYING_CONTROL)->getWeight()); setMotors(m_ragdollInstance, m_options.m_Matching.m_force * w, m_options.m_Matching.m_tau, m_options.m_Matching.m_proportinalRecovery, m_options.m_Matching.m_constantRecovery); // Do rebuild walls, save and load from XML, etc., when we have finished tweaking if (m_tweaking == false) { switch (m_options.m_Misc.m_settings) { case hkGdcMiscOptions::SAVE: { hkBinaryPackfileWriter pw; pw.setContents(&m_options, Gdc2005DemoOptionsClass); hkOfstream settingsFile("GdcDemoSettings.bin"); if (settingsFile.isOk()) { hkPackfileWriter::Options o; pw.save( settingsFile.getStreamWriter(), o ); } } break; case hkGdcMiscOptions::LOAD: { hkBinaryPackfileReader pw; hkIfstream settingsFile("GdcDemoSettings.bin"); if (settingsFile.isOk()) { pw.loadEntireFile( settingsFile.getStreamReader() ); Gdc2005DemoOptions* options = (Gdc2005DemoOptions*)pw.getContents(Gdc2005DemoOptionsClass.getName()); m_options = *options; } } break; case hkGdcMiscOptions::DEFAULT: { // Copy from defaults m_options = Gdc2005DemoOptions(); m_selected = "/"; } break; case hkGdcMiscOptions::NONE: break; } m_options.m_Misc.m_settings = hkGdcMiscOptions::NONE; if (m_options.m_Physics.m_rebuildWall) { rebuildBrickWall(); m_options.m_Physics.m_rebuildWall = false; // reset } } }
SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) #else SettingsDialog::SettingsDialog(const QString& graverFileFilter, QWidget* parent) : QDialog(parent), graverFileFilter(graverFileFilter) #endif { ui.setupUi(this); setWindowFlags(Qt::MSWindowsFixedSizeDialogHint); #ifdef TEST_ONLY QSettings settingsFile("tokenTest_Settings.ini", QSettings::IniFormat); #else QSettings settingsFile("tokenGraver_Settings.ini", QSettings::IniFormat); #endif settings.testingType = static_cast<TestingType>(settingsFile.value("testingType").toUInt()); settings.fullTestInterval = settingsFile.value("interval").toUInt(); settings.fileName = settingsFile.value("fileName").toString(); settings.currentTestingCounter = settingsFile.value("counter").toUInt(); settings.connectionType = static_cast<ConnectionType>(settingsFile.value("connectionType").toUInt()); // int i = 0; // while (true) { // QString portChain = settingsFile.value("calibrationData" + QString::number(i)).toString(); // if (portChain.isEmpty()) // break; // else { // if (i >= settings.calibrationData.size()) // settings.calibrationData.resize(i + 1); // settings.calibrationData[i] = portChain; // } // ++i; // } #ifdef TEST_ONLY ui.fileEdit->setVisible(false); ui.fileButton->setVisible(false); ui.fileLabel->setVisible(false); #else ui.connectionTypeComboBox->removeItem(2); ui.connectionTypeComboBox->removeItem(1); #endif applySettings(); } //---------------------------------------------------------------------------------------------------------------------- void SettingsDialog::saveSettings() { TestingType testingType; if (ui.quickTestButton->isChecked()) testingType = TT_QUICK; else if (ui.autoTestButton->isChecked()) testingType = TT_AUTO; else if (ui.fullTestButton->isChecked()) testingType = TT_FULL; else assert(false); settings.testingType = testingType; settings.fullTestInterval = ui.nSpinBox->value(); settings.fileName = ui.fileEdit->text(); settings.connectionType = static_cast<ConnectionType>(ui.connectionTypeComboBox->currentIndex()); #ifdef TEST_ONLY QSettings settingsFile("tokenTest_Settings.ini", QSettings::IniFormat); #else QSettings settingsFile("tokenGraver_Settings.ini", QSettings::IniFormat); #endif settingsFile.setValue("testingType", settings.testingType); settingsFile.setValue("interval", settings.fullTestInterval); settingsFile.setValue("fileName", settings.fileName); settingsFile.setValue("counter", settings.currentTestingCounter); settingsFile.setValue("connectionType", settings.connectionType); // if (settings.connectionType == CT_SEVEN_TWO_COLUMNS) { // settings.calibrationData.resize(7); // for (int i = 0; i < 7; ++i) // settings.calibrationData[i] = QString::number(i + 1); // } else if (settings.connectionType == CT_SEVEN_ONE_ROW) { // settings.calibrationData.clear(); // int i = 0; // while (true) { // QString portChain = settingsFile.value("calibrationData" + QString::number(i)).toString(); // if (portChain.isEmpty()) // break; // else { // if (i >= settings.calibrationData.size()) // settings.calibrationData.resize(i + 1); // settings.calibrationData[i] = portChain; // } // ++i; // } // } }
void CrashHandler::handleCrash(CrashHandler::Action action) { if (action != CrashHandler::DELETE_INTERFACE_INI && action != CrashHandler::RETAIN_IMPORTANT_INFO) { // CrashHandler::DO_NOTHING or unexpected value return; } QSettings settings; const QString ADDRESS_MANAGER_GROUP = "AddressManager"; const QString ADDRESS_KEY = "address"; const QString AVATAR_GROUP = "Avatar"; const QString DISPLAY_NAME_KEY = "displayName"; const QString FULL_AVATAR_URL_KEY = "fullAvatarURL"; const QString FULL_AVATAR_MODEL_NAME_KEY = "fullAvatarModelName"; const QString TUTORIAL_COMPLETE_FLAG_KEY = "tutorialComplete"; QString displayName; QUrl fullAvatarURL; QString fullAvatarModelName; QUrl address; bool tutorialComplete = false; if (action == CrashHandler::RETAIN_IMPORTANT_INFO) { // Read avatar info // Location and orientation settings.beginGroup(ADDRESS_MANAGER_GROUP); address = settings.value(ADDRESS_KEY).toUrl(); settings.endGroup(); // Display name and avatar settings.beginGroup(AVATAR_GROUP); displayName = settings.value(DISPLAY_NAME_KEY).toString(); fullAvatarURL = settings.value(FULL_AVATAR_URL_KEY).toUrl(); fullAvatarModelName = settings.value(FULL_AVATAR_MODEL_NAME_KEY).toString(); settings.endGroup(); // Tutorial complete tutorialComplete = settings.value(TUTORIAL_COMPLETE_FLAG_KEY).toBool(); } // Delete Interface.ini QFile settingsFile(settings.fileName()); if (settingsFile.exists()) { settingsFile.remove(); } if (action == CrashHandler::RETAIN_IMPORTANT_INFO) { // Write avatar info // Location and orientation settings.beginGroup(ADDRESS_MANAGER_GROUP); settings.setValue(ADDRESS_KEY, address); settings.endGroup(); // Display name and avatar settings.beginGroup(AVATAR_GROUP); settings.setValue(DISPLAY_NAME_KEY, displayName); settings.setValue(FULL_AVATAR_URL_KEY, fullAvatarURL); settings.setValue(FULL_AVATAR_MODEL_NAME_KEY, fullAvatarModelName); settings.endGroup(); // Tutorial complete settings.setValue(TUTORIAL_COMPLETE_FLAG_KEY, tutorialComplete); } }