diff --git a/src/common.h b/src/common.h index 3d2eb4cc5..457a2e494 100644 --- a/src/common.h +++ b/src/common.h @@ -35,8 +35,8 @@ static QString findWinSystemConfigPath() { QString temp; - temp = (!qgetenv("LocalAppData").isEmpty()) ? QString::fromUtf8(qgetenv("LocalAppData")) + "/antimicrox" - : QDir::homePath() + "/.antimicrox"; + temp = (!qgetenv("LocalAppData").isEmpty()) ? QString::fromUtf8(qgetenv("LocalAppData")) + "\\antimicrox" + : QDir::homePath() + "\\.antimicrox"; return temp; } @@ -95,9 +95,9 @@ const QString configFileName = "antimicrox_settings.ini"; inline QString configFilePath() { #if defined(Q_OS_WIN) && defined(WIN_PORTABLE_PACKAGE) - return QString(configPath()).append("/").append(configFileName); + return QString(configPath()).append("\\").append(configFileName); #elif defined(Q_OS_WIN) - return QString(configPath()).append("/").append(configFileName); + return QString(configPath()).append("\\").append(configFileName); #else return QString(configPath()).append("/").append(configFileName); #endif @@ -105,20 +105,28 @@ inline QString configFilePath() inline QString configLegacyFilePath() { +#if defined(Q_OS_WIN) + return ""; // earlier vesrions of antimicrox was not supported by Windows +#else QString configPath = (!qgetenv("XDG_CONFIG_HOME").isEmpty()) ? QString::fromUtf8(qgetenv("XDG_CONFIG_HOME")) + "/antimicroX" : QDir::homePath() + "/.config/antimicroX"; return QString(configPath).append("/").append("antimicroX_settings.ini"); +#endif } inline QString configAntimicroLegacyFilePath() { +#if defined(Q_OS_WIN) + QString temp = configFilePath().replace("antimicrox", "antimicro").replace("/", "\\"); + return temp; +#else QString configPath = (!qgetenv("XDG_CONFIG_HOME").isEmpty()) ? QString::fromUtf8(qgetenv("XDG_CONFIG_HOME")) + "/antimicro" : QDir::homePath() + "/.config/antimicro"; - return QString(configPath).append("/").append("antimicro_settings.ini"); +#endif } const int LATESTCONFIGFILEVERSION = 19; diff --git a/src/main.cpp b/src/main.cpp index d02972a0f..dfa679cdd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -176,20 +176,23 @@ void importLegacySettingsIfExist() if (requireMigration) { const QFileInfo fileToCopy = legacyConfigExists ? legacyConfig : legacyAntimicroConfig; +#if defined(Q_OS_WIN) + const QString location = PadderCommon::configPath(); +#else + const QString location = "~/.config/antimicrox"; +#endif + QDir(PadderCommon::configPath()).mkpath(PadderCommon::configPath()); const bool copySuccess = QFile::copy(fileToCopy.canonicalFilePath(), PadderCommon::configFilePath()); qDebug() << "Legacy settings found"; - const QString successMessage = QString("Your original settings (previously stored in %1) " - "have been copied to " - "~/.config/antimicrox to ensure consistent naming across " - "entire project.\nIf you want you can " - "delete the original directory or leave it as it is.") - .arg(fileToCopy.canonicalFilePath()); - const QString errorMessage = QString("Some problem with settings migration occurred.\nOriginal " - "configs are stored in %1 " - "but their new location is ~/.config/antimicrox.\n" - "You can migrate manually by renaming old directory and " - "renaming file to antimicrox_settings.ini.") - .arg(fileToCopy.canonicalFilePath()); + const QString successMessage = + QObject::tr("Your original settings (previously stored in %1) have been copied to\n%2\n If you want you can " + "delete the original directory or leave it as it is.") + .arg(fileToCopy.canonicalFilePath(), location); + const QString errorMessage = + QObject::tr("Some problem with settings migration occurred.\nOriginal configs are stored in \n%1\n but their " + "new location is: \n%2\nYou can migrate manually by renaming old directory and renaming file to " + "antimicrox_settings.ini.") + .arg(fileToCopy.canonicalFilePath(), location); QMessageBox msgBox; if (copySuccess)