summaryrefslogtreecommitdiff
path: root/src/settings.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-11-28 11:06:28 +0100
committerTannin <devnull@localhost>2014-11-28 11:06:28 +0100
commit78f628e0af2f2df562c40ac1424b432b6a969055 (patch)
tree294c461fc858aa9d13fa65c37fd3517db4554f2a /src/settings.cpp
parent45a46778fb9c7195cb09fbba4a2c502dca6bca13 (diff)
cleanup und bugfixes after refactoring
Diffstat (limited to 'src/settings.cpp')
-rw-r--r--src/settings.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/settings.cpp b/src/settings.cpp
index 274e5979..418c5661 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -57,13 +57,13 @@ private:
static const unsigned char Key2[20] = { 0x99, 0xb8, 0x76, 0x42, 0x3e, 0xc1, 0x60, 0xa4, 0x5b, 0x01,
0xdb, 0xf8, 0x43, 0x3a, 0xb7, 0xb6, 0x98, 0xd4, 0x7d, 0xa2 };
-Settings *Settings::s_Instance = NULL;
+Settings *Settings::s_Instance = nullptr;
-Settings::Settings()
- : m_Settings(ToQString(GameInfo::instance().getIniFilename()), QSettings::IniFormat)
+Settings::Settings(const QSettings &config)
+ : m_Settings(config.fileName(), config.format())
{
- if (s_Instance != NULL) {
+ if (s_Instance != nullptr) {
throw std::runtime_error("second instance of \"Settings\" created");
} else {
s_Instance = this;
@@ -73,13 +73,13 @@ Settings::Settings()
Settings::~Settings()
{
- s_Instance = NULL;
+ s_Instance = nullptr;
}
Settings &Settings::instance()
{
- if (s_Instance == NULL) {
+ if (s_Instance == nullptr) {
throw std::runtime_error("no instance of \"Settings\"");
}
return *s_Instance;
@@ -110,9 +110,9 @@ void Settings::registerAsNXMHandler(bool force)
std::wstring executable = ToWString(QCoreApplication::applicationFilePath());
std::wstring mode = force ? L"forcereg" : L"reg";
std::wstring parameters = mode + L" " + GameInfo::instance().getGameShortName() + L" \"" + executable + L"\"";
- HINSTANCE res = ::ShellExecuteW(NULL, L"open", nxmPath.c_str(), parameters.c_str(), NULL, SW_SHOWNORMAL);
+ HINSTANCE res = ::ShellExecuteW(nullptr, L"open", nxmPath.c_str(), parameters.c_str(), nullptr, SW_SHOWNORMAL);
if ((int)res <= 32) {
- QMessageBox::critical(NULL, tr("Failed"),
+ QMessageBox::critical(nullptr, tr("Failed"),
tr("Sorry, failed to start the helper application"));
}
}
@@ -181,10 +181,9 @@ QString Settings::getSteamAppID() const
QString Settings::getDownloadDirectory() const
{
- return QDir::toNativeSeparators(m_Settings.value("Settings/download_directory", ToQString(GameInfo::instance().getDownloadDir())).toString());
+ return QDir::toNativeSeparators(m_Settings.value("Settings/download_directory", qApp->applicationDirPath() + "/downloads").toString());
}
-
void Settings::setDownloadSpeed(const QString &serverName, int bytesPerSecond)
{
m_Settings.beginGroup("Servers");
@@ -221,12 +220,14 @@ std::map<QString, int> Settings::getPreferredServers()
QString Settings::getCacheDirectory() const
{
- return QDir::toNativeSeparators(m_Settings.value("Settings/cache_directory", ToQString(GameInfo::instance().getCacheDir())).toString());
+ return QDir::toNativeSeparators(m_Settings.value("Settings/cache_directory",
+ qApp->applicationDirPath() + "/webcache").toString());
}
QString Settings::getModDirectory() const
{
- return QDir::toNativeSeparators(m_Settings.value("Settings/mod_directory", ToQString(GameInfo::instance().getModsDir())).toString());
+ return QDir::toNativeSeparators(m_Settings.value("Settings/mod_directory",
+ qApp->applicationDirPath() + "/mods").toString());
}
QString Settings::getNMMVersion() const
@@ -647,7 +648,7 @@ void Settings::query(QWidget *parent)
{ // advanced settings
if ((QDir::fromNativeSeparators(modDirEdit->text()) != QDir::fromNativeSeparators(getModDirectory())) &&
- (QMessageBox::question(NULL, tr("Confirm"), tr("Changing the mod directory affects all your profiles! "
+ (QMessageBox::question(nullptr, tr("Confirm"), tr("Changing the mod directory affects all your profiles! "
"Mods not present (or named differently) in the new location will be disabled in all profiles. "
"There is no way to undo this unless you backed up your profiles manually. Proceed?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No)) {