summaryrefslogtreecommitdiff
path: root/utils/themeeditor/gui/devicestate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/gui/devicestate.cpp')
-rw-r--r--utils/themeeditor/gui/devicestate.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp
index d87cd70f2c..12198f5138 100644
--- a/utils/themeeditor/gui/devicestate.cpp
+++ b/utils/themeeditor/gui/devicestate.cpp
@@ -198,6 +198,36 @@ DeviceState::~DeviceState()
198QVariant DeviceState::data(QString tag, int paramCount, 198QVariant DeviceState::data(QString tag, int paramCount,
199 skin_tag_parameter *params) 199 skin_tag_parameter *params)
200{ 200{
201 /* Handling special cases */
202 if(tag.toLower() == "fm")
203 {
204 QString path = tag[0].isLower()
205 ? data("file").toString() : data("nextfile").toString();
206 return fileName(path, true);
207 }
208 else if(tag.toLower() == "fn")
209 {
210 QString path = tag[0].isLower()
211 ? data("file").toString() : data("nextfile").toString();
212 return fileName(path, false);
213 }
214 else if(tag.toLower() == "fp")
215 {
216 if(tag[0].isLower())
217 return data("file").toString();
218 else
219 return data("nextfile").toString();
220 }
221 else if(tag.toLower() == "d")
222 {
223 QString path = tag[0].isLower()
224 ? data("file").toString() : data("nextfile").toString();
225 if(paramCount > 0)
226 return directory(path, params[0].data.numeric);
227 else
228 return QVariant();
229 }
230
201 QPair<InputType, QWidget*> found = 231 QPair<InputType, QWidget*> found =
202 inputs.value(tag, QPair<InputType, QWidget*>(Slide, 0)); 232 inputs.value(tag, QPair<InputType, QWidget*>(Slide, 0));
203 233
@@ -279,3 +309,29 @@ void DeviceState::input()
279{ 309{
280 emit settingsChanged(); 310 emit settingsChanged();
281} 311}
312
313QString DeviceState::fileName(QString path, bool extension)
314{
315 path = path.split("/").last();
316 if(!extension)
317 {
318 QString sum;
319 QStringList name = path.split(".");
320 for(int i = 0; i < name.count() - 1; i++)
321 sum.append(name[i]);
322 return sum;
323 }
324 else
325 {
326 return path;
327 }
328}
329
330QString DeviceState::directory(QString path, int level)
331{
332 QStringList dirs = path.split("/");
333 int index = dirs.count() - 1 - level;
334 if(index < 0)
335 index = 0;
336 return dirs[index];
337}