summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-19 21:23:26 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-19 21:23:26 +0300
commitf64447a7c8a3ba855923e3d9a1c2e9c62e6bdba4 (patch)
treee6b2678f3e4b1f4456843246a15bf8654e89e41d
parentbf38c1a0d27aff70646022fb2a898532c1f95001 (diff)
downloadmv-f64447a7c8a3ba855923e3d9a1c2e9c62e6bdba4.tar.gz
mv-f64447a7c8a3ba855923e3d9a1c2e9c62e6bdba4.tar.bz2
mv-f64447a7c8a3ba855923e3d9a1c2e9c62e6bdba4.tar.xz
mv-f64447a7c8a3ba855923e3d9a1c2e9c62e6bdba4.zip
Fix reading default config values in setupitem class.
-rw-r--r--src/gui/setupitem.cpp41
-rw-r--r--src/gui/setupitem.h9
2 files changed, 37 insertions, 13 deletions
diff --git a/src/gui/setupitem.cpp b/src/gui/setupitem.cpp
index 9af65f23f..ecd6a9407 100644
--- a/src/gui/setupitem.cpp
+++ b/src/gui/setupitem.cpp
@@ -52,7 +52,8 @@ SetupItem::SetupItem(std::string text, std::string description,
mUseDefault(false),
mValue(""),
mDefault(""),
- mWidget(0)
+ mWidget(0),
+ mValueType(VBOOL)
{
}
@@ -68,7 +69,8 @@ SetupItem::SetupItem(std::string text, std::string description,
mUseDefault(true),
mValue(""),
mDefault(def),
- mWidget(0)
+ mWidget(0),
+ mValueType(VBOOL)
{
}
@@ -89,9 +91,28 @@ void SetupItem::load()
{
Configuration *cfg = getConfig();
if (mUseDefault)
+ {
mValue = cfg->getValue(mKeyName, mDefault);
+ }
else
- mValue = cfg->getStringValue(mKeyName);
+ {
+ switch (mValueType)
+ {
+ case VBOOL:
+ if (cfg->getBoolValue(mKeyName))
+ mValue = "1";
+ else
+ mValue = "0";
+ break;
+ case VSTR:
+ default:
+ mValue = cfg->getStringValue(mKeyName);
+ break;
+ case VINT:
+ mValue = toString(cfg->getIntValue(mKeyName));
+ break;
+ }
+ }
}
void SetupItem::save()
@@ -207,6 +228,7 @@ SetupItemTextField::SetupItemTextField(std::string text,
mButton(0),
mEditDialog(0)
{
+ mValueType = VSTR;
createControls();
}
@@ -223,6 +245,7 @@ SetupItemTextField::SetupItemTextField(std::string text,
mButton(0),
mEditDialog(0)
{
+ mValueType = VSTR;
createControls();
}
@@ -306,16 +329,6 @@ void SetupItemTextField::apply(std::string eventName)
}
-
-
-
-
-
-
-
-
-
-
SetupItemIntTextField::SetupItemIntTextField(std::string text,
std::string description,
std::string keyName,
@@ -332,6 +345,7 @@ SetupItemIntTextField::SetupItemIntTextField(std::string text,
mMax(max),
mEditDialog(0)
{
+ mValueType = VSTR;
createControls();
}
@@ -352,6 +366,7 @@ SetupItemIntTextField::SetupItemIntTextField(std::string text,
mMax(max),
mEditDialog(0)
{
+ mValueType = VSTR;
createControls();
}
diff --git a/src/gui/setupitem.h b/src/gui/setupitem.h
index b5ea566da..686f8a2a7 100644
--- a/src/gui/setupitem.h
+++ b/src/gui/setupitem.h
@@ -51,6 +51,13 @@ class TextField;
class SetupItem : public gcn::ActionListener
{
public:
+ enum
+ {
+ VBOOL,
+ VSTR,
+ VINT
+ };
+
SetupItem(std::string text, std::string description,
std::string keyName, SetupTabScroll *parent,
std::string eventName, bool mainConfig);
@@ -115,6 +122,8 @@ class SetupItem : public gcn::ActionListener
gcn::Widget *mWidget;
std::list<gcn::Widget*> mTempWidgets;
+
+ int mValueType;
};
class SetupItemCheckBox : public SetupItem