diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-07-23 03:01:00 -0400 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-11-03 11:39:03 -0500 |
| commit | 3c791b092054192fcff27b599728d3482688aec8 (patch) | |
| tree | 91e9ea09a5339575cf6e2ddd35a10cb57a012267 /src/instancemanager.cpp | |
| parent | 5b13704275fc3cf02f6c3f4d4bd77d32425ad2c9 (diff) | |
moved registry key from "Tannin" to "Mod Organizer Team"
Diffstat (limited to 'src/instancemanager.cpp')
| -rw-r--r-- | src/instancemanager.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/instancemanager.cpp b/src/instancemanager.cpp index 9bcd0f3c..aa8f1d8c 100644 --- a/src/instancemanager.cpp +++ b/src/instancemanager.cpp @@ -23,6 +23,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include "settings.h" #include "shared/appconfig.h" #include "plugincontainer.h" +#include "env.h" #include <report.h> #include <iplugingame.h> #include <utility.h> @@ -37,14 +38,15 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. using namespace MOBase; -static const char COMPANY_NAME[] = "Tannin"; -static const char APPLICATION_NAME[] = "Mod Organizer"; -static const char INSTANCE_KEY[] = "CurrentInstance"; +const QString Organization = "Mod Organizer Team"; +const QString Application = "Mod Organizer"; +const QString InstanceValue = "CurrentInstance"; InstanceManager::InstanceManager() - : m_AppSettings(COMPANY_NAME, APPLICATION_NAME) + : m_AppSettings(Organization, Application) { + updateRegistryKey(); } InstanceManager &InstanceManager::instance() @@ -53,6 +55,23 @@ InstanceManager &InstanceManager::instance() return s_Instance; } +void InstanceManager::updateRegistryKey() +{ + const QString OldOrganization = "Tannin"; + const QString OldApplication = "Mod Organizer"; + const QString OldInstanceValue = "CurrentInstance"; + + const QString OldRootKey = "Software\\" + OldOrganization; + + if (env::registryValueExists(OldRootKey + "\\" + OldApplication, OldInstanceValue)) { + QSettings old(OldOrganization, OldApplication); + setCurrentInstance(old.value(OldInstanceValue).toString()); + old.remove(OldInstanceValue); + } + + env::deleteRegistryKeyIfEmpty(OldRootKey); +} + void InstanceManager::overrideInstance(const QString& instanceName) { m_overrideInstanceName = instanceName; @@ -70,7 +89,7 @@ QString InstanceManager::currentInstance() const if (m_overrideInstance) return m_overrideInstanceName; else - return m_AppSettings.value(INSTANCE_KEY, "").toString(); + return m_AppSettings.value(InstanceValue, "").toString(); } void InstanceManager::clearCurrentInstance() @@ -82,7 +101,7 @@ void InstanceManager::clearCurrentInstance() void InstanceManager::setCurrentInstance(const QString &name) { - m_AppSettings.setValue(INSTANCE_KEY, name); + m_AppSettings.setValue(InstanceValue, name); } bool InstanceManager::deleteLocalInstance(const QString &instanceId) const |
