Root/
| 1 | /*************************************************************************** |
| 2 | * Copyright (C) 2006 by Massimiliano Torromeo * |
| 3 | * massimiliano.torromeo@gmail.com * |
| 4 | * * |
| 5 | * This program is free software; you can redistribute it and/or modify * |
| 6 | * it under the terms of the GNU General Public License as published by * |
| 7 | * the Free Software Foundation; either version 2 of the License, or * |
| 8 | * (at your option) any later version. * |
| 9 | * * |
| 10 | * This program is distributed in the hope that it will be useful, * |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 13 | * GNU General Public License for more details. * |
| 14 | * * |
| 15 | * You should have received a copy of the GNU General Public License * |
| 16 | * along with this program; if not, write to the * |
| 17 | * Free Software Foundation, Inc., * |
| 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #include "menusettingimage.h" |
| 22 | |
| 23 | #include "gmenu2x.h" |
| 24 | #include "imagedialog.h" |
| 25 | #include "utilities.h" |
| 26 | |
| 27 | using std::string; |
| 28 | |
| 29 | MenuSettingImage::MenuSettingImage( |
| 30 | GMenu2X *gmenu2x, Touchscreen &ts, |
| 31 | const string &name, const string &description, |
| 32 | string *value, const string &filter) |
| 33 | : MenuSettingFile(gmenu2x, ts, name, description, value, filter) |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | void MenuSettingImage::edit() { |
| 38 | ImageDialog id(gmenu2x, ts, description, filter, value()); |
| 39 | if (id.exec()) setValue(id.getPath() + "/" + id.getFile()); |
| 40 | } |
| 41 | |
| 42 | void MenuSettingImage::setValue(const string &value) { |
| 43 | string skinpath(gmenu2x->sc.getSkinPath(gmenu2x->confStr["skin"])); |
| 44 | bool inSkinDir = value.substr(0, skinpath.length()) == skinpath; |
| 45 | if (!inSkinDir && gmenu2x->confStr["skin"] != "Default") { |
| 46 | skinpath = gmenu2x->sc.getSkinPath("Default"); |
| 47 | inSkinDir = value.substr(0, skinpath.length()) == skinpath; |
| 48 | } |
| 49 | if (inSkinDir) { |
| 50 | string tempIcon = value.substr(skinpath.length(), value.length()); |
| 51 | string::size_type pos = tempIcon.find("/"); |
| 52 | if (pos != string::npos) { |
| 53 | *_value = "skin:" + tempIcon.substr(pos + 1, value.length()); |
| 54 | } else { |
| 55 | *_value = value; |
| 56 | } |
| 57 | } else { |
| 58 | *_value = value; |
| 59 | } |
| 60 | } |
| 61 |
Branches:
install_locations
master
opkrun
packages
