forked from AntiMicro/antimicro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathantimicrosettings.cpp
78 lines (68 loc) · 2.49 KB
/
antimicrosettings.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* antimicro Gamepad to KB+M event mapper
* Copyright (C) 2015 Travis Nickles <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "antimicrosettings.h"
const bool AntiMicroSettings::defaultDisabledWinEnhanced = false;
const bool AntiMicroSettings::defaultAssociateProfiles = true;
const int AntiMicroSettings::defaultSpringScreen = -1;
const unsigned int AntiMicroSettings::defaultSDLGamepadPollRate = 10;
AntiMicroSettings::AntiMicroSettings(const QString &fileName, Format format, QObject *parent) :
QSettings(fileName, format, parent)
{
}
/**
* @brief Get the currently used value such as an setting overridden
* with a command line argument.
* @param Setting key
* @param Default value to use if key does not exist
* @return Stored value or the default value passed
*/
QVariant AntiMicroSettings::runtimeValue(const QString &key, const QVariant &defaultValue) const
{
QVariant settingValue;
QString inGroup = group();
QString fullKey = QString(inGroup).append("/").append(key);
if (cmdSettings.contains(fullKey))
{
settingValue = cmdSettings.value(fullKey, defaultValue);
}
else
{
settingValue = value(key, defaultValue);
}
return settingValue;
}
/**
* @brief Import relevant options given on the command line into a QSettings
* instance. Used to override any options that might be present in the
* main settings file. Keys will have to be changed to the appropriate
* config key.
* @param Interpreted options set on the command line.
*/
void AntiMicroSettings::importFromCommandLine(CommandLineUtility &cmdutility)
{
cmdSettings.clear();
if (cmdutility.isLaunchInTrayEnabled())
{
cmdSettings.setValue("LaunchInTray", 1);
}
if (cmdutility.shouldMapController())
{
cmdSettings.setValue("DisplaySDLMapping", 1);
}
}
QMutex* AntiMicroSettings::getLock()
{
return &lock;
}