mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-25 17:58:27 +02:00
Removed the "Rename section" option
This option is not compatible with section names being provided by other sources than user-created links. Examples of other sources are built-in action links, links installed by a distro in a read-only directory and metadata from OPK files.
This commit is contained in:
parent
2a2634b364
commit
ef6d378c5e
@ -71,9 +71,6 @@ ContextMenu::ContextMenu(GMenu2X &gmenu2x, Menu &menu)
|
|||||||
options.push_back(std::make_shared<MenuOption>(
|
options.push_back(std::make_shared<MenuOption>(
|
||||||
tr["Add section"],
|
tr["Add section"],
|
||||||
std::bind(&GMenu2X::addSection, &gmenu2x)));
|
std::bind(&GMenu2X::addSection, &gmenu2x)));
|
||||||
options.push_back(std::make_shared<MenuOption>(
|
|
||||||
tr["Rename section"],
|
|
||||||
std::bind(&GMenu2X::renameSection, &gmenu2x)));
|
|
||||||
options.push_back(std::make_shared<MenuOption>(
|
options.push_back(std::make_shared<MenuOption>(
|
||||||
tr["Delete section"],
|
tr["Delete section"],
|
||||||
std::bind(&GMenu2X::deleteSection, &gmenu2x)));
|
std::bind(&GMenu2X::deleteSection, &gmenu2x)));
|
||||||
|
@ -1020,38 +1020,6 @@ void GMenu2X::addSection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::renameSection() {
|
|
||||||
InputDialog id(*this, input, tr["Insert a new name for this section"],menu->selSection());
|
|
||||||
if (id.exec()) {
|
|
||||||
//only if a section with the same name does not exist & !samename
|
|
||||||
if (menu->selSection() != id.getInput()
|
|
||||||
&& find(menu->getSections().begin(),menu->getSections().end(), id.getInput())
|
|
||||||
== menu->getSections().end()) {
|
|
||||||
//section directory doesn't exists
|
|
||||||
string newsectiondir = getHome() + "/sections/" + id.getInput();
|
|
||||||
string sectiondir = getHome() + "/sections/" + menu->selSection();
|
|
||||||
|
|
||||||
if (!rename(sectiondir.c_str(), newsectiondir.c_str())) {
|
|
||||||
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()) {
|
|
||||||
newicon = oldicon;
|
|
||||||
newicon.replace(newicon.find(oldpng), oldpng.length(), newpng);
|
|
||||||
|
|
||||||
if (!fileExists(newicon)) {
|
|
||||||
rename(oldicon.c_str(), newicon.c_str());
|
|
||||||
sc.move("skin:"+oldpng, "skin:"+newpng);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
menu->renameSection(menu->selSectionIndex(), id.getInput());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void GMenu2X::deleteSection() {
|
void GMenu2X::deleteSection() {
|
||||||
MessageBox mb(*this,tr["You will lose all the links in this section."]+"\n"+tr["Are you sure?"]);
|
MessageBox mb(*this,tr["You will lose all the links in this section."]+"\n"+tr["Are you sure?"]);
|
||||||
mb.setButton(InputManager::ACCEPT, tr["Yes"]);
|
mb.setButton(InputManager::ACCEPT, tr["Yes"]);
|
||||||
|
@ -199,7 +199,6 @@ public:
|
|||||||
void editLink();
|
void editLink();
|
||||||
void deleteLink();
|
void deleteLink();
|
||||||
void addSection();
|
void addSection();
|
||||||
void renameSection();
|
|
||||||
void deleteSection();
|
void deleteSection();
|
||||||
|
|
||||||
int drawButton(Surface& s, const std::string &btn, const std::string &text, int x=5, int y=-10);
|
int drawButton(Surface& s, const std::string &btn, const std::string &text, int x=5, int y=-10);
|
||||||
|
@ -820,7 +820,3 @@ void Menu::readLinksOfSection(
|
|||||||
|
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::renameSection(int index, string const& name) {
|
|
||||||
sections[index] = name;
|
|
||||||
}
|
|
||||||
|
@ -160,7 +160,6 @@ public:
|
|||||||
void setLinkIndex(int i);
|
void setLinkIndex(int i);
|
||||||
|
|
||||||
const std::vector<std::string> &getSections() { return sections; }
|
const std::vector<std::string> &getSections() { return sections; }
|
||||||
void renameSection(int index, std::string const& name);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_H
|
#endif // MENU_H
|
||||||
|
Loading…
Reference in New Issue
Block a user