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

Cleaned up Menu::loadIcons()

Most changes involve not calling the same method with the same
arguments again and again. Also use C++11 range-based loops.
This commit is contained in:
Maarten ter Huurne 2013-08-01 13:33:09 +02:00
parent a7b31669bb
commit 40372d14ef

View File

@ -115,28 +115,31 @@ void Menu::readSections(std::string parentDir)
void Menu::loadIcons() { void Menu::loadIcons() {
//reload section icons //reload section icons
for (uint i=0; i<sections.size(); i++) { vector<string>::size_type i = 0;
string sectionIcon = "sections/"+sections[i]+".png"; for (string sectionName : sections) {
string sectionIcon = "sections/" + sectionName + ".png";
if (!gmenu2x->sc.getSkinFilePath(sectionIcon).empty()) if (!gmenu2x->sc.getSkinFilePath(sectionIcon).empty())
gmenu2x->sc.add("skin:"+sectionIcon); gmenu2x->sc.add("skin:" + sectionIcon);
//check link's icons for (Link *&link : links[i]) {
string linkIcon; LinkApp *linkapp = dynamic_cast<LinkApp*>(link);
for (uint x=0; x<sectionLinks(i)->size(); x++) {
linkIcon = sectionLinks(i)->at(x)->getIcon();
LinkApp *linkapp = dynamic_cast<LinkApp*>(sectionLinks(i)->at(x));
if (linkIcon.substr(0,5)=="skin:") { //check link's icons
linkIcon = gmenu2x->sc.getSkinFilePath(linkIcon.substr(5,linkIcon.length())); string linkIcon = link->getIcon();
if (linkIcon.substr(0,5) == "skin:") {
linkIcon = gmenu2x->sc.getSkinFilePath(
linkIcon.substr(5, linkIcon.length()));
if (linkapp != NULL && !fileExists(linkIcon)) if (linkapp != NULL && !fileExists(linkIcon))
linkapp->searchIcon(); linkapp->searchIcon();
else else
sectionLinks(i)->at(x)->setIconPath(linkIcon); link->setIconPath(linkIcon);
} else if (!fileExists(linkIcon)) { } else if (!fileExists(linkIcon)) {
if (linkapp != NULL) linkapp->searchIcon(); if (linkapp != NULL) linkapp->searchIcon();
} }
} }
i++;
} }
} }