mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-26 10:04:05 +02:00
Remove code duplication between the two constructors of MenuSettingBool.
This commit is contained in:
parent
9fcaa2b8fa
commit
eff06b0319
@ -25,31 +25,29 @@ using namespace std;
|
|||||||
using namespace fastdelegate;
|
using namespace fastdelegate;
|
||||||
|
|
||||||
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value)
|
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value)
|
||||||
: MenuSetting(gmenu2x,name,description)
|
: MenuSetting(gmenu2x, name, description)
|
||||||
{
|
{
|
||||||
IconButton *btn;
|
|
||||||
|
|
||||||
_ivalue = value;
|
_ivalue = value;
|
||||||
_value = NULL;
|
_value = NULL;
|
||||||
originalValue = *value != 0;
|
originalValue = *value != 0;
|
||||||
setValue(this->value());
|
setValue(this->value());
|
||||||
|
initButton();
|
||||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/b.png", gmenu2x->tr["Switch"]);
|
|
||||||
btn->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
|
|
||||||
buttonBox.add(btn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value)
|
MenuSettingBool::MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value)
|
||||||
: MenuSetting(gmenu2x,name,description)
|
: MenuSetting(gmenu2x, name, description)
|
||||||
{
|
{
|
||||||
IconButton *btn;
|
|
||||||
|
|
||||||
_value = value;
|
_value = value;
|
||||||
_ivalue = NULL;
|
_ivalue = NULL;
|
||||||
originalValue = *value;
|
originalValue = *value;
|
||||||
setValue(this->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));
|
btn->setAction(MakeDelegate(this, &MenuSettingBool::toggle));
|
||||||
buttonBox.add(btn);
|
buttonBox.add(btn);
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,14 @@ class GMenu2X;
|
|||||||
|
|
||||||
class MenuSettingBool : public MenuSetting {
|
class MenuSettingBool : public MenuSetting {
|
||||||
private:
|
private:
|
||||||
|
void initButton();
|
||||||
|
void toggle();
|
||||||
|
|
||||||
bool originalValue;
|
bool originalValue;
|
||||||
bool *_value;
|
bool *_value;
|
||||||
int *_ivalue;
|
int *_ivalue;
|
||||||
string strvalue;
|
string strvalue;
|
||||||
|
|
||||||
void toggle();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value);
|
MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, bool *value);
|
||||||
MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value);
|
MenuSettingBool(GMenu2X *gmenu2x, const string &name, const string &description, int *value);
|
||||||
|
Loading…
Reference in New Issue
Block a user