summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-08 08:14:04 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-08 08:14:04 +0000
commitcd98d01926c9a8fbc981a93546726c3d4f7d4a03 (patch)
treeb9269f7fb48b8ed2bdc16ce4918a06a26482a0df /utils
parent6358d41f31edd6487ee76232c55d5b7385426be3 (diff)
downloadrockbox-cd98d01926c9a8fbc981a93546726c3d4f7d4a03.tar.gz
rockbox-cd98d01926c9a8fbc981a93546726c3d4f7d4a03.tar.bz2
rockbox-cd98d01926c9a8fbc981a93546726c3d4f7d4a03.zip
Theme Editor: Implemented the song time (pS, pE, px, pc, etc.) in the device configuration panel, all depending on one value for current time in song and one value for length of song
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27347 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/gui/devicestate.cpp80
-rw-r--r--utils/themeeditor/gui/devicestate.h1
-rw-r--r--utils/themeeditor/resources/deviceoptions2
3 files changed, 82 insertions, 1 deletions
diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp
index 12198f5138..8802bd5e87 100644
--- a/utils/themeeditor/gui/devicestate.cpp
+++ b/utils/themeeditor/gui/devicestate.cpp
@@ -30,7 +30,9 @@
#include <QLabel>
#include <QLineEdit>
#include <QFormLayout>
+#include <QTime>
+#include <cstdlib>
DeviceState::DeviceState(QWidget *parent) :
QWidget(parent), tabs(this)
@@ -227,6 +229,47 @@ QVariant DeviceState::data(QString tag, int paramCount,
else
return QVariant();
}
+ else if(tag == "pc")
+ {
+ int secs = data("?pc").toInt();
+ return secsToString(secs);
+ }
+ else if(tag == "pr")
+ {
+ int secs = data("?pt").toInt() - data("?pc").toInt();
+ if(secs < 0)
+ secs = 0;
+ return secsToString(secs);
+ }
+ else if(tag == "pt")
+ {
+ int secs = data("?pt").toInt();
+ return secsToString(secs);
+ }
+ else if(tag == "px")
+ {
+ int totalTime = data("?pt").toInt();
+ int currentTime = data("?pc").toInt();
+ return currentTime * 100 / totalTime;
+ }
+ else if(tag == "pS")
+ {
+ double threshhold = paramCount > 0
+ ? std::atof(params[0].data.text) : 10;
+ if(data("?pc").toDouble() <= threshhold)
+ return true;
+ else
+ return false;
+ }
+ else if(tag == "pE")
+ {
+ double threshhold = paramCount > 0
+ ? std::atof(params[0].data.text) : 10;
+ if(data("?pt").toDouble() - data("?pc").toDouble() <= threshhold)
+ return true;
+ else
+ return false;
+ }
QPair<InputType, QWidget*> found =
inputs.value(tag, QPair<InputType, QWidget*>(Slide, 0));
@@ -335,3 +378,40 @@ QString DeviceState::directory(QString path, int level)
index = 0;
return dirs[index];
}
+
+QString DeviceState::secsToString(int secs)
+{
+ int hours = 0;
+ int minutes = 0;
+ while(secs >= 60)
+ {
+ minutes++;
+ secs -= 60;
+ }
+
+ while(minutes >= 60)
+ {
+ hours++;
+ minutes -= 60;
+ }
+
+ QString retval;
+
+ if(hours > 0)
+ {
+ retval += QString::number(hours);
+ if(minutes < 10)
+ retval += ":0";
+ else
+ retval += ":";
+ }
+
+ retval += QString::number(minutes);
+ if(secs < 10)
+ retval += ":0";
+ else
+ retval += ":";
+
+ retval += QString::number(secs);
+ return retval;
+}
diff --git a/utils/themeeditor/gui/devicestate.h b/utils/themeeditor/gui/devicestate.h
index ebd4afec8c..bff27ce678 100644
--- a/utils/themeeditor/gui/devicestate.h
+++ b/utils/themeeditor/gui/devicestate.h
@@ -61,6 +61,7 @@ private slots:
private:
static QString fileName(QString path, bool extension);
static QString directory(QString path, int level);
+ static QString secsToString(int secs);
QMap<QString, QPair<InputType, QWidget*> > inputs;
QTabWidget tabs;
diff --git a/utils/themeeditor/resources/deviceoptions b/utils/themeeditor/resources/deviceoptions
index 689704577f..56c7927373 100644
--- a/utils/themeeditor/resources/deviceoptions
+++ b/utils/themeeditor/resources/deviceoptions
@@ -93,7 +93,7 @@ pe ; Playlist Entries ; spin(0,1000) ; 20
pn ; Playlist Name ; text ; Current Playlist
pp ; Playlist Position ; spin(0,1000) ; 10
ps ; Shuffle ; check ; true
-pt ; Total Track Time ; spin(0,1000) ; 180
+?pt ; Total Track Time ; spin(0,1000) ; 180
Sp ; Playback Pitch ; fspin(50,200) ; 100
rp ; Song Playcount ; spin(0,10000) ; 20
rr ; Song Rating ; spin(0,10) ; 5