Don't tinker with config and data files on Mac for now
authorManuel Nickschas <sputnick@quassel-irc.org>
Wed, 21 Jan 2009 23:27:00 +0000 (00:27 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 21 Jan 2009 23:29:19 +0000 (00:29 +0100)
Still need to figure out how to behave correctly on Mac. To not break Mac builds
until that's sorted, this should restore the old behavior.
Disabling migration code on Mac as well.

src/common/quassel.cpp
src/common/settings.cpp
src/core/core.cpp
src/qtui/qtuiapplication.cpp

index 52be52b..5014073 100644 (file)
@@ -241,17 +241,22 @@ QString Quassel::configDirPath() {
     _configDirPath = Quassel::optionValue("configdir");
   } else {
 
-    // We abuse QSettings to find us a sensible path on all platforms
-#ifdef Q_WS_WIN
+#ifdef Q_WS_MAC
+    // On Mac, the path is always the same
+    _configDirPath = QDir::homePath() + "/Library/Application Support/Quassel/";
+#else
+    // We abuse QSettings to find us a sensible path on the other platforms
+#  ifdef Q_WS_WIN
     // don't use the registry
     QSettings::Format format = QSettings::IniFormat;
-#else
+#  else
     QSettings::Format format = QSettings::NativeFormat;
-#endif
+#  endif
     QSettings s(format, QSettings::UserScope, QCoreApplication::organizationDomain(), buildInfo().applicationName);
     QFileInfo fileInfo(s.fileName());
     _configDirPath = fileInfo.dir().absolutePath();
   }
+#endif /* Q_WS_MAC */
 
   if(!_configDirPath.endsWith(QDir::separator()) && !_configDirPath.endsWith('/'))
     _configDirPath += QDir::separator();
index 6b0ce03..722be0e 100644 (file)
 QHash<QString, QHash<QString, QVariant> > Settings::settingsCache;
 QHash<QString, QHash<QString, SettingsChangeNotifier *> > Settings::settingsChangeNotifier;
 
+#ifdef Q_WS_MAC
+#  define create_qsettings QSettings s(QCoreApplication::organizationDomain(), appName)
+#else
+#  define create_qsettings QSettings s(fileName(), format())
+#endif
+
 // Settings::Settings(QString group_, QString appName_)
 //   : group(group_),
 //     appName(appName_)
@@ -56,7 +62,7 @@ void Settings::notify(const QString &key, QObject *receiver, const char *slot) {
 }
 
 QStringList Settings::allLocalKeys() {
-  QSettings s(fileName(), format());
+  create_qsettings;
   s.beginGroup(group);
   QStringList res = s.allKeys();
   s.endGroup();
@@ -70,7 +76,7 @@ QStringList Settings::localChildKeys(const QString &rootkey) {
   else
     g = QString("%1/%2").arg(group, rootkey);
 
-  QSettings s(fileName(), format());
+  create_qsettings;
   s.beginGroup(g);
   QStringList res = s.childKeys();
   s.endGroup();
@@ -84,7 +90,7 @@ QStringList Settings::localChildGroups(const QString &rootkey) {
   else
     g = QString("%1/%2").arg(group, rootkey);
 
-  QSettings s(fileName(), format());
+  create_qsettings;
   s.beginGroup(g);
   QStringList res = s.childGroups();
   s.endGroup();
@@ -92,7 +98,7 @@ QStringList Settings::localChildGroups(const QString &rootkey) {
 }
 
 void Settings::setLocalValue(const QString &key, const QVariant &data) {
-  QSettings s(fileName(), format());
+  create_qsettings;
   s.beginGroup(group);
   s.setValue(key, data);
   s.endGroup();
@@ -104,7 +110,7 @@ void Settings::setLocalValue(const QString &key, const QVariant &data) {
 
 const QVariant &Settings::localValue(const QString &key, const QVariant &def) {
   if(!isCached(group, key)) {
-    QSettings s(fileName(), format());
+    create_qsettings;
     s.beginGroup(group);
     setCacheValue(group, key, s.value(key, def));
     s.endGroup();
@@ -113,7 +119,7 @@ const QVariant &Settings::localValue(const QString &key, const QVariant &def) {
 }
 
 void Settings::removeLocalKey(const QString &key) {
-  QSettings s(fileName(), format());
+  create_qsettings;
   s.beginGroup(group);
   s.remove(key);
   s.endGroup();
index 2724378..1e1bb61 100644 (file)
@@ -55,6 +55,8 @@ Core::Core() : storage(0) {
 
   loadTranslation(QLocale::system());
 
+#ifndef Q_WS_MAC
+
   // FIXME: MIGRATION 0.3 -> 0.4: Move database and core config to new location
   // Move settings, note this does not delete the old files
 #ifdef Q_WS_WIN
@@ -113,7 +115,7 @@ Core::Core() : storage(0) {
       qWarning() << "*** Migration completed.\n\n";
     }
   }
-
+#endif /* !Q_WS_MAC */
   // MIGRATION end
 
   // Register storage backends here!
index 82013eb..49eecee 100644 (file)
@@ -64,6 +64,7 @@ QtUiApplication::QtUiApplication(int &argc, char **argv)
 bool QtUiApplication::init() {
   if(Quassel::init()) {
 
+#ifndef Q_WS_MAC
     // FIXME: MIGRATION 0.3 -> 0.4: Move database and core config to new location
     // Move settings, note this does not delete the old files
 #ifdef Q_WS_WIN
@@ -91,7 +92,7 @@ bool QtUiApplication::init() {
       }
       qWarning() << "*** Migration completed.\n\n";
     }
-
+#endif /* !Q_WS_MAC */
     // MIGRATION end
 
     // session resume