mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-22 12:24:38 +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;
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user