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
1 changed files with 281 additions and 281 deletions

View File

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