1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 16:23:52 +00:00

Fixed checkboxes saving invalid values.

This commit is contained in:
cc9cii 2014-09-22 18:50:48 +10:00
parent fc8d6da6a2
commit 48f96df29d
2 changed files with 12 additions and 5 deletions

View file

@ -12,13 +12,13 @@
CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting,
Page *parent)
: View (setting, parent)
: mType(setting->type()), View (setting, parent)
{
foreach (const QString &value, setting->declaredValues())
{
QAbstractButton *button = 0;
switch (setting->type())
switch (mType)
{
case CSMSettings::Type_CheckBox: {
if(mButtons.empty()) // show only one for checkboxes
@ -43,7 +43,7 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting,
break;
}
if(setting->type() != CSMSettings::Type_CheckBox || mButtons.empty())
if(mType != CSMSettings::Type_CheckBox || mButtons.empty())
{
connect (button, SIGNAL (clicked (bool)),
this, SLOT (slotToggled (bool)));
@ -67,8 +67,14 @@ void CSVSettings::BooleanView::slotToggled (bool state)
foreach (QString key, mButtons.keys())
{
if (mButtons.value(key)->isChecked())
values.append (key);
// checkbox values are true/false unlike radio buttons
if(mType == CSMSettings::Type_CheckBox)
values.append(mButtons.value(key)->isChecked() ? "true" : "false");
else
{
if (mButtons.value(key)->isChecked())
values.append (key);
}
}
setSelectedValues (values, false);

View file

@ -16,6 +16,7 @@ namespace CSVSettings
Q_OBJECT
QMap <QString, QAbstractButton *> mButtons;
enum CSMSettings::SettingType mType;
public:
explicit BooleanView (CSMSettings::Setting *setting,