=== modified file 'mixxx/src/configobject.cpp' --- mixxx/src/configobject.cpp 2011-11-08 07:27:00 +0000 +++ mixxx/src/configobject.cpp 2012-01-29 19:08:40 +0000 @@ -32,6 +32,8 @@ #include #include +#include "mixxx.h" + ConfigKey::ConfigKey() { } @@ -113,8 +115,8 @@ template ConfigObject::~ConfigObject() { - while (list.size() > 0) { - ConfigOption* pConfigOption = list.takeLast(); + while (m_list.size() > 0) { + ConfigOption* pConfigOption = m_list.takeLast(); delete pConfigOption; } } @@ -123,7 +125,7 @@ ConfigOption *ConfigObject::set(ConfigKey k, ValueType v) { // Search for key in list, and set value if found - QListIterator* > iterator(list); + QListIterator* > iterator(m_list); ConfigOption* it; while (iterator.hasNext()) { @@ -145,14 +147,14 @@ ConfigKey * key = new ConfigKey(k.group, k.item); it = new ConfigOption(key, new ValueType(v)); //qDebug() << "new configobject " << it->val; - list.append(it); + m_list.append(it); return it; } template ConfigOption *ConfigObject::get(ConfigKey k) { - QListIterator* > iterator(list); + QListIterator* > iterator(m_list); ConfigOption* it; while (iterator.hasNext()) { @@ -167,14 +169,14 @@ // If key is not found, insert into list with null values ConfigKey * key = new ConfigKey(k.group, k.item); it = new ConfigOption(key, new ValueType("")); - list.append(it); + m_list.append(it); return it; } template ConfigKey *ConfigObject::get(ValueType v) { - QListIterator* > iterator(list); + QListIterator* > iterator(m_list); ConfigOption* it; while (iterator.hasNext()) { @@ -189,7 +191,7 @@ return it->key; } - if (it == list.last()) { + if (it == m_list.last()) { //qDebug() << "ConfigObject: last match attempted" << it->val->value.toUpper() << "with" << v.value.toUpper(); } } @@ -206,14 +208,15 @@ template bool ConfigObject::Parse() { // Open file for reading - QFile configfile(filename); - if (filename.length()<1 || !configfile.open(QIODevice::ReadOnly)) + QFile configfile(m_filename); + if (m_filename.length()<1 || !configfile.open(QIODevice::ReadOnly)) { - qDebug() << "Could not read" << filename; + qDebug() << "ConfigObject: Could not read" << m_filename; return false; } else { + qDebug() << "ConfigObject: Parse" << m_filename; // Parse the file int group = 0; QString groupStr, line; @@ -254,34 +257,31 @@ { //Delete the pointers, because that's what we did before we //purged Mixxx of Qt3 code. -- Albert, June 18th 2010 (at 30,000 ft) - for (int i = 0; i < list.count(); i++) - delete list[i]; + for (int i = 0; i < m_list.count(); i++) + delete m_list[i]; // This shouldn't be done, since objects might have references to // members of list. Instead all member values should be set to some // null value. - list.clear(); + m_list.clear(); } template void ConfigObject::reopen(QString file) { - // First try to open the config file placed in the users .mixxx directory. - // If that fails, try the system wide CONFIG_PATH. - - filename = file; + m_filename = file; Parse(); } template void ConfigObject::Save() { - QFile file(filename); + QFile file(m_filename); if (!QDir(QFileInfo(file).absolutePath()).exists()) { QDir().mkpath(QFileInfo(file).absolutePath()); } if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - qDebug() << "Could not write file" << filename << ", don't worry."; + qDebug() << "Could not write file" << m_filename << ", don't worry."; return; } else @@ -289,7 +289,7 @@ QTextStream stream(&file); QString grp = ""; - QListIterator* > iterator(list); + QListIterator* > iterator(m_list); ConfigOption* it; while (iterator.hasNext()) { @@ -309,7 +309,7 @@ } template -QString ConfigObject::getConfigPath() +QString ConfigObject::getResourcePath() { // // Find the config path, path where midi configuration files, skins etc. are stored. @@ -317,29 +317,25 @@ // On Windows it is always (and only) app dir. // On OS X it is the current directory and then the Resources/ dir in the app bundle // - QString qConfigPath; // TODO: this only changes once (on first load) during a run should make this a singleton. + QString qResourcePath; // TODO: this only changes once (on first load) during a run should make this a singleton. // Try to read in the resource directory from the command line - QStringList commandLineArgs = QApplication::arguments(); - int resourcePath = commandLineArgs.indexOf("--resourcePath"); - if (resourcePath!=-1 && resourcePath + 1 < commandLineArgs.size()) { - qDebug() << "Setting qConfigPath from location in resourcePath commandline arg:" << commandLineArgs.at(resourcePath+1); - qConfigPath = commandLineArgs.at(resourcePath+1); - } - if (qConfigPath.isNull() || qConfigPath.isEmpty()) { + qResourcePath = CmdlineArgs::Instance().getResourcePath(); + + if (qResourcePath.isNull() || qResourcePath.isEmpty()) { #ifdef __UNIX__ // On Linux, check if the path is stored in the configuration database. if (getValueString(ConfigKey("[Config]","Path")).length()>0 && QDir(getValueString(ConfigKey("[Config]","Path"))).exists()) - qConfigPath = getValueString(ConfigKey("[Config]","Path")); + qResourcePath = getValueString(ConfigKey("[Config]","Path")); else { // Set the path according to the compile time define, UNIX_SHARE_PATH - qConfigPath = UNIX_SHARE_PATH; + qResourcePath = UNIX_SHARE_PATH; } #endif #ifdef __WINDOWS__ // On Windows, set the config dir relative to the application dir - qConfigPath = QCoreApplication::applicationDirPath(); + qResourcePath = QCoreApplication::applicationDirPath(); #endif #ifdef __APPLE__ /* @@ -361,17 +357,19 @@ */ QString mixxxPath = QCoreApplication::applicationDirPath(); if (mixxxPath.endsWith("osx_build")) //Development configuration - qConfigPath = mixxxPath + "/../res"; + qResourcePath = mixxxPath + "/../res"; else //Release configuraton - qConfigPath = mixxxPath + "/../Resources"; + qResourcePath = mixxxPath + "/../Resources"; #endif + } else { + qDebug() << "Setting qResourcePath from location in resourcePath commandline arg:" << qResourcePath; } - if (qConfigPath.length() == 0) qCritical() << "qConfigPath is empty, this can not be so -- did our developer forget to define one of __UNIX__, __WINDOWS__, __APPLE__??"; + if (qResourcePath.length() == 0) qCritical() << "qConfigPath is empty, this can not be so -- did our developer forget to define one of __UNIX__, __WINDOWS__, __APPLE__??"; // If the directory does not end with a "/", add one - if (!qConfigPath.endsWith("/")) - qConfigPath.append("/"); + if (!qResourcePath.endsWith("/")) + qResourcePath.append("/"); - return qConfigPath; + return qResourcePath; } @@ -393,6 +391,12 @@ } } +template QString ConfigObject::getSettingsPath() +{ + QFileInfo configFileInfo(m_filename); + return configFileInfo.absoluteDir().absolutePath(); +} + template class ConfigObject; template class ConfigObject; === modified file 'mixxx/src/configobject.h' --- mixxx/src/configobject.h 2011-04-03 19:29:46 +0000 +++ mixxx/src/configobject.h 2012-01-29 19:08:40 +0000 @@ -120,11 +120,12 @@ void clear(); void reopen(QString file); void Save(); - QString getConfigPath(); + QString getResourcePath(); + QString getSettingsPath(); protected: - QList< ConfigOption* > list; - QString filename; + QList< ConfigOption* > m_list; + QString m_filename; /** Loads and parses the configuration file. Returns false if the file could * not be opened; otherwise true. */ === modified file 'mixxx/src/dlgprefbpm.cpp' --- mixxx/src/dlgprefbpm.cpp 2011-10-19 16:47:15 +0000 +++ mixxx/src/dlgprefbpm.cpp 2012-01-29 19:08:40 +0000 @@ -30,6 +30,7 @@ #include "dlgbpmscheme.h" #include "bpm/bpmscheme.h" #include "xmlparse.h" +#include "mixxx.h" #define CONFIG_KEY "[BPM]" @@ -293,7 +294,7 @@ // Verify path for xml track file. QString schemeFileName = config->getValueString(ConfigKey("[BPM]","SchemeFile")); if (schemeFileName.trimmed().isEmpty() | !QFile(schemeFileName).exists() ) { - schemeFileName = QDir::homePath().append("/").append(SETTINGS_PATH).append(BPMSCHEME_FILE); + schemeFileName = CmdlineArgs::Instance().getSettingsPath() + BPMSCHEME_FILE; qDebug() << "BPM Scheme File ConfigKey not set or file missing... setting to"<< schemeFileName; config->set(ConfigKey("[BPM]","SchemeFile"), schemeFileName); config->Save(); === modified file 'mixxx/src/dlgprefmidibindings.cpp' --- mixxx/src/dlgprefmidibindings.cpp 2011-12-15 06:52:54 +0000 +++ mixxx/src/dlgprefmidibindings.cpp 2012-01-29 19:08:40 +0000 @@ -29,6 +29,7 @@ #include "midi/mididevicemanager.h" #include "configobject.h" #include "midi/midimapping.h" +#include "mixxx.h" #ifdef __MIDISCRIPT__ #include "midi/midiscriptengine.h" @@ -179,7 +180,7 @@ // paths to search for midi presets QList midiDirPaths; midiDirPaths.append(LPRESETS_PATH); - midiDirPaths.append(m_pConfig->getConfigPath().append("midi/")); + midiDirPaths.append(m_pConfig->getResourcePath().append("midi/")); QListIterator itpth(midiDirPaths); while (itpth.hasNext()) { @@ -315,7 +316,7 @@ QString filename = LPRESETS_PATH + name + MIDI_MAPPING_EXTENSION; QFile ftest(filename); - if ( !ftest.exists() ) filename = m_pConfig->getConfigPath().append("midi/") + name + MIDI_MAPPING_EXTENSION; + if ( !ftest.exists() ) filename = m_pConfig->getResourcePath().append("midi/") + name + MIDI_MAPPING_EXTENSION; if (!filename.isNull()) m_pMidiDevice->getMidiMapping()->loadPreset(filename, true); // It's applied on prefs close m_pInputMappingTableView->update(); @@ -329,7 +330,7 @@ */ void DlgPrefMidiBindings::slotExportXML() { QString fileName = QFileDialog::getSaveFileName(this, - tr("Export Mixxx MIDI Bindings"), m_pConfig->getConfigPath().append("midi/"), + tr("Export Mixxx MIDI Bindings"), m_pConfig->getResourcePath().append("midi/"), tr("Preset Files (*.midi.xml)")); if (!fileName.isNull()) m_pMidiDevice->getMidiMapping()->savePreset(fileName); } === modified file 'mixxx/src/library/itunes/itunesfeature.cpp' --- mixxx/src/library/itunes/itunesfeature.cpp 2011-10-16 03:12:52 +0000 +++ mixxx/src/library/itunes/itunesfeature.cpp 2012-01-29 19:08:40 +0000 @@ -19,7 +19,6 @@ ITunesFeature::ITunesFeature(QObject* parent, TrackCollection* pTrackCollection) : LibraryFeature(parent), m_pTrackCollection(pTrackCollection), - m_database(pTrackCollection->getDatabase()), m_cancelImport(false) { QString tableName = "itunes_library"; QString idColumn = "id"; @@ -47,11 +46,7 @@ m_title = tr("iTunes"); if (!m_database.isOpen()) { - m_database = QSqlDatabase::addDatabase("QSQLITE", "ITUNES_SCANNER"); - m_database.setHostName("localhost"); - m_database.setDatabaseName(MIXXX_DB_PATH); - m_database.setUserName("mixxx"); - m_database.setPassword("mixxx"); + m_database = QSqlDatabase::cloneDatabase( pTrackCollection->getDatabase(), "ITUNES_SCANNER"); //Open the database connection in this thread. if (!m_database.open()) { === modified file 'mixxx/src/library/legacylibraryimporter.cpp' --- mixxx/src/library/legacylibraryimporter.cpp 2010-11-19 01:54:28 +0000 +++ mixxx/src/library/legacylibraryimporter.cpp 2012-01-29 19:08:40 +0000 @@ -38,7 +38,10 @@ /** Upgrade from <= 1.7 library to 1.8 DB format */ void LegacyLibraryImporter::import() { - QString trackXML = QDir::homePath().append("/").append(SETTINGS_PATH).append("mixxxtrack.xml"); + // TODO(XXX) SETTINGS_PATH may change in new Mixxx Versions. Here we need + // the SETTINGS_PATH from Mixxx V <= 1.7 + QString settingPath17 = QDir::homePath().append("/").append(SETTINGS_PATH); + QString trackXML = settingPath17.append("mixxxtrack.xml"); QFile file(trackXML); QDomDocument doc("TrackList"); @@ -94,7 +97,7 @@ TrackInfoObject trackInfo17(track); //Only add the track to the DB if the file exists on disk, //because Mixxx <= 1.7 had no logic to deal with detecting deleted - //files. + //files.< if (trackInfo17.exists()) { //Create a TrackInfoObject by directly parsing @@ -175,7 +178,7 @@ } } - QString upgrade_filename = QDir::homePath().append("/").append(SETTINGS_PATH).append("DBUPGRADED"); + QString upgrade_filename = settingPath17.append("DBUPGRADED"); //now create stub so that the library is not readded next time program loads QFile upgradefile(upgrade_filename); if (!upgradefile.open(QIODevice::WriteOnly | QIODevice::Text)) === modified file 'mixxx/src/library/libraryscanner.cpp' --- mixxx/src/library/libraryscanner.cpp 2011-10-21 00:42:23 +0000 +++ mixxx/src/library/libraryscanner.cpp 2012-01-29 19:14:01 +0000 @@ -140,17 +140,11 @@ //Lower our priority to help not grind crappy computers. setPriority(QThread::LowPriority); - if (!m_database.isValid()) { - m_database = QSqlDatabase::addDatabase("QSQLITE", "LIBRARY_SCANNER"); + m_database = QSqlDatabase::cloneDatabase(m_pCollection->getDatabase(), "LIBRARY_SCANNER"); } if (!m_database.isOpen()) { - m_database.setHostName("localhost"); - m_database.setDatabaseName(MIXXX_DB_PATH); - m_database.setUserName("mixxx"); - m_database.setPassword("mixxx"); - //Open the database connection in this thread. if (!m_database.open()) { qDebug() << "Failed to open database from library scanner thread." << m_database.lastError(); @@ -176,6 +170,8 @@ //Try to upgrade the library from 1.7 (XML) to 1.8+ (DB) if needed. If the //upgrade_filename already exists, then do not try to upgrade since we have //already done it. + // TODO(XXX) SETTINGS_PATH may change in new Mixxx Versions. Here we need + // the SETTINGS_PATH from Mixxx V <= 1.7 QString upgrade_filename = QDir::homePath().append("/").append(SETTINGS_PATH).append("DBUPGRADED"); qDebug() << "upgrade filename is " << upgrade_filename; QFile upgradefile(upgrade_filename); === modified file 'mixxx/src/library/promotracksfeature.cpp' --- mixxx/src/library/promotracksfeature.cpp 2011-03-10 13:37:21 +0000 +++ mixxx/src/library/promotracksfeature.cpp 2012-01-29 19:08:40 +0000 @@ -31,7 +31,7 @@ QString PromoTracksFeature::m_sPromoLocalHTMLLocation; QString PromoTracksFeature::m_sPromoRemoteHTMLLocation; -#define PROMO_BUNDLE_PATH (config->getConfigPath() + "/promo/" + MIXXX_PROMO_VERSION + "/") +#define PROMO_BUNDLE_PATH (config->getResourcePath() + "promo/" + MIXXX_PROMO_VERSION + "/") #define LOCAL_HTML_LOCATION (PROMO_BUNDLE_PATH + "index.html") const QString PromoTracksFeature::m_sFeaturedArtistsViewName = "Featured Artists"; @@ -52,7 +52,7 @@ m_sPromoRemoteHTMLLocation = QString("http://promo.mixxx.org/%1/index.html").arg(MIXXX_PROMO_VERSION); //m_pConfig->getConfigPath() + "/promo/promotracks.html"; m_sPromoLocalHTMLLocation = LOCAL_HTML_LOCATION; - m_sPromoAutoloadLocation = m_pConfig->getConfigPath() + "/promo/" + MIXXX_PROMO_VERSION + "/autoload.dat"; + m_sPromoAutoloadLocation = m_pConfig->getResourcePath() + "/promo/" + MIXXX_PROMO_VERSION + "/autoload.dat"; //Load the extra.dat file so we can peek at some extra information, such //as which songs to auto-load into Mixxx's players. @@ -65,7 +65,7 @@ while (!extra.atEnd()) { QString trackPath = extra.readLine(); - trackPath = m_pConfig->getConfigPath() + "/promo/" + MIXXX_PROMO_VERSION + "/" + trackPath; + trackPath = m_pConfig->getResourcePath() + "/promo/" + MIXXX_PROMO_VERSION + "/" + trackPath; QFileInfo fileInfo(trackPath); trackPath = fileInfo.absoluteFilePath(); //qDebug() << "PROMO: Auto-loading track" << trackPath; === modified file 'mixxx/src/library/rhythmbox/rhythmboxfeature.cpp' --- mixxx/src/library/rhythmbox/rhythmboxfeature.cpp 2011-10-16 03:12:52 +0000 +++ mixxx/src/library/rhythmbox/rhythmboxfeature.cpp 2012-01-29 19:08:41 +0000 @@ -37,11 +37,7 @@ m_title = tr("Rhythmbox"); if (!m_database.isOpen()) { - m_database = QSqlDatabase::addDatabase("QSQLITE", "RHYTHMBOX_SCANNER"); - m_database.setHostName("localhost"); - m_database.setDatabaseName(MIXXX_DB_PATH); - m_database.setUserName("mixxx"); - m_database.setPassword("mixxx"); + m_database = QSqlDatabase::cloneDatabase( pTrackCollection->getDatabase(), "RHYTHMBOX_SCANNER"); //Open the database connection in this thread. if (!m_database.open()) { === modified file 'mixxx/src/library/schemamanager.cpp' --- mixxx/src/library/schemamanager.cpp 2010-12-01 03:32:33 +0000 +++ mixxx/src/library/schemamanager.cpp 2012-01-29 19:08:41 +0000 @@ -38,7 +38,7 @@ } } - QString schemaFilename = config->getConfigPath(); + QString schemaFilename = config->getResourcePath(); schemaFilename.append("schema.xml"); qDebug() << "Loading schema" << schemaFilename; QDomElement schemaRoot = WWidget::openXMLFile(schemaFilename, "schema"); === modified file 'mixxx/src/library/trackcollection.cpp' --- mixxx/src/library/trackcollection.cpp 2011-12-28 20:30:15 +0000 +++ mixxx/src/library/trackcollection.cpp 2012-01-29 19:08:41 +0000 @@ -26,11 +26,11 @@ qDebug() << "Available QtSQL drivers:" << QSqlDatabase::drivers(); m_db.setHostName("localhost"); - m_db.setDatabaseName(MIXXX_DB_PATH); + m_db.setDatabaseName(pConfig->getSettingsPath().append("/mixxxdb.sqlite")); m_db.setUserName("mixxx"); m_db.setPassword("mixxx"); bool ok = m_db.open(); - qDebug() << __FILE__ << "DB status:" << ok; + qDebug() << "DB status:" << m_db.databaseName() << "=" << ok; if (m_db.lastError().isValid()) { qDebug() << "Error loading database:" << m_db.lastError(); } === modified file 'mixxx/src/library/trackcollection.h' --- mixxx/src/library/trackcollection.h 2011-10-21 00:19:48 +0000 +++ mixxx/src/library/trackcollection.h 2012-01-29 19:08:41 +0000 @@ -35,8 +35,6 @@ #define AUTODJ_TABLE "Auto DJ" -const QString MIXXX_DB_PATH = QDir::homePath().append("/").append(SETTINGS_PATH).append("mixxxdb.sqlite"); - class BpmDetector; /** === modified file 'mixxx/src/library/traktor/traktorfeature.cpp' --- mixxx/src/library/traktor/traktorfeature.cpp 2011-10-18 05:12:35 +0000 +++ mixxx/src/library/traktor/traktorfeature.cpp 2012-01-29 19:08:41 +0000 @@ -46,11 +46,7 @@ m_pTraktorPlaylistModel = new TraktorPlaylistModel(this, m_pTrackCollection); m_title = tr("Traktor"); if (!m_database.isOpen()) { - m_database = QSqlDatabase::addDatabase("QSQLITE", "TRAKTOR_SCANNER"); - m_database.setHostName("localhost"); - m_database.setDatabaseName(MIXXX_DB_PATH); - m_database.setUserName("mixxx"); - m_database.setPassword("mixxx"); + m_database = QSqlDatabase::cloneDatabase( pTrackCollection->getDatabase(), "TRAKTOR_SCANNER"); //Open the database connection in this thread. if (!m_database.open()) { === modified file 'mixxx/src/main.cpp' --- mixxx/src/main.cpp 2011-12-25 05:45:11 +0000 +++ mixxx/src/main.cpp 2012-01-29 19:15:45 +0000 @@ -68,10 +68,6 @@ QApplication *a; -QStringList plugin_paths; //yes this is global. sometimes global is good. - -void qInitImages_mixxx(); - QFile Logfile; // global logfile variable /* Debug message handler which outputs to both a logfile and a @@ -89,7 +85,9 @@ if(!Logfile.isOpen()) { - QString logFileName = QDir::homePath().append("/").append(SETTINGS_PATH).append("/mixxx.log"); + // This Must be done in the Message Handler itself, to guarantee that the + // QApplication is initialized + QString logFileName = CmdlineArgs::Instance().getSettingsPath() + "/mixxx.log"; // XXX will there ever be a case that we can't write to our current // working directory? @@ -145,60 +143,24 @@ QCoreApplication::setOrganizationDomain("mixxx.org"); QCoreApplication::setOrganizationName("Mixxx"); -//it seems like this code should be inline in MessageHandler() but for some reason having it there corrupts the messages sometimes -kousu 2/2009 - - -#ifdef __WINDOWS__ - #ifdef DEBUGCONSOLE - InitDebugConsole(); - #endif -#endif - qInstallMsgHandler(MessageHandler); - - // Other things depend on this name to enforce thread exclusivity, - // so if you change it here, change it also in: - // * ErrorDialogHandler::errorDialog() - QThread::currentThread()->setObjectName("Main"); - QApplication a(argc, argv); - - //Enumerate and load SoundSource plugins - SoundSourceProxy::loadPlugins(); -#ifdef __LADSPA__ - //LADSPALoader ladspaloader; -#endif - - // Check if one of the command line arguments is "--no-visuals" -// bool bVisuals = true; -// for (int i=0; isetObjectName("Main"); + QApplication a(argc, argv); + + //Enumerate and load SoundSource plugins + SoundSourceProxy::loadPlugins(); +#ifdef __LADSPA__ + //LADSPALoader ladspaloader; +#endif + + // Check if one of the command line arguments is "--no-visuals" +// bool bVisuals = true; +// for (int i=0; isavePreset(BINDINGS_PATH.append(filename + MIDI_MAPPING_EXTENSION)); + mapping->savePreset(BINDINGS_PATH + filename + MIDI_MAPPING_EXTENSION); } } @@ -143,7 +144,7 @@ } filenames.append(filename); - mapping->loadPreset(BINDINGS_PATH.append(filename + MIDI_MAPPING_EXTENSION),true); + mapping->loadPreset(BINDINGS_PATH + filename + MIDI_MAPPING_EXTENSION,true); if ( m_pConfig->getValueString(ConfigKey("[Midi]", name.replace(" ", "_"))) != "1" ) continue; === modified file 'mixxx/src/midi/midimapping.cpp' --- mixxx/src/midi/midimapping.cpp 2011-12-18 20:23:14 +0000 +++ mixxx/src/midi/midimapping.cpp 2012-01-29 19:08:58 +0000 @@ -31,10 +31,11 @@ #include "midiledhandler.h" #include "configobject.h" #include "errordialoghandler.h" +#include "mixxx.h" #define REQUIRED_SCRIPT_FILE "midi-mappings-scripts.js" #define XML_SCHEMA_VERSION "1" -#define DEFAULT_DEVICE_PRESET BINDINGS_PATH.append(m_deviceName.right(m_deviceName.size()-m_deviceName.indexOf(" ")-1).replace(" ", "_") + MIDI_MAPPING_EXTENSION) +#define DEFAULT_DEVICE_PRESET (BINDINGS_PATH + m_deviceName.right(m_deviceName.size()-m_deviceName.indexOf(" ")-1).replace(" ", "_") + MIDI_MAPPING_EXTENSION) // static QString toHex(QString numberStr) { // return "0x" + QString("0" + QString::number(numberStr.toUShort(), 16).toUpper()).right(2); === modified file 'mixxx/src/midi/midimapping.h' --- mixxx/src/midi/midimapping.h 2011-04-29 07:16:19 +0000 +++ mixxx/src/midi/midimapping.h 2012-01-29 19:08:58 +0000 @@ -36,9 +36,9 @@ class MidiInputMappingTableModel; class MidiOutputMappingTableModel; -#define BINDINGS_PATH QDir::homePath().append("/").append(SETTINGS_PATH).append("midi/") +#define BINDINGS_PATH (CmdlineArgs::Instance().getSettingsPath() + "midi/") // local midi mapping presets -#define LPRESETS_PATH QDir::homePath().append("/").append(SETTINGS_PATH).append("presets/") +#define LPRESETS_PATH (CmdlineArgs::Instance().getSettingsPath() + "presets/") #define MIDI_MAPPING_EXTENSION ".midi.xml" class MidiMapping : public QObject === modified file 'mixxx/src/midi/midiscriptengine.cpp' --- mixxx/src/midi/midiscriptengine.cpp 2011-12-18 20:23:14 +0000 +++ mixxx/src/midi/midiscriptengine.cpp 2012-01-29 19:08:58 +0000 @@ -21,6 +21,7 @@ #include "mididevice.h" #include "midiscriptengine.h" #include "errordialoghandler.h" +#include "mixxx.h" // #include @@ -189,10 +190,12 @@ // scriptPaths holds the paths to search in when we're looking for scripts QList scriptPaths; - scriptPaths.append(QDir::homePath().append("/").append(SETTINGS_PATH).append("presets/")); - - ConfigObject *config = new ConfigObject(QDir::homePath().append("/").append(SETTINGS_PATH).append(SETTINGS_FILE)); - scriptPaths.append(config->getConfigPath().append("midi/")); + + // Construct a list of strings based on the command line arguments + scriptPaths.append(CmdlineArgs::Instance().getSettingsPath() + "presets/"); + + ConfigObject *config = new ConfigObject(CmdlineArgs::Instance().getSettingsPath() + SETTINGS_FILE); + scriptPaths.append(config->getResourcePath().append("midi/")); delete config; QListIterator it(scriptFileNames); === modified file 'mixxx/src/mixxx.cpp' --- mixxx/src/mixxx.cpp 2012-01-16 03:04:52 +0000 +++ mixxx/src/mixxx.cpp 2012-01-29 19:17:33 +0000 @@ -71,10 +71,8 @@ "Mixxx has encountered a serious error and needs to close."); } - -MixxxApp::MixxxApp(QApplication *a, struct CmdlineArgs args) +MixxxApp::MixxxApp(QApplication *pApp, const CmdlineArgs& args) { - m_pApp = a; QString buildBranch, buildRevision, buildFlags; #ifdef BUILD_BRANCH @@ -103,6 +101,7 @@ } QString buildInfoFormatted = QString("(%1)").arg(buildInfo.join("; ")); + // This is the first line in mixxx.log qDebug() << "Mixxx" << VERSION << buildInfoFormatted << "is starting..."; qDebug() << "Qt version is:" << qVersion(); @@ -128,59 +127,58 @@ // Check to see if this is the first time this version of Mixxx is run // after an upgrade and make any needed changes. Upgrade upgrader; - m_pConfig = upgrader.versionUpgrade(); + m_pConfig = upgrader.versionUpgrade(args.getSettingsPath()); bool bFirstRun = upgrader.isFirstRun(); bool bUpgraded = upgrader.isUpgraded(); - QString qConfigPath = m_pConfig->getConfigPath(); - QString translationsFolder = qConfigPath + "translations/"; + + QString resourcePath = m_pConfig->getResourcePath(); + QString translationsFolder = resourcePath + "translations/"; // Load Qt base translations - QString locale = args.locale; + QString locale = args.getLocale(); if (locale == "") { locale = QLocale::system().name(); } // Load Qt translations for this locale from the system translation // path. This is the lowest precedence QTranslator. - QTranslator* qtTranslator = new QTranslator(a); + QTranslator* qtTranslator = new QTranslator(pApp); if (qtTranslator->load("qt_" + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) { - a->installTranslator(qtTranslator); + pApp->installTranslator(qtTranslator); } else { delete qtTranslator; } // Load Qt translations for this locale from the Mixxx translations // folder. - QTranslator* mixxxQtTranslator = new QTranslator(a); + QTranslator* mixxxQtTranslator = new QTranslator(pApp); if (mixxxQtTranslator->load("qt_" + locale, translationsFolder)) { - a->installTranslator(mixxxQtTranslator); + pApp->installTranslator(mixxxQtTranslator); } else { delete mixxxQtTranslator; } // Load Mixxx specific translations for this locale from the Mixxx // translations folder. - QTranslator* mixxxTranslator = new QTranslator(a); + QTranslator* mixxxTranslator = new QTranslator(pApp); bool mixxxLoaded = mixxxTranslator->load("mixxx_" + locale, translationsFolder); qDebug() << "Loading translations for locale" << locale << "from translations folder" << translationsFolder << ":" << (mixxxLoaded ? "success" : "fail"); if (mixxxLoaded) { - a->installTranslator(mixxxTranslator); + pApp->installTranslator(mixxxTranslator); } else { delete mixxxTranslator; } // Store the path in the config database - m_pConfig->set(ConfigKey("[Config]", "Path"), ConfigValue(qConfigPath)); + m_pConfig->set(ConfigKey("[Config]", "Path"), ConfigValue(resourcePath)); // Read keyboard configuration and set kdbConfig object in WWidget // Check first in user's Mixxx directory - QString userKeyboard = - QDir::homePath().append("/").append(SETTINGS_PATH) - .append("Custom.kbd.cfg"); + QString userKeyboard = args.getSettingsPath() + "Custom.kbd.cfg"; ConfigObject* pKbdConfig = NULL; @@ -192,7 +190,7 @@ // Otherwise use the default pKbdConfig = new ConfigObject( - QString(qConfigPath) + QString(resourcePath) .append("keyboard/").append("Standard.kbd.cfg")); // TODO(XXX) leak pKbdConfig, MixxxKeyboard owns it? Maybe roll all keyboard @@ -259,8 +257,8 @@ // sqlite driver if this path doesn't exist. Normally config->Save() // above would make it but if it doesn't get run for whatever reason // we get hosed -- bkgood - if (!QDir(QDir::homePath().append("/").append(SETTINGS_PATH)).exists()) { - QDir().mkpath(QDir::homePath().append("/").append(SETTINGS_PATH)); + if (!QDir(args.getSettingsPath()).exists()) { + QDir().mkpath(args.getSettingsPath()); } @@ -328,20 +326,6 @@ m_pConfig->set(ConfigKey("[Library]", "SupportedFileExtensions"), QStringList(SoundSourceProxy::supportedFileExtensions()).join(",")); - // Call inits to invoke all other construction parts - - // Verify path for xml track file. - QFile trackfile( - m_pConfig->getValueString(ConfigKey("[Playlist]", "Listfile"))); - if (m_pConfig->getValueString(ConfigKey("[Playlist]", "Listfile")) - .length() < 1 || !trackfile.exists()) - { - m_pConfig->set(ConfigKey("[Playlist]", "Listfile"), - QDir::homePath().append("/").append(SETTINGS_PATH) - .append(TRACK_FILE)); - m_pConfig->Save(); - } - // Intialize default BPM system values if (m_pConfig->getValueString(ConfigKey("[BPM]", "BPMRangeStart")) .length() < 1) @@ -410,8 +394,10 @@ // Load tracks in args.qlMusicFiles (command line arguments) into player // 1 and 2: for (int i = 0; i < (int)m_pPlayerManager->numDecks() - && i < args.qlMusicFiles.count(); ++i) { - m_pPlayerManager->slotLoadToDeck(args.qlMusicFiles.at(i), i+1); + && i < args.getMusicFiles().count(); ++i) { + if ( SoundSourceProxy::isFilenameSupported(args.getMusicFiles().at(i))) { + m_pPlayerManager->slotLoadToDeck(args.getMusicFiles().at(i), i+1); + } } //Automatically load specially marked promotional tracks on first run @@ -457,13 +443,14 @@ //Install an event filter to catch certain QT events, such as tooltips. //This allows us to turn off tooltips. - m_pApp->installEventFilter(this); // The eventfilter is located in this + pApp->installEventFilter(this); // The eventfilter is located in this // Mixxx class as a callback. // If we were told to start in fullscreen mode on the command-line, // then turn on fullscreen mode. - if (args.bStartInFullscreen) + if (args.getStartInFullscreen()) { slotOptionsFullScreen(true); + } // Refresh the GUI (workaround for Qt 4.6 display bug) /* // TODO(bkgood) delete this block if the moving of setCentralWidget @@ -1363,7 +1350,7 @@ } void MixxxApp::slotHelpManual() { - QDir configDir(m_pConfig->getConfigPath()); + QDir resourceDir(m_pConfig->getResourcePath()); // Default to the mixxx.org hosted version of the manual. QUrl qManualUrl(MIXXX_MANUAL_URL); #if defined(__APPLE__) @@ -1371,16 +1358,16 @@ // web-hosted version. #elif defined(__WINDOWS__) // On Windows, the manual PDF sits in the same folder as the 'skins' folder. - if (configDir.exists(MIXXX_MANUAL_FILENAME)) { + if (resourceDir.exists(MIXXX_MANUAL_FILENAME)) { qManualUrl = QUrl::fromLocalFile( - configDir.absoluteFilePath(MIXXX_MANUAL_FILENAME)); + resourceDir.absoluteFilePath(MIXXX_MANUAL_FILENAME)); } #elif defined(__LINUX__) // On GNU/Linux, the manual is installed to e.g. /usr/share/mixxx/doc/ - configDir.cd("doc"); - if (configDir.exists(MIXXX_MANUAL_FILENAME)) { + resourceDir.cd("doc"); + if (resourceDir.exists(MIXXX_MANUAL_FILENAME)) { qManualUrl = QUrl::fromLocalFile( - configDir.absoluteFilePath(MIXXX_MANUAL_FILENAME)); + resourceDir.absoluteFilePath(MIXXX_MANUAL_FILENAME)); } #else // No idea, default to the mixxx.org hosted version. === modified file 'mixxx/src/mixxx.h' --- mixxx/src/mixxx.h 2011-12-17 05:59:20 +0000 +++ mixxx/src/mixxx.h 2012-01-29 19:08:59 +0000 @@ -60,6 +60,7 @@ class SkinLoader; class VinylControlManager; +class CmdlineArgs; /** * This Class is the base class for Mixxx. It sets up the main @@ -73,7 +74,7 @@ public: /** Construtor. files is a list of command line arguments */ - MixxxApp(QApplication *app, struct CmdlineArgs args); + MixxxApp(QApplication *app, const CmdlineArgs& args); /** destructor */ virtual ~MixxxApp(); /** initializes all QActions of the application */ @@ -148,8 +149,6 @@ QWidget* m_pView; QWidget* m_pWidgetParent; - QApplication *m_pApp; - // The mixing engine. EngineMaster *m_pEngine; @@ -235,11 +234,65 @@ }; //A structure to store the parsed command-line arguments -struct CmdlineArgs +class CmdlineArgs { - QList qlMusicFiles; /* List of files to load into players at startup */ - bool bStartInFullscreen; /* Start in fullscreen mode */ - QString locale; +public: + static CmdlineArgs& Instance() { + static CmdlineArgs cla; + return cla; + } + bool Parse(int &argc, char **argv) { + for (int i = 0; i < argc; ++i) { + if ( argv[i] == QString("-h") + || argv[i] == QString("--h") + || argv[i] == QString("--help")) { + return false; // Display Help Message + } + + if (argv[i]==QString("-f").toLower() || argv[i]==QString("--f") || argv[i]==QString("--fullScreen")) + { + m_startInFullscreen = true; + } else if (argv[i] == QString("--locale") && i+1 < argc) { + m_locale = argv[i+1]; + } else if (argv[i] == QString("--settingsPath") && i+1 < argc) { + m_settingsPath = QString::fromLocal8Bit(argv[i+1]); + if (!m_settingsPath.endsWith("/")) { + m_settingsPath.append("/"); + } + } else if (argv[i] == QString("--resourcePath") && i+1 < argc) { + m_resourcePath = QString::fromLocal8Bit(argv[i+1]); + } else if (argv[i] == QString("--pluginPath") && i+1 < argc) { + m_pluginPath = QString::fromLocal8Bit(argv[i+1]); + } else if (QString::fromLocal8Bit(argv[i]).contains("--midiDebug", Qt::CaseInsensitive)) { + m_midiDebug = true; + } else { + m_musicFiles += QString::fromLocal8Bit(argv[i]); + } + } + return true; + } + const QList& getMusicFiles() const { return m_musicFiles; }; + bool getStartInFullscreen() const { return m_startInFullscreen; }; + bool getMidiDebug() const { return m_midiDebug; }; + const QString& getLocale() const { return m_locale; }; + const QString& getSettingsPath() const { return m_settingsPath; }; + const QString& getResourcePath() const { return m_resourcePath; }; + const QString& getPluginPath() const { return m_pluginPath; }; + +private: + CmdlineArgs() : + m_startInFullscreen(false), //Initialize vars + m_midiDebug(false), + m_settingsPath(QDir::homePath().append("/").append(SETTINGS_PATH)) { + } + ~CmdlineArgs() { }; + QList m_musicFiles; /* List of files to load into players at startup */ + bool m_startInFullscreen; /* Start in fullscreen mode */ + bool m_midiDebug; + QString m_locale; + QString m_settingsPath; + QString m_resourcePath; + QString m_pluginPath; }; === modified file 'mixxx/src/recording/defs_recording.h' --- mixxx/src/recording/defs_recording.h 2011-10-19 17:24:23 +0000 +++ mixxx/src/recording/defs_recording.h 2012-01-29 19:08:59 +0000 @@ -29,6 +29,6 @@ #define SIZE_700MB 750000000 //bytes #define SIZE_1GB 1000000000 //bytes #define SIZE_2GB 2000000000 //bytes -#define SIZE_4GB 4000000000l //bytes +#define SIZE_4GB 4000000000ul //bytes #endif === modified file 'mixxx/src/recording/recordingmanager.cpp' --- mixxx/src/recording/recordingmanager.cpp 2011-12-18 20:23:14 +0000 +++ mixxx/src/recording/recordingmanager.cpp 2012-01-29 19:08:59 +0000 @@ -24,34 +24,28 @@ QDir os_music_folder_dir(m_pConfig->getValueString(ConfigKey("[Playlist]", "Directory"))); //Check if there's a folder Mixxx within the music directory QDir mixxxDir(os_music_folder_dir.absolutePath() +"/Mixxx"); - - if(!mixxxDir.exists()) { - - if(os_music_folder_dir.mkdir("Mixxx")) { + m_recordingDir = mixxxDir.absolutePath() +"/Recordings"; + m_split_size = getFileSplitSize(); + + if (!mixxxDir.exists()) { + if (os_music_folder_dir.mkdir("Mixxx")) { qDebug() << "Created folder 'Mixxx' within default OS Music directory"; - - if(mixxxDir.mkdir("Recordings")) - qDebug() << "Created folder 'Recordings' successfully"; - else - qDebug() << "Could not create folder 'Recordings' within 'Mixxx'"; - } - else{ + } else { qDebug() << "Failed to create folder 'Mixxx'' within default OS Music directory." << "Please verify that there's no file called 'Mixxx'."; - } - } - else{ // the Mixxx directory already exists - qDebug() << "Found folder 'Mixxx' within default OS music directory"; - QDir recordDir(mixxxDir.absolutePath() +"Recordings"); - if(!recordDir.exists()) { - if(mixxxDir.mkdir("Recordings")) - qDebug() << "Created folder 'Recordings' successfully"; - else - qDebug() << "Could not create folder 'Recordings' within 'Mixxx'"; - } - } - m_recordingDir = os_music_folder_dir.absolutePath() +"/Mixxx/Recordings"; - m_split_size = getFileSplitSize(); + return; + } + } + + QDir recordDir(m_recordingDir); + if (!recordDir.exists()) { + if (mixxxDir.mkdir("Recordings")) { + qDebug() << "Created folder 'Recordings' successfully"; + } + else { + qDebug() << "Could not create folder 'Recordings' within 'Mixxx'"; + } + } } RecordingManager::~RecordingManager() === modified file 'mixxx/src/skin/skinloader.cpp' --- mixxx/src/skin/skinloader.cpp 2011-09-26 01:36:19 +0000 +++ mixxx/src/skin/skinloader.cpp 2012-01-29 19:08:59 +0000 @@ -25,7 +25,7 @@ QString SkinLoader::getConfiguredSkinPath() { const QString defaultSkin = "Deere1280x800-WXGA";//XXX: App Store //"Outline1024x600-Netbook"; - QString qSkinPath = m_pConfig->getConfigPath(); + QString qSkinPath = m_pConfig->getResourcePath(); qSkinPath.append("skins/"); QDir skinPath(qSkinPath); === modified file 'mixxx/src/soundmanagerconfig.cpp' --- mixxx/src/soundmanagerconfig.cpp 2011-12-18 20:23:14 +0000 +++ mixxx/src/soundmanagerconfig.cpp 2012-01-29 19:08:59 +0000 @@ -17,6 +17,7 @@ #include "soundmanagerutil.h" #include "sounddevice.h" #include "soundmanager.h" +#include "mixxx.h" // this (7) represents latency values from 1 ms to about 80 ms -- bkgood const unsigned int SoundManagerConfig::kMaxLatency = 7; @@ -30,9 +31,7 @@ : m_api("None") , m_sampleRate(kDefaultSampleRate) , m_latency(kDefaultLatency) { - m_configFile = QFileInfo( - QString("%1/%2/%3").arg(QDir::homePath(), SETTINGS_PATH, - SOUNDMANAGERCONFIG_FILENAME)); + m_configFile = QFileInfo(CmdlineArgs::Instance().getSettingsPath() + SOUNDMANAGERCONFIG_FILENAME); } SoundManagerConfig::~SoundManagerConfig() { === modified file 'mixxx/src/soundsourceproxy.cpp' --- mixxx/src/soundsourceproxy.cpp 2012-01-07 05:48:41 +0000 +++ mixxx/src/soundsourceproxy.cpp 2012-01-29 19:08:59 +0000 @@ -33,6 +33,8 @@ #endif #include "soundsourceflac.h" +#include "mixxx.h" + #include #include #include @@ -67,6 +69,7 @@ m_pTrack = pTrack; } +// static void SoundSourceProxy::loadPlugins() { /** Scan for and initialize all plugins */ @@ -74,11 +77,11 @@ QList pluginDirs; QStringList nameFilters; - QStringList clArgs = QApplication::arguments(); - int pluginPath = clArgs.indexOf("--pluginPath"); - if (pluginPath != -1 && pluginPath + 1 < clArgs.size()) { - qDebug() << "Adding plugin path from commandline arg:" << clArgs.at(pluginPath + 1); - pluginDirs.append(QDir(clArgs.at(pluginPath + 1))); + const QString& pluginPath = CmdlineArgs::Instance().getPluginPath(); + + if (!pluginPath.isEmpty()) { + qDebug() << "Adding plugin path from commandline arg:" << pluginPath; + pluginDirs.append(QDir(pluginPath)); } #ifdef __LINUX__ pluginDirs.append(QDir("/usr/local/lib/mixxx/plugins/soundsource/")); @@ -109,6 +112,7 @@ } } +// static Mixxx::SoundSource* SoundSourceProxy::initialize(QString qFilename) { Mixxx::SoundSource* sndsrc = NULL; @@ -157,6 +161,7 @@ delete m_pSoundSource; } +// static QLibrary* SoundSourceProxy::getPlugin(QString lib_filename) { static QMutex mutex; @@ -277,6 +282,7 @@ return 0; } +// static int SoundSourceProxy::ParseHeader(TrackInfoObject* p) { QString qFilename = p->getLocation(); @@ -322,6 +328,7 @@ return 0; } +// static QStringList SoundSourceProxy::supportedFileExtensions() { QMutexLocker locker(&m_extensionsMutex); @@ -341,6 +348,7 @@ return supportedFileExtensions; } +// static QStringList SoundSourceProxy::supportedFileExtensionsByPlugins() { QMutexLocker locker(&m_extensionsMutex); QList supportedFileExtensions; @@ -348,6 +356,7 @@ return supportedFileExtensions; } +// static QString SoundSourceProxy::supportedFileExtensionsString() { QStringList supportedFileExtList = SoundSourceProxy::supportedFileExtensions(); // Turn the list into a "*.mp3 *.wav *.etc" style string @@ -357,6 +366,7 @@ return supportedFileExtList.join(" "); } +// static QString SoundSourceProxy::supportedFileExtensionsRegex() { QStringList supportedFileExtList = SoundSourceProxy::supportedFileExtensions(); @@ -369,6 +379,7 @@ return QString("\\.(%1)$").arg(supportedFileExtList.join("|")); } +// static bool SoundSourceProxy::isFilenameSupported(QString fileName) { if (m_supportedFileRegex.isValid()) { QString regex = SoundSourceProxy::supportedFileExtensionsRegex(); === modified file 'mixxx/src/upgrade.cpp' --- mixxx/src/upgrade.cpp 2011-01-07 06:36:22 +0000 +++ mixxx/src/upgrade.cpp 2012-01-29 22:13:56 +0000 @@ -34,7 +34,7 @@ // We return the ConfigObject here because we have to make changes to the // configuration and the location of the file may change between releases. -ConfigObject* Upgrade::versionUpgrade() { +ConfigObject* Upgrade::versionUpgrade(const QString& settingsPath) { /* Pre-1.7.0: * @@ -53,7 +53,7 @@ if (pre170Config->exists()) { // Move the files to their new location - QString newLocation = QDir::homePath().append("/").append(SETTINGS_PATH); + QString newLocation = settingsPath; if (!QDir(newLocation).exists()) { qDebug() << "Creating new settings directory" << newLocation; @@ -150,7 +150,7 @@ ****************************************************************************/ // Read the config file from home directory - ConfigObject *config = new ConfigObject(QDir::homePath().append("/").append(SETTINGS_PATH).append(SETTINGS_FILE)); + ConfigObject *config = new ConfigObject(settingsPath + SETTINGS_FILE); QString configVersion = config->getValueString(ConfigKey("[Config]","Version")); @@ -224,7 +224,7 @@ // Upgrade tasks go here #ifdef __APPLE__ QString OSXLocation180 = QDir::homePath().append("/").append(".mixxx"); - QString OSXLocation190 = QDir::homePath().append("/").append(SETTINGS_PATH); + QString OSXLocation190 = settingsPath; QDir newOSXDir(OSXLocation190); newOSXDir.mkpath(OSXLocation190); @@ -260,11 +260,11 @@ } //Rename the old directory. - newOSXDir.rename(OSXLocation180, OSXLocation180+ "-1.8"); + 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 = new ConfigObject(QDir::homePath().append("/").append(SETTINGS_PATH).append(SETTINGS_FILE)); + config = new ConfigObject(settingsPath + SETTINGS_FILE); #endif } // For the next release === modified file 'mixxx/src/upgrade.h' --- mixxx/src/upgrade.h 2010-07-18 20:30:24 +0000 +++ mixxx/src/upgrade.h 2012-01-29 19:08:59 +0000 @@ -23,7 +23,7 @@ public: Upgrade(); ~Upgrade(); - ConfigObject* versionUpgrade(); + ConfigObject* versionUpgrade(const QString& settingsPath); bool isFirstRun() { return m_bFirstRun; }; bool isUpgraded() { return m_bUpgraded; }; private: === modified file 'mixxx/src/widget/wsearchlineedit.cpp' --- mixxx/src/widget/wsearchlineedit.cpp 2011-11-27 07:28:09 +0000 +++ mixxx/src/widget/wsearchlineedit.cpp 2012-01-29 19:08:59 +0000 @@ -9,7 +9,7 @@ WSearchLineEdit::WSearchLineEdit(ConfigObject* pConfig, QWidget* pParent) : QLineEdit(pParent) { - QString skinpath = pConfig->getConfigPath(); + QString skinpath = pConfig->getResourcePath(); m_clearButton = new QToolButton(this); QPixmap pixmap(skinpath.append("/skins/cross.png")); m_clearButton->setIcon(QIcon(pixmap));