bool WaveformWidgetFactory::setWidgetType(WaveformWidgetType::Type type) { if (type == m_type) return true; // check if type is acceptable for (int i = 0; i < m_waveformWidgetHandles.size(); i++) { WaveformWidgetAbstractHandle& handle = m_waveformWidgetHandles[i]; if (handle.m_type == type) { // type is acceptable m_type = type; if (m_config) { m_config->set(ConfigKey("[Waveform]","WaveformType"), ConfigValue((int)m_type)); } return true; } } // fallback m_type = WaveformWidgetType::EmptyWaveform; if (m_config) { m_config->set(ConfigKey("[Waveform]","WaveformType"), ConfigValue((int)m_type)); } return false; }
void WaveformWidgetFactory::setZoomSync(bool sync) { m_zoomSync = sync; if (m_config) { m_config->set(ConfigKey("[Waveform]","ZoomSynchronization"), ConfigValue(m_zoomSync)); } if (m_waveformWidgetHolders.size() == 0) { return; } int refZoom = m_waveformWidgetHolders[0].m_waveformWidget->getZoomFactor(); for (int i = 1; i < m_waveformWidgetHolders.size(); i++) { m_waveformWidgetHolders[i].m_waveformViewer->setZoom(refZoom); } }
void WaveformWidgetFactory::setDisplayBeatGrid(bool sync) { m_beatGridEnabled = sync; if (m_config) { m_config->set(ConfigKey("[Waveform]", "beatGridLinesCheckBox"), ConfigValue(m_beatGridEnabled)); } if (m_waveformWidgetHolders.size() == 0) { return; } for (int i = 0; i < m_waveformWidgetHolders.size(); i++) { m_waveformWidgetHolders[i].m_waveformWidget->setDisplayBeatGrid(m_beatGridEnabled); } }
void BasePlaylistFeature::slotImportPlaylist() { qDebug() << "slotImportPlaylist() row:" ; //<< m_lastRightClickedIndex.data(); if (!m_pPlaylistTableModel) { return; } QString lastPlaylistDirectory = m_pConfig->getValueString( ConfigKey("[Library]", "LastImportExportPlaylistDirectory"), QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); QString playlist_file = QFileDialog::getOpenFileName( NULL, tr("Import Playlist"), lastPlaylistDirectory, tr("Playlist Files (*.m3u *.m3u8 *.pls *.csv)")); // Exit method if user cancelled the open dialog. if (playlist_file.isNull() || playlist_file.isEmpty()) { return; } // Update the import/export playlist directory QFileInfo fileName(playlist_file); m_pConfig->set(ConfigKey("[Library]","LastImportExportPlaylistDirectory"), ConfigValue(fileName.dir().absolutePath())); Parser* playlist_parser = NULL; if (playlist_file.endsWith(".m3u", Qt::CaseInsensitive) || playlist_file.endsWith(".m3u8", Qt::CaseInsensitive)) { playlist_parser = new ParserM3u(); } else if (playlist_file.endsWith(".pls", Qt::CaseInsensitive)) { playlist_parser = new ParserPls(); } else if (playlist_file.endsWith(".csv", Qt::CaseInsensitive)) { playlist_parser = new ParserCsv(); } else { return; } QList<QString> entries = playlist_parser->parse(playlist_file); // Iterate over the List that holds URLs of playlist entires m_pPlaylistTableModel->addTracks(QModelIndex(), entries); // delete the parser object if (playlist_parser) { delete playlist_parser; } }
bool TrackExportWizard::selectDestinationDirectory() { QString lastExportDirectory = m_pConfig->getValue( ConfigKey("[Library]", "LastTrackCopyDirectory"), QStandardPaths::writableLocation(QStandardPaths::MusicLocation)); QString destDir = QFileDialog::getExistingDirectory( NULL, tr("Export Track Files To"), lastExportDirectory); if (destDir.isEmpty()) { return false; } m_pConfig->set(ConfigKey("[Library]", "LastTrackCopyDirectory"), ConfigValue(destDir)); m_worker.reset(new TrackExportWorker(destDir, m_tracks)); m_dialog.reset(new TrackExportDlg(m_parent, m_pConfig, m_worker.data())); return true; }
void DlgPrefAutoDJ::slotEnableAutoDJRandomQueueComboBox(int a_iValue) { #ifdef __AUTODJCRATES__ if (a_iValue == 1) { // Requeue is enabled m_pConfig->set(ConfigKey("[Auto DJ]", "EnableRandomQueueBuff"), ConfigValue(0)); ComboBoxAutoDjRandomQueue->setCurrentIndex(0); ComboBoxAutoDjRandomQueue->setEnabled(false); autoDJRandomQueueMinimumSpinBox->setEnabled(false); } else { ComboBoxAutoDjRandomQueue->setEnabled(true); autoDJRandomQueueMinimumSpinBox->setEnabled( m_pConfig->getValueString( ConfigKey("[Auto DJ]", "EnableRandomQueueBuff"),"0").toInt()); } #endif // __AUTODJCRATES__ }
void DlgPrefAutoDJ::slotResetToDefaults() { // Re-queue tracks in AutoDJ ComboBoxAutoDjRequeue->setCurrentIndex(0); m_pConfig->set(ConfigKey("[Auto DJ]", "RequeueBuff"),ConfigValue(0)); autoDjMinimumAvailableSpinBox->setValue(20); autoDjIgnoreTimeEdit->setTime(QTime::fromString( "23:59", autoDjIgnoreTimeEdit->displayFormat())); autoDjIgnoreTimeCheckBox->setChecked(false); m_pConfig->set(ConfigKey("[Auto DJ]", "UseIgnoreTimeBuff"),QString("0")); autoDjIgnoreTimeEdit->setEnabled(false); autoDJRandomQueueMinimumSpinBox->setValue(5); ComboBoxAutoDjRandomQueue->setCurrentIndex(0); m_pConfig->set(ConfigKey("[Auto DJ]", "EnableRandomQueueBuff"),QString("0")); autoDJRandomQueueMinimumSpinBox->setEnabled(false); ComboBoxAutoDjRandomQueue->setEnabled(true); }
// Selects the option by its index. If it is a single-element option, // index 0 means disabled and 1 enabled. void EncoderMp3Settings::setGroupOption(QString groupCode, int optionIndex) { bool found=false; for (const auto& group : m_radioList) { if (groupCode == group.groupCode) { found=true; if (optionIndex < group.controlNames.size() || optionIndex == 1) { m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, ENCODING_MODE_GROUP), ConfigValue(optionIndex)); } else { qWarning() << "Received an index out of range for: " << groupCode << ", index: " << optionIndex; } } } if (!found) { qWarning() << "Received an unknown groupCode on setGroupOption: " << groupCode; } }
void AnalysisFeature::analyzeTracks(QList<int> trackIds) { if (m_pAnalyserQueue == NULL) { // Save the old BPM detection prefs setting (on or off) m_iOldBpmEnabled = m_pConfig->getValueString(ConfigKey("[BPM]","BPMDetectionEnabled")).toInt(); // Force BPM detection to be on. m_pConfig->set(ConfigKey("[BPM]","BPMDetectionEnabled"), ConfigValue(1)); // Note: this sucks... we should refactor the prefs/analyser to fix this hacky bit ^^^^. m_pAnalyserQueue = AnalyserQueue::createAnalysisFeatureAnalyserQueue(m_pConfig, m_pTrackCollection); connect(m_pAnalyserQueue, SIGNAL(trackProgress(int)), m_pAnalysisView, SLOT(trackAnalysisProgress(int))); connect(m_pAnalyserQueue, SIGNAL(trackFinished(int)), this, SLOT(slotProgressUpdate(int))); connect(m_pAnalyserQueue, SIGNAL(trackFinished(int)), m_pAnalysisView, SLOT(trackAnalysisFinished(int))); connect(m_pAnalyserQueue, SIGNAL(queueEmpty()), this, SLOT(cleanupAnalyser())); emit(analysisActive(true)); }
const ConfigValue FRTConfigResponseV3::readConfigValue() const { vespalib::string md5(_data->get()[RESPONSE_CONFIG_MD5].asString().make_string()); CompressionInfo info; info.deserialize(_data->get()[RESPONSE_COMPRESSION_INFO]); Slime * rawData = new Slime(); SlimePtr payloadData(rawData); DecompressedData data(decompress(((*_returnValues)[1]._data._buf), ((*_returnValues)[1]._data._len), info.compressionType, info.uncompressedSize)); if (data.memRef.size > 0) { size_t consumedSize = JsonFormat::decode(data.memRef, *rawData); if (consumedSize == 0) { std::string json(make_json(*payloadData, true)); LOG(error, "Error decoding JSON. Consumed size: %lu, uncompressed size: %u, compression type: %s, assumed uncompressed size(%u), compressed size: %u, slime(%s)", consumedSize, data.size, compressionTypeToString(info.compressionType).c_str(), info.uncompressedSize, ((*_returnValues)[1]._data._len), json.c_str()); LOG_ABORT("Error decoding JSON"); } } if (LOG_WOULD_LOG(spam)) { LOG(spam, "read config value md5(%s), payload size: %lu", md5.c_str(), data.memRef.size); } return ConfigValue(PayloadPtr(new V3Payload(payloadData)), md5); }
void DlgPrefPlaylist::slotApply() { m_pconfig->set(ConfigKey("[Promo]","StatTracking"), ConfigValue((int)checkBoxPromoStats->isChecked())); m_pconfig->set(ConfigKey("[Library]","RescanOnStartup"), ConfigValue((int)checkBox_library_scan->isChecked())); m_pconfig->set(ConfigKey("[Library]","WriteAudioTags"), ConfigValue((int)checkbox_ID3_sync->isChecked())); m_pconfig->set(ConfigKey("[Library]","UseRelativePathOnExport"), ConfigValue((int)checkBox_use_relative_path->isChecked())); m_pconfig->set(ConfigKey("[Library]","ShowRhythmboxLibrary"), ConfigValue((int)checkBox_show_rhythmbox->isChecked())); m_pconfig->set(ConfigKey("[Library]","ShowITunesLibrary"), ConfigValue((int)checkBox_show_itunes->isChecked())); m_pconfig->set(ConfigKey("[Library]","ShowTraktorLibrary"), ConfigValue((int)checkBox_show_traktor->isChecked())); if (LineEditSongfiles->text() != m_pconfig->getValueString(ConfigKey("[Playlist]","Directory"))) { m_pconfig->set(ConfigKey("[Playlist]","Directory"), LineEditSongfiles->text()); emit(apply()); } m_pconfig->Save(); }
// We return the UserSettings here because we have to make changes to the // configuration and the location of the file may change between releases. UserSettingsPointer Upgrade::versionUpgrade(const QString& settingsPath) { /* Pre-1.7.0: * * Since we didn't store version numbers in the config file prior to 1.7.0, * we check to see if the user is upgrading if his config files are in the old location, * since we moved them in 1.7.0. This code takes care of moving them. */ QDir oldLocation = QDir(QDir::homePath()); #ifdef __WINDOWS__ QFileInfo* pre170Config = new QFileInfo(oldLocation.filePath("mixxx.cfg")); #else QFileInfo* pre170Config = new QFileInfo(oldLocation.filePath(".mixxx.cfg")); #endif if (pre170Config->exists()) { // Move the files to their new location QDir newLocation = QDir(settingsPath); if (!newLocation.exists()) { qDebug() << "Creating new settings directory" << newLocation.absolutePath(); newLocation.mkpath("."); } QString errorText = "Error moving your %1 file %2 to the new location %3: \n"; #ifdef __WINDOWS__ QString oldFilePath = oldLocation.filePath("mixxxtrack.xml"); #else QString oldFilePath = oldLocation.filePath(".mixxxtrack.xml"); #endif QString newFilePath = newLocation.filePath("mixxxtrack.xml"); QFile* oldFile = new QFile(oldFilePath); if (oldFile->exists()) { if (oldFile->copy(newFilePath)) { oldFile->remove(); } else { if (oldFile->error()==14) qDebug() << errorText.arg("library", oldFilePath, newFilePath) << "The destination file already exists."; else qDebug() << errorText.arg("library", oldFilePath, newFilePath) << "Error #" << oldFile->error(); } } delete oldFile; #ifdef __WINDOWS__ oldFilePath = oldLocation.filePath("mixxxbpmschemes.xml"); #else oldFilePath = oldLocation.filePath(".mixxxbpmscheme.xml"); #endif newFilePath = newLocation.filePath("mixxxbpmscheme.xml"); oldFile = new QFile(oldFilePath); if (oldFile->exists()) { if (oldFile->copy(newFilePath)) oldFile->remove(); else { if (oldFile->error()==14) qDebug() << errorText.arg("settings", oldFilePath, newFilePath) << "The destination file already exists."; else qDebug() << errorText.arg("settings", oldFilePath, newFilePath) << "Error #" << oldFile->error(); } } delete oldFile; #ifdef __WINDOWS__ oldFilePath = oldLocation.filePath("MixxxMIDIBindings.xml"); #else oldFilePath = oldLocation.filePath(".MixxxMIDIBindings.xml"); #endif newFilePath = newLocation.filePath("MixxxMIDIBindings.xml"); oldFile = new QFile(oldFilePath); if (oldFile->exists()) { qWarning() << "The MIDI mapping file format has changed in this version of Mixxx. You will need to reconfigure your MIDI controller. See the Wiki for full details on the new format."; if (oldFile->copy(newFilePath)) oldFile->remove(); else { if (oldFile->error()==14) qDebug() << errorText.arg("MIDI mapping", oldFilePath, newFilePath) << "The destination file already exists."; else qDebug() << errorText.arg("MIDI mapping", oldFilePath, newFilePath) << "Error #" << oldFile->error(); } } // Tidy up delete oldFile; #ifdef __WINDOWS__ QFile::remove(oldLocation.filePath("MixxxMIDIDevice.xml")); // Obsolete file, so just delete it #else QFile::remove(oldLocation.filePath(".MixxxMIDIDevice.xml")); // Obsolete file, so just delete it #endif #ifdef __WINDOWS__ oldFilePath = oldLocation.filePath("mixxx.cfg"); #else oldFilePath = oldLocation.filePath(".mixxx.cfg"); #endif newFilePath = newLocation.filePath(SETTINGS_FILE); oldFile = new QFile(oldFilePath); if (oldFile->copy(newFilePath)) oldFile->remove(); else { if (oldFile->error()==14) qDebug() << errorText.arg("configuration", oldFilePath, newFilePath) << "The destination file already exists."; else qDebug() << errorText.arg("configuration", oldFilePath, newFilePath) << "Error #" << oldFile->error(); } delete oldFile; } // Tidy up delete pre170Config; // End pre-1.7.0 code /*************************************************************************** * Post-1.7.0 upgrade code * * Add entries to the IF ladder below if anything needs to change from the * previous to the current version. This allows for incremental upgrades * in case a user upgrades from a few versions prior. ****************************************************************************/ // Read the config file from home directory UserSettingsPointer config(new ConfigObject<ConfigValue>( QDir(settingsPath).filePath(SETTINGS_FILE))); QString configVersion = config->getValueString(ConfigKey("[Config]","Version")); if (configVersion.isEmpty()) { #ifdef __APPLE__ qDebug() << "Config version is empty, trying to read pre-1.9.0 config"; // Try to read the config from the pre-1.9.0 final directory on OS X (we moved it in 1.9.0 final) QScopedPointer<QFile> oldConfigFile(new QFile(QDir::homePath().append("/").append(".mixxx/mixxx.cfg"))); if (oldConfigFile->exists() && ! CmdlineArgs::Instance().getSettingsPathSet()) { qDebug() << "Found pre-1.9.0 config for OS X"; // Note: We changed SETTINGS_PATH in 1.9.0 final on OS X so it must be hardcoded to ".mixxx" here for legacy. config = UserSettingsPointer(new ConfigObject<ConfigValue>( QDir::homePath().append("/.mixxx/mixxx.cfg"))); // Just to be sure all files like logs and soundconfig go with mixxx.cfg // TODO(XXX) Trailing slash not needed anymore as we switches from String::append // to QDir::filePath elsewhere in the code. This is candidate for removal. CmdlineArgs::Instance().setSettingsPath(QDir::homePath().append("/.mixxx/")); configVersion = config->getValueString(ConfigKey("[Config]","Version")); } else { #elif __WINDOWS__ qDebug() << "Config version is empty, trying to read pre-1.12.0 config"; // Try to read the config from the pre-1.12.0 final directory on Windows (we moved it in 1.12.0 final) QScopedPointer<QFile> oldConfigFile(new QFile(QDir::homePath().append("/Local Settings/Application Data/Mixxx/mixxx.cfg"))); if (oldConfigFile->exists() && ! CmdlineArgs::Instance().getSettingsPathSet()) { qDebug() << "Found pre-1.12.0 config for Windows"; // Note: We changed SETTINGS_PATH in 1.12.0 final on Windows so it must be hardcoded to "Local Settings/Application Data/Mixxx/" here for legacy. config = UserSettingsPointer(new ConfigObject<ConfigValue>( QDir::homePath().append("/Local Settings/Application Data/Mixxx/mixxx.cfg"))); // Just to be sure all files like logs and soundconfig go with mixxx.cfg // TODO(XXX) Trailing slash not needed anymore as we switches from String::append // to QDir::filePath elsewhere in the code. This is candidate for removal. CmdlineArgs::Instance().setSettingsPath(QDir::homePath().append("/Local Settings/Application Data/Mixxx/")); configVersion = config->getValueString(ConfigKey("[Config]","Version")); } else { #endif // This must have been the first run... right? :) qDebug() << "No version number in configuration file. Setting to" << MIXXX_VERSION; config->set(ConfigKey("[Config]","Version"), ConfigValue(MIXXX_VERSION)); m_bFirstRun = true; return config; #ifdef __APPLE__ } #elif __WINDOWS__ } #endif } // If it's already current, stop here if (configVersion == MIXXX_VERSION) { qDebug() << "Configuration file is at the current version" << MIXXX_VERSION; return config; } // Allows for incremental upgrades in case someone upgrades from a few versions prior // (I wish we could do a switch on a QString.) /* // Examples, since we didn't store the version number prior to v1.7.0 if (configVersion.startsWith("1.6.0")) { qDebug() << "Upgrading from v1.6.0 to 1.6.1..."; // Upgrade tasks go here configVersion = "1.6.1"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.6.1")); } if (configVersion.startsWith("1.6.1")) { qDebug() << "Upgrading from v1.6.1 to 1.7.0..."; // Upgrade tasks go here configVersion = "1.7.0"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.7.0")); } */ // We use the following blocks to detect if this is the first time // you've run the latest version of Mixxx. This lets us show // the promo tracks stats agreement stuff for all users that are // upgrading Mixxx. if (configVersion.startsWith("1.7")) { qDebug() << "Upgrading from v1.7.x..."; // Upgrade tasks go here // Nothing to change, really configVersion = "1.8.0"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.8.0")); } if (configVersion.startsWith("1.8.0~beta1") || configVersion.startsWith("1.8.0~beta2")) { qDebug() << "Upgrading from v1.8.0~beta..."; // Upgrade tasks go here configVersion = "1.8.0"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.8.0")); } if (configVersion.startsWith("1.8") || configVersion.startsWith("1.9.0beta1")) { qDebug() << "Upgrading from" << configVersion << "..."; // Upgrade tasks go here #ifdef __APPLE__ QString OSXLocation180 = QDir::homePath().append("/").append(".mixxx"); QString OSXLocation190 = settingsPath; QDir newOSXDir(OSXLocation190); newOSXDir.mkpath(OSXLocation190); QList<QPair<QString, QString> > dirsToMove; dirsToMove.push_back(QPair<QString, QString>(OSXLocation180, OSXLocation190)); dirsToMove.push_back(QPair<QString, QString>(OSXLocation180 + "/midi", OSXLocation190 + "midi")); dirsToMove.push_back(QPair<QString, QString>(OSXLocation180 + "/presets", OSXLocation190 + "presets")); QListIterator<QPair<QString, QString> > dirIt(dirsToMove); QPair<QString, QString> curPair; while (dirIt.hasNext()) { curPair = dirIt.next(); qDebug() << "Moving" << curPair.first << "to" << curPair.second; QDir oldSubDir(curPair.first); QDir newSubDir(curPair.second); newSubDir.mkpath(curPair.second); // Create the new destination directory QStringList contents = oldSubDir.entryList(QDir::Files | QDir::NoDotAndDotDot); QStringListIterator it(contents); QString cur; // Iterate over all the files in the source directory and copy them to the dest dir. while (it.hasNext()) { cur = it.next(); QString src = curPair.first + "/" + cur; QString dest = curPair.second + "/" + cur; qDebug() << "Copying" << src << "to" << dest; if (!QFile::copy(src, dest)) { qDebug() << "Failed to move file during upgrade."; } } // Rename the old directory. newOSXDir.rename(OSXLocation180, OSXLocation180 + "-1.8"); } // Reload the configuration file from the new location. // (We want to make sure we save to the new location...) config = UserSettingsPointer(new ConfigObject<ConfigValue>( QDir(settingsPath).filePath(SETTINGS_FILE))); #endif configVersion = "1.9.0"; config->set(ConfigKey("[Config]","Version"), ConfigValue("1.9.0")); } if (configVersion.startsWith("1.9") || configVersion.startsWith("1.10")) { qDebug() << "Upgrading from v1.9.x/1.10.x..."; bool successful = true; qDebug() << "Copying midi/ to controllers/"; QString midiPath = legacyUserPresetsPath(config); QString controllerPath = userPresetsPath(config); QDir oldDir(midiPath); QDir newDir(controllerPath); newDir.mkpath(controllerPath); // create the new directory QStringList contents = oldDir.entryList(QDir::Files | QDir::NoDotAndDotDot); QStringListIterator it(contents); QString cur; // Iterate over all the files in the source directory and copy them to the dest dir. while (it.hasNext()) { cur = it.next(); if (newDir.exists(cur)) { qDebug() << cur << "already exists in" << controllerPath << "Skipping."; continue; } QString src = oldDir.absoluteFilePath(cur); QString dest = newDir.absoluteFilePath(cur); qDebug() << "Copying" << src << "to" << dest; if (!QFile::copy(src, dest)) { qDebug() << "Failed to copy file during upgrade."; successful = false; } } bool reanalyze_choice = askReanalyzeBeats(); BeatDetectionSettings bpmSettings(config); bpmSettings.setReanalyzeWhenSettingsChange(reanalyze_choice); if (successful) { qDebug() << "Upgrade Successful"; configVersion = "1.11.0"; config->set(ConfigKey("[Config]","Version"), ConfigValue(configVersion)); } else { qDebug() << "Upgrade Failed"; } } if (configVersion.startsWith("1.11")) { qDebug() << "Upgrading from v1.11.x..."; bool successful = false; { MixxxDb mixxxDb(config); const mixxx::DbConnectionPooler dbConnectionPooler( mixxxDb.connectionPool()); if (dbConnectionPooler.isPooling()) { QSqlDatabase dbConnection = mixxx::DbConnectionPooled(mixxxDb.connectionPool()); DEBUG_ASSERT(dbConnection.isOpen()); if (MixxxDb::initDatabaseSchema(dbConnection)) { TrackCollection tc(config); tc.connectDatabase(dbConnection); // upgrade to the multi library folder settings QString currentFolder = config->getValueString(PREF_LEGACY_LIBRARY_DIR); // to migrate the DB just add the current directory to the new // directories table // NOTE(rryan): We don't have to ask for sandbox permission to this // directory because the normal startup integrity check in Library will // notice if we don't have permission and ask for access. Also, the // Sandbox isn't setup yet at this point in startup because it relies on // the config settings path and this function is what loads the config // so it's not ready yet. successful = tc.getDirectoryDAO().addDirectory(currentFolder); tc.disconnectDatabase(); } } } // ask for library rescan to activate cover art. We can later ask for // this variable when the library scanner is constructed. m_bRescanLibrary = askReScanLibrary(); // Versions of mixxx until 1.11 had a hack that multiplied gain by 1/2, // which was compensation for another hack that set replaygain to a // default of 6. We've now removed all of the hacks, so subtracting // 6 from everyone's replay gain should keep things consistent for // all users. int oldReplayGain = config->getValue( ConfigKey("[ReplayGain]", "InitialReplayGainBoost"), 6); int newReplayGain = math_max(-6, oldReplayGain - 6); config->set(ConfigKey("[ReplayGain]", "InitialReplayGainBoost"), ConfigValue(newReplayGain)); // if everything until here worked fine we can mark the configuration as // updated if (successful) { configVersion = MIXXX_VERSION; config->set(ConfigKey("[Config]","Version"), ConfigValue(MIXXX_VERSION)); } else { qDebug() << "Upgrade failed!\n"; } } if (configVersion.startsWith("1.12") || configVersion.startsWith("2.0") || configVersion.startsWith("2.1.0")) { // No special upgrade required, just update the value. configVersion = MIXXX_VERSION; config->set(ConfigKey("[Config]","Version"), ConfigValue(MIXXX_VERSION)); } if (configVersion == MIXXX_VERSION) qDebug() << "Configuration file is now at the current version" << MIXXX_VERSION; else { qWarning() << "Configuration file is at version" << configVersion << "instead of the current" << MIXXX_VERSION; } return config; }
void ReplayGainSettings::setReplayGainReanalyze(bool value) { m_pConfig->set(ConfigKey(kConfigKey, kReplayGainReanalyze), ConfigValue(value)); }
void ReplayGainSettings::setReplayGainAnalyzerVersion(int value) { m_pConfig->set(ConfigKey(kConfigKey, kReplayGainAnalyzerVersion), ConfigValue(value)); }
void ReplayGainSettings::setReplayGainAnalyzerEnabled(bool value) { m_pConfig->set(ConfigKey(kConfigKey, kReplayGainAnalyzerEnabled), ConfigValue(value)); }
void DlgPrefRecord::slotChangeSplitSize() { m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "FileSize"), ConfigValue(comboBoxSplitting->currentText())); }
void DlgPrefReplayGain::slotSetRGAnalyserEnabled() { int enabled = EnableAnalyser->isChecked() ? 1 : 0; config->set(ConfigKey(kConfigKey,"ReplayGainAnalyserEnabled"), ConfigValue(enabled)); slotApply(); }
void DlgPrefAutoDJ::slotSetAutoDjRequeue(int) { m_pConfig->set(ConfigKey("[Auto DJ]", "RequeueBuff"), ConfigValue(ComboBoxAutoDjRequeue->currentIndex())); }
bool EngineShoutcast::serverConnect() { // set to busy in case another thread calls one of the other // EngineShoutcast calls m_iShoutStatus = SHOUTERR_BUSY; m_pShoutcastStatus->set(SHOUTCAST_CONNECTING); // reset the number of failures to zero m_iShoutFailures = 0; // set to a high number to automatically update the metadata // on the first change m_iMetaDataLife = 31337; // clear metadata, to make sure the first track is not skipped // because it was sent via an previous connection (see metaDataHasChanged) if(m_pMetaData) { m_pMetaData.clear(); } //If static metadata is available, we only need to send metadata one time m_firstCall = false; /*Check if m_encoder is initalized * Encoder is initalized in updateFromPreferences which is called always before serverConnect() * If m_encoder is NULL, then we propably want to use MP3 streaming, however, lame could not be found * It does not make sense to connect */ if(m_encoder == NULL){ m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY,"enabled"),ConfigValue("0")); m_pShoutcastStatus->set(SHOUTCAST_DISCONNECTED); return false; } const int iMaxTries = 3; while (!m_bQuit && m_iShoutFailures < iMaxTries) { if (m_pShout) shout_close(m_pShout); m_iShoutStatus = shout_open(m_pShout); if (m_iShoutStatus == SHOUTERR_SUCCESS) m_iShoutStatus = SHOUTERR_CONNECTED; if ((m_iShoutStatus == SHOUTERR_BUSY) || (m_iShoutStatus == SHOUTERR_CONNECTED) || (m_iShoutStatus == SHOUTERR_SUCCESS)) break; m_iShoutFailures++; qDebug() << "Shoutcast failed connect. Failures:" << m_iShoutFailures; sleep(1); } if (m_iShoutFailures == iMaxTries) { if (m_pShout) shout_close(m_pShout); m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY,"enabled"),ConfigValue("0")); m_pShoutcastStatus->set(SHOUTCAST_DISCONNECTED); return false; } if (m_bQuit) { if (m_pShout) shout_close(m_pShout); m_pShoutcastStatus->set(SHOUTCAST_DISCONNECTED); return false; } m_iShoutFailures = 0; int timeout = 0; while (m_iShoutStatus == SHOUTERR_BUSY && timeout < TIMEOUT) { qDebug() << "Connection pending. Sleeping..."; sleep(1); m_iShoutStatus = shout_get_connected(m_pShout); ++ timeout; } if (m_iShoutStatus == SHOUTERR_CONNECTED) { qDebug() << "***********Connected to Shoutcast server..."; m_pShoutcastStatus->set(SHOUTCAST_CONNECTED); return true; } //otherwise disable shoutcast in preferences m_pConfig->set(ConfigKey(SHOUTCAST_PREF_KEY,"enabled"),ConfigValue("0")); if(m_pShout){ shout_close(m_pShout); //errorDialog(tr("Mixxx could not connect to the server"), tr("Please check your connection to the Internet and verify that your username and password are correct.")); } m_pShoutcastStatus->set(SHOUTCAST_DISCONNECTED); return false; }
void WaveformWidgetFactory::setEndOfTrackWarningTime(int endTime) { m_endOfTrackWarningTime = endTime; if (m_config) { m_config->set(ConfigKey("[Waveform]","EndOfTrackWarningTime"), ConfigValue(m_endOfTrackWarningTime)); } }
void CrateFeature::slotExportPlaylist() { qDebug() << "Export crate" << m_lastRightClickedIndex.data(); QString lastCrateDirectory = m_pConfig->getValueString( ConfigKey("[Library]", "LastImportExportCrateDirectory"), QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); QString file_location = QFileDialog::getSaveFileName( NULL, tr("Export Crate"), lastCrateDirectory, tr("M3U Playlist (*.m3u);;M3U8 Playlist (*.m3u8);;PLS Playlist (*.pls);;Text CSV (*.csv);;Readable Text (*.txt)")); // Exit method if user cancelled the open dialog. if (file_location.isNull() || file_location.isEmpty()) { return; } // Update the import/export crate directory QFileInfo fileName(file_location); m_pConfig->set(ConfigKey("[Library]","LastImportExportCrateDirectory"), ConfigValue(fileName.dir().absolutePath())); // The user has picked a new directory via a file dialog. This means the // system sandboxer (if we are sandboxed) has granted us permission to this // folder. We don't need access to this file on a regular basis so we do not // register a security bookmark. // check config if relative paths are desired bool useRelativePath = static_cast<bool>( m_pConfig->getValueString( ConfigKey("[Library]", "UseRelativePathOnExport")).toInt()); // Create list of files of the crate QList<QString> playlist_items; // Create a new table model since the main one might have an active search. QScopedPointer<CrateTableModel> pCrateTableModel( new CrateTableModel(this, m_pTrackCollection)); pCrateTableModel->setTableModel(m_crateTableModel.getCrate()); pCrateTableModel->select(); if (file_location.endsWith(".csv", Qt::CaseInsensitive)) { ParserCsv::writeCSVFile(file_location, pCrateTableModel.data(), useRelativePath); } else if (file_location.endsWith(".txt", Qt::CaseInsensitive)) { ParserCsv::writeReadableTextFile(file_location, pCrateTableModel.data(), false); } else{ // populate a list of files of the crate QList<QString> playlist_items; int rows = pCrateTableModel->rowCount(); for (int i = 0; i < rows; ++i) { QModelIndex index = m_crateTableModel.index(i, 0); playlist_items << m_crateTableModel.getTrackLocation(index); } if (file_location.endsWith(".pls", Qt::CaseInsensitive)) { ParserPls::writePLSFile(file_location, playlist_items, useRelativePath); } else if (file_location.endsWith(".m3u8", Qt::CaseInsensitive)) { ParserM3u::writeM3U8File(file_location, playlist_items, useRelativePath); } else { //default export to M3U if file extension is missing if(!file_location.endsWith(".m3u", Qt::CaseInsensitive)) { qDebug() << "Crate export: No valid file extension specified. Appending .m3u " << "and exporting to M3U."; file_location.append(".m3u"); } ParserM3u::writeM3UFile(file_location, playlist_items, useRelativePath); } } }
void DlgPrefRecord::setMetaData() { m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "Title"), ConfigValue(LineEditTitle->text())); m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "Author"), ConfigValue(LineEditAuthor->text())); m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "Album"), ConfigValue(LineEditAlbum->text())); }
DlgPrefRecord::DlgPrefRecord(QWidget* parent, UserSettingsPointer pConfig) : DlgPreferencePage(parent), m_pConfig(pConfig), m_bConfirmOverwrite(false), m_pRadioOgg(NULL), m_pRadioMp3(NULL), m_pRadioAiff(NULL), m_pRadioFlac(NULL), m_pRadioWav(NULL) { setupUi(this); // See RECORD_* #defines in defs_recording.h m_pRecordControl = new ControlObjectSlave( RECORDING_PREF_KEY, "status", this); m_pRadioOgg = new QRadioButton("Ogg Vorbis"); m_pRadioMp3 = new QRadioButton(ENCODING_MP3); // Setting recordings path. QString recordingsPath = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "Directory")); if (recordingsPath == "") { // Initialize recordings path in config to old default path. // Do it here so we show current value in UI correctly. QString musicDir = QDesktopServices::storageLocation(QDesktopServices::MusicLocation); QDir recordDir(musicDir + "/Mixxx/Recordings"); recordingsPath = recordDir.absolutePath(); } LineEditRecordings->setText(recordingsPath); connect(PushButtonBrowseRecordings, SIGNAL(clicked()), this, SLOT(slotBrowseRecordingsDir())); connect(LineEditRecordings, SIGNAL(returnPressed()), this, SLOT(slotApply())); connect(m_pRadioOgg, SIGNAL(clicked()), this, SLOT(slotApply())); connect(m_pRadioMp3, SIGNAL(clicked()), this, SLOT(slotApply())); horizontalLayout->addWidget(m_pRadioOgg); horizontalLayout->addWidget(m_pRadioMp3); // AIFF and WAVE are supported by default. m_pRadioWav = new QRadioButton(ENCODING_WAVE); connect(m_pRadioWav, SIGNAL(clicked()), this, SLOT(slotApply())); horizontalLayout->addWidget(m_pRadioWav); m_pRadioAiff = new QRadioButton(ENCODING_AIFF); connect(m_pRadioAiff, SIGNAL(clicked()), this, SLOT(slotApply())); horizontalLayout->addWidget(m_pRadioAiff); #ifdef SF_FORMAT_FLAC m_pRadioFlac = new QRadioButton(ENCODING_FLAC); connect(m_pRadioFlac, SIGNAL(clicked()), this, SLOT(slotApply())); horizontalLayout->addWidget(m_pRadioFlac); #endif // Read config and check radio button. QString format = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "Encoding")); if (format == ENCODING_WAVE) { m_pRadioWav->setChecked(true); } else if (format == ENCODING_OGG) { m_pRadioOgg->setChecked(true); } else if (format == ENCODING_MP3) { m_pRadioMp3->setChecked(true); } else if (format == ENCODING_AIFF) { m_pRadioAiff->setChecked(true); #ifdef SF_FORMAT_FLAC } else if (format == ENCODING_FLAC) { m_pRadioFlac->setChecked(true); #endif } else { // Invalid, so set default and save. // If no config was available, set to WAVE as default. m_pRadioWav->setChecked(true); m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "Encoding"), ConfigValue(ENCODING_WAVE)); } loadMetaData(); connect(SliderQuality, SIGNAL(valueChanged(int)), this, SLOT(slotSliderQuality())); connect(SliderQuality, SIGNAL(sliderMoved(int)), this, SLOT(slotSliderQuality())); connect(SliderQuality, SIGNAL(sliderReleased()), this, SLOT(slotSliderQuality())); connect(CheckBoxRecordCueFile, SIGNAL(stateChanged(int)), this, SLOT(slotEnableCueFile(int))); connect(comboBoxSplitting, SIGNAL(activated(int)), this, SLOT(slotChangeSplitSize())); slotApply(); // Make sure a corrupt config file won't cause us to record constantly. m_pRecordControl->set(RECORD_OFF); comboBoxSplitting->addItem(SPLIT_650MB); comboBoxSplitting->addItem(SPLIT_700MB); comboBoxSplitting->addItem(SPLIT_1024MB); comboBoxSplitting->addItem(SPLIT_2048MB); comboBoxSplitting->addItem(SPLIT_4096MB); QString fileSizeStr = m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "FileSize")); int index = comboBoxSplitting->findText(fileSizeStr); if (index > 0) { // Set file split size comboBoxSplitting->setCurrentIndex(index); } // Otherwise 650 MB will be default file split size. // Read CUEfile info CheckBoxRecordCueFile->setChecked( (bool) m_pConfig->getValueString(ConfigKey(RECORDING_PREF_KEY, "CueEnabled")).toInt()); }
void DlgPrefModplug::saveSettings() { m_pConfig->set(ConfigKey(CONFIG_KEY,"PerTrackMemoryLimitMB"), ConfigValue(m_pUi->memoryLimit->value())); m_pConfig->set(ConfigKey(CONFIG_KEY,"OversamplingEnabled"), ConfigValue(m_pUi->oversampling->isChecked())); m_pConfig->set(ConfigKey(CONFIG_KEY,"NoiseReductionEnabled"), ConfigValue(m_pUi->noiseReduction->isChecked())); m_pConfig->set(ConfigKey(CONFIG_KEY,"StereoSeparation"), ConfigValue(m_pUi->stereoSeparation->value())); m_pConfig->set(ConfigKey(CONFIG_KEY,"MaxMixChannels"), ConfigValue(m_pUi->maxMixChannels->value())); m_pConfig->set(ConfigKey(CONFIG_KEY,"ResamplingMode"), ConfigValue(m_pUi->resampleMode->currentIndex())); m_pConfig->set(ConfigKey(CONFIG_KEY,"ReverbEnabled"), ConfigValue(m_pUi->reverb->isChecked())); m_pConfig->set(ConfigKey(CONFIG_KEY,"ReverbLevel"), ConfigValue(m_pUi->reverbDepth->value())); m_pConfig->set(ConfigKey(CONFIG_KEY,"ReverbDelay"), ConfigValue(m_pUi->reverbDelay->value())); m_pConfig->set(ConfigKey(CONFIG_KEY,"MegabassEnabled"), ConfigValue(m_pUi->megabass->isChecked())); m_pConfig->set(ConfigKey(CONFIG_KEY,"MegabassLevel"), ConfigValue(m_pUi->bassDepth->value())); m_pConfig->set(ConfigKey(CONFIG_KEY,"MegabassCutoff"), ConfigValue(m_pUi->bassCutoff->value())); m_pConfig->set(ConfigKey(CONFIG_KEY,"SurroundEnabled"), ConfigValue(m_pUi->surround->isChecked())); m_pConfig->set(ConfigKey(CONFIG_KEY,"SurroundLevel"), ConfigValue(m_pUi->surroundDepth->value())); m_pConfig->set(ConfigKey(CONFIG_KEY,"SurroundDelay"), ConfigValue(m_pUi->surroundDelay->value())); }
void WaveformWidgetFactory::setOverviewNormalized(bool normalize) { m_overviewNormalized = normalize; if (m_config) { m_config->set(ConfigKey("[Waveform]","OverviewNormalized"), ConfigValue(m_overviewNormalized)); } }
BaseSyncableListener::~BaseSyncableListener() { // We use the slider value because that is never set to 0.0. m_pConfig->set(ConfigKey("[InternalClock]", "bpm"), ConfigValue( m_pInternalClock->getBpm())); delete m_pInternalClock; }
void WLibraryTableView::saveVScrollBarPosState() { //Save the vertical scrollbar position. int scrollbarPosition = verticalScrollBar()->value(); m_pConfig->set(m_vScrollBarPosKey, ConfigValue(scrollbarPosition)); }
void ReplayGainSettings::setInitialDefaultBoost(int value) { m_pConfig->set(ConfigKey(kConfigKey, kInitialDefaultBoost), ConfigValue(value)); }
void DlgPrefReplayGain::slotUpdateBoost() { config->set(ConfigKey(kConfigKey, "InitialReplayGainBoost"), ConfigValue(SliderBoost->value())); slotApply(); }
void DlgPrefRecord::slotEnableCueFile(int enabled) { m_pConfig->set(ConfigKey(RECORDING_PREF_KEY, "CueEnabled"), ConfigValue(enabled != Qt::Unchecked)); }