1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 18:21:34 +02:00

Remove code duplication between the two constructors of MenuSettingBool.

This commit is contained in:
Maarten ter Huurne 2010-07-27 23:45:53 +02:00
parent 9fcaa2b8fa
commit eff06b0319
2 changed files with 12 additions and 13 deletions

View File

@ -25,31 +25,29 @@ using namespace std;
using namespace fastdelegate;
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value)
: MenuSetting(gmenu2x,name,description)
: MenuSetting(gmenu2x, name, description)
{
IconButton *btn;
_ivalue = value;
_value = NULL;
originalValue = *value != 0;
setValue(this->value());
btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Switch"]);
btn->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
buttonBox.add(btn);
initButton();
}
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value)
: MenuSetting(gmenu2x,name,description)
: MenuSetting(gmenu2x, name, description)
{
IconButton *btn;
_value = value;
_ivalue = NULL;
originalValue = *value;
setValue(this->value());
initButton();
}
btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Switch"]);
void MenuSettingBool::initButton()
{
IconButton *btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png",
gmenu2x->tr["Switch"]);
btn->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
buttonBox.add(btn);
}

View File

@ -28,13 +28,14 @@ class GMenu2X;
class MenuSettingBool : public MenuSetting {
private:
void initButton();
void toggle();
bool originalValue;
bool *_value;
int *_ivalue;
string strvalue;
void toggle();
public:
MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value);
MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value);