Date: | 2015-04-24 14:46:27 (8 years 1 month ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | ef6d378c5e401954308260d1fe3a53429fa66f4c |
Message: | 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. |
Files: |
src/contextmenu.cpp (1 diff) src/gmenu2x.cpp (1 diff) src/gmenu2x.h (1 diff) src/menu.cpp (1 diff) src/menu.h (1 diff) |
Change Details
src/contextmenu.cpp | ||
---|---|---|
72 | 72 | tr["Add section"], |
73 | 73 | std::bind(&GMenu2X::addSection, &gmenu2x))); |
74 | 74 | options.push_back(std::make_shared<MenuOption>( |
75 | tr["Rename section"], | |
76 | std::bind(&GMenu2X::renameSection, &gmenu2x))); | |
77 | options.push_back(std::make_shared<MenuOption>( | |
78 | 75 | tr["Delete section"], |
79 | 76 | std::bind(&GMenu2X::deleteSection, &gmenu2x))); |
80 | 77 |
src/gmenu2x.cpp | ||
---|---|---|
1020 | 1020 | } |
1021 | 1021 | } |
1022 | 1022 | |
1023 | void GMenu2X::renameSection() { | |
1024 | InputDialog id(*this, input, tr["Insert a new name for this section"],menu->selSection()); | |
1025 | if (id.exec()) { | |
1026 | //only if a section with the same name does not exist & !samename | |
1027 | if (menu->selSection() != id.getInput() | |
1028 | && find(menu->getSections().begin(),menu->getSections().end(), id.getInput()) | |
1029 | == menu->getSections().end()) { | |
1030 | //section directory doesn't exists | |
1031 | string newsectiondir = getHome() + "/sections/" + id.getInput(); | |
1032 | string sectiondir = getHome() + "/sections/" + menu->selSection(); | |
1033 | ||
1034 | if (!rename(sectiondir.c_str(), newsectiondir.c_str())) { | |
1035 | string oldpng = menu->selSection() + ".png"; | |
1036 | string newpng = id.getInput() + ".png"; | |
1037 | string oldicon = sc.getSkinFilePath(oldpng); | |
1038 | string newicon = sc.getSkinFilePath(newpng); | |
1039 | ||
1040 | if (!oldicon.empty() && newicon.empty()) { | |
1041 | newicon = oldicon; | |
1042 | newicon.replace(newicon.find(oldpng), oldpng.length(), newpng); | |
1043 | ||
1044 | if (!fileExists(newicon)) { | |
1045 | rename(oldicon.c_str(), newicon.c_str()); | |
1046 | sc.move("skin:"+oldpng, "skin:"+newpng); | |
1047 | } | |
1048 | } | |
1049 | menu->renameSection(menu->selSectionIndex(), id.getInput()); | |
1050 | } | |
1051 | } | |
1052 | } | |
1053 | } | |
1054 | ||
1055 | 1023 | void GMenu2X::deleteSection() { |
1056 | 1024 | MessageBox mb(*this,tr["You will lose all the links in this section."]+"\n"+tr["Are you sure?"]); |
1057 | 1025 | mb.setButton(InputManager::ACCEPT, tr["Yes"]); |
src/gmenu2x.h | ||
---|---|---|
199 | 199 | void editLink(); |
200 | 200 | void deleteLink(); |
201 | 201 | void addSection(); |
202 | void renameSection(); | |
203 | 202 | void deleteSection(); |
204 | 203 | |
205 | 204 | int drawButton(Surface& s, const std::string &btn, const std::string &text, int x=5, int y=-10); |
src/menu.cpp | ||
---|---|---|
820 | 820 | |
821 | 821 | closedir(dirp); |
822 | 822 | } |
823 | ||
824 | void Menu::renameSection(int index, string const& name) { | |
825 | sections[index] = name; | |
826 | } |
src/menu.h | ||
---|---|---|
160 | 160 | void setLinkIndex(int i); |
161 | 161 | |
162 | 162 | const std::vector<std::string> &getSections() { return sections; } |
163 | void renameSection(int index, std::string const& name); | |
164 | 163 | }; |
165 | 164 | |
166 | 165 | #endif // MENU_H |
Branches:
install_locations
master
opkrun
packages