Make time countdown setting in player persistent

This commit is contained in:
Bart De Vries 2021-04-10 19:23:31 +02:00
parent e1b374e375
commit e174269332
2 changed files with 9 additions and 3 deletions

View File

@ -135,15 +135,17 @@ Kirigami.Page {
Layout.preferredWidth: endLabel.implicitWidth + Kirigami.Units.gridUnit
Controls.Label {
id: endLabel
property int toggle: 0
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: (toggle === 0) ? ((Math.floor(audio.duration/3600000) < 10 ? "0" : "") + Math.floor(audio.duration/3600000) + ":" + (Math.floor(audio.duration/60000) % 60 < 10 ? "0" : "") + Math.floor(audio.duration/60000) % 60 + ":" + (Math.floor(audio.duration/1000) % 60 < 10 ? "0" : "") + Math.floor(audio.duration/1000) % 60) : ((Math.floor((audio.duration-audio.position)/3600000) < 10 ? "-0" : "-") + Math.floor((audio.duration-audio.position)/3600000) + ":" + (Math.floor((audio.duration-audio.position)/60000) % 60 < 10 ? "0" : "") + Math.floor((audio.duration-audio.position)/60000) % 60 + ":" + (Math.floor((audio.duration-audio.position)/1000) % 60 < 10 ? "0" : "") + Math.floor((audio.duration-audio.position)/1000) % 60)
text: (SettingsManager.showRemainingTime) ?
((Math.floor((audio.duration-audio.position)/3600000) < 10 ? "-0" : "-") + Math.floor((audio.duration-audio.position)/3600000) + ":" + (Math.floor((audio.duration-audio.position)/60000) % 60 < 10 ? "0" : "") + Math.floor((audio.duration-audio.position)/60000) % 60 + ":" + (Math.floor((audio.duration-audio.position)/1000) % 60 < 10 ? "0" : "") + Math.floor((audio.duration-audio.position)/1000) % 60)
: ((Math.floor(audio.duration/3600000) < 10 ? "0" : "") + Math.floor(audio.duration/3600000) + ":" + (Math.floor(audio.duration/60000) % 60 < 10 ? "0" : "") + Math.floor(audio.duration/60000) % 60 + ":" + (Math.floor(audio.duration/1000) % 60 < 10 ? "0" : "") + Math.floor(audio.duration/1000) % 60)
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: (endLabel.toggle === 0) ? endLabel.toggle=1 : endLabel.toggle=0
onClicked: SettingsManager.showRemainingTime = !SettingsManager.showRemainingTime
}
}
}

View File

@ -47,5 +47,9 @@
<label>The entry that was being played at shutdown</label>
<default>none</default>
</entry>
<entry name="showRemainingTime" type="Bool">
<label>Whether the player shows remaining track time instead of total track time</label>
<default>false</default>
</entry>
</group>
</kcfg>