93 lines
2.1 KiB
QML
93 lines
2.1 KiB
QML
/*
|
||
* © Mikko Ahlroth 2013–2014
|
||
* SailTime is open source software. For licensing information, please check
|
||
* the LICENCE file.
|
||
*/
|
||
|
||
import QtQuick 2.0
|
||
import Sailfish.Silica 1.0
|
||
import harbour.sailtime.UptimeChecker 2.0
|
||
import harbour.sailtime.SysinfoC 1.0
|
||
import harbour.sailtime.Sysload 1.0
|
||
import "cover"
|
||
import "pages"
|
||
|
||
ApplicationWindow
|
||
{
|
||
id: window
|
||
|
||
// Refresh whenever app is activated
|
||
onApplicationActiveChanged: {
|
||
if (applicationActive) {
|
||
updateDisplay()
|
||
}
|
||
}
|
||
|
||
FirstPage {
|
||
id: firstpage
|
||
}
|
||
|
||
SecondPage {
|
||
id: secondpage
|
||
onChangeTimer: {
|
||
if (enabled) {
|
||
//console.log("Starting timer")
|
||
refreshTimer.start()
|
||
}
|
||
else {
|
||
//console.log("Stopping timer")
|
||
refreshTimer.stop()
|
||
}
|
||
}
|
||
|
||
onChangeInterval: {
|
||
//console.log("Timer interval: " + interval)
|
||
refreshTimer.interval = interval * 60 * 1000
|
||
}
|
||
}
|
||
|
||
CoverPage {
|
||
id: coverpage
|
||
}
|
||
|
||
Timer {
|
||
id: refreshTimer
|
||
interval: secondpage.refreshInterval * 60 * 1000
|
||
onTriggered: {
|
||
//console.log("Timer fired!")
|
||
//console.log("Time is now " + new Date());
|
||
updateDisplay()
|
||
}
|
||
repeat: true
|
||
running: secondpage.timerEnable
|
||
}
|
||
|
||
function updateDisplay() {
|
||
var sysinfo = checker.fetchUptime();
|
||
var uptime_s = sysinfo.uptime;
|
||
|
||
var days = Math.floor(uptime_s / 84600);
|
||
var hours = Math.floor(uptime_s / 3600 % 24);
|
||
var minutes = Math.floor(uptime_s / 60 % 60);
|
||
var seconds = Math.floor(uptime_s % 60);
|
||
|
||
var uptime = {
|
||
"days": days,
|
||
"hours": hours,
|
||
"minutes": minutes,
|
||
"load1": sysinfo.loads.avg_1,
|
||
"load5": sysinfo.loads.avg_5,
|
||
"load15": sysinfo.loads.avg_15,
|
||
}
|
||
|
||
firstpage.updatePage(uptime);
|
||
coverpage.updateCover(uptime);
|
||
}
|
||
|
||
UptimeChecker {
|
||
id: checker
|
||
}
|
||
|
||
initialPage: firstpage
|
||
cover: coverpage
|
||
}
|