diff --git a/qml/cover/CoverPage.qml b/qml/cover/CoverPage.qml index f1315d3..ca72a13 100644 --- a/qml/cover/CoverPage.qml +++ b/qml/cover/CoverPage.qml @@ -13,11 +13,13 @@ CoverBackground { property alias cover : cover function updateCover(uptime) { - days.text = uptime.days + " days" - time.text = uptime.hours + " h " + uptime.minutes + " min" - load1.text = uptime.load1.toFixed(2) - load5.text = uptime.load5.toFixed(2) - load15.text = uptime.load15.toFixed(2) + var strings = formatUptime(uptime.days, uptime.hours, uptime.minutes); + + days.text = strings.days; + time.text = strings.hours + " " + strings.minutes; + load1.text = uptime.load1.toFixed(2); + load5.text = uptime.load5.toFixed(2); + load15.text = uptime.load15.toFixed(2); } Column { diff --git a/qml/harbour-sailtime.qml b/qml/harbour-sailtime.qml index 2830f80..ad73feb 100644 --- a/qml/harbour-sailtime.qml +++ b/qml/harbour-sailtime.qml @@ -72,27 +72,22 @@ ApplicationWindow 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 uptime_d = divideUptime(uptime_s); var record = parseInt(Storage.readSetting(Storage.db, "record", 0)); - var rDays = Math.floor(record / 84600); - var rHours = Math.floor(record / 3600 % 24); - var rMinutes = Math.floor(record / 60 % 60); + var record_d = divideUptime(record); var uptime = { - "days": days, - "hours": hours, - "minutes": minutes, + "days": uptime_d.days, + "hours": uptime_d.hours, + "minutes": uptime_d.minutes, "load1": sysinfo.loads.avg_1, "load5": sysinfo.loads.avg_5, "load15": sysinfo.loads.avg_15, "record": record, - "rDays": rDays, - "rHours": rHours, - "rMinutes": rMinutes, + "rDays": record_d.days, + "rHours": record_d.hours, + "rMinutes": record_d.minutes, } firstpage.updatePage(sysinfo, uptime); @@ -106,6 +101,30 @@ ApplicationWindow } } + // Divide uptime to days, hours and minutes + function divideUptime(seconds) { + var days = Math.floor(seconds / 84600); + var hours = Math.floor(seconds / 3600 % 24); + var minutes = Math.floor(seconds / 60 % 60); + return { + "days": days, + "hours": hours, + "minutes": minutes + }; + } + + // Return formatted language strings with plural forms + function formatUptime(days, hours, minutes) { + var days_str = days + " day" + ((days !== 1)? "s" : ""); + var hours_str = hours + " h"; + var minutes_str = minutes + " min"; + return { + "days": days_str, + "hours": hours_str, + "minutes": minutes_str + }; + } + UptimeChecker { id: checker } diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml index 977dd49..acaa628 100644 --- a/qml/pages/AboutPage.qml +++ b/qml/pages/AboutPage.qml @@ -29,7 +29,7 @@ Page { Label { anchors.horizontalCenter: parent.horizontalCenter - text: "SailTime 1.1.0" + text: "SailTime 1.1.1" color: Theme.highlightColor font.pixelSize: Theme.fontSizeLarge } diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 77a7702..9b2bf9b 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -21,8 +21,10 @@ Page { } function updatePage(sysinfo, uptime) { - days.text = uptime.days + " days"; - time.text = uptime.hours + " h " + uptime.minutes + " min"; + var strings = formatUptime(uptime.days, uptime.hours, uptime.minutes); + + days.text = strings.days; + time.text = strings.hours + " " + strings.minutes; if (sysinfo.uptime >= uptime.record) { recordLabel.text = "Making new record!"; diff --git a/rpm/harbour-sailtime.spec b/rpm/harbour-sailtime.spec index a4f2da5..c696e12 100644 --- a/rpm/harbour-sailtime.spec +++ b/rpm/harbour-sailtime.spec @@ -13,7 +13,7 @@ Name: harbour-sailtime %{!?qtc_make:%define qtc_make make} %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: SailTime -Version: 1.1.0 +Version: 1.1.1 Release: 1 Group: Qt/Qt License: MIT Expat licence diff --git a/rpm/harbour-sailtime.yaml b/rpm/harbour-sailtime.yaml index 48b012c..36ecf21 100644 --- a/rpm/harbour-sailtime.yaml +++ b/rpm/harbour-sailtime.yaml @@ -1,6 +1,6 @@ Name: harbour-sailtime Summary: SailTime -Version: 1.1.0 +Version: 1.1.1 Release: 1 Group: Qt/Qt URL: http://example.org/