diff --git a/Commons/Style.qml b/Commons/Style.qml index d2af5a8..902a225 100644 --- a/Commons/Style.qml +++ b/Commons/Style.qml @@ -29,6 +29,7 @@ Singleton { property int fontWeightBold: 700 // Radii + property int radiusXXS: 4 * Settings.data.general.radiusRatio property int radiusXS: 8 * Settings.data.general.radiusRatio property int radiusS: 12 * Settings.data.general.radiusRatio property int radiusM: 16 * Settings.data.general.radiusRatio diff --git a/Commons/Time.qml b/Commons/Time.qml index fddb4db..d7ec78e 100644 --- a/Commons/Time.qml +++ b/Commons/Time.qml @@ -81,28 +81,31 @@ Singleton { // Used to display the time remaining on the Battery widget, computer uptime, etc.. function formatVagueHumanReadableDuration(totalSeconds) { if (typeof totalSeconds !== 'number' || totalSeconds < 0) { - return '0s'; + return '0s' } - + // Floor the input to handle decimal seconds - totalSeconds = Math.floor(totalSeconds); - - const days = Math.floor(totalSeconds / 86400); - const hours = Math.floor((totalSeconds % 86400) / 3600); - const minutes = Math.floor((totalSeconds % 3600) / 60); - const seconds = totalSeconds % 60; - - const parts = []; - if (days) parts.push(`${days}d`); - if (hours) parts.push(`${hours}h`); - if (minutes) parts.push(`${minutes}m`); - + totalSeconds = Math.floor(totalSeconds) + + const days = Math.floor(totalSeconds / 86400) + const hours = Math.floor((totalSeconds % 86400) / 3600) + const minutes = Math.floor((totalSeconds % 3600) / 60) + const seconds = totalSeconds % 60 + + const parts = [] + if (days) + parts.push(`${days}d`) + if (hours) + parts.push(`${hours}h`) + if (minutes) + parts.push(`${minutes}m`) + // Only show seconds if no hours and no minutes if (!hours && !minutes) { - parts.push(`${seconds}s`); + parts.push(`${seconds}s`) } - - return parts.join(''); + + return parts.join('') } Timer {