Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Screen01.qml #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion content/Screen01.qml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Rectangle {
color: Constants.backgroundColor
property bool isDialogOpen: false


Text {
id: text1
text: qsTr("To Do")
Expand Down Expand Up @@ -137,7 +138,7 @@ Rectangle {
name: "My To Do"
}
function createListElement() {
return {
return {
"name": toDoTextInput.text
}
}
Expand All @@ -155,13 +156,63 @@ Rectangle {
CheckBox {
id: checkBox
text: name
property bool completed: false
anchors.left: parent.left
anchors.top: parent.top
anchors.bottom: parent.bottom
font.pointSize: 22
anchors.leftMargin: 0
anchors.bottomMargin: 0
anchors.topMargin: 0

Connections {
target: checkBox
onClicked: checkBox.completed = true
}
}


Item {
id: root

property double startTime: 0
property int secondsElapsed: 0
width: 200
height: 230

function restartCounter() {

root.startTime = 0;

}

function timeChanged() {
if(root.startTime==0)
{
root.startTime = new Date().getTime(); //returns the number of milliseconds since the epoch (1970-01-01T00:00:00Z);
}
var currentTime = new Date().getTime();
root.secondsElapsed = (currentTime-startTime)/1000;

}

Timer {
id: elapsedTimer
interval: 500;
running: !checkBox.completed;
repeat: true;
onTriggered: root.timeChanged()
}
}

Text {
id: counterText
text: root.secondsElapsed
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
horizontalAlignment: Text.AlignRight
font.pointSize: 22
anchors.rightMargin: 50
}
}
}
Expand Down