Incorporate nico's suggestions, fix volume slider

This commit is contained in:
Joseph Donofry 2021-11-08 22:55:16 -05:00
parent 13a5194c08
commit 42b74509ea
No known key found for this signature in database
GPG key ID: E8A1D78EF044B0CB

View file

@ -33,8 +33,9 @@ ColumnLayout {
var mm = (hours > 0) ? maybeZeroPrepend(minutes) : minutes.toString() var mm = (hours > 0) ? maybeZeroPrepend(minutes) : minutes.toString()
var hh = hours.toString() var hh = hours.toString()
if (hours < 1) if (hours < 1) {
return mm + ":" + ss return mm + ":" + ss
}
return hh + ":" + mm + ":" + ss return hh + ":" + mm + ":" + ss
} }
@ -46,6 +47,9 @@ ColumnLayout {
// TODO: Show error in overlay or so? // TODO: Show error in overlay or so?
onError: console.log(error) onError: console.log(error)
roomm: room roomm: room
// desiredVolume is a float from 0.0 -> 1.0, MediaPlayer volume is an int from 0 to 100
// this value automatically gets clamped for us between these two values.
volume: volumeSlider.desiredVolume * 100
} }
Rectangle { Rectangle {
@ -60,6 +64,7 @@ ColumnLayout {
property double divisor: isReply ? 4 : 2 property double divisor: isReply ? 4 : 2
property bool tooHigh: tempHeight > timelineRoot.height / divisor property bool tooHigh: tempHeight > timelineRoot.height / divisor
color: Nheko.colors.window
Layout.preferredHeight: tooHigh ? timelineRoot.height / divisor : tempHeight Layout.preferredHeight: tooHigh ? timelineRoot.height / divisor : tempHeight
Layout.preferredWidth: tooHigh ? (timelineRoot.height / divisor) / proportionalHeight : tempWidth Layout.preferredWidth: tooHigh ? (timelineRoot.height / divisor) / proportionalHeight : tempWidth
@ -71,13 +76,13 @@ ColumnLayout {
asynchronous: true asynchronous: true
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
// Button and window colored overlay to cache media // Button and window colored overlay to cache media
Rectangle { Item {
// Display over video controls // Display over video controls
z: videoOutput.z + 1 z: videoOutput.z + 1
visible: !mxcmedia.loaded visible: !mxcmedia.loaded
anchors.fill: parent anchors.fill: parent
color: Nheko.colors.window //color: Nheko.colors.window
opacity: 0.5 //opacity: 0.5
Image { Image {
property color buttonColor: (cacheVideoArea.containsMouse) ? Nheko.colors.highlight : property color buttonColor: (cacheVideoArea.containsMouse) ? Nheko.colors.highlight :
Nheko.colors.text Nheko.colors.text
@ -123,7 +128,7 @@ ColumnLayout {
anchors.bottom: playerMouseArea.bottom anchors.bottom: playerMouseArea.bottom
// Window color with 128/255 alpha // Window color with 128/255 alpha
color: { color: {
var wc = Nheko.colors.window var wc = Nheko.colors.alternateBase
return Qt.rgba(wc.r, wc.g, wc.b, 0.5) return Qt.rgba(wc.r, wc.g, wc.b, 0.5)
} }
height: 40 height: 40
@ -164,8 +169,8 @@ ColumnLayout {
} }
} }
Label { Label {
text: (!mxcmedia.loaded) ? "-/-" : text: (!mxcmedia.loaded) ? "-/-" : (durationToString(mxcmedia.position) + "/" + durationToString(mxcmedia.duration))
durationToString(mxcmedia.position) + "/" + durationToString(mxcmedia.duration) color: Nheko.colors.text
} }
Slider { Slider {
@ -230,28 +235,23 @@ ColumnLayout {
volumeSliderHideTimer.running || volumeSliderHideTimer.running ||
volumeSliderRectMouseArea.containsMouse volumeSliderRectMouseArea.containsMouse
Slider { Slider {
// Desired value to avoid loop onMoved -> media.volume -> value -> onMoved...
property real desiredVolume: 1
// TODO: the slider is slightly off-center on the left for some reason... // TODO: the slider is slightly off-center on the left for some reason...
id: volumeSlider id: volumeSlider
from: 0
to: 1 value: 1.0
value: (mxcmedia.muted) ? 0 : // Desired value to avoid loop onMoved -> media.volume -> value -> onMoved...
QtMultimedia.convertVolume(desiredVolume, property real desiredVolume: QtMultimedia.convertVolume(volumeSlider.value,
QtMultimedia.LinearVolumeScale, QtMultimedia.LogarithmicVolumeScale,
QtMultimedia.LogarithmicVolumeScale) QtMultimedia.LinearVolumeScale)
anchors.fill: parent anchors.fill: parent
anchors.bottomMargin: parent.height * 0.1 anchors.bottomMargin: parent.height * 0.1
anchors.topMargin: parent.height * 0.1 anchors.topMargin: parent.height * 0.1
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
orientation: Qt.Vertical orientation: Qt.Vertical
onMoved: desiredVolume = QtMultimedia.convertVolume(value, onDesiredVolumeChanged: {
QtMultimedia.LogarithmicVolumeScale, mxcmedia.muted = !(desiredVolume > 0.0)
QtMultimedia.LinearVolumeScale) }
/* This would be better handled in 'media', but it has some issue with listening
to this signal */
onDesiredVolumeChanged: mxcmedia.muted = !(desiredVolume > 0)
} }
// Used for resetting the timer on mouse moves on volumeSliderRect // Used for resetting the timer on mouse moves on volumeSliderRect
MouseArea { MouseArea {