2010-02-04 13:33:47 +02:00
|
|
|
/***************************************************************************
|
2011-10-23 17:13:02 +03:00
|
|
|
* Copyright (C) 2006 by Massimiliano Torromeo *
|
|
|
|
* massimiliano.torromeo@gmail.com *
|
2010-02-04 13:33:47 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the *
|
|
|
|
* Free Software Foundation, Inc., *
|
|
|
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
|
|
|
***************************************************************************/
|
2011-10-23 17:13:02 +03:00
|
|
|
|
2010-02-04 13:33:47 +02:00
|
|
|
#include "menusettingimage.h"
|
2011-10-23 17:13:02 +03:00
|
|
|
|
|
|
|
#include "gmenu2x.h"
|
2010-02-04 13:33:47 +02:00
|
|
|
#include "imagedialog.h"
|
|
|
|
#include "utilities.h"
|
|
|
|
|
2010-07-28 03:36:46 +03:00
|
|
|
using std::string;
|
2010-02-04 13:33:47 +02:00
|
|
|
|
2011-12-23 15:03:05 +02:00
|
|
|
MenuSettingImage::MenuSettingImage(
|
|
|
|
GMenu2X *gmenu2x, Touchscreen &ts,
|
|
|
|
const string &name, const string &description,
|
|
|
|
string *value, const string &filter)
|
|
|
|
: MenuSettingFile(gmenu2x, ts, name, description, value, filter)
|
2010-07-28 01:54:00 +03:00
|
|
|
{
|
2010-02-04 13:33:47 +02:00
|
|
|
}
|
|
|
|
|
2010-07-28 02:46:32 +03:00
|
|
|
void MenuSettingImage::edit() {
|
2011-12-23 15:03:05 +02:00
|
|
|
ImageDialog id(gmenu2x, ts, description, filter, value());
|
2010-07-28 01:54:00 +03:00
|
|
|
if (id.exec()) setValue(id.getPath() + "/" + id.getFile());
|
2010-02-04 13:33:47 +02:00
|
|
|
}
|
|
|
|
|
2010-05-02 15:29:09 +03:00
|
|
|
void MenuSettingImage::setValue(const string &value) {
|
2012-06-25 00:18:02 +03:00
|
|
|
string skinpath(gmenu2x->sc.getSkinPath(gmenu2x->confStr["skin"]));
|
2010-07-28 01:54:00 +03:00
|
|
|
bool inSkinDir = value.substr(0, skinpath.length()) == skinpath;
|
2010-02-04 13:33:47 +02:00
|
|
|
if (!inSkinDir && gmenu2x->confStr["skin"] != "Default") {
|
2012-06-25 00:18:02 +03:00
|
|
|
skinpath = gmenu2x->sc.getSkinPath("Default");
|
2010-07-28 01:54:00 +03:00
|
|
|
inSkinDir = value.substr(0, skinpath.length()) == skinpath;
|
2010-02-04 13:33:47 +02:00
|
|
|
}
|
|
|
|
if (inSkinDir) {
|
|
|
|
string tempIcon = value.substr(skinpath.length(), value.length());
|
|
|
|
string::size_type pos = tempIcon.find("/");
|
2010-07-28 01:54:00 +03:00
|
|
|
if (pos != string::npos) {
|
|
|
|
*_value = "skin:" + tempIcon.substr(pos + 1, value.length());
|
|
|
|
} else {
|
2010-05-02 15:29:09 +03:00
|
|
|
*_value = value;
|
2010-07-28 01:54:00 +03:00
|
|
|
}
|
2010-05-02 15:29:09 +03:00
|
|
|
} else {
|
|
|
|
*_value = value;
|
2010-02-04 13:33:47 +02:00
|
|
|
}
|
|
|
|
}
|