Commit d8563d18 authored by Alexis Lecanu's avatar Alexis Lecanu

add reset button

parent 395d71da
<strings>
<string id="AppName">Timer</string>
<string id="Continu">Continuer</string>
<string id="Restart">Recommencer</string>
<string id="Reset">Réinitialiser</string>
<string id="Start">Lancer</string>
<string id="Remove">Supprimer</string>
<string id="Rename">Renommer</string>
......
......@@ -2,7 +2,7 @@
<string id="AppName">Timer</string>
<string id="Continu">Continu</string>
<string id="Start">Start</string>
<string id="Restart">Restart</string>
<string id="Reset">Reset</string>
<string id="Remove">Remove</string>
<string id="Rename">Rename</string>
<string id="Bip">Sound</string>
......
......@@ -12,7 +12,7 @@ class TimerDelegate extends Ui.BehaviorDelegate {
function onSelect() {
if(models.get(data.name).status==:Stop){
models.get(data.name).dropTimer();
models.get(data.name).resetTimer();
Ui.popView(Ui.SLIDE_RIGHT);
}
}
......
......@@ -41,11 +41,17 @@ class TimerModel{
Ui.requestUpdate();
}
function dropTimer() {
function resetTimer() {
status=:Reset;
refreshTimer.stop();
displayTimer.stop();
Ui.requestUpdate();
}
function setStatus(status){
self.status=status;
}
function refresh(){
status=:Work;
if (counter > 1) {
......
......@@ -110,6 +110,8 @@ class Menu extends Ui.View {
function setMenuArray(menuArray) {
self.menuArray = menuArray;
index = 0;
nextIndex = 0;
}
function onShow () {
......@@ -158,10 +160,6 @@ class Menu extends Ui.View {
index = nextIndex;
}
function requestUpdate() {
Ui.requestUpdate();
}
function selectedItem () {
menuArray[index].index = index;
return menuArray[index];
......
......@@ -5,7 +5,7 @@ class ElementMenu extends Menu {
hidden var data;
hidden var start;
hidden var restart;
hidden var reset;
hidden var continu;
hidden var alarms;
hidden var remove;
......@@ -15,7 +15,7 @@ class ElementMenu extends Menu {
self.data=data;
continu = Ui.loadResource(Rez.Strings.Continu);
start = Ui.loadResource(Rez.Strings.Start);
restart = Ui.loadResource(Rez.Strings.Restart);
reset = Ui.loadResource(Rez.Strings.Reset);
alarms = Ui.loadResource(Rez.Strings.Alarms);
remove = Ui.loadResource(Rez.Strings.Remove);
rename = Ui.loadResource(Rez.Strings.Rename);
......@@ -34,7 +34,7 @@ class ElementMenu extends Menu {
if(models.hasKey(data.name) && models.get(data.name).status==:Work){
var menuItems = new [0];
menuItems.add(new DataMenuItem (:Continu,continu, data));
menuItems.add(new DataMenuItem (:Start,restart, data));
menuItems.add(new DataMenuItem (:Reset,reset, data));
menuItems.add(new TimeMenuItem (:Timer,data));
menuItems.add(new DataMenuItem (:Alarms,alarms,data));
menuItems.add(new DataMenuItem (:Remove,remove,data));
......@@ -43,5 +43,19 @@ class ElementMenu extends Menu {
}
Menu.setTitle(data.name);
Menu.onShow();
}
function onUpdate(dc) {
if(models.hasKey(data.name) && models.get(data.name).status==:Reset){
var menuItems = new [0];
menuItems.add(new DataMenuItem (:Start,start, data));
menuItems.add(new TimeMenuItem (:Timer,data));
menuItems.add(new DataMenuItem (:Alarms,alarms,data));
menuItems.add(new DataMenuItem (:Remove,remove,data));
menuItems.add(new DataMenuItem (:Rename,rename,data));
Menu.setMenuArray(menuItems);
models.get(data.name).setStatus(:Wait);
}
Menu.onUpdate(dc);
}
}
\ No newline at end of file
......@@ -12,6 +12,8 @@ class ElementMenuDelegate extends MenuDelegate {
function onMenuItem(item) {
if(item.id==:Continu){
Ui.pushView(new TimerView(item.data), new TimerDelegate(item.data), Ui.SLIDE_IMMEDIATE );
}else if(item.id==:Reset){
models.get(item.data.name).resetTimer();
}else if(item.id==:Start){
var model;
if(models.hasKey(item.data.name)){
......
......@@ -20,7 +20,7 @@ class HomeMenuDelegate extends MenuDelegate {
function onBack() {
var values = models.values();
for( var i=0; i<values.size();i++){
values[i].dropTimer();
values[i].resetTimer();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment