Commit 7dc736f5 authored by Aleksi Suomalainen's avatar Aleksi Suomalainen Committed by GitHub

Merge pull request #71 from neochapay/volume_fix

[VolumeControl] added repeating of volume change if key stay pressed
parents fb80d554 e3bea66e
......@@ -42,6 +42,8 @@ ProgressBar {
maximumValue: volumeControl.maximumVolume
property bool shouldbevisible
property int pressedKey
opacity: volumeSlider.shouldbevisible ? 1 : 0
Behavior on opacity {
NumberAnimation {
......@@ -49,6 +51,7 @@ ProgressBar {
onRunningChanged: if (!running && volumeSlider.opacity == 0) volumeControl.windowVisible = false
}
}
Timer {
id: voltimer
interval: 2000
......@@ -58,7 +61,70 @@ ProgressBar {
Connections {
target: volumeControl
onVolumeKeyPressed: {
if(key == Qt.Key_VolumeUp)
volumeSlider.pressedKey = key;
volumeControl.windowVisible = true
volumeChange()
keyPressTimer.start()
maxMinTimer.start()
if (volumeControl.windowVisible) {
voltimer.restart()
}
}
onVolumeKeyReleased: {
keyPressTimer.stop()
maxMinTimer.stop()
volumeSlider.pressedKey = ""
}
onWindowVisibleChanged: {
if (volumeControl.windowVisible) {
volumeSlider.shouldbevisible = true
voltimer.restart()
}
}
}
PropertyAnimation {
id: volumeChangeAinmation
target: volumeSlider
property: "value"
to: volumeControl.volume
duration: 100
}
Timer{
id: keyPressTimer
interval: 500
onTriggered: {
volumeChange()
voltimer.restart()
}
repeat: true
}
Timer{
id: maxMinTimer
interval: 1900
onTriggered: {
if(volumeSlider.pressedKey == Qt.Key_VolumeUp)
{
volumeControl.volume = volumeSlider.maximumValue
}
else if(volumeSlider.pressedKey == Qt.Key_VolumeDown)
{
volumeControl.volume = 0
}
volumeChangeAinmation.start()
}
}
function volumeChange()
{
if(volumeSlider.pressedKey == Qt.Key_VolumeUp)
{
//up volume
if(volumeControl.volume < maximumValue)
......@@ -66,7 +132,7 @@ ProgressBar {
volumeControl.volume = volumeControl.volume+1
}
}
else
else if(volumeSlider.pressedKey == Qt.Key_VolumeDown)
{
//down volume
if(volumeControl.volume > 0)
......@@ -74,19 +140,6 @@ ProgressBar {
volumeControl.volume = volumeControl.volume-1
}
}
volumeControl.windowVisible = true
volumeSlider.value = volumeControl.volume
if (volumeControl.windowVisible) {
voltimer.restart()
}
}
onWindowVisibleChanged: {
if (volumeControl.windowVisible) {
volumeSlider.shouldbevisible = true
voltimer.restart()
}
}
volumeChangeAinmation.start()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment