on xenial help sign in
Use a LiveTimer instead of the screen state to detect a new day, so the solution is valid also for the desktop version
8c6a0cfTomás Tormo
qml/Greeter/Infographics.qml+4−10
@@ -59,18 +59,12 @@ Item {
59 onDataDisappeared: startShowAnimation() // show "no data" label
59 onDataDisappeared: startShowAnimation() // show "no data" label
60 }
60 }
61
61
62− Connections {
62+ LiveTimer {
63− id: screenState
63+ frequency: LiveTimer.Hour
64− target: Powerd
64+ onTrigger: handleTimerTrigger()
65−
66− onStatusChanged: {
67− if(Powerd.status === Powerd.On){
68− handleScreenOn()
69− }
70− }
71 }
65 }
72
66
73− function handleScreenOn(){
67+ function handleTimerTrigger(){
74 var today = new Date().getDay()
68 var today = new Date().getDay()
75 if(infographic.currentWeekDay !== today){
69 if(infographic.currentWeekDay !== today){
76 infographic.currentWeekDay = today
70 infographic.currentWeekDay = today
tests/qmltests/Greeter/tst_Infographics.qml+1−1
@@ -150,7 +150,7 @@ Item {
150 infographic.currentWeekDay = (today - data.currentDayOffset)
150 infographic.currentWeekDay = (today - data.currentDayOffset)
151
151
152 //When
152 //When
153− infographic.handleScreenOn()
153+ infographic.handleTimerTrigger()
154
154
155 //Then
155 //Then
156 tryCompare(infographic, "currentWeekDay", today)
156 tryCompare(infographic, "currentWeekDay", today)