mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2025-02-17 02:54:42 +02:00
Removed duplicate code between MenuSettingFile and its MenuSettingImage subclass.
Also performed some cosmetic fixes.
This commit is contained in:
parent
ac30153cfc
commit
9d05af2881
@ -24,15 +24,14 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fastdelegate;
|
using namespace fastdelegate;
|
||||||
|
|
||||||
MenuSettingFile::MenuSettingFile(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter)
|
MenuSettingFile::MenuSettingFile(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter_)
|
||||||
: MenuSetting(gmenu2x,name,description)
|
: MenuSetting(gmenu2x, name, description)
|
||||||
|
, originalValue(*value)
|
||||||
|
, _value(value)
|
||||||
|
, filter(filter_)
|
||||||
{
|
{
|
||||||
IconButton *btn;
|
IconButton *btn;
|
||||||
|
|
||||||
this->filter = filter;
|
|
||||||
_value = value;
|
|
||||||
originalValue = *value;
|
|
||||||
|
|
||||||
btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Clear"]);
|
btn = new IconButton(gmenu2x, "skin:imgs/buttons/x.png", gmenu2x->tr["Clear"]);
|
||||||
btn->setAction(MakeDelegate(this, &MenuSettingFile::clear));
|
btn->setAction(MakeDelegate(this, &MenuSettingFile::clear));
|
||||||
buttonBox.add(btn);
|
buttonBox.add(btn);
|
||||||
@ -50,10 +49,8 @@ void MenuSettingFile::draw(int y)
|
|||||||
|
|
||||||
void MenuSettingFile::manageInput()
|
void MenuSettingFile::manageInput()
|
||||||
{
|
{
|
||||||
if (gmenu2x->input[ACTION_X])
|
if (gmenu2x->input[ACTION_X]) clear();
|
||||||
setValue("");
|
if (gmenu2x->input[ACTION_B]) select();
|
||||||
if (gmenu2x->input[ACTION_B])
|
|
||||||
select();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingFile::clear()
|
void MenuSettingFile::clear()
|
||||||
@ -64,8 +61,9 @@ void MenuSettingFile::clear()
|
|||||||
void MenuSettingFile::select()
|
void MenuSettingFile::select()
|
||||||
{
|
{
|
||||||
FileDialog fd(gmenu2x, description, filter, value());
|
FileDialog fd(gmenu2x, description, filter, value());
|
||||||
if (fd.exec())
|
if (fd.exec()) {
|
||||||
setValue(fd.getPath()+"/"+fd.getFile());
|
setValue(fd.getPath() + "/" + fd.getFile());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingFile::setValue(const string &value)
|
void MenuSettingFile::setValue(const string &value)
|
||||||
|
@ -31,12 +31,14 @@ protected:
|
|||||||
string *_value;
|
string *_value;
|
||||||
string filter;
|
string filter;
|
||||||
|
|
||||||
void select();
|
virtual void select();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingFile(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter="");
|
MenuSettingFile(GMenu2X *gmenu2x, const string &name,
|
||||||
virtual ~MenuSettingFile() {};
|
const string &description, string *value,
|
||||||
|
const string &filter = "");
|
||||||
|
virtual ~MenuSettingFile() {}
|
||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
virtual void manageInput();
|
virtual void manageInput();
|
||||||
|
@ -24,34 +24,30 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
MenuSettingImage::MenuSettingImage(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter)
|
MenuSettingImage::MenuSettingImage(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter)
|
||||||
: MenuSettingFile(gmenu2x,name,description,value,filter) {
|
: MenuSettingFile(gmenu2x, name, description, value, filter)
|
||||||
this->filter = filter;
|
{
|
||||||
_value = value;
|
|
||||||
originalValue = *value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingImage::manageInput() {
|
void MenuSettingImage::select() {
|
||||||
if ( gmenu2x->input[ACTION_X] ) setValue("");
|
|
||||||
if ( gmenu2x->input[ACTION_B] ) {
|
|
||||||
ImageDialog id(gmenu2x, description, filter, value());
|
ImageDialog id(gmenu2x, description, filter, value());
|
||||||
if (id.exec()) setValue( id.getPath()+"/"+id.getFile() );
|
if (id.exec()) setValue(id.getPath() + "/" + id.getFile());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuSettingImage::setValue(const string &value) {
|
void MenuSettingImage::setValue(const string &value) {
|
||||||
string skinpath = gmenu2x->getExePath()+"skins/"+gmenu2x->confStr["skin"];
|
string skinpath(gmenu2x->getExePath() + "skins/" + gmenu2x->confStr["skin"]);
|
||||||
bool inSkinDir = value.substr(0,skinpath.length()) == skinpath;
|
bool inSkinDir = value.substr(0, skinpath.length()) == skinpath;
|
||||||
if (!inSkinDir && gmenu2x->confStr["skin"] != "Default") {
|
if (!inSkinDir && gmenu2x->confStr["skin"] != "Default") {
|
||||||
skinpath = gmenu2x->getExePath()+"skins/Default";
|
skinpath = gmenu2x->getExePath() + "skins/Default";
|
||||||
inSkinDir = value.substr(0,skinpath.length()) == skinpath;
|
inSkinDir = value.substr(0, skinpath.length()) == skinpath;
|
||||||
}
|
}
|
||||||
if (inSkinDir) {
|
if (inSkinDir) {
|
||||||
string tempIcon = value.substr(skinpath.length(), value.length());
|
string tempIcon = value.substr(skinpath.length(), value.length());
|
||||||
string::size_type pos = tempIcon.find("/");
|
string::size_type pos = tempIcon.find("/");
|
||||||
if (pos != string::npos)
|
if (pos != string::npos) {
|
||||||
*_value = "skin:"+tempIcon.substr(pos+1,value.length());
|
*_value = "skin:" + tempIcon.substr(pos + 1, value.length());
|
||||||
else
|
} else {
|
||||||
*_value = value;
|
*_value = value;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
*_value = value;
|
*_value = value;
|
||||||
}
|
}
|
||||||
|
@ -20,17 +20,20 @@
|
|||||||
#ifndef MENUSETTINGIMAGE_H
|
#ifndef MENUSETTINGIMAGE_H
|
||||||
#define MENUSETTINGIMAGE_H
|
#define MENUSETTINGIMAGE_H
|
||||||
|
|
||||||
#include "gmenu2x.h"
|
|
||||||
#include "menusettingfile.h"
|
#include "menusettingfile.h"
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
class MenuSettingImage : public MenuSettingFile {
|
class MenuSettingImage : public MenuSettingFile {
|
||||||
public:
|
protected:
|
||||||
MenuSettingImage(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const string &filter="");
|
virtual void select();
|
||||||
virtual ~MenuSettingImage() {};
|
|
||||||
|
public:
|
||||||
|
MenuSettingImage(GMenu2X *gmenu2x, const string &name,
|
||||||
|
const string &description, string *value,
|
||||||
|
const string &filter = "");
|
||||||
|
virtual ~MenuSettingImage() {}
|
||||||
|
|
||||||
virtual void manageInput();
|
|
||||||
virtual void setValue(const string &value);
|
virtual void setValue(const string &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user