summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-07-09 02:11:34 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-07-09 02:11:34 +0000
commitb99066440f841e6d46816f7dda3cfdcf9a5b6ffb (patch)
tree2744af08857369df3537f782ff05dfa2bceccc06 /utils
parent73a3747bc1b33200207768b101bf56083416d756 (diff)
downloadrockbox-b99066440f841e6d46816f7dda3cfdcf9a5b6ffb.tar.gz
rockbox-b99066440f841e6d46816f7dda3cfdcf9a5b6ffb.tar.bz2
rockbox-b99066440f841e6d46816f7dda3cfdcf9a5b6ffb.zip
Theme Editor: Implemented timer panel functionality, added missing seconds field to device control panel
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27354 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/gui/devicestate.cpp8
-rw-r--r--utils/themeeditor/gui/skintimer.cpp123
-rw-r--r--utils/themeeditor/gui/skintimer.h5
-rw-r--r--utils/themeeditor/gui/skintimer.ui14
-rw-r--r--utils/themeeditor/resources/deviceoptions1
5 files changed, 146 insertions, 5 deletions
diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp
index 63d80342c1..21f95bfa10 100644
--- a/utils/themeeditor/gui/devicestate.cpp
+++ b/utils/themeeditor/gui/devicestate.cpp
@@ -402,6 +402,14 @@ QVariant DeviceState::data(QString tag, int paramCount,
{
return data("?cw");
}
+ else if(tag == "cs")
+ {
+ int seconds = data("seconds").toInt();
+ if(seconds < 10)
+ return "0" + QString::number(seconds);
+ else
+ return seconds;
+ }
QPair<InputType, QWidget*> found =
inputs.value(tag, QPair<InputType, QWidget*>(Slide, 0));
diff --git a/utils/themeeditor/gui/skintimer.cpp b/utils/themeeditor/gui/skintimer.cpp
index f228a2f097..d4b191e25d 100644
--- a/utils/themeeditor/gui/skintimer.cpp
+++ b/utils/themeeditor/gui/skintimer.cpp
@@ -22,7 +22,7 @@
#include "skintimer.h"
#include "ui_skintimer.h"
-const int SkinTimer::millisPerTick = 10;
+const int SkinTimer::millisPerTick = 250;
SkinTimer::SkinTimer(DeviceState* device, QWidget *parent) :
QWidget(parent),
@@ -30,6 +30,7 @@ SkinTimer::SkinTimer(DeviceState* device, QWidget *parent) :
device(device)
{
ui->setupUi(this);
+ setupUI();
}
SkinTimer::~SkinTimer()
@@ -37,22 +38,142 @@ SkinTimer::~SkinTimer()
delete ui;
}
+void SkinTimer::setupUI()
+{
+ playStateButtons.append(ui->playButton);
+ playStateButtons.append(ui->pauseButton);
+ playStateButtons.append(ui->rwndButton);
+ playStateButtons.append(ui->ffwdButton);
+
+ QObject::connect(ui->startButton, SIGNAL(clicked()),
+ this, SLOT(start()));
+ QObject::connect(ui->stopButton, SIGNAL(clicked()),
+ this, SLOT(stop()));
+ QObject::connect(&timer, SIGNAL(timeout()),
+ this, SLOT(tick()));
+ for(int i = 0; i < playStateButtons.count(); i++)
+ QObject::connect(playStateButtons[i], SIGNAL(toggled(bool)),
+ this, SLOT(stateChange()));
+ QObject::connect(device, SIGNAL(settingsChanged()),
+ this, SLOT(deviceChange()));
+
+ int playState = device->data("?mp").toInt();
+ switch(playState)
+ {
+ default:
+ case 1:
+ ui->playButton->setChecked(true);
+ break;
+ case 2:
+ ui->pauseButton->setChecked(true);
+ break;
+ case 3:
+ ui->ffwdButton->setChecked(true);
+ break;
+ case 4:
+ ui->rwndButton->setChecked(true);
+ break;
+ }
+}
+
void SkinTimer::start()
{
+ ui->startButton->setEnabled(false);
+ ui->stopButton->setEnabled(true);
+ ui->speedBox->setEnabled(false);
+ ui->durationBox->setEnabled(false);
+
+ totalTime = ui->durationBox->value() * 1000;
+ elapsedTime = 0;
+ timer.setInterval(millisPerTick);
+ ui->statusBar->setValue(0);
+ timer.start();
}
void SkinTimer::stop()
{
+ ui->startButton->setEnabled(true);
+ ui->stopButton->setEnabled(false);
+ ui->speedBox->setEnabled(true);
+ ui->durationBox->setEnabled(true);
+ timer.stop();
}
void SkinTimer::tick()
{
+ elapsedTime += millisPerTick * ui->speedBox->value();
+ if(elapsedTime >= totalTime)
+ {
+ ui->statusBar->setValue(100);
+ stop();
+ }
+
+ /* Calculating the simulated time elapsed */
+ double dTime = millisPerTick * ui->speedBox->value() / 1000;
+
+ /* Adding to the device's simtime */
+ device->setData("simtime", device->data("simtime").toDouble() + dTime);
+
+ /* Adding to the song time depending on mode*/
+ double songTime = device->data("?pc").toDouble();
+ double trackTime = device->data("?pt").toDouble();
+ if(ui->playButton->isChecked())
+ songTime += dTime;
+ else if(ui->rwndButton->isChecked())
+ songTime -= 2 * dTime;
+ else if(ui->ffwdButton->isChecked())
+ songTime += 2 * dTime;
+
+ if(songTime > trackTime)
+ {
+ songTime = trackTime;
+ ui->pauseButton->setChecked(true);
+ }
+ if(songTime < 0)
+ {
+ songTime = 0;
+ ui->pauseButton->setChecked(true);
+ }
+
+ device->setData("?pc", songTime);
+
+ /* Updating the status bar */
+ ui->statusBar->setValue(elapsedTime * 100 / totalTime);
}
void SkinTimer::stateChange()
{
+ if(ui->playButton->isChecked())
+ device->setData("mp", "Play");
+ else if(ui->pauseButton->isChecked())
+ device->setData("mp", "Pause");
+ else if(ui->rwndButton->isChecked())
+ device->setData("mp", "Rewind");
+ else if(ui->ffwdButton->isChecked())
+ device->setData("mp", "Fast Forward");
+}
+void SkinTimer::deviceChange()
+{
+ int playState = device->data("?mp").toInt();
+ switch(playState)
+ {
+ case 1:
+ ui->playButton->setChecked(true);
+ break;
+ case 2:
+ ui->pauseButton->setChecked(true);
+ break;
+ case 3:
+ ui->ffwdButton->setChecked(true);
+ break;
+ case 4:
+ ui->rwndButton->setChecked(true);
+ break;
+ default:
+ break;
+ }
}
diff --git a/utils/themeeditor/gui/skintimer.h b/utils/themeeditor/gui/skintimer.h
index b6c8061028..3ede0bcf61 100644
--- a/utils/themeeditor/gui/skintimer.h
+++ b/utils/themeeditor/gui/skintimer.h
@@ -24,6 +24,7 @@
#include <QWidget>
#include <QTimer>
+#include <QToolButton>
#include "devicestate.h"
@@ -44,6 +45,7 @@ private slots:
void stop();
void tick();
void stateChange();
+ void deviceChange();
private:
void setupUI();
@@ -53,6 +55,9 @@ private:
QTimer timer;
unsigned long int elapsedTime;
+ unsigned long int totalTime;
+
+ QList<QToolButton*> playStateButtons;
};
#endif // SKINTIMER_H
diff --git a/utils/themeeditor/gui/skintimer.ui b/utils/themeeditor/gui/skintimer.ui
index a9f5feafd7..b60be5f16c 100644
--- a/utils/themeeditor/gui/skintimer.ui
+++ b/utils/themeeditor/gui/skintimer.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>238</width>
- <height>204</height>
+ <height>198</height>
</rect>
</property>
<property name="windowTitle">
@@ -39,7 +39,7 @@
<number>1</number>
</property>
<property name="minimum">
- <double>0.100000000000000</double>
+ <double>0.600000000000000</double>
</property>
<property name="maximum">
<double>3.000000000000000</double>
@@ -58,12 +58,12 @@
<string>Duration</string>
</property>
<property name="buddy">
- <cstring>spinBox</cstring>
+ <cstring>durationBox</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
- <widget class="QSpinBox" name="spinBox">
+ <widget class="QSpinBox" name="durationBox">
<property name="suffix">
<string>s</string>
</property>
@@ -82,9 +82,15 @@
</item>
<item>
<widget class="QProgressBar" name="statusBar">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="value">
<number>0</number>
</property>
+ <property name="textVisible">
+ <bool>false</bool>
+ </property>
</widget>
</item>
<item>
diff --git a/utils/themeeditor/resources/deviceoptions b/utils/themeeditor/resources/deviceoptions
index 1fb2832d13..3d1a92cfa8 100644
--- a/utils/themeeditor/resources/deviceoptions
+++ b/utils/themeeditor/resources/deviceoptions
@@ -131,6 +131,7 @@ day ; Day of Month ; spin(1,31) ; 20
?cw ; Day of Week ; combo(Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday) ; Tuesday
hour ; Hour (24h) ; spin(0, 23) ; 12
minute ; Minute ; spin(0, 59) ; 25
+second ; Second ; spin(0, 59) ; 20
[Recording Status]
Rp ; Target Has Recorder ; check ; false