1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-29 12:37:31 +02:00

Fixed the renameSection() and deleteSection() functions to use the new directories. The sections can now be renamed and deleted.

This commit is contained in:
Ayla 2011-04-14 12:08:10 +02:00
parent d0a24ac5ce
commit 6cb7ce1c0b

View File

@ -1648,19 +1648,22 @@ void GMenu2X::renameSection() {
&& find(menu->getSections().begin(),menu->getSections().end(), id.getInput()) && find(menu->getSections().begin(),menu->getSections().end(), id.getInput())
== menu->getSections().end()) { == menu->getSections().end()) {
//section directory doesn't exists //section directory doesn't exists
string newsectiondir = "sections/" + id.getInput(); string newsectiondir = getHome() + "/sections/" + id.getInput();
string sectiondir = "sections/" + menu->selSection(); string sectiondir = getHome() + "/sections/" + menu->selSection();
ledOn(); ledOn();
if (rename(sectiondir.c_str(), "tmpsection")==0 && rename("tmpsection", newsectiondir.c_str())==0) {
string oldpng = sectiondir+".png", newpng = newsectiondir+".png"; if (!rename(sectiondir.c_str(), newsectiondir.c_str())) {
string oldicon = sc.getSkinFilePath(oldpng), newicon = sc.getSkinFilePath(newpng); string oldpng = menu->selSection() + ".png";
string newpng = id.getInput() + ".png";
string oldicon = sc.getSkinFilePath(oldpng);
string newicon = sc.getSkinFilePath(newpng);
if (!oldicon.empty() && newicon.empty()) { if (!oldicon.empty() && newicon.empty()) {
newicon = oldicon; newicon = oldicon;
newicon.replace(newicon.find(oldpng), oldpng.length(), newpng); newicon.replace(newicon.find(oldpng), oldpng.length(), newpng);
if (!fileExists(newicon)) { if (!fileExists(newicon)) {
rename(oldicon.c_str(), "tmpsectionicon"); rename(oldicon.c_str(), newicon.c_str());
rename("tmpsectionicon", newicon.c_str());
sc.move("skin:"+oldpng, "skin:"+newpng); sc.move("skin:"+oldpng, "skin:"+newpng);
} }
} }
@ -1678,7 +1681,7 @@ void GMenu2X::deleteSection() {
mb.setButton(CLEAR, tr["No"]); mb.setButton(CLEAR, tr["No"]);
if (mb.exec() == ACCEPT) { if (mb.exec() == ACCEPT) {
ledOn(); ledOn();
if (rmtree(path+"sections/"+menu->selSection())) { if (rmtree(getHome() + "/sections/" + menu->selSection())) {
menu->deleteSelectedSection(); menu->deleteSelectedSection();
sync(); sync();
} }