mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-26 12:15:21 +02:00
Converted public fields of Menu to private.
This commit is contained in:
parent
b718658bf1
commit
8a9aac028b
@ -391,14 +391,14 @@ void GMenu2X::initFont() {
|
|||||||
void GMenu2X::initMenu() {
|
void GMenu2X::initMenu() {
|
||||||
//Menu structure handler
|
//Menu structure handler
|
||||||
menu = new Menu(this);
|
menu = new Menu(this);
|
||||||
for (uint i=0; i<menu->sections.size(); i++) {
|
for (uint i=0; i<menu->getSections().size(); i++) {
|
||||||
//Add virtual links in the applications section
|
//Add virtual links in the applications section
|
||||||
if (menu->sections[i]=="applications") {
|
if (menu->getSections()[i]=="applications") {
|
||||||
menu->addActionLink(i,"Explorer",MakeDelegate(this,&GMenu2X::explorer),tr["Launch an application"],"skin:icons/explorer.png");
|
menu->addActionLink(i,"Explorer",MakeDelegate(this,&GMenu2X::explorer),tr["Launch an application"],"skin:icons/explorer.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add virtual links in the setting section
|
//Add virtual links in the setting section
|
||||||
else if (menu->sections[i]=="settings") {
|
else if (menu->getSections()[i]=="settings") {
|
||||||
menu->addActionLink(i,"GMenu2X",MakeDelegate(this,&GMenu2X::options),tr["Configure GMenu2X's options"],"skin:icons/configure.png");
|
menu->addActionLink(i,"GMenu2X",MakeDelegate(this,&GMenu2X::options),tr["Configure GMenu2X's options"],"skin:icons/configure.png");
|
||||||
if (fwType=="open2x")
|
if (fwType=="open2x")
|
||||||
menu->addActionLink(i,"Open2x",MakeDelegate(this,&GMenu2X::settingsOpen2x),tr["Configure Open2x system settings"],"skin:icons/o2xconfigure.png");
|
menu->addActionLink(i,"Open2x",MakeDelegate(this,&GMenu2X::settingsOpen2x),tr["Configure Open2x system settings"],"skin:icons/o2xconfigure.png");
|
||||||
@ -791,17 +791,17 @@ void GMenu2X::main() {
|
|||||||
sc["bgmain"]->blit(s,0,0);
|
sc["bgmain"]->blit(s,0,0);
|
||||||
|
|
||||||
//Sections
|
//Sections
|
||||||
sectionsCoordX = halfX - (constrain((uint)menu->sections.size(), 0 , linkColumns) * skinConfInt["linkWidth"]) / 2;
|
sectionsCoordX = halfX - (constrain((uint)menu->getSections().size(), 0 , linkColumns) * skinConfInt["linkWidth"]) / 2;
|
||||||
if (menu->firstDispSection()>0)
|
if (menu->firstDispSection()>0)
|
||||||
sc.skinRes("imgs/l_enabled.png")->blit(s,0,0);
|
sc.skinRes("imgs/l_enabled.png")->blit(s,0,0);
|
||||||
else
|
else
|
||||||
sc.skinRes("imgs/l_disabled.png")->blit(s,0,0);
|
sc.skinRes("imgs/l_disabled.png")->blit(s,0,0);
|
||||||
if (menu->firstDispSection()+linkColumns<menu->sections.size())
|
if (menu->firstDispSection()+linkColumns<menu->getSections().size())
|
||||||
sc.skinRes("imgs/r_enabled.png")->blit(s,resX-10,0);
|
sc.skinRes("imgs/r_enabled.png")->blit(s,resX-10,0);
|
||||||
else
|
else
|
||||||
sc.skinRes("imgs/r_disabled.png")->blit(s,resX-10,0);
|
sc.skinRes("imgs/r_disabled.png")->blit(s,resX-10,0);
|
||||||
for (i=menu->firstDispSection(); i<menu->sections.size() && i<menu->firstDispSection()+linkColumns; i++) {
|
for (i=menu->firstDispSection(); i<menu->getSections().size() && i<menu->firstDispSection()+linkColumns; i++) {
|
||||||
string sectionIcon = "skin:sections/"+menu->sections[i]+".png";
|
string sectionIcon = "skin:sections/"+menu->getSections()[i]+".png";
|
||||||
x = (i-menu->firstDispSection())*skinConfInt["linkWidth"]+sectionsCoordX;
|
x = (i-menu->firstDispSection())*skinConfInt["linkWidth"]+sectionsCoordX;
|
||||||
if (menu->selSectionIndex()==(int)i)
|
if (menu->selSectionIndex()==(int)i)
|
||||||
s->box(x, 0, skinConfInt["linkWidth"],
|
s->box(x, 0, skinConfInt["linkWidth"],
|
||||||
@ -811,7 +811,7 @@ void GMenu2X::main() {
|
|||||||
sc[sectionIcon]->blit(s,x-16,sectionLinkPadding,32,32);
|
sc[sectionIcon]->blit(s,x-16,sectionLinkPadding,32,32);
|
||||||
else
|
else
|
||||||
sc.skinRes("icons/section.png")->blit(s,x-16,sectionLinkPadding);
|
sc.skinRes("icons/section.png")->blit(s,x-16,sectionLinkPadding);
|
||||||
s->write( font, menu->sections[i], x, skinConfInt["topBarHeight"]-sectionLinkPadding, SFontHAlignCenter, SFontVAlignBottom );
|
s->write( font, menu->getSections()[i], x, skinConfInt["topBarHeight"]-sectionLinkPadding, SFontHAlignCenter, SFontVAlignBottom );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Links
|
//Links
|
||||||
@ -909,8 +909,8 @@ void GMenu2X::main() {
|
|||||||
re.x = 0; re.y = 0; re.h = skinConfInt["topBarHeight"]; re.w = resX;
|
re.x = 0; re.y = 0; re.h = skinConfInt["topBarHeight"]; re.w = resX;
|
||||||
if (ts.pressed() && ts.inRect(re)) {
|
if (ts.pressed() && ts.inRect(re)) {
|
||||||
re.w = skinConfInt["linkWidth"];
|
re.w = skinConfInt["linkWidth"];
|
||||||
sectionsCoordX = halfX - (constrain((uint)menu->sections.size(), 0 , linkColumns) * skinConfInt["linkWidth"]) / 2;
|
sectionsCoordX = halfX - (constrain((uint)menu->getSections().size(), 0 , linkColumns) * skinConfInt["linkWidth"]) / 2;
|
||||||
for (i=menu->firstDispSection(); !ts.handled() && i<menu->sections.size() && i<menu->firstDispSection()+linkColumns; i++) {
|
for (i=menu->firstDispSection(); !ts.handled() && i<menu->getSections().size() && i<menu->firstDispSection()+linkColumns; i++) {
|
||||||
re.x = (i-menu->firstDispSection())*re.w+sectionsCoordX;
|
re.x = (i-menu->firstDispSection())*re.w+sectionsCoordX;
|
||||||
|
|
||||||
if (ts.inRect(re)) {
|
if (ts.inRect(re)) {
|
||||||
@ -1433,7 +1433,7 @@ void GMenu2X::editLink() {
|
|||||||
SettingsDialog sd(this,diagTitle,diagIcon);
|
SettingsDialog sd(this,diagTitle,diagIcon);
|
||||||
sd.addSetting(new MenuSettingString(this,tr["Title"],tr["Link title"],&linkTitle, diagTitle,diagIcon));
|
sd.addSetting(new MenuSettingString(this,tr["Title"],tr["Link title"],&linkTitle, diagTitle,diagIcon));
|
||||||
sd.addSetting(new MenuSettingString(this,tr["Description"],tr["Link description"],&linkDescription, diagTitle,diagIcon));
|
sd.addSetting(new MenuSettingString(this,tr["Description"],tr["Link description"],&linkDescription, diagTitle,diagIcon));
|
||||||
sd.addSetting(new MenuSettingMultiString(this,tr["Section"],tr["The section this link belongs to"],&newSection,&menu->sections));
|
sd.addSetting(new MenuSettingMultiString(this,tr["Section"],tr["The section this link belongs to"],&newSection,&menu->getSections()));
|
||||||
sd.addSetting(new MenuSettingImage(this,tr["Icon"],tr.translate("Select an icon for the link: $1",linkTitle.c_str(),NULL),&linkIcon,".png,.bmp,.jpg,.jpeg"));
|
sd.addSetting(new MenuSettingImage(this,tr["Icon"],tr.translate("Select an icon for the link: $1",linkTitle.c_str(),NULL),&linkIcon,".png,.bmp,.jpg,.jpeg"));
|
||||||
sd.addSetting(new MenuSettingFile(this,tr["Manual"],tr["Select a graphic/textual manual or a readme"],&linkManual,".man.png,.txt"));
|
sd.addSetting(new MenuSettingFile(this,tr["Manual"],tr["Select a graphic/textual manual or a readme"],&linkManual,".man.png,.txt"));
|
||||||
sd.addSetting(new MenuSettingInt(this,tr["Clock (default: 336)"],tr["Cpu clock frequency to set when launching this link"],&linkClock,200,confInt["maxClock"]));
|
sd.addSetting(new MenuSettingInt(this,tr["Clock (default: 336)"],tr["Cpu clock frequency to set when launching this link"],&linkClock,200,confInt["maxClock"]));
|
||||||
@ -1474,8 +1474,8 @@ void GMenu2X::editLink() {
|
|||||||
#endif
|
#endif
|
||||||
//if section changed move file and update link->file
|
//if section changed move file and update link->file
|
||||||
if (oldSection!=newSection) {
|
if (oldSection!=newSection) {
|
||||||
vector<string>::iterator newSectionIndex = find(menu->sections.begin(),menu->sections.end(),newSection);
|
vector<string>::const_iterator newSectionIndex = find(menu->getSections().begin(),menu->getSections().end(),newSection);
|
||||||
if (newSectionIndex==menu->sections.end()) return;
|
if (newSectionIndex==menu->getSections().end()) return;
|
||||||
string newFileName = "sections/"+newSection+"/"+linkTitle;
|
string newFileName = "sections/"+newSection+"/"+linkTitle;
|
||||||
uint x=2;
|
uint x=2;
|
||||||
while (fileExists(newFileName)) {
|
while (fileExists(newFileName)) {
|
||||||
@ -1487,9 +1487,9 @@ void GMenu2X::editLink() {
|
|||||||
rename(menu->selLinkApp()->file.c_str(),newFileName.c_str());
|
rename(menu->selLinkApp()->file.c_str(),newFileName.c_str());
|
||||||
menu->selLinkApp()->file = newFileName;
|
menu->selLinkApp()->file = newFileName;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
cout << "New section index: " << newSectionIndex - menu->sections.begin() << endl;
|
cout << "New section index: " << newSectionIndex - menu->getSections().begin() << endl;
|
||||||
#endif
|
#endif
|
||||||
menu->linkChangeSection(menu->selLinkIndex(), menu->selSectionIndex(), newSectionIndex - menu->sections.begin());
|
menu->linkChangeSection(menu->selLinkIndex(), menu->selSectionIndex(), newSectionIndex - menu->getSections().begin());
|
||||||
}
|
}
|
||||||
menu->selLinkApp()->save();
|
menu->selLinkApp()->save();
|
||||||
sync();
|
sync();
|
||||||
@ -1516,12 +1516,12 @@ void GMenu2X::addSection() {
|
|||||||
InputDialog id(this,tr["Insert a name for the new section"]);
|
InputDialog id(this,tr["Insert a name for the new section"]);
|
||||||
if (id.exec()) {
|
if (id.exec()) {
|
||||||
//only if a section with the same name does not exist
|
//only if a section with the same name does not exist
|
||||||
if (find(menu->sections.begin(), menu->sections.end(), id.getInput())
|
if (find(menu->getSections().begin(), menu->getSections().end(), id.getInput())
|
||||||
== menu->sections.end()) {
|
== menu->getSections().end()) {
|
||||||
//section directory doesn't exists
|
//section directory doesn't exists
|
||||||
ledOn();
|
ledOn();
|
||||||
if (menu->addSection(id.getInput())) {
|
if (menu->addSection(id.getInput())) {
|
||||||
menu->setSectionIndex( menu->sections.size()-1 ); //switch to the new section
|
menu->setSectionIndex( menu->getSections().size()-1 ); //switch to the new section
|
||||||
sync();
|
sync();
|
||||||
}
|
}
|
||||||
ledOff();
|
ledOff();
|
||||||
@ -1534,8 +1534,8 @@ void GMenu2X::renameSection() {
|
|||||||
if (id.exec()) {
|
if (id.exec()) {
|
||||||
//only if a section with the same name does not exist & !samename
|
//only if a section with the same name does not exist & !samename
|
||||||
if (menu->selSection() != id.getInput()
|
if (menu->selSection() != id.getInput()
|
||||||
&& find(menu->sections.begin(),menu->sections.end(), id.getInput())
|
&& find(menu->getSections().begin(),menu->getSections().end(), id.getInput())
|
||||||
== menu->sections.end()) {
|
== menu->getSections().end()) {
|
||||||
//section directory doesn't exists
|
//section directory doesn't exists
|
||||||
string newsectiondir = "sections/" + id.getInput();
|
string newsectiondir = "sections/" + id.getInput();
|
||||||
string sectiondir = "sections/" + menu->selSection();
|
string sectiondir = "sections/" + menu->selSection();
|
||||||
@ -1553,7 +1553,7 @@ void GMenu2X::renameSection() {
|
|||||||
sc.move("skin:"+oldpng, "skin:"+newpng);
|
sc.move("skin:"+oldpng, "skin:"+newpng);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
menu->sections[menu->selSectionIndex()] = id.getInput();
|
menu->renameSection(menu->selSectionIndex(), id.getInput());
|
||||||
sync();
|
sync();
|
||||||
}
|
}
|
||||||
ledOff();
|
ledOff();
|
||||||
|
@ -436,3 +436,7 @@ void Menu::readLinks() {
|
|||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Menu::renameSection(int index, const string &name) {
|
||||||
|
sections[index] = name;
|
||||||
|
}
|
||||||
|
@ -42,6 +42,9 @@ private:
|
|||||||
GMenu2X *gmenu2x;
|
GMenu2X *gmenu2x;
|
||||||
int iSection, iLink;
|
int iSection, iLink;
|
||||||
uint iFirstDispSection, iFirstDispRow;
|
uint iFirstDispSection, iFirstDispRow;
|
||||||
|
vector<string> sections;
|
||||||
|
vector<linklist> links;
|
||||||
|
|
||||||
void readLinks();
|
void readLinks();
|
||||||
void freeLinks();
|
void freeLinks();
|
||||||
|
|
||||||
@ -49,8 +52,6 @@ public:
|
|||||||
Menu(GMenu2X *gmenu2x);
|
Menu(GMenu2X *gmenu2x);
|
||||||
~Menu();
|
~Menu();
|
||||||
|
|
||||||
vector<string> sections;
|
|
||||||
vector<linklist> links;
|
|
||||||
linklist *sectionLinks(int i = -1);
|
linklist *sectionLinks(int i = -1);
|
||||||
|
|
||||||
int selSectionIndex();
|
int selSectionIndex();
|
||||||
@ -80,6 +81,9 @@ public:
|
|||||||
void setLinkIndex(int i);
|
void setLinkIndex(int i);
|
||||||
|
|
||||||
string sectionPath(int section = -1);
|
string sectionPath(int section = -1);
|
||||||
|
|
||||||
|
const vector<string> &getSections() { return sections; }
|
||||||
|
void renameSection(int index, const string &name);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fastdelegate;
|
using namespace fastdelegate;
|
||||||
|
|
||||||
MenuSettingMultiString::MenuSettingMultiString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, vector<string> *choices)
|
MenuSettingMultiString::MenuSettingMultiString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const vector<string> *choices)
|
||||||
: MenuSetting(gmenu2x,name,description)
|
: MenuSetting(gmenu2x,name,description)
|
||||||
{
|
{
|
||||||
IconButton *btn;
|
IconButton *btn;
|
||||||
|
@ -30,7 +30,7 @@ private:
|
|||||||
uint selected;
|
uint selected;
|
||||||
string *value;
|
string *value;
|
||||||
string originalValue;
|
string originalValue;
|
||||||
vector<string> *choices;
|
const vector<string> *choices;
|
||||||
IconButton *btnDec, *btnInc;
|
IconButton *btnDec, *btnInc;
|
||||||
|
|
||||||
void incSel();
|
void incSel();
|
||||||
@ -38,7 +38,7 @@ private:
|
|||||||
void setSel(int);
|
void setSel(int);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MenuSettingMultiString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, vector<string> *choices);
|
MenuSettingMultiString(GMenu2X *gmenu2x, const string &name, const string &description, string *value, const vector<string> *choices);
|
||||||
virtual ~MenuSettingMultiString() {};
|
virtual ~MenuSettingMultiString() {};
|
||||||
|
|
||||||
virtual void draw(int y);
|
virtual void draw(int y);
|
||||||
|
Loading…
Reference in New Issue
Block a user